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 v5 6/7] coresight: etm4x: Report whether the PMU counts the external outputs
Date: Fri, 20 Nov 2026 07:21:19 -0800 [thread overview]
Message-ID: <d9c953867b9ff40c20c8ddd52771bada2fa8a4b9.1795182850.git.aaupov@fb.com> (raw)
In-Reply-To: <cover.1795182850.git.aaupov@fb.com>
Some CPUs count the trace unit's external outputs as the PMU common
events TRCEXTOUT0-3 (0x4010-0x4013), which lets a configuration drive a
PMU event from trace unit events. Other CPUs, Neoverse N1 for example,
have no such events, and a feature relying on them would silently do
nothing there.
Detect at probe, on the trace unit's CPU, whether the PMU counts every
external output: the trace unit has an external output for each of its
events (caps.nr_event), and pmuv3_event_implemented() reports whether
the PMU implements TRCEXTOUTn. Only check ETE: per its specification, an
implemented TRCEXTOUTn event counts external output n, while whether that
output is also an external input is IMPLEMENTATION DEFINED.
Add a CS_CFG_MATCH_CAP_ETE_TRCEXTOUT capability match flag, set it on
those trace units when registering them with the configuration manager,
and show it in the feature's configfs 'matches' attribute. With
capabilities matched separately from the device class, a feature that
requires it only loads on those trace units.
Assisted-by: Devmate:Opus-5.5
Reviewed-by: James Clark <james.clark@linaro.org>
Tested-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Amir Ayupov <aaupov@fb.com>
---
.../hwtracing/coresight/coresight-config.h | 2 ++
.../hwtracing/coresight/coresight-etm4x-cfg.c | 7 +++--
.../hwtracing/coresight/coresight-etm4x-cfg.h | 2 +-
.../coresight/coresight-etm4x-core.c | 29 ++++++++++++++++++-
.../coresight/coresight-syscfg-configfs.c | 3 ++
5 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-config.h b/drivers/hwtracing/coresight/coresight-config.h
index 220bc54f8e5e1b..e18143fca90f85 100644
--- a/drivers/hwtracing/coresight/coresight-config.h
+++ b/drivers/hwtracing/coresight/coresight-config.h
@@ -38,6 +38,8 @@
* a device that matches one of its classes and has all of its capabilities.
*/
#define CS_CFG_MATCH_CAP_MASK GENMASK_U32(15, 8)
+/* an ETE whose PMU counts its external outputs as TRCEXTOUTn */
+#define CS_CFG_MATCH_CAP_ETE_TRCEXTOUT BIT(8)
/*
* Limit number of presets in a configuration
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-cfg.c b/drivers/hwtracing/coresight/coresight-etm4x-cfg.c
index 52cb036bb04b96..fea003e49c262a 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-cfg.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-cfg.c
@@ -174,11 +174,14 @@ static int etm4_cfg_load_feature(struct coresight_device *csdev,
#define CS_CFG_ETM4_MATCH_FLAGS (CS_CFG_MATCH_CLASS_SRC_ALL | \
CS_CFG_MATCH_CLASS_SRC_ETM4)
-int etm4_cscfg_register(struct coresight_device *csdev)
+int etm4_cscfg_register(struct coresight_device *csdev, bool ete_trcextout)
{
struct cscfg_csdev_feat_ops ops;
+ u32 match_flags = CS_CFG_ETM4_MATCH_FLAGS;
ops.load_feat = &etm4_cfg_load_feature;
+ if (ete_trcextout)
+ match_flags |= CS_CFG_MATCH_CAP_ETE_TRCEXTOUT;
- return cscfg_register_csdev(csdev, CS_CFG_ETM4_MATCH_FLAGS, &ops);
+ return cscfg_register_csdev(csdev, match_flags, &ops);
}
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-cfg.h b/drivers/hwtracing/coresight/coresight-etm4x-cfg.h
index 32dab34c1dace0..d87bcc83e12491 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-cfg.h
+++ b/drivers/hwtracing/coresight/coresight-etm4x-cfg.h
@@ -25,6 +25,6 @@
#define ETM4_CFG_RES_MASK 0x00F
/* ETMv4 specific config functions */
-int etm4_cscfg_register(struct coresight_device *csdev);
+int etm4_cscfg_register(struct coresight_device *csdev, bool ete_trcextout);
#endif /* CORESIGHT_ETM4X_CFG_H */
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
index af017bd8a54773..ecf2a6c945cf05 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
@@ -30,6 +30,7 @@
#include <linux/uaccess.h>
#include <linux/perf_event.h>
#include <linux/perf/arm_pmu.h>
+#include <linux/perf/arm_pmuv3.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
@@ -78,6 +79,7 @@ static enum cpuhp_state hp_online;
struct etm4_init_arg {
struct device *dev;
struct csdev_access *csa;
+ bool ete_trcextout;
};
static DEFINE_PER_CPU(struct etm4_init_arg *, delayed_probe);
@@ -1399,6 +1401,29 @@ static void etm4_fixup_wrong_ccitmin(struct etmv4_caps *caps)
}
}
+/*
+ * Whether the PMU counts each external output of this trace unit as
+ * TRCEXTOUTn. The trace unit has an external output for each of its events.
+ * Only ETE is checked: per its specification, an implemented TRCEXTOUTn event
+ * counts external output n.
+ *
+ * Must run on the CPU that owns the trace unit.
+ */
+static bool etm4_pmu_counts_extout(struct etmv4_drvdata *drvdata)
+{
+ int n;
+
+ if (!etm4x_is_ete(drvdata) || !drvdata->caps.nr_event)
+ return false;
+
+ for (n = 0; n < drvdata->caps.nr_event; n++) {
+ if (!pmuv3_event_implemented(ARMV8_PMUV3_PERFCTR_TRCEXTOUT0 + n))
+ return false;
+ }
+
+ return true;
+}
+
static void etm4_init_arch_data(void *info)
{
u32 etmidr0;
@@ -1562,6 +1587,8 @@ static void etm4_init_arch_data(void *info)
/* NUMCNTR, bits[30:28] number of counters available for tracing */
caps->nr_cntr = FIELD_GET(TRCIDR5_NUMCNTR_MASK, etmidr5);
+ init_arg->ete_trcextout = etm4_pmu_counts_extout(drvdata);
+
coresight_clear_self_claim_tag_unlocked(csa);
etm4_cs_lock(drvdata, csa);
cpu_detect_trace_filtering(drvdata);
@@ -2265,7 +2292,7 @@ static int etm4_add_coresight_dev(struct etm4_init_arg *init_arg)
}
/* register with config infrastructure & load any current features */
- ret = etm4_cscfg_register(drvdata->csdev);
+ ret = etm4_cscfg_register(drvdata->csdev, init_arg->ete_trcextout);
if (ret) {
coresight_unregister(drvdata->csdev);
return ret;
diff --git a/drivers/hwtracing/coresight/coresight-syscfg-configfs.c b/drivers/hwtracing/coresight/coresight-syscfg-configfs.c
index 2b40e556be872f..6577a5085a634d 100644
--- a/drivers/hwtracing/coresight/coresight-syscfg-configfs.c
+++ b/drivers/hwtracing/coresight/coresight-syscfg-configfs.c
@@ -250,6 +250,9 @@ static ssize_t cscfg_feat_matches_show(struct config_item *item, char *page)
if (match_flags & CS_CFG_MATCH_CLASS_SRC_ETM4)
used += scnprintf(page + used, PAGE_SIZE - used, "SRC_ETMV4 ");
+ if (match_flags & CS_CFG_MATCH_CAP_ETE_TRCEXTOUT)
+ used += scnprintf(page + used, PAGE_SIZE - used, "ETE_TRCEXTOUT ");
+
used += scnprintf(page + used, PAGE_SIZE - used, "\n");
return used;
}
--
2.52.1
next prev parent reply other threads:[~2026-11-20 15:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 15:21 [PATCH v5 0/7] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-11-20 15:21 ` [PATCH v5 1/7] coresight: etm4x: Fix event count decoding Amir Ayupov
2026-11-20 15:21 ` [PATCH v5 2/7] coresight: syscfg: Fail to enable a configuration not loaded on the device Amir Ayupov
2026-11-20 15:21 ` [PATCH v5 3/7] coresight: syscfg: Match feature capabilities separately from device class Amir Ayupov
2026-11-20 15:21 ` [PATCH v5 4/7] coresight: syscfg: Remove unused CS_CFG_MATCH_INST_ANY Amir Ayupov
2026-11-20 15:21 ` [PATCH v5 5/7] perf: arm_pmuv3: Add pmuv3_event_implemented() Amir Ayupov
2026-11-20 15:21 ` Amir Ayupov [this message]
2026-11-20 15:21 ` [PATCH v5 7/7] coresight: Add pmu_pulse/extout_pulse Amir Ayupov
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=d9c953867b9ff40c20c8ddd52771bada2fa8a4b9.1795182850.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®