Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/debug_overlay.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ CONFIG_DAI_VERBOSE_GLITCH_WARNINGS=y
# CONFIG_SPIN_LOCK_TIME_LIMIT=50000

CONFIG_COLD_STORE_EXECUTE_DEBUG=y

# GDB stub

CONFIG_GDBSTUB=y
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overlay is used in our SOF driver CI, so gdb stub will be enabled. Probably ok and even preferred as this will get a minimal coverage in CI for the gdb build.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's the intension

CONFIG_GDBSTUB_ENTER_IMMEDIATELY=n
4 changes: 3 additions & 1 deletion src/include/ipc4/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ enum ipc4_message_type {
/**< Notification (FW to SW driver) */
SOF_IPC4_GLB_NOTIFICATION = 27,
/* GAP HERE- DO NOT USE - size 3 (28 .. 30) */
/**< Enter GDB stub to wait for commands in memory window */
SOF_IPC4_GLB_ENTER_GDB = 31,

/**< Maximum message number */
SOF_IPC4_GLB_MAX_IXC_MESSAGE_TYPE = 31
SOF_IPC4_GLB_MAX_IXC_MESSAGE_TYPE = 32
};

/**
Expand Down
3 changes: 2 additions & 1 deletion src/include/sof/debug/gdb/gdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
void gdb_handle_exception(void);
void gdb_debug_info(unsigned char *str);
void gdb_init_debug_exception(void);
void gdb_init(void);

#endif /* CONFIG_GDB_DEBUG */

void gdb_init(void);

#endif /* __SOF_DEBUG_GDB_GDB_H__ */
3 changes: 3 additions & 0 deletions src/include/sof/ipc/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,7 @@ void ipc_msg_reply(struct sof_ipc_reply *reply);
*/
void ipc_complete_cmd(struct ipc *ipc);

/* GDB stub: should enter GDB after completing the IPC processing */
extern bool ipc_enter_gdb;

#endif /* __SOF_DRIVERS_IPC_H__ */
5 changes: 5 additions & 0 deletions src/include/sof/ipc/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,9 @@ int ipc_platform_poll_is_host_ready(void);
*/
int ipc_platform_poll_tx_host_msg(struct ipc_msg *msg);

/**
* \brief wait for host acknowledgment to an IPC message
*/
void ipc_platform_wait_ack(struct ipc *ipc);

#endif
15 changes: 15 additions & 0 deletions src/ipc/ipc-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <sof/audio/component_ext.h>
#include <sof/audio/pipeline.h>
#include <sof/common.h>
#include <sof/debug/gdb/gdb.h>
#include <rtos/idc.h>
#include <rtos/symbol.h>
#include <sof/ipc/topology.h>
Expand Down Expand Up @@ -361,6 +362,13 @@ void ipc_complete_cmd(struct ipc *ipc)
ipc_platform_complete_cmd(ipc);
}

bool ipc_enter_gdb;

__attribute__((weak)) void ipc_platform_wait_ack(struct ipc *ipc)
{
k_msleep(1);
}

static void ipc_complete_task(void *data)
{
struct ipc *ipc = data;
Expand All @@ -370,6 +378,13 @@ static void ipc_complete_task(void *data)
ipc->task_mask &= ~IPC_TASK_INLINE;
ipc_complete_cmd(ipc);
k_spin_unlock(&ipc->lock, key);
#if CONFIG_GDBSTUB
if (ipc_enter_gdb) {
ipc_enter_gdb = false;
ipc_platform_wait_ack(ipc);
gdb_init();
}
#endif
}

static enum task_state ipc_do_cmd(void *data)
Expand Down
22 changes: 22 additions & 0 deletions src/ipc/ipc-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include <autoconf.h>

#include <zephyr/kernel.h>

#include <intel_adsp_ipc.h>
#include <sof/ipc/common.h>

Expand Down Expand Up @@ -309,3 +311,23 @@ int platform_ipc_init(struct ipc *ipc)

return 0;
}

static bool ipc_wait_complete(const struct device *dev, void *arg)
{
k_sem_give(arg);
return false;
}

void ipc_platform_wait_ack(struct ipc *ipc)
{
static struct k_sem ipc_wait_sem;

k_sem_init(&ipc_wait_sem, 0, 1);

intel_adsp_ipc_set_done_handler(INTEL_ADSP_IPC_HOST_DEV, ipc_wait_complete, &ipc_wait_sem);

if (k_sem_take(&ipc_wait_sem, Z_TIMEOUT_MS(10)) == -EAGAIN)
tr_err(&ipc_tr, "Timeout waiting for host ack!");

intel_adsp_ipc_set_done_handler(INTEL_ADSP_IPC_HOST_DEV, NULL, NULL);
}
8 changes: 6 additions & 2 deletions src/ipc/ipc3/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,10 +969,14 @@ static int ipc_glb_trace_message(uint32_t header)

static int ipc_glb_gdb_debug(uint32_t header)
{
/* no furher information needs to be extracted form header */
/* no further information needs to be extracted from header */
(void) header;

#if CONFIG_GDB_DEBUG
#if CONFIG_GDBSTUB
ipc_enter_gdb = true;
return 0;
// TODO: remove old GDB stub?
#elif CONFIG_GDB_DEBUG
gdb_init_debug_exception();
gdb_init();
/* TODO: this asm should be in arch/include/debug/debug.h
Expand Down
14 changes: 14 additions & 0 deletions src/ipc/ipc4/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,16 @@ __cold static int ipc4_process_ipcgtw_cmd(struct ipc4_message_request *ipc4)
#endif
}

static int ipc_glb_gdb_debug(struct ipc4_message_request *ipc4)
{
#if CONFIG_GDBSTUB
ipc_enter_gdb = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should log this entry as it comes from host IPC

return IPC4_SUCCESS;
#else
return IPC4_UNAVAILABLE;
#endif
}

static int ipc4_process_glb_message(struct ipc4_message_request *ipc4)
{
uint32_t type;
Expand Down Expand Up @@ -881,6 +891,10 @@ static int ipc4_process_glb_message(struct ipc4_message_request *ipc4)
ret = ipc4_process_ipcgtw_cmd(ipc4);
break;

case SOF_IPC4_GLB_ENTER_GDB:
ret = ipc_glb_gdb_debug(ipc4);
break;

default:
ipc_cmd_err(&ipc_tr, "unsupported ipc message type %d", type);
ret = IPC4_UNAVAILABLE;
Expand Down
Loading