Skip to content

Commit 1de7091

Browse files
committed
ASoC: SOF: special-case a part of the debug memory window
The debug memory window is split in 4KiB large slots. Slot zero is used for slot descriptors, which leaves one or two more free slots for actual useful work. One of them is usually used for mtrace logging, which leaves no free slots on some systems and only one such slot on others. This commit repurposes the free space in slot zero after slot descriptors to be used as slot number 16, one higher than the currently highest possible slot number. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 79a2197 commit 1de7091

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

include/sound/sof/ipc4/header.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,19 @@ struct sof_ipc4_notify_resource_data {
544544
#define SOF_IPC4_DEBUG_DESCRIPTOR_SIZE 12 /* 3 x u32 */
545545

546546
/*
547-
* The debug memory window is divided into 16 slots, and the
548-
* first slot is used as a recorder for the other 15 slots.
547+
* The debug memory window is divided into up to 16 page-size slots, and slot
548+
* zero is used as a recorder for the other slots.
549+
* Note, that the last descriptor number 15 is used in a special way: so far on
550+
* all ADSP platforms the debug memory window has 2 or 3 pages, i.e. it can only
551+
* fit 1 or 2 slots in addition to the first slot with descriptors. But those
552+
* descriptors occupy much less than 1kB of memory, so more than 3 kB of memory
553+
* remain unused there. We use index 15 to point to those 3kB of memory in slot
554+
* zero to be used for the GDB stub communication.
549555
*/
550-
#define SOF_IPC4_MAX_DEBUG_SLOTS 15
551-
#define SOF_IPC4_DEBUG_SLOT_SIZE 0x1000
556+
#define SOF_IPC4_MAX_DEBUG_SLOTS 15 /* usable slots 1..15 */
557+
#define SOF_IPC4_MAX_DEBUG_DESCS (SOF_IPC4_MAX_DEBUG_SLOTS + 1) /* including descriptor
558+
* for partial slot 0 */
559+
#define SOF_IPC4_DEBUG_SLOT_SIZE 0x1000
552560

553561
/* debug log slot types */
554562
#define SOF_IPC4_DEBUG_SLOT_UNUSED 0x00000000

sound/soc/sof/ipc4.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,16 @@ size_t sof_ipc4_find_debug_slot_offset_by_type(struct snd_sof_dev *sdev,
586586

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

592-
if (type == slot_type)
592+
if (type == slot_type) {
593+
if (i == SOF_IPC4_MAX_DEBUG_DESCS - 1)
594+
/* Desc 15: see comment on SOF_IPC4_MAX_DEBUG_DESCS in header.h */
595+
return sdev->debug_box.offset + 1024;
596+
593597
return sdev->debug_box.offset + (i + 1) * SOF_IPC4_DEBUG_SLOT_SIZE;
598+
}
594599

595600
slot_desc_type_offset += SOF_IPC4_DEBUG_DESCRIPTOR_SIZE;
596601
}

0 commit comments

Comments
 (0)