Skip to content

Commit bdc319f

Browse files
committed
Merge tag 'coresight-next-v6.16' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/coresight/linux into char-misc-next
Suzuki writes: coresight: updates for Linux v6.16 CoreSight self-hosted trace driver subsystem updates for Linux v6.16 includes: - Clear CLAIM tags on device probe if self-hosted tags are set. - Support for perf AUX pause/resume for CoreSight ETM PMU driver, with trace collection at pause. - Miscellaneous fixes for the subsystem Signed-off-by: Suzuki K Poulose <[email protected]> * tag 'coresight-next-v6.16' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/coresight/linux: (27 commits) coresight: prevent deactivate active config while enabling the config coresight: holding cscfg_csdev_lock while removing cscfg from csdev coresight/etm4: fix missing disable active config coresight: etm4x: Fix timestamp bit field handling coresight: tmc: fix failure to disable/enable ETF after reading Documentation: coresight: Document AUX pause and resume coresight: perf: Update buffer on AUX pause coresight: tmc: Re-enable sink after buffer update coresight: perf: Support AUX trace pause and resume coresight: etm4x: Hook pause and resume callbacks coresight: Introduce pause and resume APIs for source coresight: etm4x: Extract the trace unit controlling coresight: cti: Replace inclusion by struct fwnode_handle forward declaration coresight: Disable MMIO logging for coresight stm driver coresight: replicator: Fix panic for clearing claim tag coresight: Add a KUnit test for coresight_find_default_sink() coresight: Remove extern from function declarations coresight: Remove inlines from static function definitions coresight: Clear self hosted claim tag on probe coresight: etm3x: Convert raw base pointer to struct coresight access ...
2 parents 0ca7cb7 + 408c97c commit bdc319f

33 files changed

+625
-226
lines changed

Documentation/devicetree/bindings/arm/arm,coresight-static-replicator.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ properties:
3030
power-domains:
3131
maxItems: 1
3232

33+
clocks:
34+
minItems: 1
35+
maxItems: 3
36+
37+
clock-names:
38+
oneOf:
39+
- items:
40+
- enum: [apb_pclk, atclk]
41+
- items: # Zynq-700
42+
- const: apb_pclk
43+
- const: dbg_trc
44+
- const: dbg_apb
45+
3346
in-ports:
3447
$ref: /schemas/graph.yaml#/properties/ports
3548
additionalProperties: false

Documentation/trace/coresight/coresight-perf.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,37 @@ enabled like::
7878

7979
Please refer to the kernel configuration help for more information.
8080

81+
Fine-grained tracing with AUX pause and resume
82+
----------------------------------------------
83+
84+
Arm CoreSight may generate a large amount of hardware trace data, which
85+
will lead to overhead in recording and distract users when reviewing
86+
profiling result. To mitigate the issue of excessive trace data, Perf
87+
provides AUX pause and resume functionality for fine-grained tracing.
88+
89+
The AUX pause and resume can be triggered by associated events. These
90+
events can be ftrace tracepoints (including static and dynamic
91+
tracepoints) or PMU events (e.g. CPU PMU cycle event). To create a perf
92+
session with AUX pause / resume, three configuration terms are
93+
introduced:
94+
95+
- "aux-action=start-paused": it is specified for the cs_etm PMU event to
96+
launch in a paused state.
97+
- "aux-action=pause": an associated event is specified with this term
98+
to pause AUX trace.
99+
- "aux-action=resume": an associated event is specified with this term
100+
to resume AUX trace.
101+
102+
Example for triggering AUX pause and resume with ftrace tracepoints::
103+
104+
perf record -e cs_etm/aux-action=start-paused/k,syscalls:sys_enter_openat/aux-action=resume/,syscalls:sys_exit_openat/aux-action=pause/ ls
105+
106+
Example for triggering AUX pause and resume with PMU event::
107+
108+
perf record -a -e cs_etm/aux-action=start-paused/k \
109+
-e cycles/aux-action=pause,period=10000000/ \
110+
-e cycles/aux-action=resume,period=1050000/ -- sleep 1
111+
81112
Perf test - Verify kernel and userspace perf CoreSight work
82113
-----------------------------------------------------------
83114

drivers/hwtracing/coresight/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,13 @@ config CORESIGHT_DUMMY
259259

260260
To compile this driver as a module, choose M here: the module will be
261261
called coresight-dummy.
262+
263+
config CORESIGHT_KUNIT_TESTS
264+
tristate "Enable Coresight unit tests"
265+
depends on KUNIT
266+
default KUNIT_ALL_TESTS
267+
help
268+
Enable Coresight unit tests. Only useful for development and not
269+
intended for production.
270+
262271
endif

drivers/hwtracing/coresight/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ condflags := \
2222
$(call cc-option, -Wstringop-truncation)
2323
subdir-ccflags-y += $(condflags)
2424

25+
CFLAGS_coresight-stm.o := -D__DISABLE_TRACE_MMIO__
26+
2527
obj-$(CONFIG_CORESIGHT) += coresight.o
2628
coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \
2729
coresight-sysfs.o coresight-syscfg.o coresight-config.o \
@@ -53,3 +55,4 @@ obj-$(CONFIG_ULTRASOC_SMB) += ultrasoc-smb.o
5355
obj-$(CONFIG_CORESIGHT_DUMMY) += coresight-dummy.o
5456
obj-$(CONFIG_CORESIGHT_CTCU) += coresight-ctcu.o
5557
coresight-ctcu-y := coresight-ctcu-core.o
58+
obj-$(CONFIG_CORESIGHT_KUNIT_TESTS) += coresight-kunit-tests.o

drivers/hwtracing/coresight/coresight-catu.c

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ typedef u64 cate_t;
113113
* containing the data page pointer for @offset. If @daddrp is not NULL,
114114
* @daddrp points the DMA address of the beginning of the table.
115115
*/
116-
static inline cate_t *catu_get_table(struct tmc_sg_table *catu_table,
117-
unsigned long offset,
118-
dma_addr_t *daddrp)
116+
static cate_t *catu_get_table(struct tmc_sg_table *catu_table, unsigned long offset,
117+
dma_addr_t *daddrp)
119118
{
120119
unsigned long buf_size = tmc_sg_table_buf_size(catu_table);
121120
unsigned int table_nr, pg_idx, pg_offset;
@@ -165,12 +164,12 @@ static void catu_dump_table(struct tmc_sg_table *catu_table)
165164
}
166165

167166
#else
168-
static inline void catu_dump_table(struct tmc_sg_table *catu_table)
167+
static void catu_dump_table(struct tmc_sg_table *catu_table)
169168
{
170169
}
171170
#endif
172171

173-
static inline cate_t catu_make_entry(dma_addr_t addr)
172+
static cate_t catu_make_entry(dma_addr_t addr)
174173
{
175174
return addr ? CATU_VALID_ENTRY(addr) : 0;
176175
}
@@ -390,7 +389,7 @@ static const struct attribute_group *catu_groups[] = {
390389
};
391390

392391

393-
static inline int catu_wait_for_ready(struct catu_drvdata *drvdata)
392+
static int catu_wait_for_ready(struct catu_drvdata *drvdata)
394393
{
395394
struct csdev_access *csa = &drvdata->csdev->access;
396395

@@ -458,12 +457,17 @@ static int catu_enable_hw(struct catu_drvdata *drvdata, enum cs_mode cs_mode,
458457
static int catu_enable(struct coresight_device *csdev, enum cs_mode mode,
459458
void *data)
460459
{
461-
int rc;
460+
int rc = 0;
462461
struct catu_drvdata *catu_drvdata = csdev_to_catu_drvdata(csdev);
463462

464-
CS_UNLOCK(catu_drvdata->base);
465-
rc = catu_enable_hw(catu_drvdata, mode, data);
466-
CS_LOCK(catu_drvdata->base);
463+
guard(raw_spinlock_irqsave)(&catu_drvdata->spinlock);
464+
if (csdev->refcnt == 0) {
465+
CS_UNLOCK(catu_drvdata->base);
466+
rc = catu_enable_hw(catu_drvdata, mode, data);
467+
CS_LOCK(catu_drvdata->base);
468+
}
469+
if (!rc)
470+
csdev->refcnt++;
467471
return rc;
468472
}
469473

@@ -486,12 +490,15 @@ static int catu_disable_hw(struct catu_drvdata *drvdata)
486490

487491
static int catu_disable(struct coresight_device *csdev, void *__unused)
488492
{
489-
int rc;
493+
int rc = 0;
490494
struct catu_drvdata *catu_drvdata = csdev_to_catu_drvdata(csdev);
491495

492-
CS_UNLOCK(catu_drvdata->base);
493-
rc = catu_disable_hw(catu_drvdata);
494-
CS_LOCK(catu_drvdata->base);
496+
guard(raw_spinlock_irqsave)(&catu_drvdata->spinlock);
497+
if (--csdev->refcnt == 0) {
498+
CS_UNLOCK(catu_drvdata->base);
499+
rc = catu_disable_hw(catu_drvdata);
500+
CS_LOCK(catu_drvdata->base);
501+
}
495502
return rc;
496503
}
497504

@@ -550,6 +557,7 @@ static int __catu_probe(struct device *dev, struct resource *res)
550557
dev->platform_data = pdata;
551558

552559
drvdata->base = base;
560+
raw_spin_lock_init(&drvdata->spinlock);
553561
catu_desc.access = CSDEV_ACCESS_IOMEM(base);
554562
catu_desc.pdata = pdata;
555563
catu_desc.dev = dev;
@@ -558,6 +566,7 @@ static int __catu_probe(struct device *dev, struct resource *res)
558566
catu_desc.subtype.helper_subtype = CORESIGHT_DEV_SUBTYPE_HELPER_CATU;
559567
catu_desc.ops = &catu_ops;
560568

569+
coresight_clear_self_claim_tag(&catu_desc.access);
561570
drvdata->csdev = coresight_register(&catu_desc);
562571
if (IS_ERR(drvdata->csdev))
563572
ret = PTR_ERR(drvdata->csdev);
@@ -702,7 +711,7 @@ static int __init catu_init(void)
702711
{
703712
int ret;
704713

705-
ret = coresight_init_driver("catu", &catu_driver, &catu_platform_driver);
714+
ret = coresight_init_driver("catu", &catu_driver, &catu_platform_driver, THIS_MODULE);
706715
tmc_etr_set_catu_ops(&etr_catu_buf_ops);
707716
return ret;
708717
}

drivers/hwtracing/coresight/coresight-catu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct catu_drvdata {
6565
void __iomem *base;
6666
struct coresight_device *csdev;
6767
int irq;
68+
raw_spinlock_t spinlock;
6869
};
6970

7071
#define CATU_REG32(name, offset) \

drivers/hwtracing/coresight/coresight-config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ struct cscfg_feature_csdev {
228228
* @feats_csdev:references to the device features to enable.
229229
*/
230230
struct cscfg_config_csdev {
231-
const struct cscfg_config_desc *config_desc;
231+
struct cscfg_config_desc *config_desc;
232232
struct coresight_device *csdev;
233233
bool enabled;
234234
struct list_head node;

0 commit comments

Comments
 (0)