Skip to content

Commit 5ec546b

Browse files
Jyri Sarhalgirdwood
authored andcommitted
debug_stream: text_msg: Add CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS
The CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS option limit the number of debug stream slot section to lower number than the actual number of cores. In some situations a high number of cpu sections shrinks the circular buffer size so much that it limit debugging. With this option its possible to use fewer sections. The downside is that the cpus above the number of sections can not send any debug stream messages. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent ab0a089 commit 5ec546b

4 files changed

Lines changed: 35 additions & 16 deletions

File tree

src/debug/debug_stream/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ config SOF_DEBUG_STREAM_THREAD_INFO_TOTAL_CPU_LOAD_TO_LOG
5454
print the total CPU load (sum of all threads) to
5555
the logging system.
5656

57+
config SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS
58+
int "Number of cpu sections slot is divided to"
59+
default CORE_COUNT
60+
range 1 MP_MAX_NUM_CPUS
61+
help
62+
In some situations a high number of cpu sections shrinks the
63+
circular buffer size so much that it limit debugging. With
64+
this option its possible to use fewer sections. The downside
65+
is that the cpus above the number of sections can not send
66+
any debug stream messages.
67+
5768
config SOF_DEBUG_STREAM_TEXT_MSG
5869
bool "Enable text message sending through Debug-Stream"
5970
help

src/debug/debug_stream/debug_stream_slot.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct cpu_mutex {
1919
} __aligned(CONFIG_DCACHE_LINE_SIZE);
2020

2121
/* CPU specific mutexes for each circular buffer */
22-
static struct cpu_mutex cpu_mutex[CONFIG_MP_MAX_NUM_CPUS];
22+
static struct cpu_mutex cpu_mutex[CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS];
2323

2424
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
2525
static struct debug_stream_slot_hdr *dbg_stream_slot;
@@ -54,6 +54,12 @@ debug_stream_get_circular_buffer(struct debug_stream_section_descriptor *desc, u
5454
return NULL;
5555
}
5656

57+
if (core >= CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS) {
58+
LOG_DBG("No section for cpu %u >= %u ", core,
59+
CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS);
60+
return NULL;
61+
}
62+
5763
*desc = hdr->section_desc[core];
5864
LOG_DBG("Section %u (desc %u %u %u)", core, desc->core_id, desc->buf_words, desc->offset);
5965

@@ -116,18 +122,19 @@ int debug_stream_slot_send_record(struct debug_stream_record *rec)
116122
static int debug_stream_slot_init(void)
117123
{
118124
struct debug_stream_slot_hdr *hdr = debug_stream_get_slot();
119-
size_t hdr_size = ALIGN_UP(offsetof(struct debug_stream_slot_hdr,
120-
section_desc[CONFIG_MP_MAX_NUM_CPUS]),
121-
CONFIG_DCACHE_LINE_SIZE);
125+
size_t hdr_size = ALIGN_UP(
126+
offsetof(struct debug_stream_slot_hdr,
127+
section_desc[CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS]),
128+
CONFIG_DCACHE_LINE_SIZE);
122129
size_t section_area_size = ADSP_DW_SLOT_SIZE - hdr_size;
123130
size_t section_size = ALIGN_DOWN(section_area_size /
124-
CONFIG_MP_MAX_NUM_CPUS,
131+
CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS,
125132
CONFIG_DCACHE_LINE_SIZE);
126133
size_t offset = hdr_size;
127134
int i;
128135

129136
LOG_INF("%u sections of %u bytes, hdr %u, section area %u",
130-
CONFIG_MP_MAX_NUM_CPUS, section_size, hdr_size,
137+
CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS, section_size, hdr_size,
131138
section_area_size);
132139

133140
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
@@ -142,9 +149,9 @@ static int debug_stream_slot_init(void)
142149

143150
hdr->hdr.magic = DEBUG_STREAM_IDENTIFIER;
144151
hdr->hdr.hdr_size = hdr_size;
145-
hdr->total_size = hdr_size + CONFIG_MP_MAX_NUM_CPUS * section_size;
146-
hdr->num_sections = CONFIG_MP_MAX_NUM_CPUS;
147-
for (i = 0; i < CONFIG_MP_MAX_NUM_CPUS; i++) {
152+
hdr->total_size = hdr_size + CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS * section_size;
153+
hdr->num_sections = CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS;
154+
for (i = 0; i < CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS; i++) {
148155
hdr->section_desc[i].core_id = i;
149156
hdr->section_desc[i].buf_words =
150157
(section_size - offsetof(struct debug_stream_circular_buf, data[0])) /
@@ -153,7 +160,7 @@ static int debug_stream_slot_init(void)
153160
LOG_DBG("sections %u, size %u, offset %u", i, section_size, offset);
154161
offset += section_size;
155162
}
156-
for (i = 0; i < CONFIG_MP_MAX_NUM_CPUS; i++) {
163+
for (i = 0; i < CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS; i++) {
157164
struct debug_stream_section_descriptor desc = { 0 };
158165
struct debug_stream_circular_buf *buf = debug_stream_get_circular_buffer(&desc, i);
159166

src/debug/debug_stream/debug_stream_text_msg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ void ds_msg(const char *format, ...)
5252
static struct {
5353
struct debug_stream_text_msg msg;
5454
char text[640];
55-
} __packed ds_buf[CONFIG_MP_MAX_NUM_CPUS];
56-
static int reports_sent_cpu[CONFIG_MP_MAX_NUM_CPUS];
57-
static size_t ds_pos[CONFIG_MP_MAX_NUM_CPUS];
55+
} __packed ds_buf[CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS];
56+
static int reports_sent_cpu[CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS];
57+
static size_t ds_pos[CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS];
5858

5959
static void ds_exception_drain(bool flush)
6060
{

src/debug/debug_stream/debug_stream_thread_info.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static struct previous_counters { /* Cached data from previous round */
3333
void *tid; /* thread ID (the thread struct ptr) */
3434
uint64_t cycles; /* cycle counter value */
3535
} threads[THREAD_INFO_MAX_THREADS]; /* The max amount of threads we follow */
36-
} previous[CONFIG_MP_MAX_NUM_CPUS];
36+
} previous[CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS];
3737
#endif
3838

3939
/*
@@ -344,9 +344,10 @@ static void thread_info_run(void *cnum, void *a, void *b)
344344
}
345345

346346
#define THREAD_STACK_SIZE (2048)
347-
static K_THREAD_STACK_ARRAY_DEFINE(info_thread_stacks, CONFIG_MP_MAX_NUM_CPUS,
347+
static K_THREAD_STACK_ARRAY_DEFINE(info_thread_stacks,
348+
CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS,
348349
THREAD_STACK_SIZE);
349-
static struct k_thread info_thread[CONFIG_MP_MAX_NUM_CPUS];
350+
static struct k_thread info_thread[CONFIG_SOF_DEBUG_STREAM_SLOT_FORCE_MAX_CPUS];
350351

351352
static int thread_info_start(void)
352353
{

0 commit comments

Comments
 (0)