Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yemike Abhilash Chandra" <y-abhilashchandra@ti.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org,
	imx@lists.linux.dev, Frank.Li@kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 03/18] arm64: dts: ti: k3-j721s2-main: Add multiple channels for CSI2RX DMA
Date: Mon, 13 Jul 2026 11:48:52 +0000	[thread overview]
Message-ID: <20260713114853.3CD6E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260713113423.2310443-4-y-abhilashchandra@ti.com>

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

Pre-existing issues:
- [High] Leakage of allocated DMA channels during driver probe error paths due to flawed PM runtime status check.
- [High] Missing `pm_runtime_disable()` in the `ti_csi2rx_probe` error path.
- [High] Leakage of successfully requested DMA channels on partial `runtime_resume` failures.
- [High] Unreachable stream validation error check silently ignores missing streams.
--

--- Patch [3]: [PATCH v2 03/18] arm64: dts: ti: k3-j721s2-main: Add multiple channels for CSI2RX DMA ---
commit aa226bddd4872f73702e34f1bec61a88480652a0
Author: Vaishnav Achath <vaishnav.a@ti.com>

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

This commit adds additional DMA channels to the J721E CSI2RX SHIM layer
device tree node. It enables multistream support by expanding the dmas
and dma-names properties to handle up to 8 channels per node.

> 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 scaling up the number of
channels in the device tree makes a DMA channel leak regression worse on
probe errors in the driver.

If ti_csi2rx_probe() in drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
fails midway through initializing these new contexts, it cleans up here:

err_ctx:
        while (i--)
                ti_csi2rx_cleanup_ctx(&csi->ctx[i]);

However, ti_csi2rx_cleanup_ctx() has this check:

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

Since pm_runtime_set_active() hasn't been called yet during early probe,
the device is still in its default RPM_SUSPENDED state. Will this cause
the DMA channels to be permanently leaked when probe fails?

[Severity: High]
This is another pre-existing issue, but the addition of multiple DMA channels
also increases the impact of a leak during runtime resume:

drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c:ti_csi2rx_runtime_resume()
        for (unsigned int i = 0; i < csi->num_ctx; i++) {
                ret = ti_csi2rx_init_dma(&csi->ctx[i]);
                if (ret)
                        return ret;
        }

If ti_csi2rx_init_dma() fails for a later channel (e.g., rx4), the function
returns immediately without an error unwind path. Do the channels
successfully requested in earlier iterations get stranded indefinitely since
runtime_suspend won't be called?

[Severity: High]
This is a pre-existing issue in the probe error path that leaves a dangling
PM configuration:

drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c:ti_csi2rx_probe()
err_notifier:
        ti_csi2rx_cleanup_notifier(csi);
err_ctx:
        while (i--)
                ti_csi2rx_cleanup_ctx(&csi->ctx[i]);
        ti_csi2rx_cleanup_v4l2(csi);
err_dma_chan:
        dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr,
                          csi->drain.paddr);
        return ret;

This path executes after pm_runtime_enable(csi->dev) has been called. Should
pm_runtime_disable() be called here before returning to unroll the PM
enablement?

[Severity: High]
This is a pre-existing issue, but it breaks stream validation for multistream
setups.

In ti_csi2rx_get_vc_and_dt(), the loop searches for a matching stream:

drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c:ti_csi2rx_get_vc_and_dt()
        for (j = 0; j < fd.num_entries; j++) {
                ...
                        /* Return error if no matching stream found */
                        if (j == fd.num_entries)
                                return -EINVAL;
        }

Since the if statement is completely inside the for-loop where
j < fd.num_entries, it is mathematically impossible for the condition to
evaluate to true. Could the driver silently proceed with incorrect
hardware configurations if a requested stream is missing?

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

[ ... ]

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

  reply	other threads:[~2026-07-13 11:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 11:34 [PATCH v2 00/18] Add DT support for CSI2RX multi-stream Yemike Abhilash Chandra
2026-07-13 11:34 ` [PATCH v2 01/18] arm64: dts: ti: k3-{j721e/j721s2}-main: Fix indentation in CSI2RX node Yemike Abhilash Chandra
2026-07-13 11:34 ` [PATCH v2 02/18] arm64: dts: ti: k3-j721e-main: Add multiple channels for CSI2RX DMA Yemike Abhilash Chandra
2026-07-13 11:47   ` sashiko-bot
2026-07-13 11:34 ` [PATCH v2 03/18] arm64: dts: ti: k3-j721s2-main: " Yemike Abhilash Chandra
2026-07-13 11:48   ` sashiko-bot [this message]
2026-07-13 11:34 ` [PATCH v2 04/18] arm64: dts: ti: k3-j784s4-j742s2-main-common: " Yemike Abhilash Chandra
2026-07-13 11:50   ` sashiko-bot
2026-07-13 11:34 ` [PATCH v2 05/18] arm64: dts: ti: k3-am62p-j722s: " Yemike Abhilash Chandra
2026-07-13 11:49   ` sashiko-bot
2026-07-13 11:34 ` [PATCH v2 06/18] arm64: dts: ti: k3-j722s-main: " Yemike Abhilash Chandra
2026-07-13 11:34 ` [PATCH v2 07/18] arm64: dts: ti: k3-j721e: Add overlay for fusion application daughter board Yemike Abhilash Chandra
2026-07-13 11:34 ` [PATCH v2 08/18] arm64: dts: ti: k3-j721s2: " Yemike Abhilash Chandra
2026-07-13 11:34 ` [PATCH v2 09/18] arm64: dts: ti: k3-j721e-sk: " Yemike Abhilash Chandra
2026-07-13 11:34 ` [PATCH v2 10/18] arm64: dts: ti: k3-j722s-evm: " Yemike Abhilash Chandra
2026-07-13 11:34 ` [PATCH v2 11/18] arm64: dts: ti: k3-am68-sk: Add overlay for dual Arducam V3link fusion Yemike Abhilash Chandra
2026-07-13 11:47   ` sashiko-bot
2026-07-13 11:34 ` [PATCH v2 12/18] arm64: dts: ti: k3-j722s-evm: " Yemike Abhilash Chandra
2026-07-13 11:45   ` sashiko-bot
2026-07-13 11:34 ` [PATCH v2 13/18] arm64: dts: ti: k3-j784s4-evm: Add overlay for J7EXPA01EVM Fusion2 Yemike Abhilash Chandra
2026-07-13 11:45   ` sashiko-bot
2026-07-13 11:34 ` [PATCH v2 14/18] arm64: dts: ti: k3-j722s-evm: " Yemike Abhilash Chandra
2026-07-13 11:47   ` sashiko-bot
2026-07-13 11:34 ` [PATCH v2 15/18] arm64: dts: ti: k3-j721s2: Add overlay for DS90UB954-Q1EVM Yemike Abhilash Chandra
2026-07-13 11:34 ` [PATCH v2 16/18] arm64: dts: ti: k3-j721e: " Yemike Abhilash Chandra
2026-07-13 11:34 ` [PATCH v2 17/18] arm64: dts: ti: k3-v3link: Add overlay for IMX219+UB953 serializer Yemike Abhilash Chandra
2026-07-13 11:34 ` [PATCH v2 18/18] arm64: defconfig: Enable DS90UB960 deserializer and DS90UB953 serializer 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=20260713114853.3CD6E1F00A3A@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox