Skip to content

Commit c59c5ca

Browse files
committed
ipc: gdb: initialise GDB after IPC completion
To avoid timed out IPC on the host side, enter the GDB stub only after replying to the IPC. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent c3cf8ea commit c59c5ca

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/include/sof/ipc/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,7 @@ void ipc_msg_reply(struct sof_ipc_reply *reply);
243243
*/
244244
void ipc_complete_cmd(struct ipc *ipc);
245245

246+
/* GDB stub: should enter GDB after completing the IPC processing */
247+
extern bool ipc_enter_gdb;
248+
246249
#endif /* __SOF_DRIVERS_IPC_H__ */

src/ipc/ipc-common.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <sof/audio/component_ext.h>
1010
#include <sof/audio/pipeline.h>
1111
#include <sof/common.h>
12+
#include <sof/debug/gdb/gdb.h>
1213
#include <rtos/idc.h>
1314
#include <rtos/symbol.h>
1415
#include <sof/ipc/topology.h>
@@ -352,6 +353,8 @@ void ipc_complete_cmd(struct ipc *ipc)
352353
ipc_platform_complete_cmd(ipc);
353354
}
354355

356+
bool ipc_enter_gdb;
357+
355358
static void ipc_complete_task(void *data)
356359
{
357360
struct ipc *ipc = data;
@@ -361,6 +364,13 @@ static void ipc_complete_task(void *data)
361364
ipc->task_mask &= ~IPC_TASK_INLINE;
362365
ipc_complete_cmd(ipc);
363366
k_spin_unlock(&ipc->lock, key);
367+
#if CONFIG_GDBSTUB
368+
if (ipc_enter_gdb) {
369+
ipc_enter_gdb = false;
370+
k_msleep(5);
371+
gdb_init();
372+
}
373+
#endif
364374
}
365375

366376
static enum task_state ipc_do_cmd(void *data)

src/ipc/ipc3/handler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ static int ipc_glb_gdb_debug(uint32_t header)
973973
(void) header;
974974

975975
#if CONFIG_GDBSTUB
976-
gdb_init();
976+
ipc_enter_gdb = true;
977977
return 0;
978978
// TODO: remove old GDB stub?
979979
#elif CONFIG_GDB_DEBUG

0 commit comments

Comments
 (0)