linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] coresight: etm4x: Expose default timestamp source in sysfs
@ 2022-08-23 16:06 James Clark
  2022-08-23 16:06 ` [PATCH v3 1/2] " James Clark
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: James Clark @ 2022-08-23 16:06 UTC (permalink / raw)
  To: suzuki.poulose, coresight, mathieu.poirier
  Cc: mike.leach, leo.yan, linux-kernel, german.gomez, James Clark,
	Jonathan Corbet, Catalin Marinas, Will Deacon,
	Alexander Shishkin, linux-arm-kernel, linux-doc

I've taken over this one from German because he's moved to a different
team. I gave it a quick check and bumped the version number in the docs
for the next release, but the month is an estimate.

Thanks

Changes since v2:

  * Rebased onto coresight/next (b99ee26a1a)
  * Bumped release version to 6.1

Changes since v1:

  * Inline etmv4_to_ts_source() function.
  * Collect review tag from Leo.

German Gomez (2):
  coresight: etm4x: Expose default timestamp source in sysfs
  coresight: etm4x: docs: Add documentation for 'ts_source' sysfs
    interface

 .../testing/sysfs-bus-coresight-devices-etm4x |  8 +++++
 .../coresight/coresight-etm4x-reference.rst   | 14 +++++++++
 arch/arm64/include/asm/sysreg.h               |  1 +
 .../coresight/coresight-etm4x-sysfs.c         | 29 +++++++++++++++++++
 4 files changed, 52 insertions(+)

-- 
2.28.0


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

* [PATCH v3 1/2] coresight: etm4x: Expose default timestamp source in sysfs
  2022-08-23 16:06 [PATCH v3 0/2] coresight: etm4x: Expose default timestamp source in sysfs James Clark
@ 2022-08-23 16:06 ` James Clark
  2022-08-23 16:06 ` [PATCH v3 2/2] coresight: etm4x: docs: Add documentation for 'ts_source' sysfs interface James Clark
  2022-08-26 19:55 ` [PATCH v3 0/2] coresight: etm4x: Expose default timestamp source in sysfs Mathieu Poirier
  2 siblings, 0 replies; 7+ messages in thread
From: James Clark @ 2022-08-23 16:06 UTC (permalink / raw)
  To: suzuki.poulose, coresight, mathieu.poirier
  Cc: mike.leach, leo.yan, linux-kernel, german.gomez, James Clark,
	Jonathan Corbet, Catalin Marinas, Will Deacon,
	Alexander Shishkin, linux-arm-kernel, linux-doc

From: German Gomez <german.gomez@arm.com>

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: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: German Gomez <german.gomez@arm.com>
Reviewed-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: James Clark <james.clark@arm.com>
---
 arch/arm64/include/asm/sysreg.h               |  1 +
 .../coresight/coresight-etm4x-sysfs.c         | 29 +++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
index 7c71358d44c4..7a518a011669 100644
--- a/arch/arm64/include/asm/sysreg.h
+++ b/arch/arm64/include/asm/sysreg.h
@@ -1021,6 +1021,7 @@
 #define SYS_MPIDR_SAFE_VAL	(BIT(31))
 
 #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_GUEST_PHYSICAL	((0x2UL) << TRFCR_ELx_TS_SHIFT)
 #define TRFCR_ELx_TS_PHYSICAL		((0x3UL) << TRFCR_ELx_TS_SHIFT)
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
index 6ea8181816fc..9cac848cffaf 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
@@ -2306,6 +2306,34 @@ static ssize_t cpu_show(struct device *dev,
 }
 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[] = {
 	&dev_attr_nr_pe_cmp.attr,
 	&dev_attr_nr_addr_cmp.attr,
@@ -2360,6 +2388,7 @@ static struct attribute *coresight_etmv4_attrs[] = {
 	&dev_attr_vmid_val.attr,
 	&dev_attr_vmid_masks.attr,
 	&dev_attr_cpu.attr,
+	&dev_attr_ts_source.attr,
 	NULL,
 };
 
-- 
2.28.0


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

* [PATCH v3 2/2] coresight: etm4x: docs: Add documentation for 'ts_source' sysfs interface
  2022-08-23 16:06 [PATCH v3 0/2] coresight: etm4x: Expose default timestamp source in sysfs James Clark
  2022-08-23 16:06 ` [PATCH v3 1/2] " James Clark
@ 2022-08-23 16:06 ` James Clark
  2022-08-24  2:54   ` Bagas Sanjaya
  2022-08-26 19:55 ` [PATCH v3 0/2] coresight: etm4x: Expose default timestamp source in sysfs Mathieu Poirier
  2 siblings, 1 reply; 7+ messages in thread
From: James Clark @ 2022-08-23 16:06 UTC (permalink / raw)
  To: suzuki.poulose, coresight, mathieu.poirier
  Cc: mike.leach, leo.yan, linux-kernel, german.gomez, James Clark,
	Jonathan Corbet, Catalin Marinas, Will Deacon,
	Alexander Shishkin, linux-arm-kernel, linux-doc

From: German Gomez <german.gomez@arm.com>

Sync sysfs documentation pages to include the new ts_source (timestamp
source) interface.

Signed-off-by: German Gomez <german.gomez@arm.com>
Signed-off-by: James Clark <james.clark@arm.com>
---
 .../ABI/testing/sysfs-bus-coresight-devices-etm4x  |  8 ++++++++
 .../trace/coresight/coresight-etm4x-reference.rst  | 14 ++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm4x b/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm4x
index 8e53a32f8150..08b1964f27d3 100644
--- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm4x
+++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-etm4x
@@ -516,3 +516,11 @@ Contact:	Mathieu Poirier <mathieu.poirier@linaro.org>
 Description:	(Read) Returns the number of special conditional P1 right-hand keys
 		that the trace unit can use (0x194).  The value is taken
 		directly from the HW.
+
+What:		/sys/bus/coresight/devices/etm<N>/ts_source
+Date:		October 2022
+KernelVersion:	6.1
+Contact:	Mathieu Poirier <mathieu.poirier@linaro.org> or Suzuki K Poulose <suzuki.poulose@arm.com>
+Description:	(Read) When FEAT_TRF is implemented, value of TRFCR_ELx.TS used for
+		trace session. Otherwise -1 indicates an unknown time source. Check
+		trcidr0.tssize to see if a global timestamp is available.
diff --git a/Documentation/trace/coresight/coresight-etm4x-reference.rst b/Documentation/trace/coresight/coresight-etm4x-reference.rst
index fb7578fd9372..70e34b8c81c1 100644
--- a/Documentation/trace/coresight/coresight-etm4x-reference.rst
+++ b/Documentation/trace/coresight/coresight-etm4x-reference.rst
@@ -71,6 +71,20 @@
 
 ----
 
+:File:            ``ts_source`` (ro)
+:Trace Registers: None.
+:Notes:
+    When FEAT_TRF is implemented, value of TRFCR_ELx.TS used for trace session. Otherwise -1
+    indicates an unknown time source. Check trcidr0.tssize to see if a global timestamp is
+    available.
+
+:Example:
+    ``$> cat ts_source``
+
+    ``$> 1``
+
+----
+
 :File:            ``addr_idx`` (rw)
 :Trace Registers: None.
 :Notes:
-- 
2.28.0


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

* Re: [PATCH v3 2/2] coresight: etm4x: docs: Add documentation for 'ts_source' sysfs interface
  2022-08-23 16:06 ` [PATCH v3 2/2] coresight: etm4x: docs: Add documentation for 'ts_source' sysfs interface James Clark
@ 2022-08-24  2:54   ` Bagas Sanjaya
  2022-08-24 13:59     ` James Clark
  0 siblings, 1 reply; 7+ messages in thread
From: Bagas Sanjaya @ 2022-08-24  2:54 UTC (permalink / raw)
  To: James Clark, suzuki.poulose, coresight, mathieu.poirier
  Cc: mike.leach, leo.yan, linux-kernel, german.gomez, Jonathan Corbet,
	Catalin Marinas, Will Deacon, Alexander Shishkin,
	linux-arm-kernel, linux-doc

On 8/23/22 23:06, James Clark wrote:
> +:Example:
> +    ``$> cat ts_source``
> +
> +    ``$> 1``
> +

Shouldn't literal code block be used instead for example snippet
above?

-- 
An old man doll... just what I always wanted! - Clara

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

* Re: [PATCH v3 2/2] coresight: etm4x: docs: Add documentation for 'ts_source' sysfs interface
  2022-08-24  2:54   ` Bagas Sanjaya
@ 2022-08-24 13:59     ` James Clark
  0 siblings, 0 replies; 7+ messages in thread
From: James Clark @ 2022-08-24 13:59 UTC (permalink / raw)
  To: Bagas Sanjaya
  Cc: mike.leach, leo.yan, linux-kernel, german.gomez, Jonathan Corbet,
	Catalin Marinas, Will Deacon, Alexander Shishkin,
	linux-arm-kernel, linux-doc, suzuki.poulose, coresight,
	mathieu.poirier



On 24/08/2022 03:54, Bagas Sanjaya wrote:
> On 8/23/22 23:06, James Clark wrote:
>> +:Example:
>> +    ``$> cat ts_source``
>> +
>> +    ``$> 1``
>> +
> 
> Shouldn't literal code block be used instead for example snippet
> above?
> 

It's consistent with the rest of the file. I think consistency for
something like this is more important than accuracy otherwise the new
entry would appear out of place.

Maybe they should all be changed to a different style, but that would be
a separate change unrelated to this set.

James

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

* Re: [PATCH v3 0/2] coresight: etm4x: Expose default timestamp source in sysfs
  2022-08-23 16:06 [PATCH v3 0/2] coresight: etm4x: Expose default timestamp source in sysfs James Clark
  2022-08-23 16:06 ` [PATCH v3 1/2] " James Clark
  2022-08-23 16:06 ` [PATCH v3 2/2] coresight: etm4x: docs: Add documentation for 'ts_source' sysfs interface James Clark
@ 2022-08-26 19:55 ` Mathieu Poirier
  2022-08-30 17:29   ` James Clark
  2 siblings, 1 reply; 7+ messages in thread
From: Mathieu Poirier @ 2022-08-26 19:55 UTC (permalink / raw)
  To: James Clark
  Cc: suzuki.poulose, coresight, mike.leach, leo.yan, linux-kernel,
	german.gomez, Jonathan Corbet, Catalin Marinas, Will Deacon,
	Alexander Shishkin, linux-arm-kernel, linux-doc

On Tue, Aug 23, 2022 at 05:06:48PM +0100, James Clark wrote:
> I've taken over this one from German because he's moved to a different
> team. I gave it a quick check and bumped the version number in the docs
> for the next release, but the month is an estimate.
> 
> Thanks
> 
> Changes since v2:
> 
>   * Rebased onto coresight/next (b99ee26a1a)
>   * Bumped release version to 6.1

I have applied this set.  Usually I'd let Suzuki handle it since he is already
familiar with the work but 1) he is currently away and 2) the patchset is fairly
simple.

Thanks,
Mathieu

> 
> Changes since v1:
> 
>   * Inline etmv4_to_ts_source() function.
>   * Collect review tag from Leo.
> 
> German Gomez (2):
>   coresight: etm4x: Expose default timestamp source in sysfs
>   coresight: etm4x: docs: Add documentation for 'ts_source' sysfs
>     interface
> 
>  .../testing/sysfs-bus-coresight-devices-etm4x |  8 +++++
>  .../coresight/coresight-etm4x-reference.rst   | 14 +++++++++
>  arch/arm64/include/asm/sysreg.h               |  1 +
>  .../coresight/coresight-etm4x-sysfs.c         | 29 +++++++++++++++++++
>  4 files changed, 52 insertions(+)
> 
> -- 
> 2.28.0
> 

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

* Re: [PATCH v3 0/2] coresight: etm4x: Expose default timestamp source in sysfs
  2022-08-26 19:55 ` [PATCH v3 0/2] coresight: etm4x: Expose default timestamp source in sysfs Mathieu Poirier
@ 2022-08-30 17:29   ` James Clark
  0 siblings, 0 replies; 7+ messages in thread
From: James Clark @ 2022-08-30 17:29 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: suzuki.poulose, coresight, mike.leach, leo.yan, linux-kernel,
	german.gomez, Jonathan Corbet, Catalin Marinas, Will Deacon,
	Alexander Shishkin, linux-arm-kernel, linux-doc



On 26/08/2022 20:55, Mathieu Poirier wrote:
> On Tue, Aug 23, 2022 at 05:06:48PM +0100, James Clark wrote:
>> I've taken over this one from German because he's moved to a different
>> team. I gave it a quick check and bumped the version number in the docs
>> for the next release, but the month is an estimate.
>>
>> Thanks
>>
>> Changes since v2:
>>
>>   * Rebased onto coresight/next (b99ee26a1a)
>>   * Bumped release version to 6.1
> 
> I have applied this set.  Usually I'd let Suzuki handle it since he is already
> familiar with the work but 1) he is currently away and 2) the patchset is fairly
> simple.

Thanks Mathieu

> 
> Thanks,
> Mathieu
> 
>>
>> Changes since v1:
>>
>>   * Inline etmv4_to_ts_source() function.
>>   * Collect review tag from Leo.
>>
>> German Gomez (2):
>>   coresight: etm4x: Expose default timestamp source in sysfs
>>   coresight: etm4x: docs: Add documentation for 'ts_source' sysfs
>>     interface
>>
>>  .../testing/sysfs-bus-coresight-devices-etm4x |  8 +++++
>>  .../coresight/coresight-etm4x-reference.rst   | 14 +++++++++
>>  arch/arm64/include/asm/sysreg.h               |  1 +
>>  .../coresight/coresight-etm4x-sysfs.c         | 29 +++++++++++++++++++
>>  4 files changed, 52 insertions(+)
>>
>> -- 
>> 2.28.0
>>

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

end of thread, other threads:[~2022-08-30 17:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-23 16:06 [PATCH v3 0/2] coresight: etm4x: Expose default timestamp source in sysfs James Clark
2022-08-23 16:06 ` [PATCH v3 1/2] " James Clark
2022-08-23 16:06 ` [PATCH v3 2/2] coresight: etm4x: docs: Add documentation for 'ts_source' sysfs interface James Clark
2022-08-24  2:54   ` Bagas Sanjaya
2022-08-24 13:59     ` James Clark
2022-08-26 19:55 ` [PATCH v3 0/2] coresight: etm4x: Expose default timestamp source in sysfs Mathieu Poirier
2022-08-30 17:29   ` James Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).