]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: Intel: catpt: Add pretty-trace for large IPC payloads
authorCezary Rojewski <cezary.rojewski@intel.com>
Thu, 28 May 2026 08:34:43 +0000 (10:34 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 28 May 2026 18:12:49 +0000 (19:12 +0100)
Mimic mechanism found in the Intel's avs-driver and update the existing
IPC payload tracing to allow for pretty printing even large payloads.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://patch.msgid.link/20260528083444.1439233-3-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/catpt/Makefile
sound/soc/intel/catpt/device.c
sound/soc/intel/catpt/trace.c [new file with mode: 0644]
sound/soc/intel/catpt/trace.h

index e8316e33b82002a6b1812e900cbf3acc67959357..8005fc677f288e283ef9db97ec493215050539ae 100644 (file)
@@ -1,7 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 snd-soc-catpt-y := device.o dsp.o loader.o ipc.o messages.o pcm.o sysfs.o
 
+snd-soc-catpt-y += trace.o
 # tell define_trace.h where to find the trace header
-CFLAGS_device.o := -I$(src)
+CFLAGS_trace.o := -I$(src)
 
 obj-$(CONFIG_SND_SOC_INTEL_CATPT) += snd-soc-catpt.o
index ca4fd18b6a6e1afc5e16990c73945eec117f5db9..6fe212f498c6a26d3e4ae79322dcb36e4a500383 100644 (file)
@@ -25,9 +25,6 @@
 #include "core.h"
 #include "registers.h"
 
-#define CREATE_TRACE_POINTS
-#include "trace.h"
-
 static int catpt_do_suspend(struct device *dev)
 {
        struct catpt_dev *cdev = dev_get_drvdata(dev);
diff --git a/sound/soc/intel/catpt/trace.c b/sound/soc/intel/catpt/trace.c
new file mode 100644 (file)
index 0000000..e97c372
--- /dev/null
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/types.h>
+
+#define CREATE_TRACE_POINTS
+#include "trace.h"
+
+#define BYTES_PER_LINE 16
+#define MAX_CHUNK_SIZE ((PAGE_SIZE - 150) /* Place for trace header */ \
+                       / (2 * BYTES_PER_LINE + 4) /* chars per line */ \
+                       * BYTES_PER_LINE)
+
+void trace_catpt_ipc_payload(const void *data, size_t size)
+{
+       size_t remaining = size;
+       size_t offset = 0;
+
+       while (remaining > 0) {
+               u32 chunk;
+
+               chunk = min_t(size_t, remaining, MAX_CHUNK_SIZE);
+               trace_catpt_ipc_payload_chunk(data, chunk, offset, size);
+
+               remaining -= chunk;
+               offset += chunk;
+       }
+}
index 010f57b6a7a896734a9db3668a6018a0c0c31a26..6b528d9337346c7daa692abd6a519c6d5d788d2f 100644 (file)
@@ -51,29 +51,37 @@ DEFINE_EVENT(catpt_ipc_msg, catpt_ipc_notify,
        TP_ARGS(header)
 );
 
-TRACE_EVENT_CONDITION(catpt_ipc_payload,
+TRACE_EVENT_CONDITION(catpt_ipc_payload_chunk,
 
-       TP_PROTO(const u8 *data, size_t size),
+       TP_PROTO(const u8 *data, size_t size, size_t offset, size_t total),
 
-       TP_ARGS(data, size),
+       TP_ARGS(data, size, offset, total),
 
        TP_CONDITION(data && size),
 
        TP_STRUCT__entry(
-               __dynamic_array(u8, buf, size)
+               __dynamic_array(u8,     buf,    size    )
+               __field(size_t,         offset          )
+               __field(size_t,         pos             )
+               __field(size_t,         total           )
        ),
 
        TP_fast_assign(
-               memcpy(__get_dynamic_array(buf), data, size);
+               memcpy(__get_dynamic_array(buf), data + offset, size);
+               __entry->offset = offset;
+               __entry->pos = offset + size;
+               __entry->total = total;
        ),
 
-       TP_printk("%u byte(s)%s",
-                 __get_dynamic_array_len(buf),
+       TP_printk("range %zu-%zu out of %zu bytes%s",
+                 __entry->offset, __entry->pos, __entry->total,
                  __print_hex_dump("", DUMP_PREFIX_NONE, 16, 4,
                                   __get_dynamic_array(buf),
                                   __get_dynamic_array_len(buf), false))
 );
 
+void trace_catpt_ipc_payload(const void *data, size_t size);
+
 #endif /* __SND_SOC_INTEL_CATPT_TRACE_H */
 
 /* This part must be outside protection */