All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yemike Abhilash Chandra" <y-abhilashchandra@ti.com>
Cc: conor+dt@kernel.org, imx@lists.linux.dev, robh@kernel.org,
	Frank.Li@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 03/18] arm64: dts: ti: k3-j721s2-main: Add multiple channels for CSI2RX DMA
Date: Thu, 02 Jul 2026 09:55:39 +0000	[thread overview]
Message-ID: <20260702095540.E01341F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260702093123.1048575-4-y-abhilashchandra@ti.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] DMA channels are permanently leaked during early probe failures and during module unbind due to a flawed PM runtime status check.
- [High] Missing `pm_runtime_disable()` in the `probe` function's error paths leads to an unbalanced and permanently enabled PM runtime state.
--

commit 79fa01b02ba17aabe215aeb8794e92dac90f80ad
Author: Vaishnav Achath <vaishnav.a@ti.com>

arm64: dts: ti: k3-j721s2-main: Add multiple channels for CSI2RX DMA

J721E CSI2RX SHIM layer can support up to 32 DMA channel contexts. Add
additional DMA channels to enable multistream support for CSI2RX.

> diff --git a/arch/arm64/boot/dts/ti/k3-j721s2-main.dtsi b/arch/arm64/boot/dts/ti/k3-j721s2-main.dtsi
> index 5cac119e4292a..f4b8713873b17 100644
> --- a/arch/arm64/boot/dts/ti/k3-j721s2-main.dtsi
> +++ b/arch/arm64/boot/dts/ti/k3-j721s2-main.dtsi
> @@ -1239,8 +1239,11 @@ ti_csi2rx0: ticsi2rx@4500000 {
>  		ranges;
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> -		dmas = <&main_bcdma_csi 0 0x4940 0>;
> -		dma-names = "rx0";
> +		dmas = <&main_bcdma_csi 0 0x4940 0>, <&main_bcdma_csi 0 0x4941 0>,
> +		       <&main_bcdma_csi 0 0x4942 0>, <&main_bcdma_csi 0 0x4943 0>,
> +		       <&main_bcdma_csi 0 0x4944 0>, <&main_bcdma_csi 0 0x4945 0>,
> +		       <&main_bcdma_csi 0 0x4946 0>, <&main_bcdma_csi 0 0x4947 0>;
> +		dma-names = "rx0", "rx1", "rx2", "rx3", "rx4", "rx5", "rx6", "rx7";

[Severity: High]
This isn't a bug introduced by this patch, but increasing the channel
allocations from 1 to 8 will exhaust the system's DMA engine much faster due
to an existing channel leak in the driver.

During an early probe failure before pm_runtime_set_active() is called, the
device status defaults to RPM_SUSPENDED.

In drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c:ti_csi2rx_cleanup_ctx(),
the driver checks this status:

    if (!pm_runtime_status_suspended(ctx->csi->dev))
        dma_release_channel(ctx->dma.chan);

Because the status is already suspended, it wrongly assumes the channels were
freed by a suspend callback and skips releasing them.

This same leak also happens on module unbind. In ti_csi2rx_remove(), if the
device is active, the driver forces the state to suspended without disabling PM
runtime first:

    if (!pm_runtime_status_suspended(&pdev->dev))
        pm_runtime_set_suspended(&pdev->dev);

This alters the status without invoking the runtime_suspend callback that would
normally free the channels. Does it make sense to fix this PM state handling
so these newly added DMA channels aren't permanently leaked?

[Severity: High]
This is a pre-existing issue, but there is also a missing pm_runtime_disable()
in the probe error path that could cause PM state tracking issues when this
node fails to probe.

If ti_csi2rx_notifier_register() or devm_of_platform_populate() fails, the code
jumps to err_ctx:

drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c:ti_csi2rx_probe() {
    ...
err_ctx:
    while (i--)
        ti_csi2rx_cleanup_ctx(&csi->ctx[i]);
    ti_csi2rx_cleanup_v4l2(csi);
err_dma_chan:
    ...
}

This error path misses a call to pm_runtime_disable(), leaving the PM runtime
disable_depth unbalanced. When a subsequent probe attempt calls
pm_runtime_enable() again, could the disable_depth underflow and break power
management for the device?

>  		power-domains = <&k3_pds 38 TI_SCI_PD_EXCLUSIVE>;
>  		status = "disabled";

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260702093123.1048575-1-y-abhilashchandra@ti.com?part=3

  reply	other threads:[~2026-07-02  9:55 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  9:31 [PATCH 00/18] Add DT support for CSI2RX multi-stream Yemike Abhilash Chandra
2026-07-02  9:31 ` [PATCH 01/18] arm64: dts: ti: k3-{j721e/j721s2}-main: Fix indentation in CSI2RX node Yemike Abhilash Chandra
2026-07-02  9:31 ` [PATCH 02/18] arm64: dts: ti: k3-j721e-main: Add multiple channels for CSI2RX DMA Yemike Abhilash Chandra
2026-07-02  9:31 ` [PATCH 03/18] arm64: dts: ti: k3-j721s2-main: " Yemike Abhilash Chandra
2026-07-02  9:55   ` sashiko-bot [this message]
2026-07-02  9:31 ` [PATCH 04/18] arm64: dts: ti: k3-j784s4-j742s2-main-common: " Yemike Abhilash Chandra
2026-07-02  9:46   ` sashiko-bot
2026-07-02  9:31 ` [PATCH 05/18] arm64: dts: ti: k3-am62p-j722s: " Yemike Abhilash Chandra
2026-07-02  9:31 ` [PATCH 06/18] arm64: dts: ti: k3-j722s-main: " Yemike Abhilash Chandra
2026-07-02  9:47   ` sashiko-bot
2026-07-02  9:31 ` [PATCH 07/18] arm64: dts: ti: k3-j721e: Add overlay for fusion application daughter board Yemike Abhilash Chandra
2026-07-02  9:47   ` sashiko-bot
2026-07-02  9:31 ` [PATCH 08/18] arm64: dts: ti: k3-j721s2: " Yemike Abhilash Chandra
2026-07-02  9:45   ` sashiko-bot
2026-07-02  9:31 ` [PATCH 09/18] arm64: dts: ti: k3-j721e-sk: " Yemike Abhilash Chandra
2026-07-02  9:50   ` sashiko-bot
2026-07-02  9:31 ` [PATCH 10/18] arm64: dts: ti: k3-j722s-evm: " Yemike Abhilash Chandra
2026-07-02  9:48   ` sashiko-bot
2026-07-02  9:31 ` [PATCH 11/18] arm64: dts: ti: k3-am68-sk: Add overlay for dual Arducam V3link fusion Yemike Abhilash Chandra
2026-07-02  9:31 ` [PATCH 12/18] arm64: dts: ti: k3-j722s-evm: " Yemike Abhilash Chandra
2026-07-02  9:31 ` [PATCH 13/18] arm64: dts: ti: k3-j784s4-evm: Add overlay for J7EXPA01EVM Fusion2 Yemike Abhilash Chandra
2026-07-02  9:31 ` [PATCH 14/18] arm64: dts: ti: k3-j722s-evm: " Yemike Abhilash Chandra
2026-07-02  9:31 ` [PATCH 15/18] arm64: dts: ti: k3-j721s2: Add overlay for DS90UB954-Q1EVM Yemike Abhilash Chandra
2026-07-02  9:55   ` sashiko-bot
2026-07-02  9:31 ` [PATCH 16/18] arm64: dts: ti: k3-j721e: " Yemike Abhilash Chandra
2026-07-02  9:31 ` [PATCH 17/18] arm64: dts: ti: k3-v3link: Add overlay for IMX219+UB953 serializer Yemike Abhilash Chandra
2026-07-02 10:04   ` sashiko-bot
2026-07-02  9:31 ` [PATCH 18/18] arm64: defconfig: Enable DS90UB960 deserializer and DS90UB953 serializer Yemike Abhilash Chandra
2026-07-02 10:54   ` Krzysztof Kozlowski
2026-07-06  9:45     ` Yemike Abhilash Chandra

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=20260702095540.E01341F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=y-abhilashchandra@ti.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 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.