Skip to content

Commit fa50d6b

Browse files
committed
Merge tag 'coresight-next-v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux into char-misc-next
Suzuki writes: coresight: Updates for v6.5 CoreSight and hwtracing subsystem updates for v6.5 includes: - Fixes to the CTI module reference leaks. This involves, redesign of how the helper devices are tracked and CTI devices have been converted to helper devices. - Fix removal of the trctraceidr file from sysfs for ETMs. - Match all ETMv4 instances based on the ETMv4 architected registers and the CoreSight Component ID (CID), than having to add individual PIDs for CPUs. - Add support for Dummy CoreSight source and sink drivers. - Add James Clark as Reviewer for the CoreSight kernel drivers - Fixes to HiSilicon PCIe Tune and Trace Device driver Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> * tag 'coresight-next-v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux: (27 commits) hwtracing: hisi_ptt: Fix potential sleep in atomic context hwtracing: hisi_ptt: Advertise PERF_PMU_CAP_NO_EXCLUDE for PTT PMU hwtracing: hisi_ptt: Export available filters through sysfs hwtracing: hisi_ptt: Add support for dynamically updating the filter list hwtracing: hisi_ptt: Factor out filter allocation and release operation coresight: dummy: Update type of mode parameter in dummy_{sink,source}_enable() Documentation: trace: Add documentation for Coresight Dummy Trace dt-bindings: arm: Add support for Coresight dummy trace Coresight: Add coresight dummy driver MAINTAINERS: coresight: Add James Clark as Reviewer coresight: etm4x: Match all ETM4 instances based on DEVARCH and DEVTYPE coresight: etm4x: Make etm4_remove_dev() return void coresight: etm4x: Fix missing trctraceidr file in sysfs coresight: Fix CTI module refcount leak by making it a helper device coresight: Enable and disable helper devices adjacent to the path coresight: Refactor out buffer allocation function for ETR coresight: Make refcount a property of the connection coresight: Store in-connections as well as out-connections coresight: Simplify connection fixup mechanism coresight: Store pointers to connections rather than an array of them ...
2 parents 9285221 + 6c50384 commit fa50d6b

39 files changed

Lines changed: 1648 additions & 728 deletions

Documentation/ABI/testing/sysfs-devices-hisi_ptt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,55 @@ Description: (RW) Control the allocated buffer watermark of outbound packets.
5959
The available tune data is [0, 1, 2]. Writing a negative value
6060
will return an error, and out of range values will be converted
6161
to 2. The value indicates a probable level of the event.
62+
63+
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/root_port_filters
64+
Date: May 2023
65+
KernelVersion: 6.5
66+
Contact: Yicong Yang <yangyicong@hisilicon.com>
67+
Description: This directory contains the files providing the PCIe Root Port filters
68+
information used for PTT trace. Each file is named after the supported
69+
Root Port device name <domain>:<bus>:<device>.<function>.
70+
71+
See the description of the "filter" in Documentation/trace/hisi-ptt.rst
72+
for more information.
73+
74+
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/root_port_filters/multiselect
75+
Date: May 2023
76+
KernelVersion: 6.5
77+
Contact: Yicong Yang <yangyicong@hisilicon.com>
78+
Description: (Read) Indicates if this kind of filter can be selected at the same
79+
time as others filters, or must be used on it's own. 1 indicates
80+
the former case and 0 indicates the latter.
81+
82+
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/root_port_filters/<bdf>
83+
Date: May 2023
84+
KernelVersion: 6.5
85+
Contact: Yicong Yang <yangyicong@hisilicon.com>
86+
Description: (Read) Indicates the filter value of this Root Port filter, which
87+
can be used to control the TLP headers to trace by the PTT trace.
88+
89+
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/requester_filters
90+
Date: May 2023
91+
KernelVersion: 6.5
92+
Contact: Yicong Yang <yangyicong@hisilicon.com>
93+
Description: This directory contains the files providing the PCIe Requester filters
94+
information used for PTT trace. Each file is named after the supported
95+
Endpoint device name <domain>:<bus>:<device>.<function>.
96+
97+
See the description of the "filter" in Documentation/trace/hisi-ptt.rst
98+
for more information.
99+
100+
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/requester_filters/multiselect
101+
Date: May 2023
102+
KernelVersion: 6.5
103+
Contact: Yicong Yang <yangyicong@hisilicon.com>
104+
Description: (Read) Indicates if this kind of filter can be selected at the same
105+
time as others filters, or must be used on it's own. 1 indicates
106+
the former case and 0 indicates the latter.
107+
108+
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/requester_filters/<bdf>
109+
Date: May 2023
110+
KernelVersion: 6.5
111+
Contact: Yicong Yang <yangyicong@hisilicon.com>
112+
Description: (Read) Indicates the filter value of this Requester filter, which
113+
can be used to control the TLP headers to trace by the PTT trace.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/arm/arm,coresight-dummy-sink.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: ARM Coresight Dummy sink component
8+
9+
description: |
10+
CoreSight components are compliant with the ARM CoreSight architecture
11+
specification and can be connected in various topologies to suit a particular
12+
SoCs tracing needs. These trace components can generally be classified as
13+
sinks, links and sources. Trace data produced by one or more sources flows
14+
through the intermediate links connecting the source to the currently selected
15+
sink.
16+
17+
The Coresight dummy sink component is for the specific coresight sink devices
18+
kernel don't have permission to access or configure, e.g., CoreSight EUD on
19+
Qualcomm platforms. It is a mini-USB hub implemented to support the USB-based
20+
debug and trace capabilities. For this device, a dummy driver is needed to
21+
register it as Coresight sink device in kernel side, so that path can be
22+
created in the driver. Then the trace flow would be transferred to EUD via
23+
coresight link of AP processor. It provides Coresight API for operations on
24+
dummy source devices, such as enabling and disabling them. It also provides
25+
the Coresight dummy source paths for debugging.
26+
27+
The primary use case of the coresight dummy sink is to build path in kernel
28+
side for dummy sink component.
29+
30+
maintainers:
31+
- Mike Leach <mike.leach@linaro.org>
32+
- Suzuki K Poulose <suzuki.poulose@arm.com>
33+
- James Clark <james.clark@arm.com>
34+
- Mao Jinlong <quic_jinlmao@quicinc.com>
35+
- Hao Zhang <quic_hazha@quicinc.com>
36+
37+
properties:
38+
compatible:
39+
enum:
40+
- arm,coresight-dummy-sink
41+
42+
in-ports:
43+
$ref: /schemas/graph.yaml#/properties/ports
44+
45+
properties:
46+
port:
47+
description: Input connection from the Coresight Trace bus to
48+
dummy sink, such as Embedded USB debugger(EUD).
49+
50+
$ref: /schemas/graph.yaml#/properties/port
51+
52+
required:
53+
- compatible
54+
- in-ports
55+
56+
additionalProperties: false
57+
58+
examples:
59+
# Minimum dummy sink definition. Dummy sink connect to coresight replicator.
60+
- |
61+
sink {
62+
compatible = "arm,coresight-dummy-sink";
63+
64+
in-ports {
65+
port {
66+
eud_in_replicator_swao: endpoint {
67+
remote-endpoint = <&replicator_swao_out_eud>;
68+
};
69+
};
70+
};
71+
};
72+
73+
...
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/arm/arm,coresight-dummy-source.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: ARM Coresight Dummy source component
8+
9+
description: |
10+
CoreSight components are compliant with the ARM CoreSight architecture
11+
specification and can be connected in various topologies to suit a particular
12+
SoCs tracing needs. These trace components can generally be classified as
13+
sinks, links and sources. Trace data produced by one or more sources flows
14+
through the intermediate links connecting the source to the currently selected
15+
sink.
16+
17+
The Coresight dummy source component is for the specific coresight source
18+
devices kernel don't have permission to access or configure. For some SOCs,
19+
there would be Coresight source trace components on sub-processor which
20+
are conneted to AP processor via debug bus. For these devices, a dummy driver
21+
is needed to register them as Coresight source devices, so that paths can be
22+
created in the driver. It provides Coresight API for operations on dummy
23+
source devices, such as enabling and disabling them. It also provides the
24+
Coresight dummy source paths for debugging.
25+
26+
The primary use case of the coresight dummy source is to build path in kernel
27+
side for dummy source component.
28+
29+
maintainers:
30+
- Mike Leach <mike.leach@linaro.org>
31+
- Suzuki K Poulose <suzuki.poulose@arm.com>
32+
- James Clark <james.clark@arm.com>
33+
- Mao Jinlong <quic_jinlmao@quicinc.com>
34+
- Hao Zhang <quic_hazha@quicinc.com>
35+
36+
properties:
37+
compatible:
38+
enum:
39+
- arm,coresight-dummy-source
40+
41+
out-ports:
42+
$ref: /schemas/graph.yaml#/properties/ports
43+
44+
properties:
45+
port:
46+
description: Output connection from the source to Coresight
47+
Trace bus.
48+
$ref: /schemas/graph.yaml#/properties/port
49+
50+
required:
51+
- compatible
52+
- out-ports
53+
54+
additionalProperties: false
55+
56+
examples:
57+
# Minimum dummy source definition. Dummy source connect to coresight funnel.
58+
- |
59+
source {
60+
compatible = "arm,coresight-dummy-source";
61+
62+
out-ports {
63+
port {
64+
dummy_riscv_out_funnel_swao: endpoint {
65+
remote-endpoint = <&funnel_swao_in_dummy_riscv>;
66+
};
67+
};
68+
};
69+
};
70+
71+
...

