On 10/03/2026 03:01, Jie Gan wrote:
>
>
> On 3/9/2026 8:43 PM, Suzuki K Poulose wrote:
>> On 09/03/2026 09:47, Jie Gan wrote:
>>> The byte-cntr function provided by the CTCU device is used to
>>> transfer data
>>> from the ETR buffer to the userspace. An interrupt is triggered if
>>> the data
>>> size exceeds the threshold set in the BYTECNTRVAL register. The
>>> interrupt
>>> handler counts the number of triggered interruptions and the read
>>> function
>>> will read the data from the synced ETR buffer.
>>>
>>> Switching the sysfs_buf when current buffer is full or the timeout is
>>> triggered and resets rrp and rwp registers after switched the buffer.
>>> The synced buffer will become available for reading after the switch.
>>>
>>> Signed-off-by: Jie Gan <jie.gan(a)oss.qualcomm.com>
>>> ---
>>> .../ABI/testing/sysfs-bus-coresight-devices-ctcu | 8 +
>>> drivers/hwtracing/coresight/Makefile | 2 +-
>>> .../hwtracing/coresight/coresight-ctcu-byte-cntr.c | 351 ++++++++++
>>> + ++++++++++
>>> drivers/hwtracing/coresight/coresight-ctcu-core.c | 103 +++++-
>>> drivers/hwtracing/coresight/coresight-ctcu.h | 76 ++++-
>>> drivers/hwtracing/coresight/coresight-tmc-core.c | 8 +-
>>> drivers/hwtracing/coresight/coresight-tmc-etr.c | 18 ++
>>> drivers/hwtracing/coresight/coresight-tmc.h | 4 +
>>> 8 files changed, 555 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-
>>> ctcu b/Documentation/ABI/testing/sysfs-bus-coresight-devices-ctcu
>>> new file mode 100644
>>> index 000000000000..6ff1708fb944
>>> --- /dev/null
>>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-ctcu
>>> @@ -0,0 +1,8 @@
>>> +What: /sys/bus/coresight/devices/<ctcu-name>/
>>> irq_threshold[0:1]
>>> +Date: March 2026
>>> +KernelVersion: 7.1
>>> +Contact: Tingwei Zhang <tingwei.zhang(a)oss.qualcomm.com>;
>>> Jinlong Mao <jinlong.mao(a)oss.qualcomm.com>; Jie Gan
>>> <jie.gan(a)oss.qualcomm.com>
>>> +Description:
>>> + (RW) Configure the byte-cntr IRQ register for the specified
>>> ETR device
>>> + based on its port number. An interrupt is generated when the
>>> data size
>>> + exceeds the value set in the IRQ register.
>>> diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/
>>> hwtracing/ coresight/Makefile
>>> index ab16d06783a5..821a1b06b20c 100644
>>> --- a/drivers/hwtracing/coresight/Makefile
>>> +++ b/drivers/hwtracing/coresight/Makefile
>>> @@ -55,5 +55,5 @@ coresight-cti-y := coresight-cti-core.o coresight-
>>> cti-platform.o \
>>> obj-$(CONFIG_ULTRASOC_SMB) += ultrasoc-smb.o
>>> obj-$(CONFIG_CORESIGHT_DUMMY) += coresight-dummy.o
>>> obj-$(CONFIG_CORESIGHT_CTCU) += coresight-ctcu.o
>>> -coresight-ctcu-y := coresight-ctcu-core.o
>>> +coresight-ctcu-y := coresight-ctcu-core.o coresight-ctcu-byte-cntr.o
>>> obj-$(CONFIG_CORESIGHT_KUNIT_TESTS) += coresight-kunit-tests.o
>>> diff --git a/drivers/hwtracing/coresight/coresight-ctcu-byte-cntr.c
>>> b/ drivers/hwtracing/coresight/coresight-ctcu-byte-cntr.c
>>> new file mode 100644
>>> index 000000000000..0bf738d6c283
>>> --- /dev/null
>>> +++ b/drivers/hwtracing/coresight/coresight-ctcu-byte-cntr.c
>>> @@ -0,0 +1,351 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +/*
>>> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
>>> + */
>>> +
>>> +#include <linux/coresight.h>
>>> +#include <linux/device.h>
>>> +#include <linux/fs.h>
>>> +#include <linux/interrupt.h>
>>> +#include <linux/of_irq.h>
>>> +#include <linux/uaccess.h>
>>> +
>>> +#include "coresight-ctcu.h"
>>> +#include "coresight-priv.h"
>>> +#include "coresight-tmc.h"
>>> +
>>> +static irqreturn_t byte_cntr_handler(int irq, void *data)
>>> +{
>>> + struct ctcu_byte_cntr *byte_cntr_data = (struct ctcu_byte_cntr
>>> *)data;
>>> +
>>> + atomic_inc(&byte_cntr_data->irq_cnt);
>>> + wake_up(&byte_cntr_data->wq);
>>> +
>>> + return IRQ_HANDLED;
>>> +}
>>> +
>>> +static void ctcu_reset_sysfs_buf(struct tmc_drvdata *drvdata)
>>
>> minor nit: This has nothing to do with the CTCU. For what it is worth,
>> it must be called, tmc_etr_reset_sysf_buf(). But more on this below,
>> and even do we need it, further below.
>>
>>> +{
>>> + u32 sts;
>>> +
>>> + CS_UNLOCK(drvdata->base);
>>> + tmc_write_rrp(drvdata, drvdata->sysfs_buf->hwaddr);
>>> + tmc_write_rwp(drvdata, drvdata->sysfs_buf->hwaddr);
>>> + sts = readl_relaxed(drvdata->base + TMC_STS) & ~TMC_STS_FULL;
>>> + writel_relaxed(sts, drvdata->base + TMC_STS);
>>> + CS_LOCK(drvdata->base);
>>
>> Could we not keep this function in the tmc-etr.c and invoke from here ?
>>
>
> Sure, will move the function tmc-etr.c
>
>>> +}
>>> +
>>> +static void ctcu_cfg_byte_cntr_reg(struct tmc_drvdata *drvdata, u32
>>> val, u32 offset)
>>> +{
>>> + struct ctcu_drvdata *ctcu_drvdata;
>>> + struct coresight_device *helper;
>>> +
>>> + helper = tmc_etr_get_ctcu_device(drvdata);
>>> + if (!helper)
>>> + return;
>>> +
>>> + ctcu_drvdata = dev_get_drvdata(helper->dev.parent);
>>> + /* A one value for IRQCTRL register represents 8 bytes */
>>> + ctcu_program_register(ctcu_drvdata, val / 8, offset);
>>> +}
>>> +
>>> +static struct ctcu_byte_cntr *ctcu_get_byte_cntr_data(struct
>>> tmc_drvdata *drvdata)
>>> +{
>>> + struct ctcu_byte_cntr *byte_cntr_data;
>>> + struct ctcu_drvdata *ctcu_drvdata;
>>> + struct coresight_device *helper;
>>> + int port;
>>> +
>>> + helper = tmc_etr_get_ctcu_device(drvdata);
>>> + if (!helper)
>>> + return NULL;
>>> +
>>
>>
>>
>>> + port = coresight_get_in_port(drvdata->csdev, helper);
>>> + if (port < 0)
>>> + return NULL;
>>> +
>>
>> Please validate that the port_num you get is valid for the CTCU ? That
>> applies to all uses of this construct.
>>
>
> Will validate it before using.
>
>>> + ctcu_drvdata = dev_get_drvdata(helper->dev.parent);
>>> + byte_cntr_data = &ctcu_drvdata->byte_cntr_data[port];
>>> + return byte_cntr_data;
>>
>>
>>
>> nit:
>> return &ctcu_drvdata->byte_cntr_data[port]; ?
>>
>> Also, why not make this into a helper, as we seem to use this other
>> places too ?
>>
>
> Didnt get the point here. We may run more than one ETR devices
> concurrently. So we should get the proper byte_cntr_data according to
> the port number at runtime.
>
static struct ctcu_byte_cntr *ctcu_byte_cntr(struct coresight_device
*cctcu_dev, struct coresight_device *tmc_etr, ) {
port = coresight_get_in_port()..
// Verify the port in this helper and everyone uses this.
if (//!validate_port//)
return NULL
return ...
}
Suzuki
Finish removal of ETM_OPT_* defines so the coresight-pmu.h header can
by synced from the kernel.
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
Changes in v2:
- Access metadata through existing etm pointer (Leo)
- Link to v1: https://lore.kernel.org/r/20260306-james-perf-remove-etm_opt-v1-0-03c662380…
---
James Clark (2):
perf cs-etm: Finish removal of ETM_OPT_*
tools: Sync coresight-pmu.h header
tools/include/linux/coresight-pmu.h | 24 -----------------
tools/perf/arch/arm/util/cs-etm.c | 14 ----------
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 2 +-
tools/perf/util/cs-etm.c | 36 +++++++++----------------
tools/perf/util/cs-etm.h | 15 +++++++++++
5 files changed, 29 insertions(+), 62 deletions(-)
---
base-commit: b1718b0367ba31e8db273e3896ebd1707bcbe59e
change-id: 20260306-james-perf-remove-etm_opt-c0e9a768dce8
Best regards,
--
James Clark <james.clark(a)linaro.org>
Finish removal of ETM_OPT_* defines so the coresight-pmu.h header can
by synced from the kernel.
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
James Clark (2):
perf cs-etm: Finish removal of ETM_OPT_*
tools: Sync coresight-pmu.h header
tools/include/linux/coresight-pmu.h | 24 -----------------
tools/perf/arch/arm/util/cs-etm.c | 14 ----------
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 2 +-
tools/perf/util/cs-etm.c | 36 +++++++++----------------
tools/perf/util/cs-etm.h | 15 +++++++++++
5 files changed, 28 insertions(+), 63 deletions(-)
---
base-commit: b1718b0367ba31e8db273e3896ebd1707bcbe59e
change-id: 20260306-james-perf-remove-etm_opt-c0e9a768dce8
Best regards,
--
James Clark <james.clark(a)linaro.org>
The CPU power management issue in the CTI driver was first observed in
series [1]; this series resolves that issue. It fixes bugs and removes
CPU PM operations from the CoreSight CTI driver, the goal is to use the
CoreSight core layer as the central place for CPU power management.
Removing CPU PM from CTI driver can avoid conflicts with the core layer.
This series can be divided into:
Patches 01 ~ 02: Fix spinlock with irqsave and register read with CS
lock.
Patches 03 ~ 08: Access ASICCTL condintioanlly, remove CPU PM code,
and refactor register access in sysfs knob.
This series is based on coresight-next branch and has been validated on
Juno r2 platforms, pass normal sysfs and perf test, as well as CPU PM
stress testing.
[1] https://lore.kernel.org/all/20250915-arm_coresight_power_management_fix-v3-…
Signed-off-by: Leo Yan <leo.yan(a)arm.com>
---
Changes in v2:
- Rebased on coresight-next branch (v7.1).
- Kept read/write cache value in sysfs knob (Mike).
- Link to v1: https://lore.kernel.org/r/20260209-arm_coresight_cti_refactor_v1-v1-0-db71a…
---
Leo Yan (8):
coresight: cti: Make spinlock usage consistent
coresight: cti: Fix register reads
coresight: cti: Access ASICCTL only when implemented
coresight: cti: Remove CPU power management code
coresight: cti: Rename cti_active() to cti_is_active()
coresight: cti: Remove hw_powered flag
coresight: cti: Remove hw_enabled flag
coresight: cti: Properly handle negative offsets in cti_reg32_{show|store}()
drivers/hwtracing/coresight/coresight-cti-core.c | 278 ++++------------------
drivers/hwtracing/coresight/coresight-cti-sysfs.c | 171 ++++++-------
drivers/hwtracing/coresight/coresight-cti.h | 13 +-
3 files changed, 137 insertions(+), 325 deletions(-)
---
base-commit: eef33a7cce239783d0422526a4d786289a936f1b
change-id: 20251223-arm_coresight_cti_refactor_v1-76e1bda8b716
Best regards,
--
Leo Yan <leo.yan(a)arm.com>
On Sat, 28 Feb 2026 18:23:44 -0400, Elsanti wrote:
> The variable 'ret' is initialized to 0, never modified, and returned
> directly. Remove it and return 0 explicitly.
>
>
Applied, thanks!
[1/1] drivers/hwtracing/coresight: remove unneeded variable in tmc_crashdata_release()
https://git.kernel.org/coresight/c/061c39a17136
Best regards,
--
Suzuki K Poulose <suzuki.poulose(a)arm.com>