All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jie Gan" <jie.gan@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v23 8/8] arm64: dts: qcom: lemans: add interrupts to CTCU device
Date: Wed, 18 Nov 2026 08:25:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-220438@kernel.org> (raw)
In-Reply-To: <20261118-enable-byte-cntr-for-ctcu-v23-8-67fd9db6bc0e@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] coresight: ctcu: premature read_lock release in
  tmc_byte_cntr_get_data()
- [Medium] coresight: tmc: negative error codes swallowed as EOF in
  tmc_read()
--

commit edad46341b45ed2bbca9daa024c7d236792c6c79
Author: Jie Gan <jie.gan@oss.qualcomm.com>

arm64: dts: qcom: lemans: add interrupts to CTCU device

This commit adds the byte-cntr interrupt lines to the CTCU device node on
Qualcomm Lemans (SA8775P) to enable TMC ETR byte-cntr trace reading.

> diff --git a/arch/arm64/boot/dts/qcom/lemans.dtsi b/arch/arm64/boot/dts/qcom/lemans.dtsi
> index 1fdb72fa55184..852a1142100fa 100644
> --- a/arch/arm64/boot/dts/qcom/lemans.dtsi
> +++ b/arch/arm64/boot/dts/qcom/lemans.dtsi
> @@ -3132,6 +3132,9 @@ ctcu@4001000 {
>  			clocks = <&aoss_qmp>;
>  			clock-names = "apb";
>  
> +			interrupts = <GIC_SPI 270 IRQ_TYPE_EDGE_RISING>,
> +				     <GIC_SPI 262 IRQ_TYPE_EDGE_RISING>;
> +
>  			in-ports {
>  				#address-cells = <1>;
>  				#size-cells = <0>;

[Severity: Medium]
In commit "coresight: ctcu: enable byte-cntr for TMC ETR devices" that this
DT change enables, does tmc_byte_cntr_get_data() release
byte_cntr_data->read_lock too early before tmc_read() finishes copying from
byte_cntr_data->buf_node and updating its position?

Because /dev/tmc_etr* is a misc character device opened with
nonseekable_open(), concurrent read() calls on the same open file
descriptor are not serialized by file->f_pos_lock.  tmc_byte_cntr_get_data()
scopes read_guard to itself, so copy_to_user() and
tmc_etr_update_buf_node_pos() in tmc_read() run after read_lock is dropped:

CPU0                                    CPU1
tmc_read()
  tmc_get_sysfs_trace()
    tmc_byte_cntr_get_data()
      lock(&byte_cntr_data->read_lock)
      pos = buf_node->pos
      tmc_etr_read_sysfs_buf(...)
      unlock(&byte_cntr_data->read_lock)
  copy_to_user(data, bufp, actual)
                                        tmc_read()
                                          tmc_get_sysfs_trace()
                                            tmc_byte_cntr_get_data()
                                              ...
                                              actual == 0:
                                              buf_node->reading = false
                                              buf_node = NULL
                                              goto wait_buffer
                                              tmc_etr_switch_buf_node()
                                                <-- restarts ETR DMA into
                                                    bufp while CPU0 copies
  tmc_etr_update_buf_node_pos()
    nd->pos += size  <-- advances newly switched buf_node->pos

While CPU0 sleeps in copy_to_user(), CPU1 can read from the unadvanced
buf_node->pos, drain the buffer, clear buf_node->reading, and call
tmc_etr_switch_buf_node(), handing the buffer back to the ETR hardware for
active DMA while CPU0 is still copying from it and leaving CPU0 to add its
read size to the newly switched buffer's nd->pos.

[Severity: Medium]
Also in commit "coresight: ctcu: enable byte-cntr for TMC ETR devices",
does tmc_read() turn negative error codes from tmc_byte_cntr_get_data()
into EOF?

drivers/hwtracing/coresight/coresight-tmc-core.c:tmc_read() {
	...
	actual = tmc_get_sysfs_trace(drvdata, *ppos, len, &bufp);
	if (actual <= 0)
		return 0;

tmc_etr_get_sysfs_trace() propagates negative errors from
byte_cntr_ops->get_trace_data(), such as -ERESTARTSYS when
wait_event_interruptible_timeout() is interrupted by a signal, -EINTR,
-ENOMEM, or -ENODEV.  Because tmc_read() returns 0 whenever actual <= 0,
a signal or failure during a byte-cntr read reports EOF and terminates trace
collection early instead of restarting the syscall or returning the error to
userspace.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-enable-byte-cntr-for-ctcu-v23-0-67fd9db6bc0e@oss.qualcomm.com?part=8

      reply	other threads:[~2026-11-18  8:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  8:02 [PATCH v23 0/8] coresight: ctcu: Enable byte-cntr function for TMC ETR Jie Gan
2026-11-18  8:02 ` [PATCH v23 1/8] coresight: core: refactor ctcu_get_active_port and make it generic Jie Gan
2026-11-18  8:02 ` [PATCH v23 2/8] coresight: tmc: add create/clean functions for etr_buf_list Jie Gan
2026-11-18  8:02 ` [PATCH v23 3/8] coresight: tmc: add a function to switch the ETR to a free etr_buf Jie Gan
2026-11-18  8:20   ` sashiko-bot
2026-11-18  8:02 ` [PATCH v23 4/8] coresight: tmc: introduce tmc_sysfs_ops to wrap sysfs read operations Jie Gan
2026-11-18  8:02 ` [PATCH v23 5/8] coresight: etr: add a new function to retrieve the CTCU device Jie Gan
2026-11-18  8:02 ` [PATCH v23 6/8] dt-bindings: arm: add an interrupt property for Coresight CTCU Jie Gan
2026-11-18  8:02 ` [PATCH v23 7/8] coresight: ctcu: enable byte-cntr for TMC ETR devices Jie Gan
2026-11-18  8:40   ` sashiko-bot
2026-11-18  8:02 ` [PATCH v23 8/8] arm64: dts: qcom: lemans: add interrupts to CTCU device Jie Gan
2026-11-18  8:25   ` sashiko-bot [this message]

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=sashiko-outbox-220438@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jie.gan@oss.qualcomm.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.