Documentation/driver-api/driver-model/devres.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ MEM
364364
devm_kmalloc_array()
365365
devm_kmemdup()
366366
devm_krealloc()
367+
devm_krealloc_array()
367368
devm_kstrdup()
368369
devm_kstrdup_const()
369370
devm_kvasprintf()
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
=============================
4+
Coresight Dummy Trace Module
5+
=============================
6+
7+
:Author: Hao Zhang <quic_hazha@quicinc.com>
8+
:Date: June 2023
9+
10+
Introduction
11+
------------
12+
13+
The Coresight dummy trace module is for the specific devices that kernel don't
14+
have permission to access or configure, e.g., CoreSight TPDMs on Qualcomm
15+
platforms. For these devices, a dummy driver is needed to register them as
16+
Coresight devices. The module may also be used to define components that may
17+
not have any programming interfaces, so that paths can be created in the driver.
18+
It provides Coresight API for operations on dummy devices, such as enabling and
19+
disabling them. It also provides the Coresight dummy sink/source paths for
20+
debugging.
21+
22+
Config details
23+
--------------
24+
25+
There are two types of nodes, dummy sink and dummy source. These nodes
26+
are available at ``/sys/bus/coresight/devices``.
27+
28+
Example output::
29+
30+
$ ls -l /sys/bus/coresight/devices | grep dummy
31+
dummy_sink0 -> ../../../devices/platform/soc@0/soc@0:sink/dummy_sink0
32+
dummy_source0 -> ../../../devices/platform/soc@0/soc@0:source/dummy_source0

Documentation/trace/hisi-ptt.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,20 @@ For example, if the desired filter is Endpoint function 0000:01:00.1 the filter
148148
value will be 0x00101. If the desired filter is Root Port 0000:00:10.0 then
149149
then filter value is calculated as 0x80001.
150150

151+
The driver also presents every supported Root Port and Requester filter through
152+
sysfs. Each filter will be an individual file with name of its related PCIe
153+
device name (domain:bus:device.function). The files of Root Port filters are
154+
under $(PTT PMU dir)/root_port_filters and files of Requester filters
155+
are under $(PTT PMU dir)/requester_filters.
156+
151157
Note that multiple Root Ports can be specified at one time, but only one
152158
Endpoint function can be specified in one trace. Specifying both Root Port
153159
and function at the same time is not supported. Driver maintains a list of
154160
available filters and will check the invalid inputs.
155161

156-
Currently the available filters are detected in driver's probe. If the supported
157-
devices are removed/added after probe, you may need to reload the driver to update
158-
the filters.
162+
The available filters will be dynamically updated, which means you will always
163+
get correct filter information when hotplug events happen, or when you manually
164+
remove/rescan the devices.
159165

