[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <14aa800f-9585-41ee-bd51-81457045d893@quicinc.com>
Date: Wed, 6 Aug 2025 15:12:56 +0800
From: Jinlong Mao <quic_jinlmao@...cinc.com>
To: Mike Leach <mike.leach@...aro.org>
CC: Suzuki K Poulose <suzuki.poulose@....com>,
James Clark
<james.clark@....com>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski
<krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Mathieu Poirier
<mathieu.poirier@...aro.org>,
Bjorn Andersson <andersson@...nel.org>,
Konrad
Dybcio <konradybcio@...nel.org>, <coresight@...ts.linaro.org>,
<linux-arm-kernel@...ts.infradead.org>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-arm-msm@...r.kernel.org>
Subject: Re: [PATCH v9 2/2] coresight: Add label sysfs node support
On 8/5/2025 7:43 PM, Mike Leach wrote:
> Hi
>
> On Thu, 17 Jul 2025 at 13:54, Mao Jinlong <quic_jinlmao@...cinc.com> wrote:
>>
>> For some coresight components like CTI and TPDM, there could be
>> numerous of them. From the node name, we can only get the type and
>> register address of the component. We can't identify the HW or the
>> system the component belongs to. Add label sysfs node support for
>> showing the intuitive name of the device.
>>
>> Signed-off-by: Mao Jinlong <quic_jinlmao@...cinc.com>
>> Reviewed-by: Mike Leach <mike.leach@...aro.org>
>> ---
>> .../testing/sysfs-bus-coresight-devices-cti | 6 ++
>> .../sysfs-bus-coresight-devices-dummy-source | 6 ++
>> .../testing/sysfs-bus-coresight-devices-etb10 | 6 ++
>> .../testing/sysfs-bus-coresight-devices-etm3x | 6 ++
>> .../testing/sysfs-bus-coresight-devices-etm4x | 6 ++
>> .../sysfs-bus-coresight-devices-funnel | 6 ++
>> .../testing/sysfs-bus-coresight-devices-stm | 6 ++
>> .../testing/sysfs-bus-coresight-devices-tmc | 6 ++
>> .../testing/sysfs-bus-coresight-devices-tpdm | 6 ++
>> .../testing/sysfs-bus-coresight-devices-trbe | 6 ++
>> drivers/hwtracing/coresight/coresight-sysfs.c | 71 ++++++++++++++++++-
>> 11 files changed, 129 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-cti b/Documentation/ABI/testing/sysfs-bus-coresight-devices-cti
>> index a97b70f588da..55367bbc696f 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-cti
>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-cti
>> @@ -239,3 +239,9 @@ Date: March 2020
>> KernelVersion: 5.7
>> Contact: Mike Leach or Mathieu Poirier
>> Description: (Write) Clear all channel / trigger programming.
>> +
>> +What: /sys/bus/coresight/devices/<cti-name>/label
>> +Date: Jul 2025
>> +KernelVersion 6.17
>> +Contact: Mao Jinlong <quic_jinlmao@...cinc.com>
>> +Description: (Read) Show hardware context information of device.
>> diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-dummy-source b/Documentation/ABI/testing/sysfs-bus-coresight-devices-dummy-source
>> index 0830661ef656..9a11bd5b15cc 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-dummy-source
>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-dummy-source
>> @@ -13,3 +13,9 @@ KernelVersion: 6.14
>> Contact: Mao Jinlong <quic_jinlmao@...cinc.com>
>> Description: (R) Show the trace ID that will appear in the trace stream
>> coming from this trace entity.
>> +
>> +What: /sys/bus/coresight/devices/dummy_source<N>/label
>> +Date: Jul 2025
>> +KernelVersion 6.17
>> +Contact: Mao Jinlong <quic_jinlmao@...cinc.com>
>> +Description: (Read) Show hardware context information of device.
>> diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-etb10 b/Documentation/ABI/testing/sysfs-bus-coresight-devices-etb10
>> index 9a383f6a74eb..ff1f89795188 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-etb10
>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-etb10
>> @@ -19,6 +19,12 @@ Description: (RW) Disables write access to the Trace RAM by stopping the
>> into the Trace RAM following the trigger event is equal to the
>> value stored in this register+1 (from ARM ETB-TRM).
>>
>> +What: /sys/bus/coresight/devices/<memory_map>.etb/label
>> +Date: Jul 2025
>> +KernelVersion 6.17
>> +Contact: Mao Jinlong <quic_jinlmao@...cinc.com>
>> +Description: (Read) Show hardware context information of device.
>> +
>> What: /sys/bus/coresight/devices/<memory_map>.etb/mgmt/rdp
>> Date: March 2016
>> KernelVersion: 4.7
>> diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm3x b/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm3x
>> index 271b57c571aa..743f26619c69 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm3x
>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm3x
>> @@ -251,6 +251,12 @@ KernelVersion: 4.4
>> Contact: Mathieu Poirier <mathieu.poirier@...aro.org>
>> Description: (RO) Holds the cpu number this tracer is affined to.
>>
>> +What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/label
>> +Date: Jul 2025
>> +KernelVersion 6.17
>> +Contact: Mao Jinlong <quic_jinlmao@...cinc.com>
>> +Description: (Read) Show hardware context information of device.
>> +
>> What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/mgmt/etmccr
>> Date: September 2015
>> KernelVersion: 4.4
>> diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm4x b/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm4x
>> index a0425d70d009..e6a584a4b040 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm4x
>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm4x
>> @@ -329,6 +329,12 @@ Contact: Mathieu Poirier <mathieu.poirier@...aro.org>
>> Description: (RW) Access the selected single show PE comparator control
>> register.
>>
>> +What: /sys/bus/coresight/devices/etm<N>/label
>> +Date: Jul 2025
>> +KernelVersion 6.17
>> +Contact: Mao Jinlong <quic_jinlmao@...cinc.com>
>> +Description: (Read) Show hardware context information of device.
>> +
>> What: /sys/bus/coresight/devices/etm<N>/mgmt/trcoslsr
>> Date: April 2015
>> KernelVersion: 4.01
>> diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-funnel b/Documentation/ABI/testing/sysfs-bus-coresight-devices-funnel
>> index d75acda5e1b3..5578fa5f6f02 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-funnel
>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-funnel
>> @@ -10,3 +10,9 @@ Date: November 2014
>> KernelVersion: 3.19
>> Contact: Mathieu Poirier <mathieu.poirier@...aro.org>
>> Description: (RW) Defines input port priority order.
>> +
>> +What: /sys/bus/coresight/devices/<memory_map>.funnel/label
>> +Date: Jul 2025
>> +KernelVersion 6.17
>> +Contact: Mao Jinlong <quic_jinlmao@...cinc.com>
>> +Description: (Read) Show hardware context information of device.
>> diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-stm b/Documentation/ABI/testing/sysfs-bus-coresight-devices-stm
>> index 53e1f4815d64..c3a81978e30b 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-stm
>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-stm
>> @@ -51,3 +51,9 @@ KernelVersion: 4.7
>> Contact: Mathieu Poirier <mathieu.poirier@...aro.org>
>> Description: (RW) Holds the trace ID that will appear in the trace stream
>> coming from this trace entity.
>> +
>> +What: /sys/bus/coresight/devices/<memory_map>.stm/label
>> +Date: Jul 2025
>> +KernelVersion 6.17
>> +Contact: Mao Jinlong <quic_jinlmao@...cinc.com>
>> +Description: (Read) Show hardware context information of device.
>> diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tmc b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tmc
>> index 339cec3b2f1a..9554f4f453a3 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tmc
>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tmc
>> @@ -107,3 +107,9 @@ Contact: Anshuman Khandual <anshuman.khandual@....com>
>> Description: (RW) Current Coresight TMC-ETR buffer mode selected. But user could
>> only provide a mode which is supported for a given ETR device. This
>> file is available only for TMC ETR devices.
>> +
>> +What: /sys/bus/coresight/devices/<memory_map>.tmc/label
>> +Date: Jul 2025
>> +KernelVersion 6.17
>> +Contact: Mao Jinlong <quic_jinlmao@...cinc.com>
>> +Description: (Read) Show hardware context information of device.
>> diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm
>> index a341b08ae70b..e6d935e83042 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm
>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm
>> @@ -272,3 +272,9 @@ KernelVersion 6.15
>> Contact: Jinlong Mao (QUIC) <quic_jinlmao@...cinc.com>, Tao Zhang (QUIC) <quic_taozha@...cinc.com>
>> Description:
>> (RW) Set/Get the enablement of the individual lane.
>> +
>> +What: /sys/bus/coresight/devices/<tpdm-name>/label
>> +Date: Jul 2025
>> +KernelVersion 6.17
>> +Contact: Mao Jinlong <quic_jinlmao@...cinc.com>
>> +Description: (Read) Show hardware context information of device.
>> diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-trbe b/Documentation/ABI/testing/sysfs-bus-coresight-devices-trbe
>> index ad3bbc6fa751..2a5868ba3d6b 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-trbe
>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-trbe
>> @@ -12,3 +12,9 @@ Contact: Anshuman Khandual <anshuman.khandual@....com>
>> Description: (Read) Shows if TRBE updates in the memory are with access
>> and dirty flag updates as well. This value is fetched from
>> the TRBIDR register.
>> +
>> +What: /sys/bus/coresight/devices/trbe<cpu>/label
>> +Date: Jul 2025
>> +KernelVersion 6.17
>> +Contact: Mao Jinlong <quic_jinlmao@...cinc.com>
>> +Description: (Read) Show hardware context information of device.
>> diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtracing/coresight/coresight-sysfs.c
>> index feadaf065b53..f7a0c9056854 100644
>> --- a/drivers/hwtracing/coresight/coresight-sysfs.c
>> +++ b/drivers/hwtracing/coresight/coresight-sysfs.c
>> @@ -7,6 +7,7 @@
>> #include <linux/device.h>
>> #include <linux/idr.h>
>> #include <linux/kernel.h>
>> +#include <linux/property.h>
>>
>> #include "coresight-priv.h"
>> #include "coresight-trace-id.h"
>> @@ -371,17 +372,81 @@ static ssize_t enable_source_store(struct device *dev,
>> }
>> static DEVICE_ATTR_RW(enable_source);
>>
>> +static ssize_t label_show(struct device *dev,
>> + struct device_attribute *attr, char *buf)
>> +{
>> +
>> + const char *str;
>> + int ret;
>> +
>> + ret = fwnode_property_read_string(dev_fwnode(dev), "label", &str);
>> + if (ret == 0)
>> + return scnprintf(buf, PAGE_SIZE, "%s\n", str);
>
> sysfs_emit() here.
I will update it.
>
>> + else
>> + return ret;
>> +}
>> +static DEVICE_ATTR_RO(label);
>> +
>> +static umode_t label_is_visible(struct kobject *kobj,
>> + struct attribute *attr, int n)
>> +{
>> + struct device *dev = kobj_to_dev(kobj);
>> +
>> + if (attr == &dev_attr_label.attr) {
>> + if (fwnode_property_present(dev_fwnode(dev), "label"))
>> + return attr->mode;
>> + else
>> + return 0;
>> + }
>> +
>> + return attr->mode;
>> +}
>> +
>> static struct attribute *coresight_sink_attrs[] = {
>> &dev_attr_enable_sink.attr,
>> + &dev_attr_label.attr,
>> NULL,
>> };
>> -ATTRIBUTE_GROUPS(coresight_sink);
>> +
>> +static struct attribute_group coresight_sink_group = {
>> + .attrs = coresight_sink_attrs,
>> + .is_visible = label_is_visible,
>> +};
>> +__ATTRIBUTE_GROUPS(coresight_sink);
>>
>> static struct attribute *coresight_source_attrs[] = {
>> &dev_attr_enable_source.attr,
>> + &dev_attr_label.attr,
>> NULL,
>> };
>> -ATTRIBUTE_GROUPS(coresight_source);
>> +
>> +static struct attribute_group coresight_source_group = {
>> + .attrs = coresight_source_attrs,
>> + .is_visible = label_is_visible,
>> +};
>> +__ATTRIBUTE_GROUPS(coresight_source);
>> +
>> +static struct attribute *coresight_link_attrs[] = {
>> + &dev_attr_label.attr,
>> + NULL,
>> +};
>> +
>> +static struct attribute_group coresight_link_group = {
>> + .attrs = coresight_link_attrs,
>> + .is_visible = label_is_visible,
>> +};
>> +__ATTRIBUTE_GROUPS(coresight_link);
>> +
>> +static struct attribute *coresight_helper_attrs[] = {
>> + &dev_attr_label.attr,
>> + NULL,
>> +};
>> +
>> +static struct attribute_group coresight_helper_group = {
>> + .attrs = coresight_helper_attrs,
>> + .is_visible = label_is_visible,
>> +};
>> +__ATTRIBUTE_GROUPS(coresight_helper);
>>
>> const struct device_type coresight_dev_type[] = {
>> [CORESIGHT_DEV_TYPE_SINK] = {
>> @@ -390,6 +455,7 @@ const struct device_type coresight_dev_type[] = {
>> },
>> [CORESIGHT_DEV_TYPE_LINK] = {
>> .name = "link",
>> + .groups = coresight_link_groups,
>> },
>> [CORESIGHT_DEV_TYPE_LINKSINK] = {
>> .name = "linksink",
>> @@ -401,6 +467,7 @@ const struct device_type coresight_dev_type[] = {
>> },
>> [CORESIGHT_DEV_TYPE_HELPER] = {
>> .name = "helper",
>> + .groups = coresight_helper_groups,
>> }
>> };
>> /* Ensure the enum matches the names and groups */
>> --
>> 2.25.1
>>
>
> with the above change
>
> Reviewed-by: Mike Leach <mike.leach@...aro.org>
Powered by blists - more mailing lists