Skip to content

Commit 2cd87a7

Browse files
Anshuman Khandualmathieupoirier
authored andcommitted
coresight: core: Add support for dedicated percpu sinks
Add support for dedicated sinks that are bound to individual CPUs. (e.g, TRBE). To allow quicker access to the sink for a given CPU bound source, keep a percpu array of the sink devices. Also, add support for building a path to the CPU local sink from the ETM. This adds a new percpu sink type CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM. This new sink type is exclusively available and can only work with percpu source type device CORESIGHT_DEV_SUBTYPE_SOURCE_PROC. This defines a percpu structure that accommodates a single coresight_device which can be used to store an initialized instance from a sink driver. As these sinks are exclusively linked and dependent on corresponding percpu sources devices, they should also be the default sink device during a perf session. Outwards device connections are scanned while establishing paths between a source and a sink device. But such connections are not present for certain percpu source and sink devices which are exclusively linked and dependent. Build the path directly and skip connection scanning for such devices. Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Tested-by: Suzuki K Poulose <suzuki.poulose@arm.com> Reviewed-by: Mike Leach <mike.leach@linaro.org> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> [Moved the set/get percpu sink APIs from TRBE patch to here Fixed build break on arm32] Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20210405164307.1720226-17-suzuki.poulose@arm.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent 549452b commit 2cd87a7

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

drivers/hwtracing/coresight/coresight-core.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "coresight-priv.h"
2424

2525
static DEFINE_MUTEX(coresight_mutex);
26+
DEFINE_PER_CPU(struct coresight_device *, csdev_sink);
2627

2728
/**
2829
* struct coresight_node - elements of a path, from source to sink
@@ -70,6 +71,18 @@ void coresight_remove_cti_ops(void)
7071
}
7172
EXPORT_SYMBOL_GPL(coresight_remove_cti_ops);
7273

74+
void coresight_set_percpu_sink(int cpu, struct coresight_device *csdev)
75+
{
76+
per_cpu(csdev_sink, cpu) = csdev;
77+
}
78+
EXPORT_SYMBOL_GPL(coresight_set_percpu_sink);
79+
80+
struct coresight_device *coresight_get_percpu_sink(int cpu)
81+
{
82+
return per_cpu(csdev_sink, cpu);
83+
}
84+
EXPORT_SYMBOL_GPL(coresight_get_percpu_sink);
85+
7386
static int coresight_id_match(struct device *dev, void *data)
7487
{
7588
int trace_id, i_trace_id;
@@ -784,6 +797,14 @@ static int _coresight_build_path(struct coresight_device *csdev,
784797
if (csdev == sink)
785798
goto out;
786799

800+
if (coresight_is_percpu_source(csdev) && coresight_is_percpu_sink(sink) &&
801+
sink == per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev))) {
802+
if (_coresight_build_path(sink, sink, path) == 0) {
803+
found = true;
804+
goto out;
805+
}
806+
}
807+
787808
/* Not a sink - recursively explore each port found on this element */
788809
for (i = 0; i < csdev->pdata->nr_outport; i++) {
789810
struct coresight_device *child_dev;
@@ -999,8 +1020,12 @@ coresight_find_default_sink(struct coresight_device *csdev)
9991020
int depth = 0;
10001021

10011022
/* look for a default sink if we have not found for this device */
1002-
if (!csdev->def_sink)
1003-
csdev->def_sink = coresight_find_sink(csdev, &depth);
1023+
if (!csdev->def_sink) {
1024+
if (coresight_is_percpu_source(csdev))
1025+
csdev->def_sink = per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev));
1026+
if (!csdev->def_sink)
1027+
csdev->def_sink = coresight_find_sink(csdev, &depth);
1028+
}
10041029
return csdev->def_sink;
10051030
}
10061031

drivers/hwtracing/coresight/coresight-priv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,7 @@ coresight_find_csdev_by_fwnode(struct fwnode_handle *r_fwnode);
232232
void coresight_set_assoc_ectdev_mutex(struct coresight_device *csdev,
233233
struct coresight_device *ect_csdev);
234234

235+
void coresight_set_percpu_sink(int cpu, struct coresight_device *csdev);
236+
struct coresight_device *coresight_get_percpu_sink(int cpu);
237+
235238
#endif

include/linux/coresight.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ enum coresight_dev_subtype_sink {
5050
CORESIGHT_DEV_SUBTYPE_SINK_PORT,
5151
CORESIGHT_DEV_SUBTYPE_SINK_BUFFER,
5252
CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM,
53+
CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM,
5354
};
5455

5556
enum coresight_dev_subtype_link {
@@ -455,6 +456,18 @@ static inline void csdev_access_write64(struct csdev_access *csa, u64 val, u32 o
455456
}
456457
#endif /* CONFIG_64BIT */
457458

459+
static inline bool coresight_is_percpu_source(struct coresight_device *csdev)
460+
{
461+
return csdev && (csdev->type == CORESIGHT_DEV_TYPE_SOURCE) &&
462+
(csdev->subtype.source_subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_PROC);
463+
}
464+
465+
static inline bool coresight_is_percpu_sink(struct coresight_device *csdev)
466+
{
467+
return csdev && (csdev->type == CORESIGHT_DEV_TYPE_SINK) &&
468+
(csdev->subtype.sink_subtype == CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM);
469+
}
470+
458471
extern struct coresight_device *
459472
coresight_register(struct coresight_desc *desc);
460473
extern void coresight_unregister(struct coresight_device *csdev);

0 commit comments

Comments
 (0)