On 25/06/2024 03:12, Jie Gan wrote:
> The coresight_disable_source_sysfs function should verify the
> mode of the coresight device before disabling the source.
> However, the mode for the TPDM device is always set to
> CS_MODE_DISABLED, resulting in the check consistently failing.
> As a result, TPDM cannot be properly disabled.
>
> To fix the issue:
> Configure CS_MODE_SYSFS/CS_MODE_PERF during the enablement of TPDM.
> Configure CS_MODE_DISABLED during the disablement of TPDM.
>
> Fixes: 1f5149c7751c("coresight: Move all sysfs code to sysfs file")
That looks like the wrong commit. This was a problem since the original
TPDM driver. I would say :
Fixes: b3c71626a933 ("Coresight: Add coresight TPDM source driver")
> Signed-off-by: Jie Gan <quic_jiegan(a)quicinc.com>
Otherwise, the patch looks good to me.
Please could you also fixup "dummy" source driver in a separate patch.
Suzuki
On 23/06/2024 14:34, Leo Yan wrote:
> This patch series is to enable multiple Arm SPE PMUs.
>
> The patch 01 is to enable multiple Arm SPE PMUs. The second patch is to
> print out warning if not all CPUs support memory events, this can give
> users a hint that the memory profiling is absent on some CPUs.
>
>
> Leo Yan (2):
> perf arm-spe: Support multiple Arm SPE PMUs
> perf mem: Warn if memory events are not supported on all CPUs
>
> tools/perf/arch/arm/util/pmu.c | 2 +-
> tools/perf/util/mem-events.c | 14 ++++++++++++++
> 2 files changed, 15 insertions(+), 1 deletion(-)
>
Reviewed-by: James Clark <james.clark(a)arm.com>
On Mon, 19 Feb 2024 10:43:05 -0300, Ricardo B. Marliere wrote:
> Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
> core can properly handle constant struct device_type. Move the
> coresight_dev_type variable to be a constant structure as well, placing it
> into read-only memory which can not be modified at runtime.
>
>
Applied, thanks!
[1/1] coresight: constify the struct device_type usage
https://git.kernel.org/coresight/c/4dcc0f95ca2a9738e5e4e3bd7571fd95a9cbf272
Best regards,
--
Suzuki K Poulose <suzuki.poulose(a)arm.com>
On 18/06/2024 08:27, Jie Gan wrote:
> The Coresight Slave Register(CSR) device hosts miscellaneous configuration
> registers to control various features related to TMC ETR device.
>
> The CSR device works as a helper device physically connected to the TMC ETR device.
> ---------------------------------------------------------
> |ETR0| |ETR1|
> . \ / .
> . \ / .
> . \ / .
> . \ / .
> ---------------------------------------------------
> ETR0ATID0-ETR0ATID3 CSR ETR1ATID0-ETR1ATID3
> ---------------------------------------------------
> Each ETR has four ATID registers with 128 bits long in total.
> e.g. ETR0ATID0-ETR0ATID3 registers are used by ETR0 device.
What is the maximum number of connections possible for CSR ? 2 ETRs ?
>
> Based on the trace id which is programed in CSR ATID register of
> specific ETR, trace data with that trace id can get into ETR's buffer
How do you handle cases where there are multiple TraceIDs in a the
stream ? e.g., perf tracing a multi-threaded app ? Each ETM will have
a distinct traceid. Is there way to disable filtering by CSR ?
Side note, with James's trace id allocation per sink series makes this
easier for the ETR to know the trace ids allocated for the current
session. Works only for perf though.
> while other trace data gets ignored. CSR may contain several ATID registers.
> Each ATID register is associated with an ETR device.
>
> To achieve this function, the trace id is obtained and stored in the related
> ETR device's driver data just before enabling the CSR. Then, the CSR
> device can easily obtain the trace ID from the ETR's driver data because the
> ETR's driver data is passed to the CSR's enable/disable functions.
>
> Ensure that every source device has already allocated a trace ID in its probe
> session because the sink device should always be the first device to
How is that possible ? We are going backwards in the trace id allocation
with your proposal. What is the purpose of this hardware when you could
use a replicator with trace filtering based on masks ?
> enable when operating coresight_enable_path function. As a helper device of the
> ETR, the CSR device will program the ATID register of a specific ETR according to
> the trace id to enable data filter function at a very early stage. Without the
> correct trace ID, the enablement session will not work.
>
> Each CSR's enable session will set one bit in the ATID register.
So is this a bitmap of "enable/disable" ATID ? I really don't see the
usecase of the CSR "device" yet. Please could you share "usecase" ?
Suzuki
> Every CSR's disbale seesion will reset all bits of the ATID register.
>
> This patch only supports sysfs mode. I will send the perf mode part patch
> once it is ready.
>
> Looking forward to receiving comments as this is a new driver.
>
> Thanks!
>
> Jie Gan (3):
> dt-bindings: arm: Add binding document for Coresight Slave Register
> device.
> coresight: Add coresight slave register driver to support data filter
> function in sysfs mode
> arm64: dts: qcom: Add CSR and ETR nodes for SA8775p
>
> .../bindings/arm/arm,coresight-tmc.yaml | 8 +
> .../bindings/arm/qcom,coresight-csr.yaml | 49 +++
> arch/arm64/boot/dts/qcom/sa8775p.dtsi | 167 ++++++++++
> drivers/hwtracing/coresight/Kconfig | 6 +
> drivers/hwtracing/coresight/Makefile | 1 +
> drivers/hwtracing/coresight/coresight-core.c | 6 +-
> drivers/hwtracing/coresight/coresight-csr.c | 315 ++++++++++++++++++
> drivers/hwtracing/coresight/coresight-csr.h | 24 ++
> .../coresight/coresight-etm4x-core.c | 1 +
> drivers/hwtracing/coresight/coresight-stm.c | 50 ---
> drivers/hwtracing/coresight/coresight-sysfs.c | 45 ++-
> .../hwtracing/coresight/coresight-tmc-core.c | 1 +
> drivers/hwtracing/coresight/coresight-tmc.h | 2 +
> include/linux/coresight-stm.h | 44 +++
> 14 files changed, 665 insertions(+), 54 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/arm/qcom,coresight-csr.yaml
> create mode 100644 drivers/hwtracing/coresight/coresight-csr.c
> create mode 100644 drivers/hwtracing/coresight/coresight-csr.h
>
This will allow sessions with more than CORESIGHT_TRACE_IDS_MAX ETMs
as long as there are fewer than that many ETMs connected to each sink.
Each sink owns its own trace ID map, and any Perf session connecting to
that sink will allocate from it, even if the sink is currently in use by
other users. This is similar to the existing behavior where the dynamic
trace IDs are constant as long as there is any concurrent Perf session
active. It's not completely optimal because slightly more IDs will be
used than necessary, but the optimal solution involves tracking the PIDs
of each session and allocating ID maps based on the session owner. This
is difficult to do with the combination of per-thread and per-cpu modes
and some scheduling issues. The complexity of this isn't likely to worth
it because even with multiple users they'd just see a difference in the
ordering of ID allocations rather than hitting any limits (unless the
hardware does have too many ETMs connected to one sink).
Per-thread mode works but only until there are any overlapping IDs, at
which point Perf will error out. Both per-thread mode and sysfs mode are
left to future changes, but both can be added on top of this initial
implementation and only sysfs mode requires further driver changes.
The HW_ID version field hasn't been bumped in order to not break Perf
which already has an error condition for other values of that field.
Instead a new minor version has been added which signifies that there
are new fields but the old fields are backwards compatible.
Changes since v2:
* Rebase on coresight-next 6.10-rc2 (b9b25c8496).
* Fix double free of csdev if device registration fails.
* Fix leak of coresight_trace_id_perf_start() if trace ID allocation
fails.
* Don't resend HW_ID for sink changes in per-thread mode. The existing
CPU field on AUX records can be used to track this instead.
* Tidy function doc for coresight_trace_id_release_all()
* Drop first two commits now that they are in coresight-next
* Add a commit to make the trace ID spinlock local to the map
Changes since V1:
* Rename coresight_device.perf_id_map to perf_sink_id_map.
* Instead of outputting a HW_ID for each reachable ETM, output
the sink ID and continue to output only the HW_ID once for
each mapping.
* Keep the first two Perf patches so that it applies cleanly
on coresight-next, although they have been applied on perf-tools-next
* Add new *_map() functions to the trace ID public API instead of
modifying existing ones.
* Collapse "coresight: Pass trace ID map into source enable" into
"coresight: Use per-sink trace ID maps for Perf sessions" because the
first commit relied on the default map being accessible which is no
longer necessary due to the previous bullet point.
James Clark (14):
perf: cs-etm: Create decoders after both AUX and HW_ID search passes
perf: cs-etm: Allocate queues for all CPUs
perf: cs-etm: Move traceid_list to each queue
perf: cs-etm: Create decoders based on the trace ID mappings
perf: cs-etm: Support version 0.1 of HW_ID packets
coresight: Remove unused ETM Perf stubs
coresight: Clarify comments around the PID of the sink owner
coresight: Move struct coresight_trace_id_map to common header
coresight: Expose map arguments in trace ID API
coresight: Make CPU id map a property of a trace ID map
coresight: Use per-sink trace ID maps for Perf sessions
coresight: Remove pending trace ID release mechanism
coresight: Emit sink ID in the HW_ID packets
coresight: Make trace ID map spinlock local to the map
drivers/hwtracing/coresight/coresight-core.c | 37 +-
drivers/hwtracing/coresight/coresight-dummy.c | 3 +-
.../hwtracing/coresight/coresight-etm-perf.c | 36 +-
.../hwtracing/coresight/coresight-etm-perf.h | 18 -
.../coresight/coresight-etm3x-core.c | 9 +-
.../coresight/coresight-etm4x-core.c | 9 +-
drivers/hwtracing/coresight/coresight-priv.h | 1 +
drivers/hwtracing/coresight/coresight-stm.c | 3 +-
drivers/hwtracing/coresight/coresight-sysfs.c | 3 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 5 +-
drivers/hwtracing/coresight/coresight-tmc.h | 5 +-
drivers/hwtracing/coresight/coresight-tpdm.c | 3 +-
.../hwtracing/coresight/coresight-trace-id.c | 133 ++--
.../hwtracing/coresight/coresight-trace-id.h | 70 +-
include/linux/coresight-pmu.h | 17 +-
include/linux/coresight.h | 21 +-
tools/include/linux/coresight-pmu.h | 17 +-
.../perf/util/cs-etm-decoder/cs-etm-decoder.c | 28 +-
tools/perf/util/cs-etm.c | 600 +++++++++++-------
tools/perf/util/cs-etm.h | 2 +-
20 files changed, 614 insertions(+), 406 deletions(-)
--
2.34.1
This will allow sessions with more than CORESIGHT_TRACE_IDS_MAX ETMs
as long as there are fewer than that many ETMs connected to each sink.
Each sink owns its own trace ID map, and any Perf session connecting to
that sink will allocate from it, even if the sink is currently in use by
other users. This is similar to the existing behavior where the dynamic
trace IDs are constant as long as there is any concurrent Perf session
active. It's not completely optimal because slightly more IDs will be
used than necessary, but the optimal solution involves tracking the PIDs
of each session and allocating ID maps based on the session owner. This
is difficult to do with the combination of per-thread and per-cpu modes
and some scheduling issues. The complexity of this isn't likely to worth
it because even with multiple users they'd just see a difference in the
ordering of ID allocations rather than hitting any limits (unless the
hardware does have too many ETMs connected to one sink).
Per-thread mode works but only until there are any overlapping IDs, at
which point Perf will error out. Both per-thread mode and sysfs mode are
left to future changes, but both can be added on top of this initial
implementation and only sysfs mode requires further driver changes.
The HW_ID version field hasn't been bumped in order to not break Perf
which already has an error condition for other values of that field.
Instead a new minor version has been added which signifies that there
are new fields but the old fields are backwards compatible.
Changes since V1:
* Rename coresight_device.perf_id_map to perf_sink_id_map.
* Instead of outputting a HW_ID for each reachable ETM, output
the sink ID and continue to output only the HW_ID once for
each mapping.
* Keep the first two Perf patches so that it applies cleanly
on coresight-next, although they have been applied on perf-tools-next
* Add new *_map() functions to the trace ID public API instead of
modifying existing ones.
* Collapse "coresight: Pass trace ID map into source enable" into
"coresight: Use per-sink trace ID maps for Perf sessions" because the
first commit relied on the default map being accessible which is no
longer necessary due to the previous bullet point.
James Clark (16):
perf cs-etm: Print error for new PERF_RECORD_AUX_OUTPUT_HW_ID versions
perf auxtrace: Allow number of queues to be specified
perf: cs-etm: Create decoders after both AUX and HW_ID search passes
perf: cs-etm: Allocate queues for all CPUs
perf: cs-etm: Move traceid_list to each queue
perf: cs-etm: Create decoders based on the trace ID mappings
perf: cs-etm: Support version 0.1 of HW_ID packets
coresight: Remove unused ETM Perf stubs
coresight: Clarify comments around the PID of the sink owner
coresight: Move struct coresight_trace_id_map to common header
coresight: Expose map arguments in trace ID API
coresight: Make CPU id map a property of a trace ID map
coresight: Use per-sink trace ID maps for Perf sessions
coresight: Remove pending trace ID release mechanism
coresight: Re-emit trace IDs when the sink changes in per-thread mode
coresight: Emit sink ID in the HW_ID packets
drivers/hwtracing/coresight/coresight-core.c | 36 +-
drivers/hwtracing/coresight/coresight-dummy.c | 3 +-
.../hwtracing/coresight/coresight-etm-perf.c | 50 +-
.../hwtracing/coresight/coresight-etm-perf.h | 20 +-
.../coresight/coresight-etm3x-core.c | 9 +-
.../coresight/coresight-etm4x-core.c | 9 +-
drivers/hwtracing/coresight/coresight-priv.h | 1 +
drivers/hwtracing/coresight/coresight-stm.c | 3 +-
drivers/hwtracing/coresight/coresight-sysfs.c | 3 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 5 +-
drivers/hwtracing/coresight/coresight-tmc.h | 5 +-
drivers/hwtracing/coresight/coresight-tpdm.c | 3 +-
.../hwtracing/coresight/coresight-trace-id.c | 109 ++--
.../hwtracing/coresight/coresight-trace-id.h | 70 +-
include/linux/coresight-pmu.h | 17 +-
include/linux/coresight.h | 20 +-
tools/include/linux/coresight-pmu.h | 17 +-
tools/perf/util/auxtrace.c | 9 +-
tools/perf/util/auxtrace.h | 1 +
.../perf/util/cs-etm-decoder/cs-etm-decoder.c | 28 +-
tools/perf/util/cs-etm.c | 603 ++++++++++++------
tools/perf/util/cs-etm.h | 2 +-
22 files changed, 628 insertions(+), 395 deletions(-)
--
2.34.1
On Mon, 6 May 2024 09:11:21 +0800, Yang Li wrote:
> The header files linux/acpi.h is included twice in coresight-tmc-core.c,
> so one inclusion of each can be removed.
>
>
Applied, thanks!
[1/1] coresight: tmc: Remove duplicated include in coresight-tmc-core.c
https://git.kernel.org/coresight/c/b9b25c8496019402ecd64ddc5ae56f9bd97b12b2
Best regards,
--
Suzuki K Poulose <suzuki.poulose(a)arm.com>
of_graph_get_next_endpoint() releases the reference to the previous
endpoint on each iteration, but when parsing fails the loop exits
early meaning the last reference is never dropped.
Fix it by dropping the refcount in the exit condition.
Fixes: d375b356e687 ("coresight: Fix support for sparsely populated ports")
Signed-off-by: James Clark <james.clark(a)arm.com>
---
drivers/hwtracing/coresight/coresight-platform.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
index 9d550f5697fa..57a009552cc5 100644
--- a/drivers/hwtracing/coresight/coresight-platform.c
+++ b/drivers/hwtracing/coresight/coresight-platform.c
@@ -297,8 +297,10 @@ static int of_get_coresight_platform_data(struct device *dev,
continue;
ret = of_coresight_parse_endpoint(dev, ep, pdata);
- if (ret)
+ if (ret) {
+ of_node_put(ep);
return ret;
+ }
}
return 0;
--
2.34.1
On 05/06/2024 06:26, Adrian Hunter wrote:
> On 4/06/24 17:30, James Clark wrote:
>> Currently it's only possible to initialize with the default number of
>> queues and then use auxtrace_queues__add_event() to grow the array. But
>> that's problematic if you don't have a real event to pass into that
>> function yet.
>>
>> The queues hold a void *priv member to store custom state, and for
>> Coresight we want to create decoders upfront before receiving data, so
>> add a new function that allows pre-allocating queues. One reason to do
>> this is because we might need to store metadata (HW_ID events) that
>> effects other queues, but never actually receive auxtrace data on that
>> queue.
>>
>> Signed-off-by: James Clark <james.clark(a)arm.com>
>
> Acked-by: Adrian Hunter <adrian.hunter(a)intel.com>
>
> Again ;-)
>
Oops yeah I should have picked that up. This one was already applied to
perf-tools-next as well.
Thanks
>> ---
>> tools/perf/util/auxtrace.c | 9 +++++++--
>> tools/perf/util/auxtrace.h | 1 +
>> 2 files changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
>> index 3684e6009b63..563b6c4fca31 100644
>> --- a/tools/perf/util/auxtrace.c
>> +++ b/tools/perf/util/auxtrace.c
>> @@ -218,15 +218,20 @@ static struct auxtrace_queue *auxtrace_alloc_queue_array(unsigned int nr_queues)
>> return queue_array;
>> }
>>
>> -int auxtrace_queues__init(struct auxtrace_queues *queues)
>> +int auxtrace_queues__init_nr(struct auxtrace_queues *queues, int nr_queues)
>> {
>> - queues->nr_queues = AUXTRACE_INIT_NR_QUEUES;
>> + queues->nr_queues = nr_queues;
>> queues->queue_array = auxtrace_alloc_queue_array(queues->nr_queues);
>> if (!queues->queue_array)
>> return -ENOMEM;
>> return 0;
>> }
>>
>> +int auxtrace_queues__init(struct auxtrace_queues *queues)
>> +{
>> + return auxtrace_queues__init_nr(queues, AUXTRACE_INIT_NR_QUEUES);
>> +}
>> +
>> static int auxtrace_queues__grow(struct auxtrace_queues *queues,
>> unsigned int new_nr_queues)
>> {
>> diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
>> index 55702215a82d..8a6ec9565835 100644
>> --- a/tools/perf/util/auxtrace.h
>> +++ b/tools/perf/util/auxtrace.h
>> @@ -521,6 +521,7 @@ int auxtrace_mmap__read_snapshot(struct mmap *map,
>> struct perf_tool *tool, process_auxtrace_t fn,
>> size_t snapshot_size);
>>
>> +int auxtrace_queues__init_nr(struct auxtrace_queues *queues, int nr_queues);
>> int auxtrace_queues__init(struct auxtrace_queues *queues);
>> int auxtrace_queues__add_event(struct auxtrace_queues *queues,
>> struct perf_session *session,
>