This series is to fix and refactor CoreSight device registration and
unregistration, it can be divided into three small parts:
Patches 01-03: Three fixes for memory leak, device reference and mutex
protection.
Patches 04-05: Move connection cleanup operations into
coresight_remove_conns().
Patches 06-08: Refactor error handling in coresight_register().
This series is verified on Juno board with kmemleak detector.
For kmemleak verifying:
echo clear > /sys/kernel/debug/kmemleak
insmod coresight modules
rmmod coresight modules
echo scan > /sys/kernel/debug/kmemleak
The result shows no memory leak during a cycle of device registration
and unregistration.
---
Changes in v3:
- Updated patch 01 to use coesight core layer for device index list
(Suzuki).
- Link to v2: https://lore.kernel.org/r/20260126-arm_coresight_refactor_dev_register-v2-0…
Changes in v2:
- Refined the commit log in patch 06 (Suzuki).
- Unified to call coresight_unregister() for error handling (Suzuki).
- Refactor connection and sysfs group release.
- Link to v1: https://lore.kernel.org/linux-arm-kernel/20250512154108.23920-1-leo.yan@arm…
To: Suzuki K Poulose <suzuki.poulose(a)arm.com>
To: Mike Leach <mike.leach(a)arm.com>
To: James Clark <james.clark(a)linaro.org>
To: Alexander Shishkin <alexander.shishkin(a)linux.intel.com>
To: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
To: Mathieu Poirier <mathieu.poirier(a)linaro.org>
To: Mao Jinlong <quic_jinlmao(a)quicinc.com>
Cc: coresight(a)lists.linaro.org
Cc: linux-arm-kernel(a)lists.infradead.org
Cc: linux-kernel(a)vger.kernel.org
Signed-off-by: Leo Yan <leo.yan(a)arm.com>
---
Leo Yan (8):
coresight: Fix memory leak in coresight_alloc_device_name()
coresight: Get parent device reference after sink ID map allocation
coresight: Protect unregistration with mutex
coresight: Refactor output connection sysfs link cleanup
coresight: Refactor sysfs connection group cleanup
coresight: Move sink validation into etm_perf_add_symlink_sink()
coresight: Do not mix success path with failure handling
coresight: Unify error handling in coresight_register()
drivers/hwtracing/coresight/coresight-catu.c | 4 +-
drivers/hwtracing/coresight/coresight-core.c | 230 +++++++++++++--------
drivers/hwtracing/coresight/coresight-ctcu-core.c | 4 +-
drivers/hwtracing/coresight/coresight-cti-core.c | 19 +-
drivers/hwtracing/coresight/coresight-dummy.c | 7 +-
drivers/hwtracing/coresight/coresight-etb10.c | 4 +-
drivers/hwtracing/coresight/coresight-etm-perf.c | 5 +-
drivers/hwtracing/coresight/coresight-funnel.c | 4 +-
drivers/hwtracing/coresight/coresight-platform.c | 2 +-
drivers/hwtracing/coresight/coresight-priv.h | 3 +-
drivers/hwtracing/coresight/coresight-replicator.c | 4 +-
drivers/hwtracing/coresight/coresight-stm.c | 4 +-
drivers/hwtracing/coresight/coresight-tmc-core.c | 12 +-
drivers/hwtracing/coresight/coresight-tnoc.c | 4 +-
drivers/hwtracing/coresight/coresight-tpda.c | 4 +-
drivers/hwtracing/coresight/coresight-tpdm.c | 4 +-
drivers/hwtracing/coresight/coresight-tpiu.c | 4 +-
drivers/hwtracing/coresight/ultrasoc-smb.c | 4 +-
include/linux/coresight.h | 14 +-
19 files changed, 175 insertions(+), 161 deletions(-)
---
base-commit: eebe8dbd8630f51cf70b1f68a440cd3d7f7a914d
change-id: 20260120-arm_coresight_refactor_dev_register-f16c069db41d
Best regards,
--
Leo Yan <leo.yan(a)arm.com>
Hello
On 02/02/2026 05:09, Kuan-Wei Chiu wrote:
> On Tue, Dec 02, 2025 at 09:26:19AM +0000, James Clark wrote:
>>
>>
>> On 02/12/2025 8:26 am, Kuan-Wei Chiu wrote:
>>> The cntr_val_show() function was intended to print the values of all
>>> counters using a loop. However, due to a buffer overwrite issue with
>>> sprintf(), it effectively only displayed the value of the last counter.
>>>
>>> The companion function, cntr_val_store(), allows users to modify a
>>> specific counter selected by 'cntr_idx'. To maintain consistency
>>> between read and write operations and to align with the ETM4x driver
>>> behavior, modify cntr_val_show() to report only the value of the
>>> currently selected counter.
>>>
>>> This change removes the loop and the "counter %d:" prefix, printing
>>> only the hexadecimal value. It also adopts sysfs_emit() for standard
>>> sysfs output formatting.
>>>
>>> Fixes: a939fc5a71ad ("coresight-etm: add CoreSight ETM/PTM driver")
>>> Cc: stable(a)vger.kernel.org
>>> Signed-off-by: Kuan-Wei Chiu <visitorckw(a)gmail.com>
>>> ---
>>> Build test only.
>>>
>>> Changes in v3:
>>> - Switch format specifier to %#x to include the 0x prefix.
>>> - Add Cc stable
>>>
>>> v2: https://lore.kernel.org/lkml/20251201095228.1905489-1-visitorckw@gmail.com/
>>>
>>> .../hwtracing/coresight/coresight-etm3x-sysfs.c | 15 ++++-----------
>>> 1 file changed, 4 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
>>> index 762109307b86..b3c67e96a82a 100644
>>> --- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
>>> +++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
>>> @@ -717,26 +717,19 @@ static DEVICE_ATTR_RW(cntr_rld_event);
>>> static ssize_t cntr_val_show(struct device *dev,
>>> struct device_attribute *attr, char *buf)
>>> {
>>> - int i, ret = 0;
>>> u32 val;
>>> struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
>>> struct etm_config *config = &drvdata->config;
>>> 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",
>>> - i, config->cntr_val[i]);
>>> + val = config->cntr_val[config->cntr_idx];
>>> spin_unlock(&drvdata->spinlock);
>>> - return ret;
>>> - }
>>> -
>>> - for (i = 0; i < drvdata->nr_cntr; i++) {
>>> - val = etm_readl(drvdata, ETMCNTVRn(i));
>>> - ret += sprintf(buf, "counter %d: %x\n", i, val);
>>> + } else {
>>> + val = etm_readl(drvdata, ETMCNTVRn(config->cntr_idx));
>>> }
>>> - return ret;
>>> + return sysfs_emit(buf, "%#x\n", val);
>>> }
>>> static ssize_t cntr_val_store(struct device *dev,
>>
>> Reviewed-by: James Clark <james.clark(a)linaro.org>
>>
> Thanks for the review!
> Is there anything else I need to do for this fix to land?
Thanks for the patch, I will queue this for the next release (v7.1).
Suzuki
>
> Regards,
> Kuan-Wei
>
I invested $320,000 in Tether (USDT) on a fraudulent website after falling for a romantic scam. I felt completely helpless and in need of assistance after realizing I had been duped. I started looking for a hacker online and found SAFEGUARD RECOVERY. I had optimism because of his professionalism and knowledge. I'm happy to report that SAFEGUARD RECOVERY successfully recovered my stolen money after working relentlessly to do so! I am immensely appreciative of their help and heartily urge anyone in a comparable circumstance to use their services. I'm grateful
Email: safeguardbitcoin(a)consultant.com
WhatsApp: +44 7426 168300
Website: https://safeguardbitcoin.wixsite.com/safeguard-bitcoin--1
I invested $320,000 in Tether (USDT) on a fraudulent website after falling for a romantic scam. I felt completely helpless and in need of assistance after realizing I had been duped. I started looking for a hacker online and found SAFEGUARD RECOVERY. I had optimism because of his professionalism and knowledge. I'm happy to report that SAFEGUARD RECOVERY successfully recovered my stolen money after working relentlessly to do so! I am immensely appreciative of their help and heartily urge anyone in a comparable circumstance to use their services. I'm grateful
Email: safeguardbitcoin(a)consultant.com
WhatsApp: +44 7426 168300
Website: https://safeguardbitcoin.wixsite.com/safeguard-bitcoin--1
Kconfig symbols must not include the CONFIG_ prefix. Remove the CONFIG_
prefix for default values to work.
The STM_PROTO_SYS_T config is selected by default when STM is enabled.
However, its description currently says "If you don't know what this is,
say N," which contradicts the default behavior. Update the description
to say "Y" to align with the default setting.
Fixes: a02509f301c6 ("stm class: Factor out default framing protocol")
Fixes: d69d5e83110f ("stm class: Add MIPI SyS-T protocol support")
Signed-off-by: Leo Yan <leo.yan(a)arm.com>
---
Changes in v2:
- Updated STM_PROTO_BASIC description to align with default selection
(James).
- Link to v1: https://lore.kernel.org/r/20251217-fix_stm_kconfig-v1-1-531fb3674549@arm.com
---
drivers/hwtracing/stm/Kconfig | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hwtracing/stm/Kconfig b/drivers/hwtracing/stm/Kconfig
index eda6b11d40a1f9ab49a1ec1e6faae8ee178c5ed3..8ab079785189052945521e9b0a93a0d458de37e0 100644
--- a/drivers/hwtracing/stm/Kconfig
+++ b/drivers/hwtracing/stm/Kconfig
@@ -13,7 +13,7 @@ if STM
config STM_PROTO_BASIC
tristate "Basic STM framing protocol driver"
- default CONFIG_STM
+ default STM
help
This is a simple framing protocol for sending data over STM
devices. This was the protocol that the STM framework used
@@ -28,7 +28,7 @@ config STM_PROTO_BASIC
config STM_PROTO_SYS_T
tristate "MIPI SyS-T STM framing protocol driver"
- default CONFIG_STM
+ default STM
help
This is an implementation of MIPI SyS-T protocol to be used
over the STP transport. In addition to the data payload, it
@@ -38,7 +38,7 @@ config STM_PROTO_SYS_T
The receiving side must be able to decode this protocol in
addition to the MIPI STP, in order to extract the data.
- If you don't know what this is, say N.
+ If you don't know what this is, say Y.
config STM_DUMMY
tristate "Dummy STM driver"
---
base-commit: fcb70a56f4d81450114034b2c61f48ce7444a0e2
change-id: 20251216-fix_stm_kconfig-a72f40c7612c
Best regards,
--
Leo Yan <leo.yan(a)arm.com>
This series is to fix and refactor CoreSight device registration and
unregistration, it can be divided into three small parts:
Patches 01-03: Three fixes for memory leak, device reference and mutex
protection.
Patches 04-05: Move connection cleanup operations into
coresight_remove_conns().
Patches 06-08: Refactor error handling in coresight_register().
This series is verified on Juno board with kmemleak detector.
For kmemleak verifying:
echo clear > /sys/kernel/debug/kmemleak
insmod coresight modules
rmmod coresight modules
echo scan > /sys/kernel/debug/kmemleak
The result shows no memory leak during a cycle of device registration
and unregistration.
---
Changes in v2:
- Refined the commit log in patch 06 (Suzuki).
- Unified to call coresight_unregister() for error handling (Suzuki).
- Refactor connection and sysfs group release.
- Link to v1: https://lore.kernel.org/linux-arm-kernel/20250512154108.23920-1-leo.yan@arm…
To: Suzuki K Poulose <suzuki.poulose(a)arm.com>
To: Mike Leach <mike.leach(a)linaro.org>
To: James Clark <james.clark(a)linaro.org>
To: Alexander Shishkin <alexander.shishkin(a)linux.intel.com>
To: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
To: Mathieu Poirier <mathieu.poirier(a)linaro.org>
To: Mao Jinlong <quic_jinlmao(a)quicinc.com>
Cc: coresight(a)lists.linaro.org
Cc: linux-arm-kernel(a)lists.infradead.org
Cc: linux-kernel(a)vger.kernel.org
Signed-off-by: Leo Yan <leo.yan(a)arm.com>
---
Leo Yan (8):
coresight: Fix memory leak in coresight_alloc_device_name()
coresight: Get parent device reference after sink ID map allocation
coresight: Protect unregistration with mutex
coresight: Refactor output connection sysfs link cleanup
coresight: Refactor sysfs connection group cleanup
coresight: Move sink validation into etm_perf_add_symlink_sink()
coresight: Do not mix success path with failure handling
coresight: Unify error handling in coresight_register()
drivers/hwtracing/coresight/coresight-core.c | 105 +++++++++++------------
drivers/hwtracing/coresight/coresight-etm-perf.c | 5 +-
drivers/hwtracing/coresight/coresight-platform.c | 2 +-
drivers/hwtracing/coresight/coresight-priv.h | 3 +-
4 files changed, 56 insertions(+), 59 deletions(-)
---
base-commit: eebe8dbd8630f51cf70b1f68a440cd3d7f7a914d
change-id: 20260120-arm_coresight_refactor_dev_register-f16c069db41d
Best regards,
--
Leo Yan <leo.yan(a)arm.com>
The first patch fixes an build failure issued caused by bitfield on the
stable kernel, the second patch is a minor polish to avoid including
redundant headers.
Verified for Arm64 perf building.
Signed-off-by: Leo Yan <leo.yan(a)arm.com>
---
Leo Yan (2):
tools: Fix bitfield dependency failure
perf: Remove redundant kernel.h include
tools/include/linux/bitfield.h | 1 +
tools/perf/arch/arm64/util/header.c | 1 -
tools/perf/util/cs-etm.c | 1 -
3 files changed, 1 insertion(+), 2 deletions(-)
---
base-commit: 800af362d68945e589f73cda429d04bfe4287feb
change-id: 20260123-perf_fix_bitfield-h-084902f55c35
Best regards,
--
Leo Yan <leo.yan(a)arm.com>