Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: SOF: ipc4-mtrace: move debug slot related definitions to header.h

The macro definitions of debug slot can be used by gdb, telemetry
and mtrace log, so move these definitions to header.h from mtrace.
Then these macro definitions can be shared

Signed-off-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230919092416.4137-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Rander Wang and committed by
Mark Brown
42872050 58bb5081

+26 -21
+17
include/sound/sof/ipc4/header.h
··· 515 515 uint32_t data[6]; 516 516 } __packed __aligned(4); 517 517 518 + #define SOF_IPC4_DEBUG_DESCRIPTOR_SIZE 12 /* 3 x u32 */ 519 + 520 + /* 521 + * The debug memory window is divided into 16 slots, and the 522 + * first slot is used as a recorder for the other 15 slots. 523 + */ 524 + #define SOF_IPC4_MAX_DEBUG_SLOTS 15 525 + #define SOF_IPC4_DEBUG_SLOT_SIZE 0x1000 526 + 527 + /* debug log slot types */ 528 + #define SOF_IPC4_DEBUG_SLOT_UNUSED 0x00000000 529 + #define SOF_IPC4_DEBUG_SLOT_CRITICAL_LOG 0x54524300 /* byte 0: core ID */ 530 + #define SOF_IPC4_DEBUG_SLOT_DEBUG_LOG 0x474f4c00 /* byte 0: core ID */ 531 + #define SOF_IPC4_DEBUG_SLOT_GDB_STUB 0x42444700 532 + #define SOF_IPC4_DEBUG_SLOT_TELEMETRY 0x4c455400 533 + #define SOF_IPC4_DEBUG_SLOT_BROKEN 0x44414544 534 + 518 535 /** @}*/ 519 536 520 537 #endif
+9 -21
sound/soc/sof/ipc4-mtrace.c
··· 41 41 * The two pointers are offsets within the buffer. 42 42 */ 43 43 44 - #define SOF_MTRACE_DESCRIPTOR_SIZE 12 /* 3 x u32 */ 45 - 46 44 #define FW_EPOCH_DELTA 11644473600LL 47 45 48 - #define INVALID_SLOT_OFFSET 0xffffffff 49 46 #define MAX_ALLOWED_LIBRARIES 16 50 - #define MAX_MTRACE_SLOTS 15 51 47 52 - #define SOF_MTRACE_PAGE_SIZE 0x1000 53 - #define SOF_MTRACE_SLOT_SIZE SOF_MTRACE_PAGE_SIZE 48 + #define SOF_IPC4_INVALID_SLOT_OFFSET 0xffffffff 54 49 55 - /* debug log slot types */ 56 - #define SOF_MTRACE_SLOT_UNUSED 0x00000000 57 - #define SOF_MTRACE_SLOT_CRITICAL_LOG 0x54524300 /* byte 0: core ID */ 58 - #define SOF_MTRACE_SLOT_DEBUG_LOG 0x474f4c00 /* byte 0: core ID */ 59 - #define SOF_MTRACE_SLOT_GDB_STUB 0x42444700 60 - #define SOF_MTRACE_SLOT_TELEMETRY 0x4c455400 61 - #define SOF_MTRACE_SLOT_BROKEN 0x44414544 62 50 /* for debug and critical types */ 63 51 #define SOF_MTRACE_SLOT_CORE_MASK GENMASK(7, 0) 64 52 #define SOF_MTRACE_SLOT_TYPE_MASK GENMASK(31, 8) ··· 128 140 if (unlikely(ret)) 129 141 goto out; 130 142 131 - core_data->log_buffer = kmalloc(SOF_MTRACE_SLOT_SIZE, GFP_KERNEL); 143 + core_data->log_buffer = kmalloc(SOF_IPC4_DEBUG_SLOT_SIZE, GFP_KERNEL); 132 144 if (!core_data->log_buffer) { 133 145 debugfs_file_put(file->f_path.dentry); 134 146 ret = -ENOMEM; ··· 200 212 return 0; 201 213 } 202 214 203 - if (core_data->slot_offset == INVALID_SLOT_OFFSET) 215 + if (core_data->slot_offset == SOF_IPC4_INVALID_SLOT_OFFSET) 204 216 return 0; 205 217 206 218 /* The log data buffer starts after the two pointer in the slot */ 207 219 log_buffer_offset = core_data->slot_offset + (sizeof(u32) * 2); 208 220 /* The log data size excludes the pointers */ 209 - log_buffer_size = SOF_MTRACE_SLOT_SIZE - (sizeof(u32) * 2); 221 + log_buffer_size = SOF_IPC4_DEBUG_SLOT_SIZE - (sizeof(u32) * 2); 210 222 211 223 read_ptr = core_data->host_read_ptr; 212 224 write_ptr = core_data->dsp_write_ptr; ··· 498 510 u32 slot_desc_type_offset, type, core; 499 511 int i; 500 512 501 - for (i = 0; i < MAX_MTRACE_SLOTS; i++) { 513 + for (i = 0; i < SOF_IPC4_MAX_DEBUG_SLOTS; i++) { 502 514 /* The type is the second u32 in the slot descriptor */ 503 515 slot_desc_type_offset = sdev->debug_box.offset; 504 - slot_desc_type_offset += SOF_MTRACE_DESCRIPTOR_SIZE * i + sizeof(u32); 516 + slot_desc_type_offset += SOF_IPC4_DEBUG_DESCRIPTOR_SIZE * i + sizeof(u32); 505 517 sof_mailbox_read(sdev, slot_desc_type_offset, &type, sizeof(type)); 506 518 507 - if ((type & SOF_MTRACE_SLOT_TYPE_MASK) == SOF_MTRACE_SLOT_DEBUG_LOG) { 519 + if ((type & SOF_MTRACE_SLOT_TYPE_MASK) == SOF_IPC4_DEBUG_SLOT_DEBUG_LOG) { 508 520 core = type & SOF_MTRACE_SLOT_CORE_MASK; 509 521 510 522 if (core >= sdev->num_cores) { ··· 521 533 * debug_box + SOF_MTRACE_SLOT_SIZE offset 522 534 */ 523 535 core_data->slot_offset = sdev->debug_box.offset; 524 - core_data->slot_offset += SOF_MTRACE_SLOT_SIZE * (i + 1); 536 + core_data->slot_offset += SOF_IPC4_DEBUG_SLOT_SIZE * (i + 1); 525 537 dev_dbg(sdev->dev, "slot%d is used for core%u\n", i, core); 526 538 if (core_data->delayed_pos_update) { 527 539 sof_ipc4_mtrace_update_pos(sdev, core); ··· 621 633 622 634 core_data = &priv->cores[core]; 623 635 624 - if (core_data->slot_offset == INVALID_SLOT_OFFSET) { 636 + if (core_data->slot_offset == SOF_IPC4_INVALID_SLOT_OFFSET) { 625 637 core_data->delayed_pos_update = true; 626 638 return 0; 627 639 }