Skip to content

Commit 11102d0

Browse files
nxpfranklivinodkoul
authored andcommitted
dmaengine: fsl-edma: add trace event support
Implement trace event support to enhance logging functionality for register access and the transfer control descriptor (TCD) context. This will enable more comprehensive monitoring and analysis of system activities Signed-off-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 76e43fa commit 11102d0

File tree

5 files changed

+178
-11
lines changed

5 files changed

+178
-11
lines changed

drivers/dma/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ obj-$(CONFIG_DW_AXI_DMAC) += dw-axi-dmac/
3131
obj-$(CONFIG_DW_DMAC_CORE) += dw/
3232
obj-$(CONFIG_DW_EDMA) += dw-edma/
3333
obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
34+
fsl-edma-trace-$(CONFIG_TRACING) := fsl-edma-trace.o
35+
CFLAGS_fsl-edma-trace.o := -I$(src)
3436
obj-$(CONFIG_FSL_DMA) += fsldma.o
35-
fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o
37+
fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
3638
obj-$(CONFIG_FSL_EDMA) += fsl-edma.o
37-
mcf-edma-objs := mcf-edma-main.o fsl-edma-common.o
39+
mcf-edma-objs := mcf-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
3840
obj-$(CONFIG_MCF_EDMA) += mcf-edma.o
3941
obj-$(CONFIG_FSL_QDMA) += fsl-qdma.o
4042
obj-$(CONFIG_FSL_RAID) += fsl_raid.o

drivers/dma/fsl-edma-common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,8 @@ void fsl_edma_fill_tcd(struct fsl_edma_chan *fsl_chan,
540540
csr |= EDMA_TCD_CSR_START;
541541

542542
fsl_edma_set_tcd_to_le(fsl_chan, tcd, csr, csr);
543+
544+
trace_edma_fill_tcd(fsl_chan, tcd);
543545
}
544546

