All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Loic Poulain <loic.poulain@linaro.org>
Cc: manivannan.sadhasivam@linaro.org, hemantk@codeaurora.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH] mhi: Add tracepoints
Date: Tue, 12 Jan 2021 09:14:49 -0500	[thread overview]
Message-ID: <20210112091449.60f223e0@gandalf.local.home> (raw)
In-Reply-To: <1610445628-29799-1-git-send-email-loic.poulain@linaro.org>

On Tue, 12 Jan 2021 11:00:28 +0100
Loic Poulain <loic.poulain@linaro.org> wrote:

> Add a set of tracepoints for reporting MHI events such as
> MHI transfers, events, doorbell, etc...
> 
> This can be used for debugging purpose.
> 
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> ---
>  drivers/bus/mhi/core/main.c |  12 +++++
>  include/trace/events/mhi.h  | 121 ++++++++++++++++++++++++++++++++++++++++++++

I would make the events/mhi.h file as drivers/bus/mhi/core/trace.h instead.
See below.

>  2 files changed, 133 insertions(+)
>  create mode 100644 include/trace/events/mhi.h
> 
> diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
> index c1eb43d..312e4db 100644
> --- a/drivers/bus/mhi/core/main.c
> +++ b/drivers/bus/mhi/core/main.c
> @@ -15,6 +15,9 @@
>  #include <linux/slab.h>
>  #include "internal.h"
>  
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/mhi.h>
> +
>  int __must_check mhi_read_reg(struct mhi_controller *mhi_cntrl,
>  			      void __iomem *base, u32 offset, u32 *out)
>  {
> @@ -61,6 +64,8 @@ void mhi_write_reg_field(struct mhi_controller *mhi_cntrl, void __iomem *base,
>  void mhi_write_db(struct mhi_controller *mhi_cntrl, void __iomem *db_addr,
>  		  dma_addr_t db_val)
>  {
> +	trace_mhi_ring_doorbell(db_addr, db_val, mhi_cntrl);
> +
>  	mhi_write_reg(mhi_cntrl, db_addr, 4, upper_32_bits(db_val));
>  	mhi_write_reg(mhi_cntrl, db_addr, 0, lower_32_bits(db_val));
>  }
> @@ -118,6 +123,7 @@ void mhi_ring_chan_db(struct mhi_controller *mhi_cntrl,
>  	 */
>  	dma_wmb();
>  	*ring->ctxt_wp = db;
> +	trace_mhi_update_ring_wp(ring, mhi_cntrl);
>  
>  	mhi_chan->db_cfg.process_db(mhi_cntrl, &mhi_chan->db_cfg,
>  				    ring->db_addr, db);
> @@ -724,6 +730,8 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl,
>  	while (dev_rp != local_rp) {
>  		enum mhi_pkt_type type = MHI_TRE_GET_EV_TYPE(local_rp);
>  
> +		trace_mhi_event(local_rp, mhi_cntrl);
> +
>  		switch (type) {
>  		case MHI_PKT_TYPE_BW_REQ_EVENT:
>  		{
> @@ -872,6 +880,8 @@ int mhi_process_data_event_ring(struct mhi_controller *mhi_cntrl,
>  
>  		WARN_ON(chan >= mhi_cntrl->max_chan);
>  
> +		trace_mhi_event(local_rp, mhi_cntrl);
> +
>  		/*
>  		 * Only process the event ring elements whose channel
>  		 * ID is within the maximum supported range.
> @@ -1098,6 +1108,8 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
>  	mhi_add_ring_element(mhi_cntrl, tre_ring);
>  	mhi_add_ring_element(mhi_cntrl, buf_ring);
>  
> +	trace_mhi_transfer(mhi_tre, mhi_cntrl, mhi_chan->chan);
> +
>  	return 0;
>  }
>  
> diff --git a/include/trace/events/mhi.h b/include/trace/events/mhi.h
> new file mode 100644
> index 0000000..903fdd4
> --- /dev/null
> +++ b/include/trace/events/mhi.h
> @@ -0,0 +1,121 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM mhi
> +
> +#if !defined(_TRACE_MHI_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _TRACE_MHI_H
> +
> +#include <linux/mhi.h>
> +#include <linux/tracepoint.h>
> +
> +#include "../../drivers/bus/mhi/core/internal.h"


Instead of adding the mhi.h file into the top level events directory, and
doing the above path search, simply place this file in the
drivers/bus/mhi/core directory as "trace.h". It would require adding:

CFLAGS_main.o := -I$(src)

in drivers/bus/mhi/core/Makefile and some updates at the end of this file
(see below).


> +
> +TRACE_EVENT(mhi_transfer,
> +
> +	TP_PROTO(struct mhi_tre *tre, struct mhi_controller *cntrl, u32 chan),
> +
> +	TP_ARGS(tre, cntrl, chan),
> +
> +	TP_STRUCT__entry(
> +		__field(int,	cntrl_index)
> +		__field(u32,	channel)
> +		__field(void *,	treaddr)
> +		__field(u64,	treptr)
> +		__field(u32,	tredword0)
> +		__field(u32,	tredword1)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->cntrl_index = cntrl->index;
> +		__entry->channel = chan;
> +		__entry->treaddr = tre;
> +		__entry->treptr = tre->ptr;
> +		__entry->tredword0 = tre->dword[0];
> +		__entry->tredword1 = tre->dword[1];
> +	),
> +
> +	TP_printk("mhi%d.%u treaddr=%p treptr=%llx tredword0=%08x tredword1=%08x",
> +		  __entry->cntrl_index, __entry->channel, __entry->treaddr,
> +		  __entry->treptr, __entry->tredword0, __entry->tredword1)
> +);
> +
> +TRACE_EVENT(mhi_update_ring_wp,
> +
> +	TP_PROTO(struct mhi_ring *ring, struct mhi_controller *cntrl),
> +
> +	TP_ARGS(ring, cntrl),
> +
> +	TP_STRUCT__entry(
> +		__field(int,	cntrl_index)
> +		__field(void *,	ring)
> +		__field(void *,	wp_host)
> +		__field(u64,	wp_device)

BTW, when possible, always place extra 32 bit types at the end if there's
64 bit types or long/pointer values. That is, if you can't pair two 32 bit
types together, have the last one at the end of the TP_STRUCT. It will save
4 bytes in the ring buffer for archs that only need 4 byte alignment on 64
bit words.

> +	),
> +
> +	TP_fast_assign(
> +		__entry->cntrl_index = cntrl->index;
> +		__entry->ring = ring;
> +		__entry->wp_host = ring->wp;
> +		__entry->wp_device = *ring->ctxt_wp;
> +	),
> +
> +	TP_printk("mhi%d ringaddr=%p wp_host=%p wp_device=%llx",
> +		  __entry->cntrl_index, __entry->ring, __entry->wp_host,
> +		  __entry->wp_device)
> +);
> +
> +TRACE_EVENT(mhi_ring_doorbell,
> +
> +	TP_PROTO(void __iomem *db_addr, dma_addr_t db_val, struct mhi_controller *cntrl),
> +
> +	TP_ARGS(db_addr, db_val, cntrl),
> +
> +	TP_STRUCT__entry(
> +		__field(int,		cntrl_index)
> +		__field(void *,		dbaddr)
> +		__field(dma_addr_t,	dbval)

I don't know how big dma_addr_t is, but still I would place the int at the
end.

> +	),
> +
> +	TP_fast_assign(
> +		__entry->cntrl_index = cntrl->index;
> +		__entry->dbaddr = db_addr;
> +		__entry->dbval = db_val;
> +	),
> +
> +	TP_printk("mhi%d dbaddr=%p dbval=%llx", __entry->cntrl_index,
> +		  __entry->dbaddr, __entry->dbval)
> +);
> +
> +TRACE_EVENT(mhi_event,
> +
> +	TP_PROTO(struct mhi_tre *tre, struct mhi_controller *cntrl),
> +
> +	TP_ARGS(tre, cntrl),
> +
> +	TP_STRUCT__entry(
> +		__field(int,		cntrl_index)
> +		__field(u32,		channel)
> +		__field(unsigned int,	type)

One of the above int 32 bit types should go to the end.

> +		__field(u64,		treptr)
> +		__field(u32,		tredword0)
> +		__field(u32,		tredword1)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->cntrl_index = cntrl->index;
> +		__entry->channel = MHI_TRE_GET_EV_CHID(tre);
> +		__entry->type = MHI_TRE_GET_EV_TYPE(tre);
> +		__entry->treptr = tre->ptr;
> +		__entry->tredword0 = tre->dword[0];
> +		__entry->tredword1 = tre->dword[1];
> +	),
> +
> +	TP_printk("mhi%d.%u type=%u treptr=%llx tredword0=%08x tredword1=%08x",
> +		  __entry->cntrl_index, __entry->channel, __entry->type,
> +		  __entry->treptr, __entry->tredword0, __entry->tredword1)
> +);
> +
> +#endif /* _TRACE_MHI_H */
> +

To have this file called "trace.h" in the drivers/bus/mhi/core directory,
you would need to also add:

#undef TRACE_INCLUDE_PATH
#undef TRACE_INCLUDE_FILE

#define TRACE_INCLUDE_PATH .
#define TRACE_INCLUDE_FILE trace


-- Steve

> +/* This part must be outside protection */
> +#include <trace/define_trace.h>


      reply	other threads:[~2021-01-12 14:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 10:00 [PATCH] mhi: Add tracepoints Loic Poulain
2021-01-12 14:14 ` Steven Rostedt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210112091449.60f223e0@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=hemantk@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=loic.poulain@linaro.org \
    --cc=manivannan.sadhasivam@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.