Commit 0f00b223 authored by German Gomez's avatar German Gomez Committed by Mathieu Poirier

coresight: etm4x: Expose default timestamp source in sysfs

Add a new sysfs interface in /sys/bus/coresight/devices/etm<N>/ts_source
indicating the configured timestamp source when the ETM device driver
was probed.

The perf tool will use this information to detect if the trace data
timestamp matches the kernel time, enabling correlation of CoreSight
trace with perf events.
Suggested-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: default avatarGerman Gomez <german.gomez@arm.com>
Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
Signed-off-by: default avatarJames Clark <james.clark@arm.com>
Link: https://lore.kernel.org/r/20220823160650.455823-2-james.clark@arm.comSigned-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
parent 84fa8f15
...@@ -1021,6 +1021,7 @@ ...@@ -1021,6 +1021,7 @@
#define SYS_MPIDR_SAFE_VAL (BIT(31)) #define SYS_MPIDR_SAFE_VAL (BIT(31))
#define TRFCR_ELx_TS_SHIFT 5 #define TRFCR_ELx_TS_SHIFT 5
#define TRFCR_ELx_TS_MASK ((0x3UL) << TRFCR_ELx_TS_SHIFT)
#define TRFCR_ELx_TS_VIRTUAL ((0x1UL) << TRFCR_ELx_TS_SHIFT) #define TRFCR_ELx_TS_VIRTUAL ((0x1UL) << TRFCR_ELx_TS_SHIFT)
#define TRFCR_ELx_TS_GUEST_PHYSICAL ((0x2UL) << TRFCR_ELx_TS_SHIFT) #define TRFCR_ELx_TS_GUEST_PHYSICAL ((0x2UL) << TRFCR_ELx_TS_SHIFT)
#define TRFCR_ELx_TS_PHYSICAL ((0x3UL) << TRFCR_ELx_TS_SHIFT) #define TRFCR_ELx_TS_PHYSICAL ((0x3UL) << TRFCR_ELx_TS_SHIFT)
......
...@@ -2306,6 +2306,34 @@ static ssize_t cpu_show(struct device *dev, ...@@ -2306,6 +2306,34 @@ static ssize_t cpu_show(struct device *dev,
} }
static DEVICE_ATTR_RO(cpu); static DEVICE_ATTR_RO(cpu);
static ssize_t ts_source_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
int val;
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
if (!drvdata->trfcr) {
val = -1;
goto out;
}
switch (drvdata->trfcr & TRFCR_ELx_TS_MASK) {
case TRFCR_ELx_TS_VIRTUAL:
case TRFCR_ELx_TS_GUEST_PHYSICAL:
case TRFCR_ELx_TS_PHYSICAL:
val = FIELD_GET(TRFCR_ELx_TS_MASK, drvdata->trfcr);
break;
default:
val = -1;
break;
}
out:
return sysfs_emit(buf, "%d\n", val);
}
static DEVICE_ATTR_RO(ts_source);
static struct attribute *coresight_etmv4_attrs[] = { static struct attribute *coresight_etmv4_attrs[] = {
&dev_attr_nr_pe_cmp.attr, &dev_attr_nr_pe_cmp.attr,
&dev_attr_nr_addr_cmp.attr, &dev_attr_nr_addr_cmp.attr,
...@@ -2360,6 +2388,7 @@ static struct attribute *coresight_etmv4_attrs[] = { ...@@ -2360,6 +2388,7 @@ static struct attribute *coresight_etmv4_attrs[] = {
&dev_attr_vmid_val.attr, &dev_attr_vmid_val.attr,
&dev_attr_vmid_masks.attr, &dev_attr_vmid_masks.attr,
&dev_attr_cpu.attr, &dev_attr_cpu.attr,
&dev_attr_ts_source.attr,
NULL, NULL,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment