From: Jie Gan <jie.gan@oss.qualcomm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@linaro.org>,
James Clark <james.clark@linaro.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Tingwei Zhang <tingwei.zhang@oss.qualcomm.com>,
Jinlong Mao <jinlong.mao@oss.qualcomm.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
devicetree@vger.kernel.org, Jie Gan <jie.gan@oss.qualcomm.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Subject: [PATCH v6 0/9] coresight: ctcu: Enable byte-cntr function for TMC ETR
Date: Mon, 08 Sep 2025 10:01:52 +0800 [thread overview]
Message-ID: <20250908-enable-byte-cntr-for-tmc-v6-0-1db9e621441a@oss.qualcomm.com> (raw)
The byte-cntr function provided by the CTCU device is used to count the
trace data entering the ETR. 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.
Based on this concept, the irq_cnt can be used to determine whether
the etr_buf is full. The ETR device will be disabled when the active
etr_buf is nearly full or a timeout occurs. The nearly full buffer will
be switched to background after synced. A new buffer will be picked from
the etr_buf_list, then restart the ETR device.
The byte-cntr reading functions can access data from the synced and
deactivated buffer, transferring trace data from the etr_buf to userspace
without stopping the ETR device.
The byte-cntr read operation has integrated with the file node tmc_etr,
for example:
/dev/tmc_etr0
/dev/tmc_etr1
There are two scenarios for the tmc_etr file node with byte-cntr function:
1. BYTECNTRVAL register is configured and byte-cntr is enabled -> byte-cntr read
2. BYTECNTRVAL register is reset or byte-cntr is disabled -> original behavior
Shell commands to enable byte-cntr reading for etr0:
echo 0x10000 > /sys/bus/coresight/devices/ctcu0/irq_threshold
echo 1 > /sys/bus/coresight/devices/tmc_etr0/enable_sink
echo 1 > /sys/bus/coresight/devices/etm0/enable_source
cat /dev/tmc_etr0
Enable both ETR0 and ETR1:
echo 0x10000 0x10000 > /sys/bus/coresight/devices/ctcu0/irq_threshold
Reset the BYTECNTR register for etr0:
echo 0 > /sys/bus/coresight/devices/ctcu0/irq_threshold
Changes in V6:
1. rebased on next-20250905.
2. fixed the issue that the dtsi file has re-named from sa8775p.dtsi to
lemans.dtsi.
3. fixed some minor issues about comments.
Changes in V5:
1. Add Mike's reviewed-by tag for patchset 1,2,5.
2. Remove the function pointer added to helper_ops according to Mike's
comment, it also results the patchset has been removed.
3. Optimizing the paired create/clean functions for etr_buf_list.
4. Remove the unneeded parameter "reading" from the etr_buf_node.
Link to V4 - https://lore.kernel.org/all/20250725100806.1157-1-jie.gan@oss.qualcomm.com/
Changes in V4:
1. Rename the function to coresight_get_in_port_dest regarding to Mike's
comment (patch 1/10).
2. Add lock to protect the connections regarding to Mike's comment
(patch 2/10).
3. Move all byte-cntr functions to coresight-ctcu-byte-cntr file.
4. Add tmc_read_ops to wrap all read operations for TMC device.
5. Add a function in helper_ops to check whether the byte-cntr is
enabkled.
6. Call byte-cntr's read_ops if byte-cntr is enabled when reading data
from the sysfs node.
Link to V3 resend - https://lore.kernel.org/all/20250714063109.591-1-jie.gan@oss.qualcomm.com/
Changes in V3 resend:
1. rebased on next-20250711.
Link to V3 - https://lore.kernel.org/all/20250624060438.7469-1-jie.gan@oss.qualcomm.com/
Changes in V3:
1. The previous solution has been deprecated.
2. Add a etr_buf_list to manage allcated etr buffers.
3. Add a logic to switch buffer for ETR.
4. Add read functions to read trace data from synced etr buffer.
Link to V2 - https://lore.kernel.org/all/20250410013330.3609482-1-jie.gan@oss.qualcomm.com/
Changes in V2:
1. Removed the independent file node /dev/byte_cntr.
2. Integrated the byte-cntr's file operations with current ETR file
node.
3. Optimized the driver code of the CTCU that associated with byte-cntr.
4. Add kernel document for the export API tmc_etr_get_rwp_offset.
5. Optimized the way to read the rwp_offset according to Mike's
suggestion.
6. Removed the dependency of the dts patch.
Link to V1 - https://lore.kernel.org/all/20250310090407.2069489-1-quic_jiegan@quicinc.com/
Signed-off-by: Jie Gan <jie.gan@oss.qualcomm.com>
---
Jie Gan (9):
coresight: core: Refactoring ctcu_get_active_port and make it generic
coresight: core: add a new API to retrieve the helper device
coresight: tmc: add etr_buf_list to store allocated etr_buf
coresight: tmc: add create/clean functions for etr_buf_list
coresight: tmc: Introduce sysfs_read_ops to wrap sysfs read operations
dt-bindings: arm: add an interrupt property for Coresight CTCU
coresight: ctcu: enable byte-cntr for TMC ETR devices
coresight: tmc: integrate byte-cntr's read_ops with sysfs file_ops
arm64: dts: qcom: lemans: Add interrupts to CTCU device
.../ABI/testing/sysfs-bus-coresight-devices-ctcu | 6 +
.../bindings/arm/qcom,coresight-ctcu.yaml | 17 +
arch/arm64/boot/dts/qcom/lemans.dtsi | 5 +
drivers/hwtracing/coresight/Makefile | 2 +-
drivers/hwtracing/coresight/coresight-core.c | 59 ++++
.../hwtracing/coresight/coresight-ctcu-byte-cntr.c | 368 +++++++++++++++++++++
drivers/hwtracing/coresight/coresight-ctcu-core.c | 108 ++++--
drivers/hwtracing/coresight/coresight-ctcu.h | 62 +++-
drivers/hwtracing/coresight/coresight-priv.h | 4 +
drivers/hwtracing/coresight/coresight-tmc-core.c | 104 ++++--
drivers/hwtracing/coresight/coresight-tmc-etr.c | 112 +++++++
drivers/hwtracing/coresight/coresight-tmc.h | 38 +++
12 files changed, 826 insertions(+), 59 deletions(-)
---
base-commit: be5d4872e528796df9d7425f2bd9b3893eb3a42c
change-id: 20250906-enable-byte-cntr-for-tmc-0ca0a83e8f93
Best regards,
--
Jie Gan <jie.gan@oss.qualcomm.com>
next reply other threads:[~2025-09-08 2:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 2:01 Jie Gan [this message]
2025-09-08 2:01 ` [PATCH v6 1/9] coresight: core: Refactoring ctcu_get_active_port and make it generic Jie Gan
2025-12-03 16:18 ` Suzuki K Poulose
2025-12-04 2:45 ` Jie Gan
2025-09-08 2:01 ` [PATCH v6 2/9] coresight: core: add a new API to retrieve the helper device Jie Gan
2025-12-03 16:15 ` Suzuki K Poulose
2025-12-04 2:47 ` Jie Gan
2025-09-08 2:01 ` [PATCH v6 3/9] coresight: tmc: add etr_buf_list to store allocated etr_buf Jie Gan
2025-12-03 14:24 ` Mike Leach
2025-12-03 16:20 ` Suzuki K Poulose
2025-09-08 2:01 ` [PATCH v6 4/9] coresight: tmc: add create/clean functions for etr_buf_list Jie Gan
2025-12-03 14:26 ` Mike Leach
2025-09-08 2:01 ` [PATCH v6 5/9] coresight: tmc: Introduce sysfs_read_ops to wrap sysfs read operations Jie Gan
2025-09-08 2:01 ` [PATCH v6 6/9] dt-bindings: arm: add an interrupt property for Coresight CTCU Jie Gan
2025-12-03 14:30 ` Mike Leach
2025-12-04 2:49 ` Jie Gan
2025-12-03 18:14 ` Suzuki K Poulose
2025-12-04 2:53 ` Jie Gan
2025-12-04 9:22 ` Suzuki K Poulose
2025-12-05 1:01 ` Jie Gan
2025-09-08 2:01 ` [PATCH v6 7/9] coresight: ctcu: enable byte-cntr for TMC ETR devices Jie Gan
2025-09-08 2:02 ` [PATCH v6 8/9] coresight: tmc: integrate byte-cntr's read_ops with sysfs file_ops Jie Gan
2025-09-08 2:02 ` [PATCH v6 9/9] arm64: dts: qcom: lemans: Add interrupts to CTCU device Jie Gan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250908-enable-byte-cntr-for-tmc-v6-0-1db9e621441a@oss.qualcomm.com \
--to=jie.gan@oss.qualcomm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=coresight@lists.linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=james.clark@linaro.org \
--cc=jinlong.mao@oss.qualcomm.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.leach@linaro.org \
--cc=robh@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=tingwei.zhang@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).