[PATCH v5 04/13] coresight: Hide unused ETMv3 format attributes

James Clark posted 13 patches 1 week, 6 days ago
There is a newer version of this series
[PATCH v5 04/13] coresight: Hide unused ETMv3 format attributes
Posted by James Clark 1 week, 6 days ago
ETMv3 only has a few attributes, and setting unused ones results in an
error, so hide them to begin with.

Signed-off-by: James Clark <james.clark@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm-perf.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 17afa0f4cdee..faebd7822a77 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -106,8 +106,30 @@ static struct attribute *etm_config_formats_attr[] = {
 	NULL,
 };
 
+static umode_t etm_format_attr_is_visible(struct kobject *kobj,
+					  struct attribute *attr, int unused)
+{
+	/* ETM4 has all attributes */
+	if (IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X))
+		return attr->mode;
+
+	/*
+	 * ETM3 only uses these attributes for programming itself (see
+	 * ETM3X_SUPPORTED_OPTIONS). Sink ID is also supported for selecting a
+	 * sink, but not used for configuring the ETM.
+	 */
+	if (attr == &format_attr_cycacc.attr ||
+	    attr == &format_attr_timestamp.attr ||
+	    attr == &format_attr_retstack.attr ||
+	    attr == &format_attr_sinkid.attr)
+		return attr->mode;
+
+	return 0;
+}
+
 static const struct attribute_group etm_pmu_format_group = {
 	.name   = "format",
+	.is_visible = etm_format_attr_is_visible,
 	.attrs  = etm_config_formats_attr,
 };
 

-- 
2.34.1
Re: [PATCH v5 04/13] coresight: Hide unused ETMv3 format attributes
Posted by Mike Leach 1 week, 4 days ago
On Tue, 18 Nov 2025 at 16:28, James Clark <james.clark@linaro.org> wrote:
>
> ETMv3 only has a few attributes, and setting unused ones results in an
> error, so hide them to begin with.
>
> Signed-off-by: James Clark <james.clark@linaro.org>
> ---
>  drivers/hwtracing/coresight/coresight-etm-perf.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
> index 17afa0f4cdee..faebd7822a77 100644
> --- a/drivers/hwtracing/coresight/coresight-etm-perf.c
> +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
> @@ -106,8 +106,30 @@ static struct attribute *etm_config_formats_attr[] = {
>         NULL,
>  };
>
> +static umode_t etm_format_attr_is_visible(struct kobject *kobj,
> +                                         struct attribute *attr, int unused)
> +{
> +       /* ETM4 has all attributes */
> +       if (IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X))
> +               return attr->mode;
> +
> +       /*
> +        * ETM3 only uses these attributes for programming itself (see
> +        * ETM3X_SUPPORTED_OPTIONS). Sink ID is also supported for selecting a
> +        * sink, but not used for configuring the ETM.
> +        */
> +       if (attr == &format_attr_cycacc.attr ||
> +           attr == &format_attr_timestamp.attr ||
> +           attr == &format_attr_retstack.attr ||
> +           attr == &format_attr_sinkid.attr)
> +               return attr->mode;
> +
> +       return 0;
> +}
> +
>  static const struct attribute_group etm_pmu_format_group = {
>         .name   = "format",
> +       .is_visible = etm_format_attr_is_visible,
>         .attrs  = etm_config_formats_attr,
>  };
>
>
> --
> 2.34.1
>
Reviewed-by: Mike Leach <mike.leach@linaro.org>


--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK