Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rishikesh Donadkar" <r-donadkar@ti.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v13 07/17] media: cadence: csi2rx: Move to .enable/disable_streams API
Date: Wed, 20 May 2026 12:39:48 +0000	[thread overview]
Message-ID: <20260520123949.49B3F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260520120022.539913-8-r-donadkar@ti.com>

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

New issues:
- [High] Source subdev streams are unconditionally enabled and disabled, breaking multi-stream reference counting.

Pre-existing issues:
- [High] Accessing the D-PHY lane control register after its peripheral clock is disabled and reset is asserted.
--

commit 5179e5527e6b2b1932479629edc9186d143ce51c
Author: Rishikesh Donadkar <r-donadkar@ti.com>
Subject: media: cadence: csi2rx: Move to .enable/disable_streams API

This patch updates the cadence csi2rx driver to use the V4L2
enable_streams() and disable_streams() API rather than s_stream(). It
also drops the local stream start/stop mutex, relying instead on V4L2
core serialization.

> diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
> index cde690c6fdee6..2b25314ba6ab0 100644
> --- a/drivers/media/platform/cadence/cdns-csi2rx.c
> +++ b/drivers/media/platform/cadence/cdns-csi2rx.c
[ ... ]
> @@ -459,9 +448,6 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx)
>  	reset_control_assert(csi2rx->p_rst);
>  	clk_disable_unprepare(csi2rx->p_clk);
>  
> -	if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false))
> -		dev_warn(csi2rx->dev, "Couldn't disable our subdev\n");
> -
>  	if (csi2rx->dphy) {
>  		writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);

[Severity: High]
This is a pre-existing issue, but can this sequence cause a bus hang?

This function asserts csi2rx->p_rst and disables csi2rx->p_clk, but then
subsequently writes to CSI2RX_DPHY_LANE_CTRL_REG. Writing to a memory-mapped
I/O register while its bus clock is turned off and the peripheral is held in
reset can cause synchronous external aborts on ARM platforms.

I notice this is resolved later in the series by commit a72fbe3bfad52
("media: cadence: csi2rx: Support runtime PM"), which moves the clock disable
sequence into runtime_suspend() so the register is accessed while clocks are
still enabled.

>  
> @@ -485,38 +471,56 @@ static int csi2rx_log_status(struct v4l2_subdev *sd)
[ ... ]
> +static int csi2rx_enable_streams(struct v4l2_subdev *subdev,
> +				 struct v4l2_subdev_state *state, u32 pad,
> +				 u64 streams_mask)
>  {
>  	struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev);
> -	int ret = 0;
> -
> -	mutex_lock(&csi2rx->lock);
> -
> -	if (enable) {
> -		/*
> -		 * If we're not the first users, there's no need to
> -		 * enable the whole controller.
> -		 */
> -		if (!csi2rx->count) {
> -			ret = csi2rx_start(csi2rx);
> -			if (ret)
> -				goto out;
> -		}
> +	int ret;
>  
> -		csi2rx->count++;
> -	} else {
> -		csi2rx->count--;
> +	/*
> +	 * If we're not the first users, there's no need to
> +	 * enable the whole controller.
> +	 */
> +	if (!csi2rx->count) {
> +		ret = csi2rx_start(csi2rx);
> +		if (ret)
> +			return ret;
> +	}
>  
> -		/*
> -		 * Let the last user turn off the lights.
> -		 */
> +	/* Start streaming on the source */
> +	ret = v4l2_subdev_enable_streams(csi2rx->source_subdev, csi2rx->source_pad,
> +					 BIT_U64(0));

[Severity: High]
Will this break the ability to start multiple independent streams?

Since v4l2_subdev_enable_streams() is called unconditionally outside the
if (!csi2rx->count) block, a second stream start will call it again with the
exact same mask BIT_U64(0). Because the V4L2 core tracks enabled streams,
won't this second call fail and return -EALREADY?

I see this is fixed later in the series in commit dc92c5b7cb43f ("media:
cadence: csi2rx: add multistream support"), which translates pad-specific
stream masks into disjoint sink_streams masks to avoid the -EALREADY
collision, but does this intermediate patch break bisectability?

> +	if (ret) {
> +		dev_err(csi2rx->dev,
> +			"Failed to start streams %d on subdev\n", 0);
>  		if (!csi2rx->count)
>  			csi2rx_stop(csi2rx);
> +		return ret;
>  	}
>  
> -out:
> -	mutex_unlock(&csi2rx->lock);
> -	return ret;
> +	csi2rx->count++;
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260520120022.539913-1-r-donadkar@ti.com?part=7

  reply	other threads:[~2026-05-20 12:39 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 12:00 [PATCH v13 00/17] media: cadence,ti: CSI2RX Multistream Support Rishikesh Donadkar
2026-05-20 12:00 ` [PATCH v13 01/17] media: ti: j721e-csi2rx: Remove word size alignment on frame width Rishikesh Donadkar
2026-05-20 12:27   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 02/17] dt-bindings: media: ti,j721e-csi2rx-shim: Support 32 dma chans Rishikesh Donadkar
2026-05-20 12:00 ` [PATCH v13 03/17] media: ti: j721e-csi2rx: separate out device and context Rishikesh Donadkar
2026-05-20 12:37   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 04/17] media: ti: j721e-csi2rx: prepare SHIM code for multiple contexts Rishikesh Donadkar
2026-05-20 12:00 ` [PATCH v13 05/17] media: ti: j721e-csi2rx: allocate DMA channel based on context index Rishikesh Donadkar
2026-05-20 12:32   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 06/17] media: ti: j721e-csi2rx: add a subdev for the core device Rishikesh Donadkar
2026-05-20 12:28   ` Sakari Ailus
2026-05-20 12:49   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 07/17] media: cadence: csi2rx: Move to .enable/disable_streams API Rishikesh Donadkar
2026-05-20 12:39   ` sashiko-bot [this message]
2026-05-20 12:00 ` [PATCH v13 08/17] media: ti: j721e-csi2rx: get number of contexts from device tree Rishikesh Donadkar
2026-05-20 12:45   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 09/17] media: cadence: csi2rx: Add .get_frame_desc op Rishikesh Donadkar
2026-05-20 14:25   ` Jai Luthra
2026-05-20 12:00 ` [PATCH v13 10/17] media: ti: j721e-csi2rx: add support for processing virtual channels Rishikesh Donadkar
2026-05-20 12:44   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 11/17] media: cadence: csi2rx: add multistream support Rishikesh Donadkar
2026-05-20 12:58   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 12/17] media: ti: j721e-csi2rx: " Rishikesh Donadkar
2026-05-20 12:48   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 13/17] media: ti: j721e-csi2rx: Submit all available buffers Rishikesh Donadkar
2026-05-20 12:59   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 14/17] media: ti: j721e-csi2rx: Change the drain architecture for multistream Rishikesh Donadkar
2026-05-20 13:01   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 15/17] media: cadence: csi2rx: Support runtime PM Rishikesh Donadkar
2026-05-20 13:00   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 16/17] media: ti: j721e-csi2rx: Support runtime suspend Rishikesh Donadkar
2026-05-20 13:01   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 17/17] media: ti: j721e-csi2rx: Support system suspend using pm_notifier Rishikesh Donadkar
2026-05-20 12:25   ` Sakari Ailus
2026-05-20 13:14   ` sashiko-bot

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=20260520123949.49B3F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=r-donadkar@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox