From: Amir Ayupov <aaupov@fb.com>
To: James Clark <james.clark@linaro.org>, Leo Yan <leo.yan@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jonathan Corbet <corbet@lwn.net>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Randy Dunlap <rdunlap@infradead.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Daniel Pereira <danielmaraboo@gmail.com>,
<coresight@lists.linaro.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-perf-users@vger.kernel.org>, <linux-doc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH v6 4/4] coresight: Add pmu_pulse/extout_pulse
Date: Fri, 20 Nov 2026 10:54:34 -0800 [thread overview]
Message-ID: <d15e5919ff7c24a6454befcc6ccd2e1928530528.1795196854.git.aaupov@fb.com> (raw)
In-Reply-To: <cover.1795196854.git.aaupov@fb.com>
Drive external output 1 from the always-true trace resource for an
external consumer to count. Change only EVENT1 so other event fields
remain intact, and avoid output 0 because it is the trace trigger and
can stop TRBE capture.
Producer resource validation loads the feature only on trace units
implementing EVENT1. PMU counting support and implementation-defined
output routing remain independent consumer responsibilities. Include
the preload declarations in the defining translation unit and document
setup-time source filtering and the separately selected trcextout1 event.
Assisted-by: Devmate:GPT-6.1-Sol
Signed-off-by: Amir Ayupov <aaupov@fb.com>
---
.../trace/coresight/coresight-config.rst | 6 +++
.../trace/coresight/coresight-perf.rst | 15 +++++++
drivers/hwtracing/coresight/Makefile | 3 +-
.../coresight/coresight-cfg-pmu-pulse.c | 39 +++++++++++++++++++
.../coresight/coresight-cfg-preload.c | 2 +
.../coresight/coresight-cfg-preload.h | 2 +
6 files changed, 66 insertions(+), 1 deletion(-)
create mode 100644 drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c
diff --git a/Documentation/trace/coresight/coresight-config.rst b/Documentation/trace/coresight/coresight-config.rst
index 6d5ffa6f73471b..1c194fd5f55816 100644
--- a/Documentation/trace/coresight/coresight-config.rst
+++ b/Documentation/trace/coresight/coresight-config.rst
@@ -42,6 +42,12 @@ accesses in the driver - the resource usage and parameter descriptions
translated into appropriate register accesses. This interpretation makes it easy
and efficient for the feature to be programmed onto the device when required.
+The device driver checks requested event fields when loading a feature. For
+example, ``extout_pulse`` is loaded only where EVENT1 is implemented, based on
+the trace unit's decoded event count. A valid feature requiring unavailable
+resources is skipped for that device. This does not check whether a PMU can
+count the output.
+
The feature will not be active on the device until the feature is enabled, and
the device itself is enabled. When the device is enabled then enabled features
will be programmed into the device hardware.
diff --git a/Documentation/trace/coresight/coresight-perf.rst b/Documentation/trace/coresight/coresight-perf.rst
index 0a77741a431ef9..dbae2acd3634a9 100644
--- a/Documentation/trace/coresight/coresight-perf.rst
+++ b/Documentation/trace/coresight/coresight-perf.rst
@@ -109,6 +109,21 @@ Example for triggering AUX pause and resume with PMU event::
-e cycles/aux-action=pause,period=10000000/ \
-e cycles/aux-action=resume,period=1050000/ -- sleep 1
+Using external-output pulses
+----------------------------
+
+The ``pmu_pulse`` configuration drives fixed external output 1. Separately
+select the matching PMU event, ``trcextout1``, to count it. The hardware must
+support and connect this output to that PMU; this is not checked automatically.
+
+Perf skips CPUs whose trace units do not support this configuration and fails
+setup if none remain. Use the PMU instance that counts output 1 on your system::
+
+ perf record -a -e '{cs_etm/pmu_pulse,aux-action=start-paused/u,cycles/aux-action=resume,period=10000000/u,armv8_pmuv3_0/trcextout1,aux-action=pause,period=5000/u}' -- sleep 1
+
+Tracing starts paused. The cycles event resumes it every 10000000 cycles;
+``trcextout1`` pauses it after 5000 counted pulses.
+
Perf test - Verify kernel and userspace perf CoreSight work
-----------------------------------------------------------
diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile
index ab16d06783a572..e2768c79d08616 100644
--- a/drivers/hwtracing/coresight/Makefile
+++ b/drivers/hwtracing/coresight/Makefile
@@ -28,7 +28,8 @@ obj-$(CONFIG_CORESIGHT) += coresight.o
coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \
coresight-sysfs.o coresight-syscfg.o coresight-config.o \
coresight-cfg-preload.o coresight-cfg-afdo.o coresight-cfg-pstop.o \
- coresight-syscfg-configfs.o coresight-trace-id.o
+ coresight-syscfg-configfs.o coresight-trace-id.o \
+ coresight-cfg-pmu-pulse.o
obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o
coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \
coresight-tmc-etr.o
diff --git a/drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c b/drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c
new file mode 100644
index 00000000000000..139596d54d5883
--- /dev/null
+++ b/drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Pulse trace-unit external output 1 with the always-true resource. */
+
+#include "coresight-config.h"
+
+#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
+#include "coresight-etm4x-cfg.h"
+#include "coresight-cfg-preload.h"
+
+/* Output 0 is the trace trigger and can stop TRBE capture. */
+static struct cscfg_regval_desc extout_pulse_regs[] = {
+ {
+ .type = CS_CFG_REG_TYPE_STD | CS_CFG_REG_TYPE_VAL_MASK,
+ .offset = TRCEVENTCTL0R,
+ .val32 = ETM4_RES_SEL_TRUE << 8,
+ .mask32 = GENMASK_U32(15, 8),
+ },
+};
+
+struct cscfg_feature_desc extout_pulse_etm4x = {
+ .name = "extout_pulse",
+ .description = "Pulse external output 1 with the always-true resource.\n",
+ .match_flags = CS_CFG_MATCH_CLASS_SRC_ETM4,
+ .nr_regs = ARRAY_SIZE(extout_pulse_regs),
+ .regs_desc = extout_pulse_regs,
+};
+
+static const char *pmu_pulse_ref_names[] = {
+ "extout_pulse",
+};
+
+struct cscfg_config_desc pmu_pulse_etm4x = {
+ .name = "pmu_pulse",
+ .description = "Pulse external output 1 for an external consumer.\n",
+ .nr_feat_refs = ARRAY_SIZE(pmu_pulse_ref_names),
+ .feat_ref_names = pmu_pulse_ref_names,
+};
+
+#endif
diff --git a/drivers/hwtracing/coresight/coresight-cfg-preload.c b/drivers/hwtracing/coresight/coresight-cfg-preload.c
index 4980e68483c5b9..a9a60a1c408455 100644
--- a/drivers/hwtracing/coresight/coresight-cfg-preload.c
+++ b/drivers/hwtracing/coresight/coresight-cfg-preload.c
@@ -14,6 +14,7 @@ static struct cscfg_feature_desc *preload_feats[] = {
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
&strobe_etm4x,
&gen_etrig_etm4x,
+ &extout_pulse_etm4x,
#endif
NULL
};
@@ -22,6 +23,7 @@ static struct cscfg_config_desc *preload_cfgs[] = {
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
&afdo_etm4x,
&pstop_etm4x,
+ &pmu_pulse_etm4x,
#endif
NULL
};
diff --git a/drivers/hwtracing/coresight/coresight-cfg-preload.h b/drivers/hwtracing/coresight/coresight-cfg-preload.h
index 291ba530a6a520..0058627f65ae5b 100644
--- a/drivers/hwtracing/coresight/coresight-cfg-preload.h
+++ b/drivers/hwtracing/coresight/coresight-cfg-preload.h
@@ -12,4 +12,6 @@ extern struct cscfg_feature_desc strobe_etm4x;
extern struct cscfg_config_desc afdo_etm4x;
extern struct cscfg_feature_desc gen_etrig_etm4x;
extern struct cscfg_config_desc pstop_etm4x;
+extern struct cscfg_feature_desc extout_pulse_etm4x;
+extern struct cscfg_config_desc pmu_pulse_etm4x;
#endif
--
2.52.1
prev parent reply other threads:[~2026-11-20 18:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 18:54 [PATCH v6 0/4] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 1/4] coresight: etm4x: Fix event count decoding Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 2/4] coresight: etm4x: Skip features requiring unavailable events Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 3/4] coresight: perf: Filter sources lacking the selected configuration Amir Ayupov
2026-11-20 18:54 ` Amir Ayupov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d15e5919ff7c24a6454befcc6ccd2e1928530528.1795196854.git.aaupov@fb.com \
--to=aaupov@fb.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=corbet@lwn.net \
--cc=coresight@lists.linaro.org \
--cc=danielmaraboo@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=james.clark@linaro.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.poirier@linaro.org \
--cc=mike.leach@arm.com \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®