]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
coresight: tpdm: add traceid_show for checking traceid
authorJie Gan <jie.gan@oss.qualcomm.com>
Tue, 31 Mar 2026 10:05:22 +0000 (18:05 +0800)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Tue, 31 Mar 2026 10:53:50 +0000 (11:53 +0100)
Save the trace ID in drvdata during TPDM enablement and expose it
to userspace to support trace data parsing.

The TPDM device’s trace ID corresponds to the trace ID allocated
to the connected TPDA device.

Signed-off-by: Jie Gan <jie.gan@oss.qualcomm.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260331-add-traceid-show-for-tpdm-v4-1-ed3dda24a562@oss.qualcomm.com
Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm
drivers/hwtracing/coresight/coresight-tpdm.c
drivers/hwtracing/coresight/coresight-tpdm.h

index f8016df64532e4377ade5c6abeae11ef8eaa173d..bc36ba32c90087ca35dccca36801e28315960272 100644 (file)
@@ -278,3 +278,13 @@ Date:           Aug 2025
 KernelVersion   6.18
 Contact:        Mao Jinlong <quic_jinlmao@quicinc.com>
 Description:    (Read) Show hardware context information of device.
+
+What:          /sys/bus/coresight/devices/<tpdm-name>/traceid
+Date:          March 2026
+KernelVersion: 7.1
+Contact:       Jie Gan <jie.gan@oss.qualcomm.com>
+Description:
+               (R) Show the trace ID that will appear in the trace stream
+               coming from this TPDM. The trace ID is inherited from the
+               connected TPDA device and is fixed for the lifetime of the
+               device. Returns -EINVAL if the device has not been enabled yet.
index da77bdaad0a4519bd4e0653cc92e2a333e59e60d..9b16f368a58bcc094fa8a113e5b65d68c0495047 100644 (file)
@@ -481,7 +481,7 @@ static void __tpdm_enable(struct tpdm_drvdata *drvdata)
 
 static int tpdm_enable(struct coresight_device *csdev, struct perf_event *event,
                       enum cs_mode mode,
-                      __maybe_unused struct coresight_path *path)
+                      struct coresight_path *path)
 {
        struct tpdm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
 
@@ -497,6 +497,7 @@ static int tpdm_enable(struct coresight_device *csdev, struct perf_event *event,
        }
 
        __tpdm_enable(drvdata);
+       drvdata->traceid = path->trace_id;
        drvdata->enable = true;
        spin_unlock(&drvdata->spinlock);
 
@@ -693,6 +694,29 @@ static struct attribute_group tpdm_attr_grp = {
        .attrs = tpdm_attrs,
 };
 
+static ssize_t traceid_show(struct device *dev,
+                           struct device_attribute *attr, char *buf)
+{
+       unsigned long val;
+       struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
+
+       val = drvdata->traceid;
+       if (!val)
+               return -EINVAL;
+
+       return sysfs_emit(buf, "%#lx\n", val);
+}
+static DEVICE_ATTR_RO(traceid);
+
+static struct attribute *traceid_attrs[] = {
+       &dev_attr_traceid.attr,
+       NULL,
+};
+
+static struct attribute_group traceid_attr_grp = {
+       .attrs = traceid_attrs,
+};
+
 static ssize_t dsb_mode_show(struct device *dev,
                             struct device_attribute *attr,
                             char *buf)
@@ -1367,6 +1391,12 @@ static const struct attribute_group *tpdm_attr_grps[] = {
        &tpdm_cmb_patt_grp,
        &tpdm_cmb_msr_grp,
        &tpdm_mcmb_attr_grp,
+       &traceid_attr_grp,
+       NULL,
+};
+
+static const struct attribute_group *static_tpdm_attr_grps[] = {
+       &traceid_attr_grp,
        NULL,
 };
 
@@ -1425,6 +1455,8 @@ static int tpdm_probe(struct device *dev, struct resource *res)
        desc.access = CSDEV_ACCESS_IOMEM(base);
        if (res)
                desc.groups = tpdm_attr_grps;
+       else
+               desc.groups = static_tpdm_attr_grps;
        drvdata->csdev = coresight_register(&desc);
        if (IS_ERR(drvdata->csdev))
                return PTR_ERR(drvdata->csdev);
index 2867f3ab818618fb6cf7f4eb6baa72b4f85edaf5..11da64e1ade8cd9459d74c07757397d1861f20ba 100644 (file)
@@ -300,6 +300,7 @@ struct cmb_dataset {
  * @cmb         Specifics associated to TPDM CMB.
  * @dsb_msr_num Number of MSR supported by DSB TPDM
  * @cmb_msr_num Number of MSR supported by CMB TPDM
+ * @traceid    Trace ID of the path.
  */
 
 struct tpdm_drvdata {
@@ -313,6 +314,7 @@ struct tpdm_drvdata {
        struct cmb_dataset      *cmb;
        u32                     dsb_msr_num;
        u32                     cmb_msr_num;
+       u8                      traceid;
 };
 
 /* Enumerate members of various datasets */