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
44 changes: 37 additions & 7 deletions include/sound/sof/ipc4/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ enum sof_ipc4_global_msg {
/* Notification (FW to SW driver) */
SOF_IPC4_GLB_NOTIFICATION,

/* 28 .. 31: RESERVED - do not use */
/* 28 .. 30: RESERVED - do not use */

SOF_IPC4_GLB_ENTER_GDB = 31,
SOF_IPC4_GLB_TYPE_LAST,
};

Expand Down Expand Up @@ -540,16 +541,45 @@ struct sof_ipc4_notify_resource_data {
uint32_t data[6];
} __packed __aligned(4);

#define SOF_IPC4_DEBUG_DESCRIPTOR_SIZE 12 /* 3 x u32 */

/*
* The debug memory window is divided into 16 slots, and the
* first slot is used as a recorder for the other 15 slots.
* The debug memory window contains up to 16 4kB large pages, where pages one to
* fifteen are used for user slots and page zero contains slot descriptors:
*
* ------------------------
* | Page0 - descriptors |
* ------------------------
* | Page1 - slot0 |
* ------------------------
* | Page2 - slot1 |
* ------------------------
* | ... |
* ------------------------
* | Page14 - slot13 |
* ------------------------
* | Page15 - slot14 |
* ------------------------
*
* The slot descriptor is:
* u32 res_id;
* u32 type;
* u32 vma;
*/

#define SOF_IPC4_DEBUG_PAGE_SIZE 0x1000
#define SOF_IPC4_DEBUG_SLOT_SIZE SOF_IPC4_DEBUG_PAGE_SIZE
#define SOF_IPC4_DEBUG_PAGE0_SLOT_OFFSET 1024

/* Usable slots 0..14 (page 1..15) */
#define SOF_IPC4_MAX_DEBUG_SLOTS 15
#define SOF_IPC4_DEBUG_SLOT_SIZE 0x1000

/* debug log slot types */
/*
* Descriptor 0-14: slot 0-14 (page 1-15)
* Descriptor 15: partial slot at page 0 + 1024
*/
#define SOF_IPC4_MAX_DEBUG_DESCS (SOF_IPC4_MAX_DEBUG_SLOTS + 1)
#define SOF_IPC4_DEBUG_DESCRIPTOR_SIZE 12 /* 3 x u32 */

/* Debug log slot types */
#define SOF_IPC4_DEBUG_SLOT_UNUSED 0x00000000
#define SOF_IPC4_DEBUG_SLOT_CRITICAL_LOG 0x54524300 /* byte 0: core ID */
#define SOF_IPC4_DEBUG_SLOT_DEBUG_LOG 0x474f4c00 /* byte 0: core ID */
Expand Down
12 changes: 12 additions & 0 deletions sound/soc/sof/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ config SND_SOC_SOF_DEBUG_IPC_KERNEL_INJECTOR
Say Y if you want to enable the IPC kernel injector.
If unsure, select "N".

config SND_SOC_SOF_DEBUG_FW_GDB
tristate "SOF enable Firmware GDB debugging"
select SND_SOC_SOF_CLIENT
help
This enables GDB debugging of the SOF firmware. If selected, this
will make the kernel create a debugfs file, that can be used to
communicate with the firmware GDB stub. When the file is opened, the
kernel sends a command to the firmware to switch to the GDB mode and
to wait for GDB commands. socat can be used to connect that file to a
socket, to which GDB can then connect.
If unsure, select "N".

config SND_SOC_SOF_DEBUG_RETAIN_DSP_CONTEXT
bool "SOF retain DSP context on any FW exceptions"
help
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/sof/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ endif
ifneq ($(CONFIG_SND_SOC_SOF_IPC4),)
snd-sof-probes-y += sof-client-probes-ipc4.o
endif
snd-sof-fw-gdb-objs := sof-client-fw-gdb.o

snd-sof-nocodec-y := nocodec.o

Expand All @@ -53,6 +54,7 @@ obj-$(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST) += snd-sof-ipc-flood-test.o
obj-$(CONFIG_SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR) += snd-sof-ipc-msg-injector.o
obj-$(CONFIG_SND_SOC_SOF_DEBUG_IPC_KERNEL_INJECTOR) += snd-sof-ipc-kernel-injector.o
obj-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES) += snd-sof-probes.o
obj-$(CONFIG_SND_SOC_SOF_DEBUG_FW_GDB) += snd-sof-fw-gdb.o

obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/
obj-$(CONFIG_SND_SOC_SOF_IMX_TOPLEVEL) += imx/
Expand Down
26 changes: 1 addition & 25 deletions sound/soc/sof/ipc4-mtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,7 @@
#include "ipc4-priv.h"

/*
* debug info window is organized in 16 (equal sized) pages:
*
* ------------------------
* | Page0 - descriptors |
* ------------------------
* | Page1 - slot0 |
* ------------------------
* | Page2 - slot1 |
* ------------------------
* | ... |
* ------------------------
* | Page14 - slot13 |
* ------------------------
* | Page15 - slot14 |
* ------------------------
*
* The slot size == page size
*
* The first page contains descriptors for the remaining 15 cores
* The slot descriptor is:
* u32 res_id;
* u32 type;
* u32 vma;
*
* Log buffer slots have the following layout:
* Log buffer debug window slots have the following layout:
* u32 host_read_ptr;
* u32 dsp_write_ptr;
* u8 buffer[];
Expand Down
10 changes: 8 additions & 2 deletions sound/soc/sof/ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ static const char * const ipc4_dbg_glb_msg_type[] = {
DBG_IPC4_MSG_TYPE_ENTRY(GLB_LOAD_LIBRARY_PREPARE),
DBG_IPC4_MSG_TYPE_ENTRY(GLB_INTERNAL_MESSAGE),
DBG_IPC4_MSG_TYPE_ENTRY(GLB_NOTIFICATION),
DBG_IPC4_MSG_TYPE_ENTRY(GLB_ENTER_GDB),
};

#define DBG_IPC4_NOTIFICATION_TYPE_ENTRY(type) [SOF_IPC4_NOTIFY_##type] = #type
Expand Down Expand Up @@ -585,11 +586,16 @@ size_t sof_ipc4_find_debug_slot_offset_by_type(struct snd_sof_dev *sdev,

/* The type is the second u32 in the slot descriptor */
slot_desc_type_offset = sdev->debug_box.offset + sizeof(u32);
for (i = 0; i < SOF_IPC4_MAX_DEBUG_SLOTS; i++) {
for (i = 0; i < SOF_IPC4_MAX_DEBUG_DESCS; i++) {
sof_mailbox_read(sdev, slot_desc_type_offset, &type, sizeof(type));

if (type == slot_type)
if (type == slot_type) {
if (i == SOF_IPC4_MAX_DEBUG_DESCS - 1)
/* Desc 15: see comment on SOF_IPC4_MAX_DEBUG_DESCS in header.h */
return sdev->debug_box.offset + SOF_IPC4_DEBUG_PAGE0_SLOT_OFFSET;

return sdev->debug_box.offset + (i + 1) * SOF_IPC4_DEBUG_SLOT_SIZE;
}

slot_desc_type_offset += SOF_IPC4_DEBUG_DESCRIPTOR_SIZE;
}
Expand Down
Loading
Loading