mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v9 0/2] coresight: Add label sysfs node support
@ 2025-07-17 12:53 Mao Jinlong
  2025-07-17 12:53 ` [PATCH v9 1/2] dt-bindings: arm: Add label in the coresight components Mao Jinlong
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Mao Jinlong @ 2025-07-17 12:53 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Mathieu Poirier,
	Bjorn Andersson, Konrad Dybcio
  Cc: Mao Jinlong, coresight, linux-arm-kernel, devicetree,
	linux-kernel, linux-arm-msm

Change since V8:
1. Add label in all documentations of coresight components.
2. Add control of the visibility of the label sysfs attribute.
V8 link: https://lkml.org/lkml/2025/7/3/985

Change since V7:
1. Update the conflict when apply to coresight next.
2. Update the Date and version in ABI file.
V7 link: https://patchwork.kernel.org/project/linux-arm-kernel/patch/20250226121926.2687497-3-quic_jinlmao@quicinc.com/

Change since V6:
1. Update the date and verison in ABI file.

Change since V5:
1. Update the kernel version of ABI files.
2. Add link of different patch versions.
V5 link: https://patchwork.kernel.org/project/linux-arm-msm/cover/20241210122253.31926-1-quic_jinlmao@quicinc.com/

Change since V4:
1. Add label in DT and add label sysfs node for each coresight device.
V4 link: https://patchwork.kernel.org/project/linux-arm-msm/cover/20240703122340.26864-1-quic_jinlmao@quicinc.com/

Change since V3:
1. Change device-name to arm,cs-dev-name.
2. Add arm,cs-dev-name to only CTI and sources' dt-binding.
V3 link: https://patchwork.kernel.org/project/linux-arm-msm/cover/20240131082628.6288-1-quic_jinlmao@quicinc.com/

Change since V2:
1. Fix the error in coresight core.
drivers/hwtracing/coresight/coresight-core.c:1775:7: error: assigning to 'char *' from 'const char *' discards qualifiers

2. Fix the warning when run dtbinding check.
Documentation/devicetree/bindings/arm/arm,coresight-cpu-debug.yaml: device-name: missing type definition
V2 link: https://patchwork.kernel.org/project/linux-arm-msm/cover/20240115164252.26510-1-quic_jinlmao@quicinc.com/

Change since V1:
1. Change coresight-name to device name.
2. Add the device-name in coresight dt bindings.
V1 link: https://patchwork.kernel.org/project/linux-arm-kernel/patch/20230208110716.18321-1-quic_jinlmao@quicinc.com/#25231737

Mao Jinlong (2):
  dt-bindings: arm: Add label in the coresight components
  coresight: Add label sysfs node support

 .../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 ++
 .../bindings/arm/arm,coresight-cti.yaml       |  4 ++
 .../arm/arm,coresight-dummy-sink.yaml         |  4 ++
 .../arm/arm,coresight-dummy-source.yaml       |  4 ++
 .../arm/arm,coresight-dynamic-funnel.yaml     |  4 ++
 .../arm/arm,coresight-dynamic-replicator.yaml |  4 ++
 .../bindings/arm/arm,coresight-etb10.yaml     |  4 ++
 .../bindings/arm/arm,coresight-etm.yaml       |  4 ++
 .../arm/arm,coresight-static-funnel.yaml      |  4 ++
 .../arm/arm,coresight-static-replicator.yaml  |  4 ++
 .../bindings/arm/arm,coresight-tmc.yaml       |  4 ++
 .../bindings/arm/arm,coresight-tpiu.yaml      |  4 ++
 .../bindings/arm/qcom,coresight-ctcu.yaml     |  4 ++
 .../arm/qcom,coresight-remote-etm.yaml        |  4 ++
 .../bindings/arm/qcom,coresight-tpda.yaml     |  4 ++
 .../bindings/arm/qcom,coresight-tpdm.yaml     |  4 ++
 drivers/hwtracing/coresight/coresight-sysfs.c | 71 ++++++++++++++++++-
 26 files changed, 189 insertions(+), 2 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v9 1/2] dt-bindings: arm: Add label in the coresight components
  2025-07-17 12:53 [PATCH v9 0/2] coresight: Add label sysfs node support Mao Jinlong
@ 2025-07-17 12:53 ` Mao Jinlong
  2025-07-17 12:53 ` [PATCH v9 2/2] coresight: Add label sysfs node support Mao Jinlong
  2025-08-05  2:55 ` [PATCH v9 0/2] " Jinlong Mao
  2 siblings, 0 replies; 6+ messages in thread
