From: James Clark <james.clark@linaro.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@arm.com>, Leo Yan <leo.yan@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
James Clark <james.clark@linaro.org>
Subject: [PATCH] coresight: trbe: Hide enable_sink sysfs file
Date: Thu, 07 May 2026 11:53:45 +0100 [thread overview]
Message-ID: <20260507-james-cs-hide-trbe-enable-v1-1-b4e40439f44c@linaro.org> (raw)
TRBE doesn't support sysfs mode, but the enable_sink file can still be
successfully written to enable the device, and only attempting to enable
the source would later fail.
Avoid misleading users by adding a flag that devices can use to hide
either the enable_sink or enable_source files, and set it for TRBE.
Don't set it for ETE as it's possible that ETE could appear on the
legacy bus and work with sysfs, and writing to enable_source already
reports EINVAL if the device doesn't support sysfs mode.
Signed-off-by: James Clark <james.clark@linaro.org>
---
drivers/hwtracing/coresight/coresight-core.c | 1 +
drivers/hwtracing/coresight/coresight-sysfs.c | 19 +++++++++++++------
drivers/hwtracing/coresight/coresight-trbe.c | 7 +++++++
include/linux/coresight.h | 10 ++++++++--
4 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index 46f247f73cf6..5244ff579ef6 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1341,6 +1341,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
csdev->ops = desc->ops;
csdev->access = desc->access;
csdev->orphan = true;
+ csdev->no_sysfs_mode = desc->flags & CORESIGHT_DESC_NO_SYSFS_MODE;
csdev->dev.type = &coresight_dev_type[desc->type];
csdev->dev.groups = desc->groups;
diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtracing/coresight/coresight-sysfs.c
index d2a6ed8bcc74..5729f16df2c4 100644
--- a/drivers/hwtracing/coresight/coresight-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-sysfs.c
@@ -387,16 +387,23 @@ static ssize_t label_show(struct device *dev,
}
static DEVICE_ATTR_RO(label);
-static umode_t label_is_visible(struct kobject *kobj,
- struct attribute *attr, int n)
+static umode_t coresight_attr_is_visible(struct kobject *kobj,
+ struct attribute *attr, int n)
{
struct device *dev = kobj_to_dev(kobj);
+ struct coresight_device *csdev = to_coresight_device(dev);
if (attr == &dev_attr_label.attr) {
if (fwnode_property_present(dev_fwnode(dev), "label"))
return attr->mode;
else
return 0;
+ } else if (attr == &dev_attr_enable_sink.attr ||
+ attr == &dev_attr_enable_source.attr) {
+ if (csdev->no_sysfs_mode)
+ return 0;
+ else
+ return attr->mode;
}
return attr->mode;
@@ -410,7 +417,7 @@ static struct attribute *coresight_sink_attrs[] = {
static struct attribute_group coresight_sink_group = {
.attrs = coresight_sink_attrs,
- .is_visible = label_is_visible,
+ .is_visible = coresight_attr_is_visible,
};
__ATTRIBUTE_GROUPS(coresight_sink);
@@ -422,7 +429,7 @@ static struct attribute *coresight_source_attrs[] = {
static struct attribute_group coresight_source_group = {
.attrs = coresight_source_attrs,
- .is_visible = label_is_visible,
+ .is_visible = coresight_attr_is_visible,
};
__ATTRIBUTE_GROUPS(coresight_source);
@@ -433,7 +440,7 @@ static struct attribute *coresight_link_attrs[] = {
static struct attribute_group coresight_link_group = {
.attrs = coresight_link_attrs,
- .is_visible = label_is_visible,
+ .is_visible = coresight_attr_is_visible,
};
__ATTRIBUTE_GROUPS(coresight_link);
@@ -444,7 +451,7 @@ static struct attribute *coresight_helper_attrs[] = {
static struct attribute_group coresight_helper_group = {
.attrs = coresight_helper_attrs,
- .is_visible = label_is_visible,
+ .is_visible = coresight_attr_is_visible,
};
__ATTRIBUTE_GROUPS(coresight_helper);
diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
index 1511f8eb95af..75c1fa6ab620 100644
--- a/drivers/hwtracing/coresight/coresight-trbe.c
+++ b/drivers/hwtracing/coresight/coresight-trbe.c
@@ -1289,6 +1289,13 @@ static void arm_trbe_register_coresight_cpu(struct trbe_drvdata *drvdata, int cp
desc.ops = &arm_trbe_cs_ops;
desc.groups = arm_trbe_groups;
desc.dev = dev;
+ /*
+ * ETE isn't connected to TRBE with a link like other Coresight devices
+ * and the TRBE driver has been written to always assume Perf mode, so
+ * Prevent sysfs from being used.
+ */
+ desc.flags = CORESIGHT_DESC_NO_SYSFS_MODE;
+
trbe_csdev = coresight_register(&desc);
if (IS_ERR(trbe_csdev))
goto cpu_clear;
diff --git a/include/linux/coresight.h b/include/linux/coresight.h
index 2131febebee9..ccd99a480477 100644
--- a/include/linux/coresight.h
+++ b/include/linux/coresight.h
@@ -141,6 +141,8 @@ struct csdev_access {
.base = (_addr), \
})
+#define CORESIGHT_DESC_NO_SYSFS_MODE BIT(0)
+
/**
* struct coresight_desc - description of a component required from drivers
* @type: as defined by @coresight_dev_type.
@@ -163,6 +165,7 @@ struct coresight_desc {
const struct attribute_group **groups;
const char *name;
struct csdev_access access;
+ u32 flags;
};
/**
@@ -260,7 +263,6 @@ struct coresight_trace_id_map {
* device's spinlock when the coresight_mutex held and mode ==
* CS_MODE_SYSFS. Otherwise it must be accessed from inside the
* spinlock.
- * @orphan: true if the component has connections that haven't been linked.
* @sysfs_sink_activated: 'true' when a sink has been selected for use via sysfs
* by writing a 1 to the 'enable_sink' file. A sink can be
* activated but not yet enabled. Enabling for a _sink_ happens
@@ -276,6 +278,8 @@ struct coresight_trace_id_map {
* @config_csdev_list: List of system configurations added to the device.
* @cscfg_csdev_lock: Protect the lists of configurations and features.
* @active_cscfg_ctxt: Context information for current active system configuration.
+ * @orphan: true if the component has connections that haven't been linked.
+ * @no_sysfs_mode: Device can't be activated from sysfs, only via Perf.
*/
struct coresight_device {
struct coresight_platform_data *pdata;
@@ -286,7 +290,6 @@ struct coresight_device {
struct device dev;
atomic_t mode;
int refcnt;
- bool orphan;
/* sink specific fields */
bool sysfs_sink_activated;
struct dev_ext_attribute *ea;
@@ -300,6 +303,9 @@ struct coresight_device {
struct list_head config_csdev_list;
raw_spinlock_t cscfg_csdev_lock;
void *active_cscfg_ctxt;
+ /* flags */
+ bool orphan : 1;
+ bool no_sysfs_mode : 1;
};
/*
---
base-commit: 551bb2fd5e4ed63d33aa11f07102cce5179b7595
change-id: 20260506-james-cs-hide-trbe-enable-3c8d784e72d8
Best regards,
--
James Clark <james.clark@linaro.org>
reply other threads:[~2026-05-07 10:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260507-james-cs-hide-trbe-enable-v1-1-b4e40439f44c@linaro.org \
--to=james.clark@linaro.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.leach@arm.com \
--cc=suzuki.poulose@arm.com \
/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