545547
static struct fsl_edma_desc *fsl_edma_alloc_desc(struct fsl_edma_chan *fsl_chan,

drivers/dma/fsl-edma-common.h

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ struct fsl_edma_engine {
246246
struct fsl_edma_chan chans[] __counted_by(n_chans);
247247
};
248248

249+
static inline u32 fsl_edma_drvflags(struct fsl_edma_chan *fsl_chan)
250+
{
251+
return fsl_chan->edma->drvdata->flags;
252+
}
253+
249254
#define edma_read_tcdreg_c(chan, _tcd, __name) \
250255
(sizeof((_tcd)->__name) == sizeof(u64) ? \
251256
edma_readq(chan->edma, &(_tcd)->__name) : \
@@ -349,6 +354,9 @@ do { \
349354
fsl_edma_set_tcd_to_le_c((struct fsl_edma_hw_tcd *)_tcd, _val, _field); \
350355
} while (0)
351356

357+
/* Need after struct defination */
358+
#include "fsl-edma-trace.h"
359+
352360
/*
353361
* R/W functions for big- or little-endian registers:
354362
* The eDMA controller's endian is independent of the CPU core's endian.
@@ -367,23 +375,38 @@ static inline u64 edma_readq(struct fsl_edma_engine *edma, void __iomem *addr)
367375
h = ioread32(addr + 4);
368376
}
369377

378+
trace_edma_readl(edma, addr, l);
379+
trace_edma_readl(edma, addr + 4, h);
380+
370381
return (h << 32) | l;
371382
}
372383

373384
static inline u32 edma_readl(struct fsl_edma_engine *edma, void __iomem *addr)
374385
{
386+
u32 val;
387+
375388
if (edma->big_endian)
376-
return ioread32be(addr);
389+
val = ioread32be(addr);
377390
else
378-
return ioread32(addr);
391+
val = ioread32(addr);
392+
393+
trace_edma_readl(edma, addr, val);
394+
395+
return val;
379396
}
380397

381398
static inline u16 edma_readw(struct fsl_edma_engine *edma, void __iomem *addr)
382399
{
400+
u16 val;
401+
383402
if (edma->big_endian)
384-
return ioread16be(addr);
403+
val = ioread16be(addr);
385404
else
386-
return ioread16(addr);
405+
val = ioread16(addr);
406+
407+
trace_edma_readw(edma, addr, val);
408+
409+
return val;
387410
}
388411

389412
static inline void edma_writeb(struct fsl_edma_engine *edma,
@@ -394,6 +417,8 @@ static inline void edma_writeb(struct fsl_edma_engine *edma,
394417
iowrite8(val, (void __iomem *)((unsigned long)addr ^ 0x3));
395418
else
396419
iowrite8(val, addr);
420+
421+
trace_edma_writeb(edma, addr, val);
397422
}
398423

399424
static inline void edma_writew(struct fsl_edma_engine *edma,
@@ -404,6 +429,8 @@ static inline void edma_writew(struct fsl_edma_engine *edma,
404429
iowrite16be(val, (void __iomem *)((unsigned long)addr ^ 0x2));
405430
else
406431
iowrite16(val, addr);
432+
433+
trace_edma_writew(edma, addr, val);
407434
}
408435

409436
static inline void edma_writel(struct fsl_edma_engine *edma,
@@ -413,6 +440,8 @@ static inline void edma_writel(struct fsl_edma_engine *edma,
413440
iowrite32be(val, addr);
414441
else
415442
iowrite32(val, addr);
443+
444+
trace_edma_writel(edma, addr, val);
416445
}
417446

418447
static inline void edma_writeq(struct fsl_edma_engine *edma,
@@ -425,18 +454,16 @@ static inline void edma_writeq(struct fsl_edma_engine *edma,
425454
iowrite32(val & 0xFFFFFFFF, addr);
426455
iowrite32(val >> 32, addr + 4);
427456
}
457+
458+
trace_edma_writel(edma, addr, val & 0xFFFFFFFF);
459+
trace_edma_writel(edma, addr + 4, val >> 32);
428460
}
429461

430462
static inline struct fsl_edma_chan *to_fsl_edma_chan(struct dma_chan *chan)
431463
{
432464
return container_of(chan, struct fsl_edma_chan, vchan.chan);
433465
}
434466

435-
static inline u32 fsl_edma_drvflags(struct fsl_edma_chan *fsl_chan)
436-
{
437-
return fsl_chan->edma->drvdata->flags;
438-
}
439-
440467
static inline struct fsl_edma_desc *to_fsl_edma_desc(struct virt_dma_desc *vd)
441468
{
442469
return container_of(vd, struct fsl_edma_desc, vdesc);

drivers/dma/fsl-edma-trace.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#define CREATE_TRACE_POINTS
4+
#include "fsl-edma-common.h"

drivers/dma/fsl-edma-trace.h

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/* SPDX-License-Identifier: GPL-2.0+ */
2+
/*
3+
* Copyright 2023 NXP.
4+
*/
5+
6+
#undef TRACE_SYSTEM
7+
#define TRACE_SYSTEM fsl_edma
8+
9+
#if !defined(__LINUX_FSL_EDMA_TRACE) || defined(TRACE_HEADER_MULTI_READ)
10+
#define __LINUX_FSL_EDMA_TRACE
11+
12+
#include <linux/types.h>
13+
#include <linux/tracepoint.h>
14+
15+
DECLARE_EVENT_CLASS(edma_log_io,
16+
TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value),
17+
TP_ARGS(edma, addr, value),
18+
TP_STRUCT__entry(
19+
__field(struct fsl_edma_engine *, edma)
20+
__field(void __iomem *, addr)
21+
__field(u32, value)
22+
),
23+
TP_fast_assign(
24+
__entry->edma = edma;
25+
__entry->addr = addr;
26+
__entry->value = value;
27+
),
28+
TP_printk("offset %08x: value %08x",
29+
(u32)(__entry->addr - __entry->edma->membase), __entry->value)
30+
);
31+
32+
DEFINE_EVENT(edma_log_io, edma_readl,
33+
TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value),
34+
TP_ARGS(edma, addr, value)
35+
);
36+
37+
DEFINE_EVENT(edma_log_io, edma_writel,
38+
TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value),
39+
TP_ARGS(edma, addr, value)
40+
);
41+
42+
DEFINE_EVENT(edma_log_io, edma_readw,
43+
TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value),
44+
TP_ARGS(edma, addr, value)
45+
);
46+
47+
DEFINE_EVENT(edma_log_io, edma_writew,
48+
TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value),
49+
TP_ARGS(edma, addr, value)
50+
);
51+
52+
DEFINE_EVENT(edma_log_io, edma_readb,
53+
TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value),
54+
TP_ARGS(edma, addr, value)
55+
);
56+
57+
DEFINE_EVENT(edma_log_io, edma_writeb,
58+
TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value),
59+
TP_ARGS(edma, addr, value)
60+
);
61+
62+
DECLARE_EVENT_CLASS(edma_log_tcd,
63+
TP_PROTO(struct fsl_edma_chan *chan, void *tcd),
64+
TP_ARGS(chan, tcd),
65+
TP_STRUCT__entry(
66+
__field(u64, saddr)
67+
__field(u16, soff)
68+
__field(u16, attr)
69+
__field(u32, nbytes)
70+
__field(u64, slast)
71+
__field(u64, daddr)
72+
__field(u16, doff)
73+
__field(u16, citer)
74+
__field(u64, dlast_sga)
75+
__field(u16, csr)
76+
__field(u16, biter)
77+
78+
),
79+
TP_fast_assign(
80+
__entry->saddr = fsl_edma_get_tcd_to_cpu(chan, tcd, saddr),
81+
__entry->soff = fsl_edma_get_tcd_to_cpu(chan, tcd, soff),
82+
__entry->attr = fsl_edma_get_tcd_to_cpu(chan, tcd, attr),
83+
__entry->nbytes = fsl_edma_get_tcd_to_cpu(chan, tcd, nbytes),
84+
__entry->slast = fsl_edma_get_tcd_to_cpu(chan, tcd, slast),
85+
__entry->daddr = fsl_edma_get_tcd_to_cpu(chan, tcd, daddr),
86+
__entry->doff = fsl_edma_get_tcd_to_cpu(chan, tcd, doff),
87+
__entry->citer = fsl_edma_get_tcd_to_cpu(chan, tcd, citer),
88+
__entry->dlast_sga = fsl_edma_get_tcd_to_cpu(chan, tcd, dlast_sga),
89+
__entry->csr = fsl_edma_get_tcd_to_cpu(chan, tcd, csr),
90+
__entry->biter = fsl_edma_get_tcd_to_cpu(chan, tcd, biter);
91+
),
92+
TP_printk("\n==== TCD =====\n"
93+
" saddr: 0x%016llx\n"
94+
" soff: 0x%04x\n"
95+
" attr: 0x%04x\n"
96+
" nbytes: 0x%08x\n"
97+
" slast: 0x%016llx\n"
98+
" daddr: 0x%016llx\n"
99+
" doff: 0x%04x\n"
100+
" citer: 0x%04x\n"
101+
" dlast: 0x%016llx\n"
102+
" csr: 0x%04x\n"
103+
" biter: 0x%04x\n",
104+
__entry->saddr,
105+
__entry->soff,
106+
__entry->attr,
107+
__entry->nbytes,
108+
__entry->slast,
109+
__entry->daddr,
110+
__entry->doff,
111+
__entry->citer,
112+
__entry->dlast_sga,
113+
__entry->csr,
114+
__entry->biter)
115+
);
116+
117+
DEFINE_EVENT(edma_log_tcd, edma_fill_tcd,
118+
TP_PROTO(struct fsl_edma_chan *chan, void *tcd),
119+
TP_ARGS(chan, tcd)
120+
);
121+
122+
#endif
123+
124+
/* this part must be outside header guard */
125+
126+
#undef TRACE_INCLUDE_PATH
127+
#define TRACE_INCLUDE_PATH .
128+
129+
#undef TRACE_INCLUDE_FILE
130+
#define TRACE_INCLUDE_FILE fsl-edma-trace
131+
132+
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)