160166
2. Type
161167
-------

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,7 @@ N: digicolor
20982098
ARM/CORESIGHT FRAMEWORK AND DRIVERS
20992099
M: Suzuki K Poulose <suzuki.poulose@arm.com>
21002100
R: Mike Leach <mike.leach@linaro.org>
2101+
R: James Clark <james.clark@arm.com>
21012102
R: Leo Yan <leo.yan@linaro.org>
21022103
L: coresight@lists.linaro.org (moderated for non-subscribers)
21032104
L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)

drivers/hwtracing/coresight/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,15 @@ config CORESIGHT_TPDA
236236

237237
To compile this driver as a module, choose M here: the module will be
238238
called coresight-tpda.
239+
240+
config CORESIGHT_DUMMY
241+
tristate "Dummy driver support"
242+
help
243+
Enables support for dummy driver. Dummy driver can be used for
244+
CoreSight sources/sinks that are owned and configured by some
245+
other subsystem and use Linux drivers to configure rest of trace
246+
path.
247+
248+
To compile this driver as a module, choose M here: the module will be
249+
called coresight-dummy.
239250
endif

drivers/hwtracing/coresight/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ obj-$(CONFIG_CORESIGHT_TPDA) += coresight-tpda.o
3030
coresight-cti-y := coresight-cti-core.o coresight-cti-platform.o \
3131
coresight-cti-sysfs.o
3232
obj-$(CONFIG_ULTRASOC_SMB) += ultrasoc-smb.o
33+
obj-$(CONFIG_CORESIGHT_DUMMY) += coresight-dummy.o

drivers/hwtracing/coresight/coresight-catu.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,18 @@ static inline int catu_wait_for_ready(struct catu_drvdata *drvdata)
395395
return coresight_timeout(csa, CATU_STATUS, CATU_STATUS_READY, 1);
396396
}
397397

398-
static int catu_enable_hw(struct catu_drvdata *drvdata, void *data)
398+
static int catu_enable_hw(struct catu_drvdata *drvdata, enum cs_mode cs_mode,
399+
void *data)
399400
{
400401
int rc;
401402
u32 control, mode;
402-
struct etr_buf *etr_buf = data;
403+
struct etr_buf *etr_buf = NULL;
403404
struct device *dev = &drvdata->csdev->dev;
404405
struct coresight_device *csdev = drvdata->csdev;
406+
struct coresight_device *etrdev;
407+
union coresight_dev_subtype etr_subtype = {
408+
.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM
409+
};
405410

406411
if (catu_wait_for_ready(drvdata))
407412
dev_warn(dev, "Timeout while waiting for READY\n");
@@ -416,6 +421,13 @@ static int catu_enable_hw(struct catu_drvdata *drvdata, void *data)
416421
if (rc)
417422
return rc;
418423

424+
etrdev = coresight_find_input_type(
425+
csdev->pdata, CORESIGHT_DEV_TYPE_SINK, etr_subtype);
426+
if (etrdev) {
427+
etr_buf = tmc_etr_get_buffer(etrdev, cs_mode, data);
428+
if (IS_ERR(etr_buf))
429+
return PTR_ERR(etr_buf);
430+
}
419431
control |= BIT(CATU_CONTROL_ENABLE);
420432

421433
if (etr_buf && etr_buf->mode == ETR_MODE_CATU) {
@@ -441,13 +453,14 @@ static int catu_enable_hw(struct catu_drvdata *drvdata, void *data)
441453
return 0;
442454
}
443455

444-
static int catu_enable(struct coresight_device *csdev, void *data)
456+
static int catu_enable(struct coresight_device *csdev, enum cs_mode mode,
457+
void *data)
445458
{
446459
int rc;
447460
struct catu_drvdata *catu_drvdata = csdev_to_catu_drvdata(csdev);
448461

449462
CS_UNLOCK(catu_drvdata->base);
450-
rc = catu_enable_hw(catu_drvdata, data);
463+
rc = catu_enable_hw(catu_drvdata, mode, data);
451464
CS_LOCK(catu_drvdata->base);
452465
return rc;
453466
}

0 commit comments

Comments
 (0)