* [PATCH] coresight: trbe: Hide enable_sink sysfs file
@ 2026-05-07 10:53 James Clark
2026-05-13 8:15 ` Leo Yan
0 siblings, 1 reply; 4+ messages in thread
From: James Clark @ 2026-05-07 10:53 UTC (permalink / raw)
To: Suzuki K Poulose, Mike Leach, Leo Yan, Alexander Shishkin
Cc: coresight, linux-arm-kernel, linux-kernel, James Clark
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>
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] coresight: trbe: Hide enable_sink sysfs file
2026-05-07 10:53 [PATCH] coresight: trbe: Hide enable_sink sysfs file James Clark
@ 2026-05-13 8:15 ` Leo Yan
2026-05-13 9:33 ` James Clark
0 siblings, 1 reply; 4+ messages in thread
From: Leo Yan @ 2026-05-13 8:15 UTC (permalink / raw)
To: James Clark
Cc: Suzuki K Poulose, Mike Leach, Alexander Shishkin, coresight,
linux-arm-kernel, linux-kernel
On Thu, May 07, 2026 at 11:53:45AM +0100, James Clark wrote:
[...]
> +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;
I'd prefer no_sysfs_mode to work as a general flag rather than being
limited to sink/source devices only. Otherwise, LGTM.
Thanks,
Leo
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] coresight: trbe: Hide enable_sink sysfs file
2026-05-13 8:15 ` Leo Yan
@ 2026-05-13 9:33 ` James Clark
2026-05-13 9:54 ` Leo Yan
0 siblings, 1 reply; 4+ messages in thread
From: James Clark @ 2026-05-13 9:33 UTC (permalink / raw)
To: Leo Yan
Cc: Suzuki K Poulose, Mike Leach, Alexander Shishkin, coresight,
linux-arm-kernel, linux-kernel
On 13/05/2026 9:15 am, Leo Yan wrote:
> On Thu, May 07, 2026 at 11:53:45AM +0100, James Clark wrote:
>
> [...]
>
>> +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;
>
> I'd prefer no_sysfs_mode to work as a general flag rather than being
> limited to sink/source devices only. Otherwise, LGTM.
>
> Thanks,
> Leo
Which other files would you hide though? These are the only two that I
could think of.
I wouldn't hide all sysfs files for 'no_sysfs_mode' as there are read
only things that aren't strictly related to sysfs mode.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] coresight: trbe: Hide enable_sink sysfs file
2026-05-13 9:33 ` James Clark
@ 2026-05-13 9:54 ` Leo Yan
0 siblings, 0 replies; 4+ messages in thread
From: Leo Yan @ 2026-05-13 9:54 UTC (permalink / raw)
To: James Clark
Cc: Suzuki K Poulose, Mike Leach, Alexander Shishkin, coresight,
linux-arm-kernel, linux-kernel
On Wed, May 13, 2026 at 10:33:40AM +0100, James Clark wrote:
[...]
> > > +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;
> >
> > I'd prefer no_sysfs_mode to work as a general flag rather than being
> > limited to sink/source devices only. Otherwise, LGTM.
>
> Which other files would you hide though? These are the only two that I could
> think of.
>
> I wouldn't hide all sysfs files for 'no_sysfs_mode' as there are read only
> things that aren't strictly related to sysfs mode.
In coresight-sysfs.c, there are two kinds of attributes: the label and
the sink/source enable knobs.
The label is already handled separately. So we can hide the rest
attributes when no_sysfs_mode is set?
Thanks,
Leo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-13 9:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 10:53 [PATCH] coresight: trbe: Hide enable_sink sysfs file James Clark
2026-05-13 8:15 ` Leo Yan
2026-05-13 9:33 ` James Clark
2026-05-13 9:54 ` Leo Yan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox