ASoC: SOF: ipc4-mtrace: move debug slot related definitions to header.h
authorRander Wang <rander.wang@intel.com>
Tue, 19 Sep 2023 09:24:09 +0000 (12:24 +0300)
committerMark Brown <broonie@kernel.org>
Tue, 19 Sep 2023 12:48:45 +0000 (13:48 +0100)
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>
include/sound/sof/ipc4/header.h
sound/soc/sof/ipc4-mtrace.c

index c58f00ef054a78b76acf2315ef0dc37416e55804..574a9d581f8895c0a8a434623bd17be561279aae 100644 (file)
@@ -515,6 +515,23 @@ 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.
+ */
+#define SOF_IPC4_MAX_DEBUG_SLOTS               15
+#define SOF_IPC4_DEBUG_SLOT_SIZE               0x1000
+
+/* 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 */
+#define SOF_IPC4_DEBUG_SLOT_GDB_STUB           0x42444700
+#define SOF_IPC4_DEBUG_SLOT_TELEMETRY          0x4c455400
+#define SOF_IPC4_DEBUG_SLOT_BROKEN             0x44414544
+
 /** @}*/
 
 #endif
index 2b4659a1768e96154cbd730d0a066d50c776489e..9f1e33ee8826123cdc57bd0da78b876e79bf6f27 100644 (file)
  * The two pointers are offsets within the buffer.
  */
 
-#define SOF_MTRACE_DESCRIPTOR_SIZE             12 /* 3 x u32 */
-
 #define FW_EPOCH_DELTA                         11644473600LL
 
-#define INVALID_SLOT_OFFSET                    0xffffffff
 #define MAX_ALLOWED_LIBRARIES                  16
-#define MAX_MTRACE_SLOTS                       15
-
-#define SOF_MTRACE_PAGE_SIZE                   0x1000
-#define SOF_MTRACE_SLOT_SIZE                   SOF_MTRACE_PAGE_SIZE
-
-/* debug log slot types */
-#define SOF_MTRACE_SLOT_UNUSED                 0x00000000
-#define SOF_MTRACE_SLOT_CRITICAL_LOG           0x54524300 /* byte 0: core ID */
-#define SOF_MTRACE_SLOT_DEBUG_LOG              0x474f4c00 /* byte 0: core ID */
-#define SOF_MTRACE_SLOT_GDB_STUB               0x42444700
-#define SOF_MTRACE_SLOT_TELEMETRY              0x4c455400
-#define SOF_MTRACE_SLOT_BROKEN                 0x44414544
+
+#define SOF_IPC4_INVALID_SLOT_OFFSET           0xffffffff
+
  /* for debug and critical types */
 #define SOF_MTRACE_SLOT_CORE_MASK              GENMASK(7, 0)
 #define SOF_MTRACE_SLOT_TYPE_MASK              GENMASK(31, 8)
@@ -140,7 +128,7 @@ static int sof_ipc4_mtrace_dfs_open(struct inode *inode, struct file *file)
        if (unlikely(ret))
                goto out;
 
-       core_data->log_buffer = kmalloc(SOF_MTRACE_SLOT_SIZE, GFP_KERNEL);
+       core_data->log_buffer = kmalloc(SOF_IPC4_DEBUG_SLOT_SIZE, GFP_KERNEL);
        if (!core_data->log_buffer) {
                debugfs_file_put(file->f_path.dentry);
                ret = -ENOMEM;
@@ -212,13 +200,13 @@ static ssize_t sof_ipc4_mtrace_dfs_read(struct file *file, char __user *buffer,
                return 0;
        }
 
-       if (core_data->slot_offset == INVALID_SLOT_OFFSET)
+       if (core_data->slot_offset == SOF_IPC4_INVALID_SLOT_OFFSET)
                return 0;
 
        /* The log data buffer starts after the two pointer in the slot */
        log_buffer_offset =  core_data->slot_offset + (sizeof(u32) * 2);
        /* The log data size excludes the pointers */
-       log_buffer_size = SOF_MTRACE_SLOT_SIZE - (sizeof(u32) * 2);
+       log_buffer_size = SOF_IPC4_DEBUG_SLOT_SIZE - (sizeof(u32) * 2);
 
        read_ptr = core_data->host_read_ptr;
        write_ptr = core_data->dsp_write_ptr;
@@ -510,13 +498,13 @@ static void sof_mtrace_find_core_slots(struct snd_sof_dev *sdev)
        u32 slot_desc_type_offset, type, core;
        int i;
 
-       for (i = 0; i < MAX_MTRACE_SLOTS; i++) {
+       for (i = 0; i < SOF_IPC4_MAX_DEBUG_SLOTS; i++) {
                /* The type is the second u32 in the slot descriptor */
                slot_desc_type_offset = sdev->debug_box.offset;
-               slot_desc_type_offset += SOF_MTRACE_DESCRIPTOR_SIZE * i + sizeof(u32);
+               slot_desc_type_offset += SOF_IPC4_DEBUG_DESCRIPTOR_SIZE * i + sizeof(u32);
                sof_mailbox_read(sdev, slot_desc_type_offset, &type, sizeof(type));
 
-               if ((type & SOF_MTRACE_SLOT_TYPE_MASK) == SOF_MTRACE_SLOT_DEBUG_LOG) {
+               if ((type & SOF_MTRACE_SLOT_TYPE_MASK) == SOF_IPC4_DEBUG_SLOT_DEBUG_LOG) {
                        core = type & SOF_MTRACE_SLOT_CORE_MASK;
 
                        if (core >= sdev->num_cores) {
@@ -533,7 +521,7 @@ static void sof_mtrace_find_core_slots(struct snd_sof_dev *sdev)
                         * debug_box + SOF_MTRACE_SLOT_SIZE offset
                         */
                        core_data->slot_offset = sdev->debug_box.offset;
-                       core_data->slot_offset += SOF_MTRACE_SLOT_SIZE * (i + 1);
+                       core_data->slot_offset += SOF_IPC4_DEBUG_SLOT_SIZE * (i + 1);
                        dev_dbg(sdev->dev, "slot%d is used for core%u\n", i, core);
                        if (core_data->delayed_pos_update) {
                                sof_ipc4_mtrace_update_pos(sdev, core);
@@ -633,7 +621,7 @@ int sof_ipc4_mtrace_update_pos(struct snd_sof_dev *sdev, int core)
 
        core_data = &priv->cores[core];
 
-       if (core_data->slot_offset == INVALID_SLOT_OFFSET) {
+       if (core_data->slot_offset == SOF_IPC4_INVALID_SLOT_OFFSET) {
                core_data->delayed_pos_update = true;
                return 0;
        }