Skip to content

Commit 9f37d37

Browse files
mikel-armbbSuzuki K Poulose
authored andcommitted
coresight: etm4x: Fix missing trctraceidr file in sysfs
The trace ID patchset adjusted the handling of the TRCTRACEIDR register sysfs to allocate on read. Although this was initally correct, the final version of the patch series introduced an error which resulted in the mgmt/trctraceidr file in sysfs not being visible. This patch fixes that issue. Fixes: df48712 ("coresight: etm4x: Update ETM4 driver to use Trace ID API") Reported-by: Junhao He <hejunhao3@huawei.com> Link: https://lists.linaro.org/archives/list/coresight@lists.linaro.org/thread/KK3CVVMRHJWVUORKMFJRSXYCEDFKENQJ/ Signed-off-by: Mike Leach <mike.leach@linaro.org> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20230512133054.235073-1-mike.leach@linaro.org
1 parent 1b5b164 commit 9f37d37

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

drivers/hwtracing/coresight/coresight-etm4x-sysfs.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,6 @@ static ssize_t trctraceid_show(struct device *dev,
24112411

24122412
return sysfs_emit(buf, "0x%x\n", trace_id);
24132413
}
2414-
static DEVICE_ATTR_RO(trctraceid);
24152414

24162415
struct etmv4_reg {
24172416
struct coresight_device *csdev;
@@ -2528,13 +2527,23 @@ coresight_etm4x_attr_reg_implemented(struct kobject *kobj,
25282527
return 0;
25292528
}
25302529

2531-
#define coresight_etm4x_reg(name, offset) \
2532-
&((struct dev_ext_attribute[]) { \
2533-
{ \
2534-
__ATTR(name, 0444, coresight_etm4x_reg_show, NULL), \
2535-
(void *)(unsigned long)offset \
2536-
} \
2537-
})[0].attr.attr
2530+
/*
2531+
* Macro to set an RO ext attribute with offset and show function.
2532+
* Offset is used in mgmt group to ensure only correct registers for
2533+
* the ETM / ETE variant are visible.
2534+
*/
2535+
#define coresight_etm4x_reg_showfn(name, offset, showfn) ( \
2536+
&((struct dev_ext_attribute[]) { \
2537+
{ \
2538+
__ATTR(name, 0444, showfn, NULL), \
2539+
(void *)(unsigned long)offset \
2540+
} \
2541+
})[0].attr.attr \
2542+
)
2543+
2544+
/* macro using the default coresight_etm4x_reg_show function */
2545+
#define coresight_etm4x_reg(name, offset) \
2546+
coresight_etm4x_reg_showfn(name, offset, coresight_etm4x_reg_show)
25382547

25392548
static struct attribute *coresight_etmv4_mgmt_attrs[] = {
25402549
coresight_etm4x_reg(trcpdcr, TRCPDCR),
@@ -2549,7 +2558,7 @@ static struct attribute *coresight_etmv4_mgmt_attrs[] = {
25492558
coresight_etm4x_reg(trcpidr3, TRCPIDR3),
25502559
coresight_etm4x_reg(trcoslsr, TRCOSLSR),
25512560
coresight_etm4x_reg(trcconfig, TRCCONFIGR),
2552-
&dev_attr_trctraceid.attr,
2561+
coresight_etm4x_reg_showfn(trctraceid, TRCTRACEIDR, trctraceid_show),
25532562
coresight_etm4x_reg(trcdevarch, TRCDEVARCH),
25542563
NULL,
25552564
};

0 commit comments

Comments
 (0)