dma: tegra: add tracepoints to driver
PATCH 5/6 dma: tegra: add tracepoints to driver
Quoted 10 lines · On Wed, 31 Oct 2018 16:03:08 +0000 Ben Dooks <[email protected]> wrote:
include/trace/events/tegra_apb_dma.h new file +4
-0@@ -0,0 +1,61 @@ +#if !defined(_TRACE_TEGRA_APB_DMA_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_TEGRA_APM_DMA_H + +#include <linux/tracepoint.h>
include/trace/events/tegra_apb_dma.h line 14
Quoted 10 lines
include/trace/events/tegra_apb_dma.h new file +10
-0+#include <linux/dmaengine.h> + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM tegra_apb_dma + +TRACE_EVENT(tegra_dma_tx_status, + TP_PROTO(struct dma_chan *dc, s32 cookie, u32 residue), + TP_ARGS(dc, cookie, residue), + TP_STRUCT__entry( + __string(chan, 16)
Hi Ben,
Was this tested? Because I think __string(chan, 16) would fault, as the second parameter is meant to be a pointer to the source parameter.
Otherwise, you need to add dev_name(&dc->dev->device) as the second parameter.
If you are just using fixed string lengths then it's best not to use the __string() type, as that's for dynamic strings (strings changing in size for each event) and uses 8 more bytes to store the offset and length of the string in the event.
If you take a look at the sched_waking or sched_switch trace events in include/trace/events/sched.h you'll see that it saves the comm string directly as a character array:
__array( char, comm, TASK_COMM_LEN)
For you, you can use:
__array(char, chan, 16)
include/trace/events/tegra_apb_dma.h line 19
Quoted 5 lines
include/trace/events/tegra_apb_dma.h new file +5
-0+ __field(__s32, cookie) +__field (__u32, residue) + ), +TP_fast_assign ( + __assign_str(chan, dev_name(&dc->dev->device));
Then to store the array:
memcpy(__entry->chan, dev_name(&dc->dev->device), 16);
include/trace/events/tegra_apb_dma.h line 23
Quoted 4 lines
include/trace/events/tegra_apb_dma.h new file +4
-0+ __entry->cookie = cookie; + __entry->residue = residue; + ), + TP_printk("channel %s: dma cookie %d, residue %u",
__entry->chan,
is all that's needed.
Same for the other references to chan.
Unless you meant to store each with a different size, then you need to replace that "16" with the dev_name(&dc->dev->device).
-- Steve
Quoted 38 lines
include/trace/events/tegra_apb_dma.h new file +38
-0+ __get_str(chan), __entry->cookie, __entry->residue) +); + +TRACE_EVENT (tegra_dma_complete_cb, + TP_PROTO(struct dma_chan *dc, int count, void *ptr), +TP_ARGS (dc, count, ptr), +TP_STRUCT__entry ( + __string(chan, 16) + __field(int, count) + __field(void *, ptr) + ), +TP_fast_assign ( + __assign_str(chan, dev_name(&dc->dev->device)); + __entry->count = count; + __entry->ptr = ptr; + ), +TP_printk ("channel %s: done %d, ptr %p" , +__get_str (chan), __entry->count, __entry->ptr) +); + +TRACE_EVENT (tegra_dma_isr, + TP_PROTO(struct dma_chan *dc, int irq), +TP_ARGS (dc, irq), +TP_STRUCT__entry ( + __string(chan, 16) +__field (int, irq) + ), +TP_fast_assign ( + __assign_str(chan, dev_name(&dc->dev->device)); + __entry->irq = irq; + ), +TP_printk ("%s: irq %d\n" ,__get_str (chan), __entry->irq) +); + +#endif /* _TRACE_TEGRADMA_H */ + +/* This part must be outside protection */ +#include <trace/define_trace.h>