On 21/11/2025 5:02 pm, Kuan-Wei Chiu wrote:
> Hi James,
>
> On Fri, Nov 21, 2025 at 09:50:03AM +0000, James Clark wrote:
>>
>>
>> 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.
>
> Thanks for your feedback.
>
> I agree that if any tool relies on the current behavior, this patch
> would break the ABI and violate the hard rule that we must never break
> userspace.
>
> However, I am not sure how to determine if any userspace tools are
> actually using this sysfs interface. Is there a recommended way to
> verify this, or a standard procedure/convention to follow in this
> situation?
>
> Regards,
> Kuan-Wei
>
There's no way of knowing apart from deducing that there are 0 users of
the 'correct' version of the API because it never existed. This isn't
even a regression, it was broken from the beginning.
I suppose it does work when hardware only has one counter, but I don't
know how likely that is?
Looking at cntr_val_store() I think I was wrong before when I said it
should be a separate file for each counter. Writing to it already writes
to the counter currently selected by cntr_idx and splitting it out to
separate files would have to break that too. So we can fix the display
bug by making show operate on the currently selected counter in the same
way as store. Then it makes a bit more sense and we can delete the
"counter %d: " prefix.
ETM4 already does it this way too.
>>
>> 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>
Hi Greg,
Please find the coresight self hosted tracing subsystem updates targeting v6.19.
Kindly pull,
Suzuki
The following changes since commit dcb6fa37fd7bc9c3d2b066329b0d27dedf8becaa:
Linux 6.18-rc3 (2025-10-26 15:59:49 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux.git tags/coresight-next-v6.19
for you to fetch changes up to 9e9182cab5ebc3ee7544e60ef08ba19fdf216920:
coresight: etm4x: Remove the state_needs_restore flag (2025-11-12 16:53:19 +0000)
----------------------------------------------------------------
coresight: Updates for Linux v6.19
The changes for Linux v6.19 include :
- Support for static TPDM
- Fixes to TMC-ETR with CATU where buffer wasn't available to CATU in perf mode
- Clean ups to the component operations to accept coresight_path
- Fixes to the ETM4x/ETM3x driver
Signed-off-by: Suzuki K Poulose <suzuki.poulose(a)arm.com>
----------------------------------------------------------------
Carl Worth (1):
coresight: tmc: add the handle of the event to the path
Jie Gan (5):
dt-bindings: arm: document the static TPDM compatible
coresight: tpdm: add static tpdm support
coresight: tpdm: remove redundant check for drvdata
coresight: change helper_ops to accept coresight_path
coresight: change the sink_ops to accept coresight_path
Leo Yan (8):
coresight: Change device mode to atomic type
coresight: etm4x: Always set tracer's device mode on target CPU
coresight: etm3x: Always set tracer's device mode on target CPU
coresight: etm4x: Correct polling IDLE bit
coresight: etm4x: Add context synchronization before enabling trace
coresight: etm4x: Properly control filter in CPU idle with FEAT_TRF
coresight: etm4x: Remove the redundant DSB
coresight: etm4x: Remove the state_needs_restore flag
Xiaoqi Zhuang (1):
coresight: ETR: Fix ETR buffer use-after-free issue
.../bindings/arm/qcom,coresight-tpdm.yaml | 23 ++-
drivers/hwtracing/coresight/coresight-catu.c | 10 +-
drivers/hwtracing/coresight/coresight-core.c | 30 ++--
drivers/hwtracing/coresight/coresight-ctcu-core.c | 9 +-
drivers/hwtracing/coresight/coresight-cti-core.c | 5 +-
drivers/hwtracing/coresight/coresight-cti.h | 5 +-
drivers/hwtracing/coresight/coresight-dummy.c | 2 +-
drivers/hwtracing/coresight/coresight-etb10.c | 8 +-
drivers/hwtracing/coresight/coresight-etm-perf.c | 3 +-
drivers/hwtracing/coresight/coresight-etm3x-core.c | 59 ++++---
drivers/hwtracing/coresight/coresight-etm4x-core.c | 140 +++++++++++------
drivers/hwtracing/coresight/coresight-etm4x.h | 5 -
drivers/hwtracing/coresight/coresight-priv.h | 3 +-
drivers/hwtracing/coresight/coresight-sysfs.c | 2 +-
drivers/hwtracing/coresight/coresight-tmc-etf.c | 10 +-
drivers/hwtracing/coresight/coresight-tmc-etr.c | 22 ++-
drivers/hwtracing/coresight/coresight-tmc.h | 3 +-
drivers/hwtracing/coresight/coresight-tpda.c | 7 -
drivers/hwtracing/coresight/coresight-tpdm.c | 174 +++++++++++++++++----
drivers/hwtracing/coresight/coresight-tpdm.h | 12 ++
drivers/hwtracing/coresight/coresight-tpiu.c | 2 +-
drivers/hwtracing/coresight/coresight-trbe.c | 4 +-
drivers/hwtracing/coresight/ultrasoc-smb.c | 9 +-
include/linux/coresight.h | 42 ++---
24 files changed, 402 insertions(+), 187 deletions(-)
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;
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>