From: Cezary Rojewski Date: Thu, 28 May 2026 08:34:43 +0000 (+0200) Subject: ASoC: Intel: catpt: Add pretty-trace for large IPC payloads X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ee392ea75c7e5dc172c769dd16b55b314f93208;p=thirdparty%2Flinux.git ASoC: Intel: catpt: Add pretty-trace for large IPC payloads 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 Link: https://patch.msgid.link/20260528083444.1439233-3-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/intel/catpt/Makefile b/sound/soc/intel/catpt/Makefile index e8316e33b8200..8005fc677f288 100644 --- a/sound/soc/intel/catpt/Makefile +++ b/sound/soc/intel/catpt/Makefile @@ -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 diff --git a/sound/soc/intel/catpt/device.c b/sound/soc/intel/catpt/device.c index ca4fd18b6a6e1..6fe212f498c6a 100644 --- a/sound/soc/intel/catpt/device.c +++ b/sound/soc/intel/catpt/device.c @@ -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 index 0000000000000..e97c372cc2afb --- /dev/null +++ b/sound/soc/intel/catpt/trace.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include + +#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; + } +} diff --git a/sound/soc/intel/catpt/trace.h b/sound/soc/intel/catpt/trace.h index 010f57b6a7a89..6b528d9337346 100644 --- a/sound/soc/intel/catpt/trace.h +++ b/sound/soc/intel/catpt/trace.h @@ -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 */