Skip to content

Commit b37b7e4

Browse files
lyakhbardliao
authored andcommitted
ASoC: SOF: special-case a part of the debug memory window
The debug memory window is split in 4KiB large pages. Page 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 page zero after slot descriptors to be used as slot number 16, one higher than the currently highest possible slot number. To improve documentation we move the tabular representation of the window layout from ipc4-mtrace.c to header.h. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent d56c26a commit b37b7e4

3 files changed

Lines changed: 43 additions & 33 deletions

File tree

include/sound/sof/ipc4/header.h

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,16 +541,45 @@ struct sof_ipc4_notify_resource_data {
541541
uint32_t data[6];
542542
} __packed __aligned(4);
543543

544-
#define SOF_IPC4_DEBUG_DESCRIPTOR_SIZE 12 /* 3 x u32 */
545-
546544
/*
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.
545+
* The debug memory window contains up to 16 4kB large pages, where pages one to
546+
* fifteen are used for user slots and page zero contains slot descriptors:
547+
*
548+
* ------------------------
549+
* | Page0 - descriptors |
550+
* ------------------------
551+
* | Page1 - slot0 |
552+
* ------------------------
553+
* | Page2 - slot1 |
554+
* ------------------------
555+
* | ... |
556+
* ------------------------
557+
* | Page14 - slot13 |
558+
* ------------------------
559+
* | Page15 - slot14 |
560+
* ------------------------
561+
*
562+
* The slot descriptor is:
563+
* u32 res_id;
564+
* u32 type;
565+
* u32 vma;
549566
*/
567+
568+
#define SOF_IPC4_DEBUG_PAGE_SIZE 0x1000
569+
#define SOF_IPC4_DEBUG_SLOT_SIZE SOF_IPC4_DEBUG_PAGE_SIZE
570+
#define SOF_IPC4_DEBUG_PAGE0_SLOT_OFFSET 1024
571+
572+
/* Usable slots 0..14 (page 1..15) */
550573
#define SOF_IPC4_MAX_DEBUG_SLOTS 15
551-
#define SOF_IPC4_DEBUG_SLOT_SIZE 0x1000
552574

553-
/* debug log slot types */
575+
/*
576+
* Descriptor 0-14: slot 0-14 (page 1-15)
577+
* Descriptor 15: partial slot at page 0 + 1024
578+
*/
579+
#define SOF_IPC4_MAX_DEBUG_DESCS (SOF_IPC4_MAX_DEBUG_SLOTS + 1)
580+
#define SOF_IPC4_DEBUG_DESCRIPTOR_SIZE 12 /* 3 x u32 */
581+
582+
/* Debug log slot types */
554583
#define SOF_IPC4_DEBUG_SLOT_UNUSED 0x00000000
555584
#define SOF_IPC4_DEBUG_SLOT_CRITICAL_LOG 0x54524300 /* byte 0: core ID */
556585
#define SOF_IPC4_DEBUG_SLOT_DEBUG_LOG 0x474f4c00 /* byte 0: core ID */

sound/soc/sof/ipc4-mtrace.c

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,7 @@
1010
#include "ipc4-priv.h"
1111

1212
/*
13-
* debug info window is organized in 16 (equal sized) pages:
14-
*
15-
* ------------------------
16-
* | Page0 - descriptors |
17-
* ------------------------
18-
* | Page1 - slot0 |
19-
* ------------------------
20-
* | Page2 - slot1 |
21-
* ------------------------
22-
* | ... |
23-
* ------------------------
24-
* | Page14 - slot13 |
25-
* ------------------------
26-
* | Page15 - slot14 |
27-
* ------------------------
28-
*
29-
* The slot size == page size
30-
*
31-
* The first page contains descriptors for the remaining 15 cores
32-
* The slot descriptor is:
33-
* u32 res_id;
34-
* u32 type;
35-
* u32 vma;
36-
*
37-
* Log buffer slots have the following layout:
13+
* Log buffer debug window slots have the following layout:
3814
* u32 host_read_ptr;
3915
* u32 dsp_write_ptr;
4016
* u8 buffer[];

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 + SOF_IPC4_DEBUG_PAGE0_SLOT_OFFSET;
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)