From: Mao Jinlong @ 2025-07-17 12:53 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Mathieu Poirier,
	Bjorn Andersson, Konrad Dybcio
  Cc: Mao Jinlong, coresight, linux-arm-kernel, devicetree,
	linux-kernel, linux-arm-msm, Krzysztof Kozlowski

Current name of coresight component's folder consists of prefix of
the device and the id in the device list. When run 'ls' command,
we can get the register address of the device. Take CTI for example,
if we want to set the config for modem CTI, but we can't know which
CTI is modem CTI from all current information.

cti_sys0 -> ../../../devices/platform/soc@0/138f0000.cti/cti_sys0
cti_sys1 -> ../../../devices/platform/soc@0/13900000.cti/cti_sys1

Add label to show hardware context information of each coresight
device. There will be a sysfs node label in each device folder.

cat /sys/bus/coresight/devices/cti_sys0/label

Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Mike Leach <mike.leach@linaro.org>
---
 Documentation/devicetree/bindings/arm/arm,coresight-cti.yaml  | 4 ++++
 .../devicetree/bindings/arm/arm,coresight-dummy-sink.yaml     | 4 ++++
 .../devicetree/bindings/arm/arm,coresight-dummy-source.yaml   | 4 ++++
 .../devicetree/bindings/arm/arm,coresight-dynamic-funnel.yaml | 4 ++++
 .../bindings/arm/arm,coresight-dynamic-replicator.yaml        | 4 ++++
 .../devicetree/bindings/arm/arm,coresight-etb10.yaml          | 4 ++++
 Documentation/devicetree/bindings/arm/arm,coresight-etm.yaml  | 4 ++++
 .../devicetree/bindings/arm/arm,coresight-static-funnel.yaml  | 4 ++++
 .../bindings/arm/arm,coresight-static-replicator.yaml         | 4 ++++
 Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml  | 4 ++++
 Documentation/devicetree/bindings/arm/arm,coresight-tpiu.yaml | 4 ++++
 .../devicetree/bindings/arm/qcom,coresight-ctcu.yaml          | 4 ++++
 .../devicetree/bindings/arm/qcom,coresight-remote-etm.yaml    | 4 ++++
 .../devicetree/bindings/arm/qcom,coresight-tpda.yaml          | 4 ++++
 .../devicetree/bindings/arm/qcom,coresight-tpdm.yaml          | 4 ++++
 15 files changed, 60 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/arm,coresight-cti.yaml b/Documentation/devicetree/bindings/arm/arm,coresight-cti.yaml
index 2d5545a2b49c..2a91670ccb8c 100644
--- a/Documentation/devicetree/bindings/arm/arm,coresight-cti.yaml
+++ b/Documentation/devicetree/bindings/arm/arm,coresight-cti.yaml
@@ -98,6 +98,10 @@ properties:
   power-domains:
     maxItems: 1
 
+  label:
+    description:
+      Description of a coresight device.
+
   arm,cti-ctm-id:
     $ref: /schemas/types.yaml#/definitions/uint32
     description:
diff --git a/Documentation/devicetree/bindings/arm/arm,coresight-dummy-sink.yaml b/Documentation/devicetree/bindings/arm/arm,coresight-dummy-sink.yaml
index 08b89b62c505..ed091dc0c10a 100644
--- a/Documentation/devicetree/bindings/arm/arm,coresight-dummy-sink.yaml
+++ b/Documentation/devicetree/bindings/arm/arm,coresight-dummy-sink.yaml
@@ -39,6 +39,10 @@ properties:
     enum:
       - arm,coresight-dummy-sink
 
+  label:
+    description:
+      Description of a coresight device.
+
   in-ports:
     $ref: /schemas/graph.yaml#/properties/ports
 
