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 3/4] coresight: perf: Filter sources lacking the selected configuration
Date: Fri, 20 Nov 2026 10:54:33 -0800 [thread overview]
Message-ID: <7ba910406fc81e09d31e9c6f3909012b9b85bf22.1795196854.git.aaupov@fb.com> (raw)
In-Reply-To: <cover.1795196854.git.aaupov@fb.com>
A system configuration may deliberately omit some CoreSight devices.
Keep generic configuration enablement as a successful no-op for
nonparticipants, but exclude ETM sources without the selected
configuration before allocating an AUX session.
Add a setup-only query while the configuration is globally activated,
checking device registration and per-device availability under the
manager mutex. Use the existing path-building failure handling to remove
unsupported CPUs and fail setup if no usable source remains.
Suggested-by: Mike Leach <mike.leach@arm.com>
Assisted-by: Devmate:GPT-6.1-Sol
Signed-off-by: Amir Ayupov <aaupov@fb.com>
---
.../hwtracing/coresight/coresight-etm-perf.c | 4 +++
.../hwtracing/coresight/coresight-syscfg.c | 32 +++++++++++++++++++
.../hwtracing/coresight/coresight-syscfg.h | 2 ++
3 files changed, 38 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 09b21a711a8764..2d64c3314c0bad 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -350,6 +350,7 @@ etm_event_build_path(struct perf_event *event, int cpu,
{
struct coresight_path *path = NULL;
struct coresight_device *source, *sink;
+ u32 cfg_hash = ATTR_CFG_GET_FLD(&event->attr, configid);
int ret;
source = coresight_get_percpu_source_ref(cpu);
@@ -361,6 +362,9 @@ etm_event_build_path(struct perf_event *event, int cpu,
if (!source)
return NULL;
+ if (cfg_hash && !cscfg_csdev_can_activate_config(source, cfg_hash))
+ goto out;
+
/*
* If AUX pause feature is enabled but the ETM driver does not
* support the operations, skip for this source.
diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c
index 11946e5718fc5e..f4e122f66e98c8 100644
--- a/drivers/hwtracing/coresight/coresight-syscfg.c
+++ b/drivers/hwtracing/coresight/coresight-syscfg.c
@@ -1050,6 +1050,38 @@ void cscfg_deactivate_config(unsigned long cfg_hash)
}
EXPORT_SYMBOL_GPL(cscfg_deactivate_config);
+/**
+ * cscfg_csdev_can_activate_config - Check whether a configuration is loaded on a device.
+ * @csdev: CoreSight device to check.
+ * @cfg_hash: Selector for the configuration.
+ *
+ * Does not activate or program the configuration. May sleep. The caller must
+ * keep the configuration activated while using the result to prevent unloading.
+ */
+bool cscfg_csdev_can_activate_config(struct coresight_device *csdev,
+ unsigned long cfg_hash)
+{
+ struct cscfg_registered_csdev *csdev_item;
+ struct cscfg_config_csdev *config_csdev;
+
+ guard(mutex)(&cscfg_mutex);
+ if (!cscfg_mgr)
+ return false;
+
+ /* Unregistered devices do not have initialized configuration lists. */
+ list_for_each_entry(csdev_item, &cscfg_mgr->csdev_desc_list, item) {
+ if (csdev_item->csdev != csdev)
+ continue;
+ list_for_each_entry(config_csdev, &csdev->config_csdev_list, node) {
+ if ((unsigned long)config_csdev->config_desc->event_ea->var == cfg_hash)
+ return config_csdev->config_desc->available;
+ }
+ break;
+ }
+ return false;
+}
+EXPORT_SYMBOL_GPL(cscfg_csdev_can_activate_config);
+
/**
* cscfg_csdev_enable_active_config - Enable matching active configuration for device.
*
diff --git a/drivers/hwtracing/coresight/coresight-syscfg.h b/drivers/hwtracing/coresight/coresight-syscfg.h
index 658e93c3705f1c..05289060a277e5 100644
--- a/drivers/hwtracing/coresight/coresight-syscfg.h
+++ b/drivers/hwtracing/coresight/coresight-syscfg.h
@@ -120,6 +120,8 @@ int cscfg_register_csdev(struct coresight_device *csdev, u32 match_flags,
void cscfg_unregister_csdev(struct coresight_device *csdev);
int cscfg_activate_config(unsigned long cfg_hash);
void cscfg_deactivate_config(unsigned long cfg_hash);
+bool cscfg_csdev_can_activate_config(struct coresight_device *csdev,
+ unsigned long cfg_hash);
void cscfg_csdev_reset_feats(struct coresight_device *csdev);
int cscfg_csdev_enable_active_config(struct coresight_device *csdev,
unsigned long cfg_hash, int preset);
--
2.52.1
next 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 ` Amir Ayupov [this message]
2026-11-20 18:54 ` [PATCH v6 4/4] 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=7ba910406fc81e09d31e9c6f3909012b9b85bf22.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®