On 21/11/2025 12:23 am, Kuan-Wei Chiu wrote:
> The cntr_val_show() function is meant to display the values of all
> available counters. However, the sprintf() call inside the loop was
> always writing to the beginning of the buffer, causing the output of
> previous iterations to be overwritten. As a result, only the value of
> the last counter was actually returned to the user.
>
> Fix this by using the return value of sprintf() to calculate the
> correct offset into the buffer for the next write, ensuring that all
> counter values are appended sequentially.
>
> Fixes: a939fc5a71ad ("coresight-etm: add CoreSight ETM/PTM driver")
> Signed-off-by: Kuan-Wei Chiu <visitorckw(a)gmail.com>
> ---
> Build tested only. I do not have the hardware to run the etm3x driver,
> so I would be grateful if someone could verify this on actual hardware.
>
> I noticed this issue while browsing the coresight code after attending
> a technical talk on the subject. This code dates back to the initial
> driver submission over 10 years ago, so I was surprised it hadn't been
> caught earlier. Although I cannot perform runtime testing, the logic
> error seems obvious to me, so I still decided to submit this patch.
Nice find. I think the point that it wasn't caught changes how we fix
it. Either nobody used it ever - so we can just delete it. Or someone
was using it and they expect it to always return a single entry with the
value of the last counter and this is a potentially breaking change. So
maybe instead of fixing this we should add a new cntr_vals_show() which
works correctly. But then again if nobody is using it we shouldn't do
that either.
The interface isn't even that great, it should be a separate file per
counter. You don't want to be parsing strings and colons to try to read
a single value, especially in C. Separate files allows you to read it
directly without any hassle.
>
> drivers/hwtracing/coresight/coresight-etm3x-sysfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
> index 762109307b86..312033e74b7a 100644
> --- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
> @@ -725,7 +725,7 @@ static ssize_t cntr_val_show(struct device *dev,
> if (!coresight_get_mode(drvdata->csdev)) {
> spin_lock(&drvdata->spinlock);
> for (i = 0; i < drvdata->nr_cntr; i++)
> - ret += sprintf(buf, "counter %d: %x\n",
> + ret += sprintf(buf + ret, "counter %d: %x\n",
> i, config->cntr_val[i]);
> spin_unlock(&drvdata->spinlock);
> return ret;
> @@ -733,7 +733,7 @@ static ssize_t cntr_val_show(struct device *dev,
>
> for (i = 0; i < drvdata->nr_cntr; i++) {
> val = etm_readl(drvdata, ETMCNTVRn(i));
> - ret += sprintf(buf, "counter %d: %x\n", i, val);
> + ret += sprintf(buf + ret, "counter %d: %x\n", i, val);
> }
>
> return ret;
Do some cleanups then expand the timestamp format attribute from 1 bit
to 4 bits for ETMv4 in Perf mode. The current interval is too high for
most use cases, and particularly on the FVP the number of timestamps
generated is excessive. This change not only still allows disabling or
enabling timestamps, but also allows the interval to be configured.
The old bit is kept deprecated and undocumented for now. There are known
broken versions of Perf that don't read the format attribute positions
from sysfs and instead hard code the timestamp bit. We can leave the old
bit in the driver until we need the bit for another feature or enough
time has passed that these old Perfs are unlikely to be used.
The interval option is added as an event format attribute, rather than a
Coresight config because it's something that the driver is already
configuring automatically in Perf mode using any unused counter, so it's
not possible to modify this with a config.
Applies to coresight/next
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
Changes in v5:
- Add parens to interval calculation in docs (Randy)
- Swap "minimum interval" and "maximum interval" in docs. (Leo)
- Add TRCSYNCPR.PERIOD to docs (Leo)
- Use CONFIG_ARM64 to avoid is_kernel_in_hyp_mode() (Leo)
- Add a comment for hidden ETMv3 format attributes (Leo)
- Hide configid for ETMv3 (Leo)
- Link to v4: https://lore.kernel.org/r/20251112-james-cs-syncfreq-v4-0-165ba21401dc@lina…
Changes in v4:
- Add #defines for true and false resources ETM_RES_SEL_TRUE/FALSE
- Reword comment about finding a counter to say if there are no
resources there are no counters.
- Extend existing timestamp format attribute instead of adding a new one
- Refactor all the config definitions and parsing to use
GEN_PMU_FORMAT_ATTR()/ATTR_CFG_GET_FLD() so we can see where the
unused bits are.
- Link to v3: https://lore.kernel.org/r/20251002-james-cs-syncfreq-v3-0-fe5df2bf91d1@lina…
Changes in v3:
- Move the format attr definitions to coresight-etm-perf.h we can
compile on arm32 without #ifdefs - (Leo)
- Convert the new #ifdefs to a single one in an is_visible() function so
that the code is cleaner - (Leo)
- Drop the change to remove the holes in struct etmv4_config as they
were grouped by function - (Mike)
- Link to v2: https://lore.kernel.org/r/20250814-james-cs-syncfreq-v2-0-c76fcb87696d@lina…
Changes in v2:
- Only show the attribute for ETMv4 to improve usability and fix the
arm32 build error. Wrapping everything in
IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) isn't ideal, but the -perf.c
file is shared between ETMv3 and ETMv4, and there is already precedent
for doing it this way.
- Link to v1: https://lore.kernel.org/r/20250811-james-cs-syncfreq-v1-0-b001cd6e3404@lina…
---
James Clark (13):
coresight: Change syncfreq to be a u8
coresight: Repack struct etmv4_drvdata
coresight: Refactor etm4_config_timestamp_event()
coresight: Hide unused ETMv3 format attributes
coresight: Define format attributes with GEN_PMU_FORMAT_ATTR()
coresight: Interpret ETMv3 config with ATTR_CFG_GET_FLD()
coresight: Don't reject unrecognized ETMv3 format attributes
coresight: Interpret perf config with ATTR_CFG_GET_FLD()
coresight: Interpret ETMv4 config with ATTR_CFG_GET_FLD()
coresight: Remove misleading definitions
coresight: Extend width of timestamp format attribute
coresight: Allow setting the timestamp interval
coresight: docs: Document etm4x timestamp interval option
Documentation/trace/coresight/coresight.rst | 16 +-
drivers/hwtracing/coresight/coresight-etm-perf.c | 70 ++++++---
drivers/hwtracing/coresight/coresight-etm-perf.h | 39 +++++
drivers/hwtracing/coresight/coresight-etm3x-core.c | 36 ++---
drivers/hwtracing/coresight/coresight-etm4x-core.c | 164 +++++++++++++--------
drivers/hwtracing/coresight/coresight-etm4x.h | 61 +++++---
include/linux/coresight-pmu.h | 24 ---
7 files changed, 258 insertions(+), 152 deletions(-)
---
base-commit: 9e9182cab5ebc3ee7544e60ef08ba19fdf216920
change-id: 20250724-james-cs-syncfreq-7c2257a38ed3
Best regards,
--
James Clark <james.clark(a)linaro.org>
On 20/11/2025 9:41 am, Jiapeng Chong wrote:
> No functional modification involved.
>
> ./drivers/hwtracing/coresight/coresight-priv.h:238:2-3: Unneeded semicolon.
>
> Reported-by: Abaci Robot <abaci(a)linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=27327
> Signed-off-by: Jiapeng Chong <jiapeng.chong(a)linux.alibaba.com>
> ---
> drivers/hwtracing/coresight/coresight-priv.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h
> index fd896ac07942..16f0cee8cad6 100644
> --- a/drivers/hwtracing/coresight/coresight-priv.h
> +++ b/drivers/hwtracing/coresight/coresight-priv.h
> @@ -235,7 +235,7 @@ static inline void *coresight_get_uci_data_from_amba(const struct amba_id *table
> if ((pid & table->mask) == table->id)
> return coresight_get_uci_data(table);
> table++;
> - };
> + }
> return NULL;
> }
>
Reviewed-by: James Clark <james.clark(a)linaro.org>
I turned on -Wextra-semi-stmt for Coresight but it results in hundreds
warnings because of the way macros like wmb() are always used with a
semicolon.
So I'm not really sure what the point of fixing these up is? Because
they can never all be fixed without a fundamental style change so why
not just ignore them?
James
This patchset builds upon Yicong's previous patches [1].
Patch 2 introducing fix race issues found by using TMC-ETR.
Patch 1 & 3 introducing two cleanups found when debugging the issues.
[1] https://lore.kernel.org/linux-arm-kernel/20241202092419.11777-1-yangyicong@…
---
Changes in v4:
- a) Add comment at the context of set etr to sysfs mode.
- b) Move the check on drvdata->read to the start of enable etr.
- c) Add checks to prevent multiple sysfs processes from simultaneously
competing to enable ETR.
- d) Fix the issue with the guard used.
Link: https://lore.kernel.org/linux-arm-kernel/20250818080600.418425-1-hejunhao3@…
---
Changes in v3:
- Patches 1: Additional comment for tmc_drvdata::etr_mode. Update
comment for tmc_drvdata::reading with Jonathan's Tag.
- Patches 2: Replace scoped_guard with guard with Jonathan's Tag.
- Patches 2: Fix spinlock to raw_spinlock, and refactor this code based
on Leo's suggested solution.
- Patches 3: change the size's type to ssize_t and use max_t to simplify
the code with Leo's Tag.
Link: https://lore.kernel.org/linux-arm-kernel/20250620075412.952934-1-hejunhao3@…
Changes in v2:
- Updated the commit of patch2.
- Rebase to v6.16-rc1
Junhao He (1):
coresight: tmc: refactor the tmc-etr mode setting to avoid race
conditions
Yicong Yang (2):
coresight: tmc: Add missing doc including reading and etr_mode of
struct tmc_drvdata
coresight: tmc: Decouple the perf buffer allocation from sysfs mode
.../hwtracing/coresight/coresight-tmc-etr.c | 136 +++++++++---------
drivers/hwtracing/coresight/coresight-tmc.h | 2 +
2 files changed, 66 insertions(+), 72 deletions(-)
--
2.33.0
Do some cleanups then expand the timestamp format attribute from 1 bit
to 4 bits for ETMv4 in Perf mode. The current interval is too high for
most use cases, and particularly on the FVP the number of timestamps
generated is excessive. This change not only still allows disabling or
enabling timestamps, but also allows the interval to be configured.
The old bit is kept deprecated and undocumented for now. There are known
broken versions of Perf that don't read the format attribute positions
from sysfs and instead hard code the timestamp bit. We can leave the old
bit in the driver until we need the bit for another feature or enough
time has passed that these old Perfs are unlikely to be used.
The interval option is added as an event format attribute, rather than a
Coresight config because it's something that the driver is already
configuring automatically in Perf mode using any unused counter, so it's
not possible to modify this with a config.
Applies to coresight/next
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
Changes in v6:
- #ifdef out format attributes for ETMv3 instead of using is_visible().
Then the same block can be used to define format_attr_contextid_show()
which avoids an awkward WARN_ONCE() and comments in arm32 for a
function that's never called.
- Link to v5: https://lore.kernel.org/r/20251118-james-cs-syncfreq-v5-0-82efd7b1a751@lina…
Changes in v5:
- Add parens to interval calculation in docs (Randy)
- Swap "minimum interval" and "maximum interval" in docs. (Leo)
- Add TRCSYNCPR.PERIOD to docs (Leo)
- Use CONFIG_ARM64 to avoid is_kernel_in_hyp_mode() (Leo)
- Add a comment for hidden ETMv3 format attributes (Leo)
- Hide configid for ETMv3 (Leo)
- Link to v4: https://lore.kernel.org/r/20251112-james-cs-syncfreq-v4-0-165ba21401dc@lina…
Changes in v4:
- Add #defines for true and false resources ETM_RES_SEL_TRUE/FALSE
- Reword comment about finding a counter to say if there are no
resources there are no counters.
- Extend existing timestamp format attribute instead of adding a new one
- Refactor all the config definitions and parsing to use
GEN_PMU_FORMAT_ATTR()/ATTR_CFG_GET_FLD() so we can see where the
unused bits are.
- Link to v3: https://lore.kernel.org/r/20251002-james-cs-syncfreq-v3-0-fe5df2bf91d1@lina…
Changes in v3:
- Move the format attr definitions to coresight-etm-perf.h we can
compile on arm32 without #ifdefs - (Leo)
- Convert the new #ifdefs to a single one in an is_visible() function so
that the code is cleaner - (Leo)
- Drop the change to remove the holes in struct etmv4_config as they
were grouped by function - (Mike)
- Link to v2: https://lore.kernel.org/r/20250814-james-cs-syncfreq-v2-0-c76fcb87696d@lina…
Changes in v2:
- Only show the attribute for ETMv4 to improve usability and fix the
arm32 build error. Wrapping everything in
IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) isn't ideal, but the -perf.c
file is shared between ETMv3 and ETMv4, and there is already precedent
for doing it this way.
- Link to v1: https://lore.kernel.org/r/20250811-james-cs-syncfreq-v1-0-b001cd6e3404@lina…
---
James Clark (13):
coresight: Change syncfreq to be a u8
coresight: Repack struct etmv4_drvdata
coresight: Refactor etm4_config_timestamp_event()
coresight: Hide unused ETMv3 format attributes
coresight: Define format attributes with GEN_PMU_FORMAT_ATTR()
coresight: Interpret ETMv3 config with ATTR_CFG_GET_FLD()
coresight: Don't reject unrecognized ETMv3 format attributes
coresight: Interpret perf config with ATTR_CFG_GET_FLD()
coresight: Interpret ETMv4 config with ATTR_CFG_GET_FLD()
coresight: Remove misleading definitions
coresight: Extend width of timestamp format attribute
coresight: Allow setting the timestamp interval
coresight: docs: Document etm4x timestamp interval option
Documentation/trace/coresight/coresight.rst | 16 +-
drivers/hwtracing/coresight/coresight-etm-perf.c | 68 ++++-----
drivers/hwtracing/coresight/coresight-etm-perf.h | 39 +++++
drivers/hwtracing/coresight/coresight-etm3x-core.c | 36 ++---
drivers/hwtracing/coresight/coresight-etm4x-core.c | 164 +++++++++++++--------
drivers/hwtracing/coresight/coresight-etm4x.h | 61 +++++---
include/linux/coresight-pmu.h | 24 ---
7 files changed, 244 insertions(+), 164 deletions(-)
---
base-commit: 9e9182cab5ebc3ee7544e60ef08ba19fdf216920
change-id: 20250724-james-cs-syncfreq-7c2257a38ed3
Best regards,
--
James Clark <james.clark(a)linaro.org>
This series focuses on CoreSight path power management. The changes can
be divided into four parts for review:
Patches 01~06: Refactor the CPU idle flow with moving common code into
the CoreSight core layer.
Patches 07~14: Add link control during CPU idle.
Patches 15~16: Support the sink (TRBE) control during CPU idle.
Patches 17~19: Move the CPU hotplug flow into the coresight core layer
and simplify the code.
This series is rebased on the coresight-next branch and has been verified
on Juno-r2 and FVP RevC.
---
Changes in v5:
- Set the per-CPU source pointer on target CPU (Suzuki).
- Reused existed enable/disable buffer functions in TRBE callbacks
(James).
- Refactored refcount for source devices in SysFS mode.
- Released path in cpu-hotplug off flow to avoid memory leak.
- Updated ETMv3 driver when move common code into core layer.
- Rebased on the latest coresight-next branch.
- Link to v4: https://lore.kernel.org/r/20251104-arm_coresight_path_power_management_impr…
Changes in v4:
- Changed to store path pointer in coresight_device, this is easier for
fetching path pointer based on source device (Mike).
- Dropped changes in CTI driver.
- Only disabled path for CPU hot-plugged off but not enable path for
hot-plugged in.
- Removed James' test tags for modified patches.
- Link to v3: https://lore.kernel.org/r/20250915-arm_coresight_power_management_fix-v3-0-…
Signed-off-by: Leo Yan <leo.yan(a)arm.com>
---
Leo Yan (18):
coresight: sysfs: Validate CPU online status for per-CPU sources
coresight: Set per-CPU source pointer
coresight: Register CPU PM notifier in core layer
coresight: etm4x: Hook CPU PM callbacks
coresight: Add callback to determine if PM is needed
coresight: etm4x: Remove redundant condition checks in save and restore
coresight: syscfg: Use spinlock to protect active variables
coresight: Introduce coresight_enable_source() helper
coresight: Save active path for system tracers
coresight: etm4x: Set active path on target CPU
coresight: etm3x: Set active path on target CPU
coresight: sysfs: Use source's path pointer for path control
coresight: Add 'in_idle' argument to path
coresight: Control path during CPU idle
coresight: Add PM callbacks for sink device
coresight: sysfs: Increment refcount only for system tracers
coresight: Take hotplug lock in enable_source_store() for Sysfs mode
coresight: Move CPU hotplug callbacks to core layer
Yabin Cui (1):
coresight: trbe: Save and restore state across CPU low power state
drivers/hwtracing/coresight/coresight-catu.c | 1 +
drivers/hwtracing/coresight/coresight-core.c | 242 ++++++++++++++++++++-
drivers/hwtracing/coresight/coresight-ctcu-core.c | 1 +
drivers/hwtracing/coresight/coresight-cti-core.c | 1 +
drivers/hwtracing/coresight/coresight-dummy.c | 1 +
drivers/hwtracing/coresight/coresight-etb10.c | 1 +
drivers/hwtracing/coresight/coresight-etm-perf.c | 2 +-
drivers/hwtracing/coresight/coresight-etm3x-core.c | 65 ++----
drivers/hwtracing/coresight/coresight-etm4x-core.c | 153 +++----------
drivers/hwtracing/coresight/coresight-funnel.c | 1 +
drivers/hwtracing/coresight/coresight-priv.h | 3 +
drivers/hwtracing/coresight/coresight-replicator.c | 1 +
drivers/hwtracing/coresight/coresight-stm.c | 1 +
drivers/hwtracing/coresight/coresight-syscfg.c | 22 +-
drivers/hwtracing/coresight/coresight-syscfg.h | 2 +
drivers/hwtracing/coresight/coresight-sysfs.c | 126 ++++-------
drivers/hwtracing/coresight/coresight-tmc-core.c | 1 +
drivers/hwtracing/coresight/coresight-tnoc.c | 2 +
drivers/hwtracing/coresight/coresight-tpda.c | 1 +
drivers/hwtracing/coresight/coresight-tpdm.c | 1 +
drivers/hwtracing/coresight/coresight-tpiu.c | 1 +
drivers/hwtracing/coresight/coresight-trbe.c | 62 +++++-
drivers/hwtracing/coresight/ultrasoc-smb.c | 1 +
include/linux/coresight.h | 11 +
24 files changed, 429 insertions(+), 274 deletions(-)
---
base-commit: 9e9182cab5ebc3ee7544e60ef08ba19fdf216920
change-id: 20251104-arm_coresight_path_power_management_improvement-dab4966f8280
Best regards,
--
Leo Yan <leo.yan(a)arm.com>
This series is extracted from [1], focusing on CoreSight path power
management.
Compared to the previous version, this series is updated heavily for:
1) Dropped the global per CPU variable for saving path pointers.
Instead, the activate path is now stored in the source device's
structure. This allows fetching the path pointer naturally based on
the source regardless of whether it is a per-CPU source or a system
source (such as STM).
This improvement addresses Mike's comment that, later we can polish
coresight-sysfs.c to remove the tracer_path variables.
2) To simplify the series and make it easier to review, the CTI driver
related fixes have been removed from this series and which will be
sent out separately.
3) This series disables the path when a CPU is hot-plugged off but does
not re-enable it when the CPU is subsequently hot-plugged in. This
simplifies the implementation and keep it consistent with the perf
session's behavior.
It also improves security, as there is no risk of unintended tracing
caused by a CPU being hot-plugged after a long period of inactivity.
This series is dependent on ETM driver's PM improvement series [2] and
has been verified on Juno-r2 and FVP RevC.
[1] https://lore.kernel.org/linux-arm-kernel/20250915-arm_coresight_power_manag…
[2] https://lore.kernel.org/linux-arm-kernel/20251103-arm_coresight_power_manag…
---
Changes in v4:
- Changed to store path pointer in coresight_device, this is easier for
fetching path pointer based on source device (Mike).
- Dropped changes in CTI driver.
- Only disabled path for CPU hot-plugged off but not enable path for
hot-plugged in.
- Removed James' test tags for modified patches.
- Link to v3: https://lore.kernel.org/r/20250915-arm_coresight_power_management_fix-v3-0-…
Signed-off-by: Leo Yan <leo.yan(a)arm.com>
---
Leo Yan (14):
coresight: sysfs: Validate CPU online status for per-CPU sources
coresight: Set per CPU source pointer
coresight: Register CPU PM notifier in core layer
coresight: etm4x: Hook CPU PM callbacks
coresight: Add callback to determine if PM is needed
coresight: etm4x: Remove redundant condition checks in save and restore
coresight: syscfg: Use spinlock to protect active variables
coresight: Introduce coresight_enable_source() helper
coresight: Save activated path into source device
coresight: Add 'in_idle' argument to enable/disable path functions
coresight: Control path during CPU idle
coresight: Add PM callbacks for percpu sink
coresight: Take hotplug lock in enable_source_store() for Sysfs mode
coresight: Move CPU hotplug callbacks to core layer
Yabin Cui (1):
coresight: trbe: Save and restore state across CPU low power state
drivers/hwtracing/coresight/coresight-catu.c | 1 +
drivers/hwtracing/coresight/coresight-core.c | 273 ++++++++++++++++++++-
drivers/hwtracing/coresight/coresight-ctcu-core.c | 1 +
drivers/hwtracing/coresight/coresight-cti-core.c | 1 +
drivers/hwtracing/coresight/coresight-dummy.c | 1 +
drivers/hwtracing/coresight/coresight-etb10.c | 1 +
drivers/hwtracing/coresight/coresight-etm-perf.c | 2 +-
drivers/hwtracing/coresight/coresight-etm3x-core.c | 1 +
drivers/hwtracing/coresight/coresight-etm4x-core.c | 137 ++---------
drivers/hwtracing/coresight/coresight-funnel.c | 1 +
drivers/hwtracing/coresight/coresight-priv.h | 3 +
drivers/hwtracing/coresight/coresight-replicator.c | 1 +
drivers/hwtracing/coresight/coresight-stm.c | 1 +
drivers/hwtracing/coresight/coresight-syscfg.c | 22 +-
drivers/hwtracing/coresight/coresight-syscfg.h | 2 +
drivers/hwtracing/coresight/coresight-sysfs.c | 12 +-
drivers/hwtracing/coresight/coresight-tmc-core.c | 1 +
drivers/hwtracing/coresight/coresight-tnoc.c | 2 +
drivers/hwtracing/coresight/coresight-tpda.c | 1 +
drivers/hwtracing/coresight/coresight-tpdm.c | 1 +
drivers/hwtracing/coresight/coresight-tpiu.c | 1 +
drivers/hwtracing/coresight/coresight-trbe.c | 85 ++++++-
drivers/hwtracing/coresight/ultrasoc-smb.c | 1 +
include/linux/coresight.h | 13 +
24 files changed, 425 insertions(+), 140 deletions(-)
---
base-commit: f9ac95561513e18c2a2cf8905355dc5f0e030c46
change-id: 20251104-arm_coresight_path_power_management_improvement-dab4966f8280
Best regards,
--
Leo Yan <leo.yan(a)arm.com>
Do some cleanups then expand the timestamp format attribute from 1 bit
to 4 bits for ETMv4 in Perf mode. The current interval is too high for
most use cases, and particularly on the FVP the number of timestamps
generated is excessive. This change not only still allows disabling or
enabling timestamps, but also allows the interval to be configured.
The old bit is kept deprecated and undocumented for now. There are known
broken versions of Perf that don't read the format attribute positions
from sysfs and instead hard code the timestamp bit. We can leave the old
bit in the driver until we need the bit for another feature or enough
time has passed that these old Perfs are unlikely to be used.
The interval option is added as an event format attribute, rather than a
Coresight config because it's something that the driver is already
configuring automatically in Perf mode using any unused counter, so it's
not possible to modify this with a config.
Applies to coresight/next
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
Changes in v4:
- Add #defines for true and false resources ETM_RES_SEL_TRUE/FALSE
- Reword comment about finding a counter to say if there are no
resources there are no counters.
- Extend existing timestamp format attribute instead of adding a new one
- Refactor all the config definitions and parsing to use
GEN_PMU_FORMAT_ATTR()/ATTR_CFG_GET_FLD() so we can see where the
unused bits are.
- Link to v3: https://lore.kernel.org/r/20251002-james-cs-syncfreq-v3-0-fe5df2bf91d1@lina…
Changes in v3:
- Move the format attr definitions to coresight-etm-perf.h we can
compile on arm32 without #ifdefs - (Leo)
- Convert the new #ifdefs to a single one in an is_visible() function so
that the code is cleaner - (Leo)
- Drop the change to remove the holes in struct etmv4_config as they
were grouped by function - (Mike)
- Link to v2: https://lore.kernel.org/r/20250814-james-cs-syncfreq-v2-0-c76fcb87696d@lina…
Changes in v2:
- Only show the attribute for ETMv4 to improve usability and fix the
arm32 build error. Wrapping everything in
IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) isn't ideal, but the -perf.c
file is shared between ETMv3 and ETMv4, and there is already precedent
for doing it this way.
- Link to v1: https://lore.kernel.org/r/20250811-james-cs-syncfreq-v1-0-b001cd6e3404@lina…
---
James Clark (13):
coresight: Change syncfreq to be a u8
coresight: Repack struct etmv4_drvdata
coresight: Refactor etm4_config_timestamp_event()
coresight: Hide unused ETMv3 format attributes
coresight: Define format attributes with GEN_PMU_FORMAT_ATTR()
coresight: Interpret ETMv3 config with ATTR_CFG_GET_FLD()
coresight: Don't reject unrecognized ETMv3 format attributes
coresight: Interpret perf config with ATTR_CFG_GET_FLD()
coresight: Interpret ETMv4 config with ATTR_CFG_GET_FLD()
coresight: Remove misleading definitions
coresight: Extend width of timestamp format attribute
coresight: Allow setting the timestamp interval
coresight: docs: Document etm4x timestamp interval option
Documentation/trace/coresight/coresight.rst | 15 +-
drivers/hwtracing/coresight/coresight-etm-perf.c | 59 +++++---
drivers/hwtracing/coresight/coresight-etm-perf.h | 39 +++++
drivers/hwtracing/coresight/coresight-etm3x-core.c | 36 ++---
drivers/hwtracing/coresight/coresight-etm4x-core.c | 164 +++++++++++++--------
drivers/hwtracing/coresight/coresight-etm4x.h | 62 +++++---
include/linux/coresight-pmu.h | 24 ---
7 files changed, 247 insertions(+), 152 deletions(-)
---
base-commit: efdccf6a511891db037e08f1351e72eaa101021e
change-id: 20250724-james-cs-syncfreq-7c2257a38ed3
Best regards,
--
James Clark <james.clark(a)linaro.org>
All CoreSight compliant components have an implementation defined number
of 0 to 8 claim tag bits in the claim tag registers.
These are used to claim the CoreSight resources by system agents.
ARM recommends implementions have 4 claim tag registers.
The CoreSight drivers implement a 2 claim tag bit protocol to allow
self hosted and external debug agents to manage access to the hardware.
However, if there are less than 2 claim tags available the protocol
incorrectly returns an error on device claim, as no checks are made.
If insufficient claim tags are present in a component then the protocol
must return success on claim / disclaim to allow components to be used
normally.
Changes read the CLAIMSET bits to establish the number of available tags,
and adjust the claim returns accordingly.
Cache the claimtag protocol availablity in the coresight_device to reduce
reads for the main claim/disclaim api.
changes since v1:
1) Added claim tag availability cache into coresight_device when using the
main coresight_claim_device() / coresight_disclaim_device() API.
Applies to coresight/next
Mike Leach (1):
coresight: fix issue where coresight component has no claimtags
drivers/hwtracing/coresight/coresight-core.c | 46 ++++++++++++++++++--
drivers/hwtracing/coresight/coresight-priv.h | 10 +++++
include/linux/coresight.h | 15 +++++++
3 files changed, 68 insertions(+), 3 deletions(-)
--
2.32.0
On 14/11/2025 5:02 am, Randy Dunlap wrote:
>
>
> On 11/12/25 7:22 AM, James Clark wrote:
>> Document how the new field is used, maximum value and the interaction
>> with SYNC timestamps.
>>
>> Signed-off-by: James Clark <james.clark(a)linaro.org>
>> ---
>> Documentation/trace/coresight/coresight.rst | 15 +++++++++++++--
>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/trace/coresight/coresight.rst b/Documentation/trace/coresight/coresight.rst
>> index 806699871b80..80b5ed09d69b 100644
>> --- a/Documentation/trace/coresight/coresight.rst
>> +++ b/Documentation/trace/coresight/coresight.rst
>> @@ -613,8 +613,19 @@ They are also listed in the folder /sys/bus/event_source/devices/cs_etm/format/
>> - Session local version of the system wide setting: :ref:`ETM_MODE_RETURNSTACK
>> <coresight-return-stack>`
>> * - timestamp
>> - - Session local version of the system wide setting: :ref:`ETMv4_MODE_TIMESTAMP
>> - <coresight-timestamp>`
>> + - Controls generation and interval of timestamps.
>> +
>> + 0 = off, 1 = maximum interval .. 15 = minimum interval.
>> +
>> + Values 1 - 14 use a counter that decrements every cycle to generate a
>> + timestamp on underflow. The reload value for the counter is 2 raised to
>> + the power of timestamp interval - 1. If the value is 1 then the reload
>> + value is 1, if the value is 11 then the reload value is 1024 etc.
>
> value = 11: 2^11-1 = 2047
>
> Maybe add some parens?
>
>
Will do. I had them but I removed them because it was in a sentence so
it made it look like a side note. I think I'll change from words to symbols:
The reload value for the counter is 2 ^ (interval - 1).
Thanks
James