diff --git a/Documentation/devicetree/bindings/arm/arm,coresight-dummy-source.yaml b/Documentation/devicetree/bindings/arm/arm,coresight-dummy-source.yaml
index 742dc4e25d3b..78337be42b55 100644
--- a/Documentation/devicetree/bindings/arm/arm,coresight-dummy-source.yaml
+++ b/Documentation/devicetree/bindings/arm/arm,coresight-dummy-source.yaml
@@ -38,6 +38,10 @@ properties:
     enum:
       - arm,coresight-dummy-source
 
+  label:
+    description:
+      Description of a coresight device.
+
   arm,static-trace-id:
     description: If dummy source needs static id support, use this to set trace id.
     $ref: /schemas/types.yaml#/definitions/uint32
diff --git a/Documentation/devicetree/bindings/arm/arm,coresight-dynamic-funnel.yaml b/Documentation/devicetree/bindings/arm/arm,coresight-dynamic-funnel.yaml
index 44a1041cb0fc..b74db15e5f8a 100644
--- a/Documentation/devicetree/bindings/arm/arm,coresight-dynamic-funnel.yaml
+++ b/Documentation/devicetree/bindings/arm/arm,coresight-dynamic-funnel.yaml
@@ -57,6 +57,10 @@ properties:
   power-domains:
     maxItems: 1
 
+  label:
+    description:
+      Description of a coresight device.
+
   in-ports:
     $ref: /schemas/graph.yaml#/properties/ports
 
diff --git a/Documentation/devicetree/bindings/arm/arm,coresight-dynamic-replicator.yaml b/Documentation/devicetree/bindings/arm/arm,coresight-dynamic-replicator.yaml
index 03792e9bd97a..17ea936b796f 100644
--- a/Documentation/devicetree/bindings/arm/arm,coresight-dynamic-replicator.yaml
+++ b/Documentation/devicetree/bindings/arm/arm,coresight-dynamic-replicator.yaml
@@ -54,6 +54,10 @@ properties:
       - const: apb_pclk
       - const: atclk
 
+  label:
+    description:
+      Description of a coresight device.
+
   power-domains:
     maxItems: 1
 
diff --git a/Documentation/devicetree/bindings/arm/arm,coresight-etb10.yaml b/Documentation/devicetree/bindings/arm/arm,coresight-etb10.yaml
index 90679788e0bf..892df7aca1ac 100644
--- a/Documentation/devicetree/bindings/arm/arm,coresight-etb10.yaml
+++ b/Documentation/devicetree/bindings/arm/arm,coresight-etb10.yaml
@@ -54,6 +54,10 @@ properties:
       - const: apb_pclk
       - const: atclk
 
+  label:
+    description:
+      Description of a coresight device.
+
   power-domains:
     maxItems: 1
 
diff --git a/Documentation/devicetree/bindings/arm/arm,coresight-etm.yaml b/Documentation/devicetree/bindings/arm/arm,coresight-etm.yaml
index 01200f67504a..71f2e1ed27e5 100644
--- a/Documentation/devicetree/bindings/arm/arm,coresight-etm.yaml
+++ b/Documentation/devicetree/bindings/arm/arm,coresight-etm.yaml
@@ -85,6 +85,10 @@ properties:
       CPU powers down the coresight component also powers down and loses its
       context.
 
+  label:
+    description:
+      Description of a coresight device.
+
   arm,cp14:
     type: boolean
     description:
diff --git a/Documentation/devicetree/bindings/arm/arm,coresight-static-funnel.yaml b/Documentation/devicetree/bindings/arm/arm,coresight-static-funnel.yaml
index cc8c3baa79b4..9598a3d0a95b 100644
--- a/Documentation/devicetree/bindings/arm/arm,coresight-static-funnel.yaml
+++ b/Documentation/devicetree/bindings/arm/arm,coresight-static-funnel.yaml
@@ -30,6 +30,10 @@ properties:
   power-domains:
     maxItems: 1
 
+  label:
+    description:
+      Description of a coresight device.
+
   in-ports:
     $ref: /schemas/graph.yaml#/properties/ports
 
diff --git a/Documentation/devicetree/bindings/arm/arm,coresight-static-replicator.yaml b/Documentation/devicetree/bindings/arm/arm,coresight-static-replicator.yaml
index 0c1017affbad..b81851b26c74 100644
--- a/Documentation/devicetree/bindings/arm/arm,coresight-static-replicator.yaml
+++ b/Documentation/devicetree/bindings/arm/arm,coresight-static-replicator.yaml
@@ -43,6 +43,10 @@ properties:
           - const: dbg_trc
           - const: dbg_apb
 
+  label:
+    description:
+      Description of a coresight device.
+
   in-ports:
     $ref: /schemas/graph.yaml#/properties/ports
     additionalProperties: false
diff --git a/Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml b/Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml
index 4787d7c6bac2..96dd5b5f771a 100644
--- a/Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml
+++ b/Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml
@@ -55,6 +55,10 @@ properties:
       - const: apb_pclk
       - const: atclk
 
+  label:
+    description:
+      Description of a coresight device.
+
   iommus:
     maxItems: 1
 
diff --git a/Documentation/devicetree/bindings/arm/arm,coresight-tpiu.yaml b/Documentation/devicetree/bindings/arm/arm,coresight-tpiu.yaml
index 61a0cdc27745..a207f6899e67 100644
--- a/Documentation/devicetree/bindings/arm/arm,coresight-tpiu.yaml
+++ b/Documentation/devicetree/bindings/arm/arm,coresight-tpiu.yaml
@@ -54,6 +54,10 @@ properties:
       - const: apb_pclk
       - const: atclk
 
+  label:
+    description:
+      Description of a coresight device.
+
   power-domains:
     maxItems: 1
 
diff --git a/Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml b/Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml
index 843b52eaf872..c969c16c21ef 100644
--- a/Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml
+++ b/Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml
@@ -39,6 +39,10 @@ properties:
     items:
       - const: apb
 
+  label:
+    description:
+      Description of a coresight device.
+
   in-ports:
     $ref: /schemas/graph.yaml#/properties/ports
 
diff --git a/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml b/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml
index 4fd5752978cd..ffe613efeabe 100644
--- a/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml
+++ b/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml
@@ -20,6 +20,10 @@ properties:
   compatible:
     const: qcom,coresight-remote-etm
 
+  label:
+    description:
+      Description of a coresight device.
+
   out-ports:
     $ref: /schemas/graph.yaml#/properties/ports
     additionalProperties: false
diff --git a/Documentation/devicetree/bindings/arm/qcom,coresight-tpda.yaml b/Documentation/devicetree/bindings/arm/qcom,coresight-tpda.yaml
index 5ed40f21b8eb..a48c9ac3eaa9 100644
--- a/Documentation/devicetree/bindings/arm/qcom,coresight-tpda.yaml
+++ b/Documentation/devicetree/bindings/arm/qcom,coresight-tpda.yaml
@@ -64,6 +64,10 @@ properties:
     items:
       - const: apb_pclk
 
+  label:
+    description:
+      Description of a coresight device.
+
   in-ports:
     description: |
       Input connections from TPDM to TPDA
diff --git a/Documentation/devicetree/bindings/arm/qcom,coresight-tpdm.yaml b/Documentation/devicetree/bindings/arm/qcom,coresight-tpdm.yaml
index 07d21a3617f5..4edc47483851 100644
--- a/Documentation/devicetree/bindings/arm/qcom,coresight-tpdm.yaml
+++ b/Documentation/devicetree/bindings/arm/qcom,coresight-tpdm.yaml
@@ -76,6 +76,10 @@ properties:
     minimum: 0
     maximum: 32
 
+  label:
+    description:
+      Description of a coresight device.
+
   clocks:
     maxItems: 1
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v9 2/2] coresight: Add label sysfs node support
  2025-07-17 12:53 [PATCH v9 0/2] coresight: Add label sysfs node support Mao Jinlong
  2025-07-17 12:53 ` [PATCH v9 1/2] dt-bindings: arm: Add label in the coresight components Mao Jinlong
@ 2025-07-17 12:53 ` Mao Jinlong
  2025-08-05 11:43   ` Mike Leach
  2025-08-05  2:55 ` [PATCH v9 0/2] " Jinlong Mao
  2 siblings, 1 reply; 6+ messages in thread
From: Mao Jinlong @ 2025-07-17 12:53 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Mathieu Poirier,
	Bjorn Andersson, Konrad Dybcio
  Cc: Mao Jinlong, coresight, linux-arm-kernel, devicetree,
	linux-kernel, linux-arm-msm

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@quicinc.com>
Reviewed-by: Mike Leach <mike.leach@linaro.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@quicinc.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@quicinc.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@quicinc.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@quicinc.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@linaro.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@quicinc.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@linaro.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@quicinc.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@linaro.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@quicinc.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@linaro.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@quicinc.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@arm.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@quicinc.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@quicinc.com>, Tao Zhang (QUIC) <quic_taozha@quicinc.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@quicinc.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@arm.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@quicinc.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);
+	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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v9 0/2] coresight: Add label sysfs node support
  2025-07-17 12:53 [PATCH v9 0/2] coresight: Add label sysfs node support Mao Jinlong
  2025-07-17 12:53 ` [PATCH v9 1/2] dt-bindings: arm: Add label in the coresight components Mao Jinlong
  2025-07-17 12:53 ` [PATCH v9 2/2] coresight: Add label sysfs node support Mao Jinlong
@ 2025-08-05  2:55 ` Jinlong Mao
  2 siblings, 0 replies; 6+ messages in thread
From: Jinlong Mao @ 2025-08-05  2:55 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Mathieu Poirier,
	Bjorn Andersson, Konrad Dybcio
  Cc: coresight, linux-arm-kernel, devicetree, linux-kernel, linux-arm-msm


On 7/17/2025 8:53 PM, Mao Jinlong wrote:
> Change since V8:
> 1. Add label in all documentations of coresight components.
> 2. Add control of the visibility of the label sysfs attribute.
> V8 link: https://lkml.org/lkml/2025/7/3/985

Gentle reminder for the review of V9.

> 
> Change since V7:
> 1. Update the conflict when apply to coresight next.
> 2. Update the Date and version in ABI file.
> V7 link: https://patchwork.kernel.org/project/linux-arm-kernel/patch/20250226121926.2687497-3-quic_jinlmao@quicinc.com/
> 
> Change since V6:
> 1. Update the date and verison in ABI file.
> 
> Change since V5:
> 1. Update the kernel version of ABI files.
> 2. Add link of different patch versions.
> V5 link: https://patchwork.kernel.org/project/linux-arm-msm/cover/20241210122253.31926-1-quic_jinlmao@quicinc.com/
> 
> Change since V4:
> 1. Add label in DT and add label sysfs node for each coresight device.
> V4 link: https://patchwork.kernel.org/project/linux-arm-msm/cover/20240703122340.26864-1-quic_jinlmao@quicinc.com/
> 
> Change since V3:
> 1. Change device-name to arm,cs-dev-name.
> 2. Add arm,cs-dev-name to only CTI and sources' dt-binding.
> V3 link: https://patchwork.kernel.org/project/linux-arm-msm/cover/20240131082628.6288-1-quic_jinlmao@quicinc.com/
> 
> Change since V2:
> 1. Fix the error in coresight core.
> drivers/hwtracing/coresight/coresight-core.c:1775:7: error: assigning to 'char *' from 'const char *' discards qualifiers
> 
> 2. Fix the warning when run dtbinding check.
> Documentation/devicetree/bindings/arm/arm,coresight-cpu-debug.yaml: device-name: missing type definition
> V2 link: https://patchwork.kernel.org/project/linux-arm-msm/cover/20240115164252.26510-1-quic_jinlmao@quicinc.com/
> 
> Change since V1:
> 1. Change coresight-name to device name.
> 2. Add the device-name in coresight dt bindings.
> V1 link: https://patchwork.kernel.org/project/linux-arm-kernel/patch/20230208110716.18321-1-quic_jinlmao@quicinc.com/#25231737
> 
> Mao Jinlong (2):
>    dt-bindings: arm: Add label in the coresight components
>    coresight: Add label sysfs node support
> 
>   .../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 ++
>   .../bindings/arm/arm,coresight-cti.yaml       |  4 ++
>   .../arm/arm,coresight-dummy-sink.yaml         |  4 ++
>   .../arm/arm,coresight-dummy-source.yaml       |  4 ++
>   .../arm/arm,coresight-dynamic-funnel.yaml     |  4 ++
>   .../arm/arm,coresight-dynamic-replicator.yaml |  4 ++
>   .../bindings/arm/arm,coresight-etb10.yaml     |  4 ++
>   .../bindings/arm/arm,coresight-etm.yaml       |  4 ++
>   .../arm/arm,coresight-static-funnel.yaml      |  4 ++
>   .../arm/arm,coresight-static-replicator.yaml  |  4 ++
>   .../bindings/arm/arm,coresight-tmc.yaml       |  4 ++
>   .../bindings/arm/arm,coresight-tpiu.yaml      |  4 ++
>   .../bindings/arm/qcom,coresight-ctcu.yaml     |  4 ++
>   .../arm/qcom,coresight-remote-etm.yaml        |  4 ++
>   .../bindings/arm/qcom,coresight-tpda.yaml     |  4 ++
>   .../bindings/arm/qcom,coresight-tpdm.yaml     |  4 ++
>   drivers/hwtracing/coresight/coresight-sysfs.c | 71 ++++++++++++++++++-
>   26 files changed, 189 insertions(+), 2 deletions(-)
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v9 2/2] coresight: Add label sysfs node support
  2025-07-17 12:53 ` [PATCH v9 2/2] coresight: Add label sysfs node support Mao Jinlong
@ 2025-08-05 11:43   ` Mike Leach
  2025-08-06  7:12     ` Jinlong Mao
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Leach @ 2025-08-05 11:43 UTC (permalink / raw)
  To: Mao Jinlong
  Cc: Suzuki K Poulose, James Clark, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Mathieu Poirier, Bjorn Andersson, Konrad Dybcio,
	coresight, linux-arm-kernel, devicetree, linux-kernel,
	linux-arm-msm

Hi

On Thu, 17 Jul 2025 at 13:54, Mao Jinlong <quic_jinlmao@quicinc.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@quicinc.com>
> Reviewed-by: Mike Leach <mike.leach@linaro.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@quicinc.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@quicinc.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@quicinc.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@quicinc.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@linaro.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@quicinc.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@linaro.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@quicinc.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@linaro.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@quicinc.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@linaro.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@quicinc.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@arm.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@quicinc.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@quicinc.com>, Tao Zhang (QUIC) <quic_taozha@quicinc.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@quicinc.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@arm.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@quicinc.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.

> +       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@linaro.org>
-- 
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v9 2/2] coresight: Add label sysfs node support
  2025-08-05 11:43   ` Mike Leach
@ 2025-08-06  7:12     ` Jinlong Mao
  0 siblings, 0 replies; 6+ messages in thread
From: Jinlong Mao @ 2025-08-06  7:12 UTC (permalink / raw)
  To: Mike Leach
  Cc: Suzuki K Poulose, James Clark, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Mathieu Poirier, Bjorn Andersson, Konrad Dybcio,
	coresight, linux-arm-kernel, devicetree, linux-kernel,
	linux-arm-msm



On 8/5/2025 7:43 PM, Mike Leach wrote:
> Hi
> 
> On Thu, 17 Jul 2025 at 13:54, Mao Jinlong <quic_jinlmao@quicinc.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@quicinc.com>
>> Reviewed-by: Mike Leach <mike.leach@linaro.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@quicinc.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@quicinc.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@quicinc.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@quicinc.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@linaro.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@quicinc.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@linaro.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@quicinc.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@linaro.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@quicinc.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@linaro.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@quicinc.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@arm.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@quicinc.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@quicinc.com>, Tao Zhang (QUIC) <quic_taozha@quicinc.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@quicinc.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@arm.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@quicinc.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@linaro.org>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-06  7:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-17 12:53 [PATCH v9 0/2] coresight: Add label sysfs node support Mao Jinlong
2025-07-17 12:53 ` [PATCH v9 1/2] dt-bindings: arm: Add label in the coresight components Mao Jinlong
2025-07-17 12:53 ` [PATCH v9 2/2] coresight: Add label sysfs node support Mao Jinlong
2025-08-05 11:43   ` Mike Leach
2025-08-06  7:12     ` Jinlong Mao
2025-08-05  2:55 ` [PATCH v9 0/2] " Jinlong Mao

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®