Skip to content

Commit ee811bc

Browse files
Leo-YanSuzuki K Poulose
authored andcommitted
coresight: etm4x: Fix timestamp bit field handling
Timestamps in the trace data appear as all zeros on recent kernels, although the feature works correctly on old kernels (e.g., v6.12). Since commit c382ee6 ("arm64/sysreg/tools: Move TRFCR definitions to sysreg"), the TRFCR_ELx_TS_{VIRTUAL|GUEST_PHYSICAL|PHYSICAL} macros were updated to remove the bit shift. As a result, the driver no longer shifts bits when operates the timestamp field. Fix this by using the FIELD_PREP() and FIELD_GET() helpers. Reported-by: Tamas Zsoldos <[email protected]> Fixes: c382ee6 ("arm64/sysreg/tools: Move TRFCR definitions to sysreg") Signed-off-by: Leo Yan <[email protected]> Reviewed-by: James Clark <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d23bc38 commit ee811bc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ static void cpu_detect_trace_filtering(struct etmv4_drvdata *drvdata)
12371237
* tracing at the kernel EL and EL0, forcing to use the
12381238
* virtual time as the timestamp.
12391239
*/
1240-
trfcr = (TRFCR_EL1_TS_VIRTUAL |
1240+
trfcr = (FIELD_PREP(TRFCR_EL1_TS_MASK, TRFCR_EL1_TS_VIRTUAL) |
12411241
TRFCR_EL1_ExTRE |
12421242
TRFCR_EL1_E0TRE);
12431243

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,11 +2320,11 @@ static ssize_t ts_source_show(struct device *dev,
23202320
goto out;
23212321
}
23222322

2323-
switch (drvdata->trfcr & TRFCR_EL1_TS_MASK) {
2323+
val = FIELD_GET(TRFCR_EL1_TS_MASK, drvdata->trfcr);
2324+
switch (val) {
23242325
case TRFCR_EL1_TS_VIRTUAL:
23252326
case TRFCR_EL1_TS_GUEST_PHYSICAL:
23262327
case TRFCR_EL1_TS_PHYSICAL:
2327-
val = FIELD_GET(TRFCR_EL1_TS_MASK, drvdata->trfcr);
23282328
break;
23292329
default:
23302330
val = -1;

0 commit comments

Comments
 (0)