Skip to content

Commit 6400f34

Browse files
author
Herton R. Krzesinski
committed
Merge: The Neoverse N2/A710 self hosted trace errata, and updated coresight and spe subsystem
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/638 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2055405 Tested: N1SDP (hacked up) Per the defect: 5.16 merged a number of neoverse/cortexA errata, the one that I think is important for RHEL is one affecting the trace functionality on neoverse N2 cpus. The upstream patch was merged to 5.16 from this set: https://www.spinics.net/lists/arm-kernel/msg928313.html and fixes the following errata: * TRBE may overwrite trace in FILL mode * Arm Neoverse-N2 #2139208 * Cortex-A710 #211985 * A TSB instruction may not flush the trace completely when executed in trace prohibited region. * Arm Neoverse-N2 #2067961 * Cortex-A710 #2054223 * TRBE may write to out-of-range address * Arm Neoverse-N2 #2253138 * Cortex-A710 #2224489 The current errata doc: https://developer.arm.com/documentation/SDEN1982442/0900/?lang=en This set turned out to be easier to just pull the coresight system forward rather than wedge just the fixes into the existing kernel. Mostly everything was applied cleanly. New with this update, much of the perf subsystem is also updated to handle newer coresight functionality. There are some further A510 fixes for 5.18 which might be useful if that CPU turns out to be in any machines RHEL is targeting. (its also possible that there are a couple of conflicts with other sets in flight, in particular, the part numbers patch might have to be dropped from this set). Signed-off-by: Jeremy Linton <jlinton@redhat.com> Approved-by: Mark Langsdorf <mlangsdo@redhat.com> Approved-by: Mark Salter <msalter@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 1d1d96e + e8c2c55 commit 6400f34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4213
-198
lines changed

Documentation/devicetree/bindings/arm/coresight.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ its hardware characteristcs.
127127
* arm,scatter-gather: boolean. Indicates that the TMC-ETR can safely
128128
use the SG mode on this system.
129129

130+
* arm,max-burst-size: The maximum burst size initiated by TMC on the
131+
AXI master interface. The burst size can be in the range [0..15],
132+
the setting supports one data transfer per burst up to a maximum of
133+
16 data transfers per burst.
134+
130135
* Optional property for CATU :
131136
* interrupts : Exactly one SPI may be listed for reporting the address
132137
error
Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
======================================
4+
CoreSight System Configuration Manager
5+
======================================
6+
7+
:Author: Mike Leach <mike.leach@linaro.org>
8+
:Date: October 2020
9+
10+
Introduction
11+
============
12+
13+
The CoreSight System Configuration manager is an API that allows the
14+
programming of the CoreSight system with pre-defined configurations that
15+
can then be easily enabled from sysfs or perf.
16+
17+
Many CoreSight components can be programmed in complex ways - especially ETMs.
18+
In addition, components can interact across the CoreSight system, often via
19+
the cross trigger components such as CTI and CTM. These system settings can
20+
be defined and enabled as named configurations.
21+
22+
23+
Basic Concepts
24+
==============
25+
26+
This section introduces the basic concepts of a CoreSight system configuration.
27+
28+
29+
Features
30+
--------
31+
32+
A feature is a named set of programming for a CoreSight device. The programming
33+
is device dependent, and can be defined in terms of absolute register values,
34+
resource usage and parameter values.
35+
36+
The feature is defined using a descriptor. This descriptor is used to load onto
37+
a matching device, either when the feature is loaded into the system, or when the
38+
CoreSight device is registered with the configuration manager.
39+
40+
The load process involves interpreting the descriptor into a set of register
41+
accesses in the driver - the resource usage and parameter descriptions
42+
translated into appropriate register accesses. This interpretation makes it easy
43+
and efficient for the feature to be programmed onto the device when required.
44+
45+
The feature will not be active on the device until the feature is enabled, and
46+
the device itself is enabled. When the device is enabled then enabled features
47+
will be programmed into the device hardware.
48+
49+
A feature is enabled as part of a configuration being enabled on the system.
50+
51+
52+
Parameter Value
53+
~~~~~~~~~~~~~~~
54+
55+
A parameter value is a named value that may be set by the user prior to the
56+
feature being enabled that can adjust the behaviour of the operation programmed
57+
by the feature.
58+
59+
For example, this could be a count value in a programmed operation that repeats
60+
at a given rate. When the feature is enabled then the current value of the
61+
parameter is used in programming the device.
62+
63+
The feature descriptor defines a default value for a parameter, which is used
64+
if the user does not supply a new value.
65+
66+
Users can update parameter values using the configfs API for the CoreSight
67+
system - which is described below.
68+
69+
The current value of the parameter is loaded into the device when the feature
70+
is enabled on that device.
71+
72+
73+
Configurations
74+
--------------
75+
76+
A configuration defines a set of features that are to be used in a trace
77+
session where the configuration is selected. For any trace session only one
78+
configuration may be selected.
79+
80+
The features defined may be on any type of device that is registered
81+
to support system configuration. A configuration may select features to be
82+
enabled on a class of devices - i.e. any ETMv4, or specific devices, e.g. a
83+
specific CTI on the system.
84+
85+
As with the feature, a descriptor is used to define the configuration.
86+
This will define the features that must be enabled as part of the configuration
87+
as well as any preset values that can be used to override default parameter
88+
values.
89+
90+
91+
Preset Values
92+
~~~~~~~~~~~~~
93+
94+
Preset values are easily selectable sets of parameter values for the features
95+
that the configuration uses. The number of values in a single preset set, equals
96+
the sum of parameter values in the features used by the configuration.
97+
98+
e.g. a configuration consists of 3 features, one has 2 parameters, one has
99+
a single parameter, and another has no parameters. A single preset set will
100+
therefore have 3 values.
101+
102+
Presets are optionally defined by the configuration, up to 15 can be defined.
103+
If no preset is selected, then the parameter values defined in the feature
104+
are used as normal.
105+
106+
107+
Operation
108+
~~~~~~~~~
109+
110+
The following steps take place in the operation of a configuration.
111+
112+
1) In this example, the configuration is 'autofdo', which has an
113+
associated feature 'strobing' that works on ETMv4 CoreSight Devices.
114+
115+
2) The configuration is enabled. For example 'perf' may select the
116+
configuration as part of its command line::
117+
118+
perf record -e cs_etm/autofdo/ myapp
119+
120+
which will enable the 'autofdo' configuration.
121+
122+
3) perf starts tracing on the system. As each ETMv4 that perf uses for
123+
trace is enabled, the configuration manager will check if the ETMv4
124+
has a feature that relates to the currently active configuration.
125+
In this case 'strobing' is enabled & programmed into the ETMv4.
126+
127+
4) When the ETMv4 is disabled, any registers marked as needing to be
128+
saved will be read back.
129+
130+
5) At the end of the perf session, the configuration will be disabled.
131+
132+
133+
Viewing Configurations and Features
134+
===================================
135+
136+
The set of configurations and features that are currently loaded into the
137+
system can be viewed using the configfs API.
138+
139+
Mount configfs as normal and the 'cs-syscfg' subsystem will appear::
140+
141+
$ ls /config
142+
cs-syscfg stp-policy
143+
144+
This has two sub-directories::
145+
146+
$ cd cs-syscfg/
147+
$ ls
148+
configurations features
149+
150+
The system has the configuration 'autofdo' built in. It may be examined as
151+
follows::
152+
153+
$ cd configurations/
154+
$ ls
155+
autofdo
156+
$ cd autofdo/
157+
$ ls
158+
description feature_refs preset1 preset3 preset5 preset7 preset9
159+
enable preset preset2 preset4 preset6 preset8
160+
$ cat description
161+
Setup ETMs with strobing for autofdo
162+
$ cat feature_refs
163+
strobing
164+
165+
Each preset declared has a 'preset<n>' subdirectory declared. The values for
166+
the preset can be examined::
167+
168+
$ cat preset1/values
169+
strobing.window = 0x1388 strobing.period = 0x2
170+
$ cat preset2/values
171+
strobing.window = 0x1388 strobing.period = 0x4
172+
173+
The 'enable' and 'preset' files allow the control of a configuration when
174+
using CoreSight with sysfs.
175+
176+
The features referenced by the configuration can be examined in the features
177+
directory::
178+
179+
$ cd ../../features/strobing/
180+
$ ls
181+
description matches nr_params params
182+
$ cat description
183+
Generate periodic trace capture windows.
184+
parameter 'window': a number of CPU cycles (W)
185+
parameter 'period': trace enabled for W cycles every period x W cycles
186+
$ cat matches
187+
SRC_ETMV4
188+
$ cat nr_params
189+
2
190+
191+
Move to the params directory to examine and adjust parameters::
192+
193+
cd params
194+
$ ls
195+
period window
196+
$ cd period
197+
$ ls
198+
value
199+
$ cat value
200+
0x2710
201+
# echo 15000 > value
202+
# cat value
203+
0x3a98
204+
205+
Parameters adjusted in this way are reflected in all device instances that have
206+
loaded the feature.
207+
208+
209+
Using Configurations in perf
210+
============================
211+
212+
The configurations loaded into the CoreSight configuration management are
213+
also declared in the perf 'cs_etm' event infrastructure so that they can
214+
be selected when running trace under perf::
215+
216+
$ ls /sys/devices/cs_etm
217+
cpu0 cpu2 events nr_addr_filters power subsystem uevent
218+
cpu1 cpu3 format perf_event_mux_interval_ms sinks type
219+
220+
The key directory here is 'events' - a generic perf directory which allows
221+
selection on the perf command line. As with the sinks entries, this provides
222+
a hash of the configuration name.
223+
224+
The entry in the 'events' directory uses perfs built in syntax generator
225+
to substitute the syntax for the name when evaluating the command::
226+
227+
$ ls events/
228+
autofdo
229+
$ cat events/autofdo
230+
configid=0xa7c3dddd
231+
232+
The 'autofdo' configuration may be selected on the perf command line::
233+
234+
$ perf record -e cs_etm/autofdo/u --per-thread <application>
235+
236+
A preset to override the current parameter values can also be selected::
237+
238+
$ perf record -e cs_etm/autofdo,preset=1/u --per-thread <application>
239+
240+
When configurations are selected in this way, then the trace sink used is
241+
automatically selected.
242+
243+
Using Configurations in sysfs
244+
=============================
245+
246+
Coresight can be controlled using sysfs. When this is in use then a configuration
247+
can be made active for the devices that are used in the sysfs session.
248+
249+
In a configuration there are 'enable' and 'preset' files.
250+
251+
To enable a configuration for use with sysfs::
252+
253+
$ cd configurations/autofdo
254+
$ echo 1 > enable
255+
256+
This will then use any default parameter values in the features - which can be
257+
adjusted as described above.
258+
259+
To use a preset<n> set of parameter values::
260+
261+
$ echo 3 > preset
262+
263+
This will select preset3 for the configuration.
264+
The valid values for preset are 0 - to deselect presets, and any value of
265+
<n> where a preset<n> sub-directory is present.
266+
267+
Note that the active sysfs configuration is a global parameter, therefore
268+
only a single configuration can be active for sysfs at any one time.
269+
Attempting to enable a second configuration will result in an error.
270+
Additionally, attempting to disable the configuration while in use will
271+
also result in an error.
272+
273+
The use of the active configuration by sysfs is independent of the configuration
274+
used in perf.
275+
276+
277+
Creating and Loading Custom Configurations
278+
==========================================
279+
280+
Custom configurations and / or features can be dynamically loaded into the
281+
system by using a loadable module.
282+
283+
An example of a custom configuration is found in ./samples/coresight.
284+
285+
This creates a new configuration that uses the existing built in
286+
strobing feature, but provides a different set of presets.
287+
288+
When the module is loaded, then the configuration appears in the configfs
289+
file system and is selectable in the same way as the built in configuration
290+
described above.
291+
292+
Configurations can use previously loaded features. The system will ensure
293+
that it is not possible to unload a feature that is currently in use, by
294+
enforcing the unload order as the strict reverse of the load order.

Documentation/trace/coresight/coresight.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,19 @@ channels on the CTM (Cross Trigger Matrix).
620620
A separate documentation file is provided to explain the use of these devices.
621621
(Documentation/trace/coresight/coresight-ect.rst) [#fourth]_.
622622

623+
CoreSight System Configuration
624+
------------------------------
625+
626+
CoreSight components can be complex devices with many programming options.
627+
Furthermore, components can be programmed to interact with each other across the
628+
complete system.
629+
630+
A CoreSight System Configuration manager is provided to allow these complex programming
631+
configurations to be selected and used easily from perf and sysfs.
632+
633+
See the separate document for further information.
634+
(Documentation/trace/coresight/coresight-config.rst) [#fifth]_.
635+
623636

624637
.. [#first] Documentation/ABI/testing/sysfs-bus-coresight-devices-stm
625638
@@ -628,3 +641,5 @@ A separate documentation file is provided to explain the use of these devices.
628641
.. [#third] https://github.com/Linaro/perf-opencsd
629642
630643
.. [#fourth] Documentation/trace/coresight/coresight-ect.rst
644+
645+
.. [#fifth] Documentation/trace/coresight/coresight-config.rst

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,7 @@ F: Documentation/trace/coresight/*
18901890
F: drivers/hwtracing/coresight/*
18911891
F: include/dt-bindings/arm/coresight-cti-dt.h
18921892
F: include/linux/coresight*
1893+
F: samples/coresight/*
18931894
F: tools/perf/arch/arm/util/auxtrace.c
18941895
F: tools/perf/arch/arm/util/cs-etm.c
18951896
F: tools/perf/arch/arm/util/cs-etm.h

drivers/hwtracing/coresight/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ menuconfig CORESIGHT
88
depends on OF || ACPI
99
select ARM_AMBA
1010
select PERF_EVENTS
11+
select CONFIGFS_FS
1112
help
1213
This framework provides a kernel interface for the CoreSight debug
1314
and trace drivers to register themselves with. It's intended to build
@@ -149,6 +150,19 @@ config CORESIGHT_CPU_DEBUG
149150
To compile this driver as a module, choose M here: the
150151
module will be called coresight-cpu-debug.
151152

153+
config CORESIGHT_CPU_DEBUG_DEFAULT_ON
154+
bool "Enable CoreSight CPU Debug by default"
155+
depends on CORESIGHT_CPU_DEBUG
156+
help
157+
Say Y here to enable the CoreSight Debug panic-debug by default. This
158+
can also be enabled via debugfs, but this ensures the debug feature
159+
is enabled as early as possible.
160+
161+
Has the same effect as setting coresight_cpu_debug.enable=1 on the
162+
kernel command line.
163+
164+
Say N if unsure.
165+
152166
config CORESIGHT_CTI
153167
tristate "CoreSight Cross Trigger Interface (CTI) driver"
154168
depends on ARM || ARM64

drivers/hwtracing/coresight/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#
55
obj-$(CONFIG_CORESIGHT) += coresight.o
66
coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \
7-
coresight-sysfs.o
7+
coresight-sysfs.o coresight-syscfg.o coresight-config.o \
8+
coresight-cfg-preload.o coresight-cfg-afdo.o \
9+
coresight-syscfg-configfs.o
810
obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o
911
coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \
1012
coresight-tmc-etr.o
@@ -16,7 +18,8 @@ obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.o
1618
coresight-etm3x-y := coresight-etm3x-core.o coresight-etm-cp14.o \
1719
coresight-etm3x-sysfs.o
1820
obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o
19-
coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o
21+
coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o \
22+
coresight-etm4x-cfg.o
2023
obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o
2124
obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o
2225
obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o

0 commit comments

Comments
 (0)