[PATCH v8 08/14] ASoC: Intel: catpt: Event tracing
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Wed Sep 23 15:29:57 CEST 2020
On Wed, Sep 23, 2020 at 02:25:02PM +0200, Cezary Rojewski wrote:
> Define tracing macros for easy catpt debug. These cover all IPC message
> types: requests, replies and notifications.
FWIW,
Reviewed-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
> Signed-off-by: Cezary Rojewski <cezary.rojewski at intel.com>
> ---
>
> Changes in v6:
> - trace usage now part of this patch instead of being separated from it
>
> Changes in v2:
> - trace.h events for updating registers have been removed and usages
> replaced by dev_dbg (SRAMPGE/ LPCS)
> - trace.h events for catpt_mbank and catpt_mregion have been removed
>
> sound/soc/intel/catpt/device.c | 3 ++
> sound/soc/intel/catpt/ipc.c | 11 +++++
> sound/soc/intel/catpt/trace.h | 83 ++++++++++++++++++++++++++++++++++
> 3 files changed, 97 insertions(+)
> create mode 100644 sound/soc/intel/catpt/trace.h
>
> diff --git a/sound/soc/intel/catpt/device.c b/sound/soc/intel/catpt/device.c
> index e7dc2fb69ea8..c02d46e5bc81 100644
> --- a/sound/soc/intel/catpt/device.c
> +++ b/sound/soc/intel/catpt/device.c
> @@ -25,6 +25,9 @@
> #include "core.h"
> #include "registers.h"
>
> +#define CREATE_TRACE_POINTS
> +#include "trace.h"
> +
> static int __maybe_unused catpt_suspend(struct device *dev)
> {
> struct catpt_dev *cdev = dev_get_drvdata(dev);
> diff --git a/sound/soc/intel/catpt/ipc.c b/sound/soc/intel/catpt/ipc.c
> index e4569be02bbc..925a193a9932 100644
> --- a/sound/soc/intel/catpt/ipc.c
> +++ b/sound/soc/intel/catpt/ipc.c
> @@ -9,6 +9,7 @@
> #include "core.h"
> #include "messages.h"
> #include "registers.h"
> +#include "trace.h"
>
> #define CATPT_IPC_TIMEOUT_MS 300
>
> @@ -56,6 +57,9 @@ static void catpt_dsp_send_tx(struct catpt_dev *cdev,
> {
> u32 header = tx->header | CATPT_IPCC_BUSY;
>
> + trace_catpt_ipc_request(header);
> + trace_catpt_ipc_payload(tx->data, tx->size);
> +
> if (tx->size)
> memcpy_toio(catpt_outbox_addr(cdev), tx->data, tx->size);
> catpt_writel_shim(cdev, IPCC, header);
> @@ -155,12 +159,14 @@ catpt_dsp_notify_stream(struct catpt_dev *cdev, union catpt_notify_msg msg)
> switch (msg.notify_reason) {
> case CATPT_NOTIFY_POSITION_CHANGED:
> memcpy_fromio(&pos, catpt_inbox_addr(cdev), sizeof(pos));
> + trace_catpt_ipc_payload((u8 *)&pos, sizeof(pos));
>
> catpt_stream_update_position(cdev, stream, &pos);
> break;
>
> case CATPT_NOTIFY_GLITCH_OCCURRED:
> memcpy_fromio(&glitch, catpt_inbox_addr(cdev), sizeof(glitch));
> + trace_catpt_ipc_payload((u8 *)&glitch, sizeof(glitch));
>
> dev_warn(cdev->dev, "glitch %d at pos: 0x%08llx, wp: 0x%08x\n",
> glitch.type, glitch.presentation_pos,
> @@ -182,6 +188,7 @@ static void catpt_dsp_copy_rx(struct catpt_dev *cdev, u32 header)
> if (ipc->rx.size && ipc->rx.rsp.status == CATPT_REPLY_SUCCESS) {
> memcpy_fromio(ipc->rx.data, catpt_outbox_addr(cdev),
> ipc->rx.size);
> + trace_catpt_ipc_payload(ipc->rx.data, ipc->rx.size);
> }
> }
>
> @@ -196,6 +203,7 @@ static void catpt_dsp_process_response(struct catpt_dev *cdev, u32 header)
> u32 off = msg.mailbox_address << 3;
>
> memcpy_fromio(&config, cdev->lpe_ba + off, sizeof(config));
> + trace_catpt_ipc_payload((u8 *)&config, sizeof(config));
>
> catpt_ipc_arm(ipc, &config);
> complete(&cdev->fw_ready);
> @@ -236,6 +244,7 @@ irqreturn_t catpt_dsp_irq_thread(int irq, void *dev_id)
> u32 ipcd;
>
> ipcd = catpt_readl_shim(cdev, IPCD);
> + trace_catpt_ipc_notify(ipcd);
>
> /* ensure there is delayed reply or notification to process */
> if (!(ipcd & CATPT_IPCD_BUSY))
> @@ -259,6 +268,7 @@ irqreturn_t catpt_dsp_irq_handler(int irq, void *dev_id)
> u32 isc, ipcc;
>
> isc = catpt_readl_shim(cdev, ISC);
> + trace_catpt_irq(isc);
>
> /* immediate reply */
> if (isc & CATPT_ISC_IPCCD) {
> @@ -266,6 +276,7 @@ irqreturn_t catpt_dsp_irq_handler(int irq, void *dev_id)
> catpt_updatel_shim(cdev, IMC, CATPT_IMC_IPCCD, CATPT_IMC_IPCCD);
>
> ipcc = catpt_readl_shim(cdev, IPCC);
> + trace_catpt_ipc_reply(ipcc);
> catpt_dsp_copy_rx(cdev, ipcc);
> complete(&cdev->ipc.done_completion);
>
> diff --git a/sound/soc/intel/catpt/trace.h b/sound/soc/intel/catpt/trace.h
> new file mode 100644
> index 000000000000..bb3d627dbeaf
> --- /dev/null
> +++ b/sound/soc/intel/catpt/trace.h
> @@ -0,0 +1,83 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright(c) 2020 Intel Corporation. All rights reserved.
> + *
> + * Author: Cezary Rojewski <cezary.rojewski at intel.com>
> + */
> +
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM intel_catpt
> +
> +#if !defined(__SND_SOC_INTEL_CATPT_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define __SND_SOC_INTEL_CATPT_TRACE_H
> +
> +#include <linux/types.h>
> +#include <linux/tracepoint.h>
> +
> +DECLARE_EVENT_CLASS(catpt_ipc_msg,
> +
> + TP_PROTO(u32 header),
> +
> + TP_ARGS(header),
> +
> + TP_STRUCT__entry(
> + __field(u32, header)
> + ),
> +
> + TP_fast_assign(
> + __entry->header = header;
> + ),
> +
> + TP_printk("0x%08x", __entry->header)
> +);
> +
> +DEFINE_EVENT(catpt_ipc_msg, catpt_irq,
> + TP_PROTO(u32 header),
> + TP_ARGS(header)
> +);
> +
> +DEFINE_EVENT(catpt_ipc_msg, catpt_ipc_request,
> + TP_PROTO(u32 header),
> + TP_ARGS(header)
> +);
> +
> +DEFINE_EVENT(catpt_ipc_msg, catpt_ipc_reply,
> + TP_PROTO(u32 header),
> + TP_ARGS(header)
> +);
> +
> +DEFINE_EVENT(catpt_ipc_msg, catpt_ipc_notify,
> + TP_PROTO(u32 header),
> + TP_ARGS(header)
> +);
> +
> +TRACE_EVENT_CONDITION(catpt_ipc_payload,
> +
> + TP_PROTO(const u8 *data, size_t size),
> +
> + TP_ARGS(data, size),
> +
> + TP_CONDITION(data && size),
> +
> + TP_STRUCT__entry(
> + __dynamic_array(u8, buf, size)
> + ),
> +
> + TP_fast_assign(
> + memcpy(__get_dynamic_array(buf), data, size);
> + ),
> +
> + TP_printk("%u byte(s)%s",
> + __get_dynamic_array_len(buf),
> + __print_hex_dump("", DUMP_PREFIX_NONE, 16, 4,
> + __get_dynamic_array(buf),
> + __get_dynamic_array_len(buf), false))
> +);
> +
> +#endif /* __SND_SOC_INTEL_CATPT_TRACE_H */
> +
> +/* This part must be outside protection */
> +#undef TRACE_INCLUDE_PATH
> +#define TRACE_INCLUDE_PATH .
> +#define TRACE_INCLUDE_FILE trace
> +#include <trace/define_trace.h>
> --
> 2.17.1
>
--
With Best Regards,
Andy Shevchenko
More information about the Alsa-devel
mailing list