From: Rishikesh Donadkar <r-donadkar@ti.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
<jai.luthra@linux.dev>, <laurent.pinchart@ideasonboard.com>,
<mripard@kernel.org>
Cc: <y-abhilashchandra@ti.com>, <devarsht@ti.com>, <s-jain1@ti.com>,
<vigneshr@ti.com>, <mchehab@kernel.org>, <robh@kernel.org>,
<krzk+dt@kernel.org>, <p.zabel@pengutronix.de>,
<conor+dt@kernel.org>, <sakari.ailus@linux.intel.com>,
<hverkuil-cisco@xs4all.nl>, <jai.luthra@ideasonboard.com>,
<changhuang.liang@starfivetech.com>, <jack.zhu@starfivetech.com>,
<sjoerd@collabora.com>, <dan.carpenter@linaro.org>,
<hverkuil+cisco@kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>
Subject: Re: [PATCH v8 07/18] media: cadence: csi2rx: Move to .enable/disable_streams API
Date: Fri, 21 Nov 2025 12:32:41 +0530 [thread overview]
Message-ID: <0ef7834f-5efc-4cd3-91ac-482937debc3e@ti.com> (raw)
In-Reply-To: <810d566f-af2e-4a19-af39-2abcc558aa6b@ideasonboard.com>
On 20/11/25 18:30, Tomi Valkeinen wrote:
> Hi,
Hi Tomi
>
> On 12/11/2025 13:54, Rishikesh Donadkar wrote:
>> The enable_streams() API in v4l2 supports passing a bitmask to enable
>> each pad/stream combination individually on any media subdev. Use this
>> API instead of s_stream() API.
>>
>> Implement the enable_stream and disable_stream hooks in place of the
>> stream-unaware s_stream hook.
>>
>> Remove the lock that was used to serialize stream starts/stops which
>> is not required anymore since the v4l2-core serializes the
>> enable/disable_streams() calls for the subdev.
>>
>> Signed-off-by: Rishikesh Donadkar <r-donadkar@ti.com>
>> ---
>> drivers/media/platform/cadence/cdns-csi2rx.c | 108 +++++++++----------
>> 1 file changed, 54 insertions(+), 54 deletions(-)
>>
>> diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
>> index 8c19f125da3e5..34da81893308b 100644
>> --- a/drivers/media/platform/cadence/cdns-csi2rx.c
>> +++ b/drivers/media/platform/cadence/cdns-csi2rx.c
>> @@ -125,12 +125,6 @@ struct csi2rx_priv {
>> unsigned int count;
>> int error_irq;
>>
>> - /*
>> - * Used to prevent race conditions between multiple,
>> - * concurrent calls to start and stop.
>> - */
>> - struct mutex lock;
>> -
>> void __iomem *base;
>> struct clk *sys_clk;
>> struct clk *p_clk;
>> @@ -268,20 +262,21 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx)
>> &csi2rx->source_subdev->entity.pads[csi2rx->source_pad];
>> union phy_configure_opts opts = { };
>> struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy;
>> - struct v4l2_subdev_format sd_fmt = {
>> - .which = V4L2_SUBDEV_FORMAT_ACTIVE,
>> - .pad = CSI2RX_PAD_SINK,
>> - };
>> + struct v4l2_subdev_state *state;
>> + struct v4l2_mbus_framefmt *framefmt;
>> const struct csi2rx_fmt *fmt;
>> s64 link_freq;
>> int ret;
>>
>> - ret = v4l2_subdev_call_state_active(&csi2rx->subdev, pad, get_fmt,
>> - &sd_fmt);
>> - if (ret < 0)
>> - return ret;
>> + state = v4l2_subdev_get_locked_active_state(&csi2rx->subdev);
>>
>> - fmt = csi2rx_get_fmt_by_code(sd_fmt.format.code);
>> + framefmt = v4l2_subdev_state_get_format(state, CSI2RX_PAD_SINK, 0);
>> + if (!framefmt) {
>> + dev_err(csi2rx->dev, "Did not find active sink format\n");
>> + return -EINVAL;
>> + }
>> +
>> + fmt = csi2rx_get_fmt_by_code(framefmt->code);
>>
>> link_freq = v4l2_get_link_freq(src_pad,
>> fmt->bpp, 2 * csi2rx->num_lanes);
>> @@ -401,16 +396,10 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
>>
>> reset_control_deassert(csi2rx->sys_rst);
>>
>> - ret = v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, true);
>> - if (ret)
>> - goto err_disable_sysclk;
>> -
>> clk_disable_unprepare(csi2rx->p_clk);
>>
>> return 0;
>>
>> -err_disable_sysclk:
>> - clk_disable_unprepare(csi2rx->sys_clk);
>> err_disable_pixclk:
>> for (; i > 0; i--) {
>> reset_control_assert(csi2rx->pixel_rst[i - 1]);
>> @@ -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);
>>
>> @@ -485,38 +471,56 @@ static int csi2rx_log_status(struct v4l2_subdev *sd)
>> return 0;
>> }
>>
>> -static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable)
>> +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(0));
> The stream mask is u64, so better use BIT_U64. It doesn't matter here,
> but before you know it, you have switched BIT(0) to BIT(foo->bar), and
> someone sets bar to 34 and it's broken...
>
> Yes, I see this being changed later, to variable set with BIT_ULL()
> (that could be changed to BIT_U64). Nevertheless, better use the correct
> macro.
Sure, I will change it in the next revision.
>
> But a bigger issue is if this and patches 6 and 8 are correct or could
> be improved.
>
> I think in this one you remove s_stream from cdns-csi2. But the j7
> csi2rx is still calling s_stream, so it would fail with this patch. In
> patch 8 you switch j7 csi2rx from s_stream to enable_streams. But in
> patch 6 you added mutex, locking and s_stream to j7 csi2rx, and in patch
> 8 you remove that.
>
> Maybe the end result is fine, but it all does feel messy. I think the
> patches we should have are:
>
> - Use v4l2_subdev_enable_streams() in j7-csi2rx instead of calling
> s_stream. v4l2_subdev_enable_streams() will work with either .s_stream
> and .enable_stream in cdns-csi2rx
>
> - Patch 7 (with BIT_64()) to convert cdns-csi2rx
>
> - Patches 6 and 8 combined. You're essentially adding a new subdev, just
> do it right from the start with .enable_streams, state, etc., instead of
> mutex and s_stream which are removed two patches later.
Right, I will merge changes from 08/18 into 06/18.
Thanks,
Rishikesh
>
> Tomi
>
>> + 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;
>> +}
>> +
>> +static int csi2rx_disable_streams(struct v4l2_subdev *subdev,
>> + struct v4l2_subdev_state *state, u32 pad,
>> + u64 streams_mask)
>> +{
>> + struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev);
>> +
>> + if (v4l2_subdev_disable_streams(csi2rx->source_subdev,
>> + csi2rx->source_pad, BIT(0))) {
>> + dev_err(csi2rx->dev, "Couldn't disable our subdev\n");
>> + }
>> +
>> + csi2rx->count--;
>> +
>> + /* Let the last user turn off the lights. */
>> + if (!csi2rx->count)
>> + csi2rx_stop(csi2rx);
>> +
>> + return 0;
>> }
>>
>> static int csi2rx_enum_mbus_code(struct v4l2_subdev *subdev,
>> @@ -611,10 +615,8 @@ static const struct v4l2_subdev_pad_ops csi2rx_pad_ops = {
>> .enum_mbus_code = csi2rx_enum_mbus_code,
>> .get_fmt = v4l2_subdev_get_fmt,
>> .set_fmt = csi2rx_set_fmt,
>> -};
>> -
>> -static const struct v4l2_subdev_video_ops csi2rx_video_ops = {
>> - .s_stream = csi2rx_s_stream,
>> + .enable_streams = csi2rx_enable_streams,
>> + .disable_streams = csi2rx_disable_streams,
>> };
>>
>> static const struct v4l2_subdev_core_ops csi2rx_core_ops = {
>> @@ -623,7 +625,6 @@ static const struct v4l2_subdev_core_ops csi2rx_core_ops = {
>>
>> static const struct v4l2_subdev_ops csi2rx_subdev_ops = {
>> .core = &csi2rx_core_ops,
>> - .video = &csi2rx_video_ops,
>> .pad = &csi2rx_pad_ops,
>> };
>>
>> @@ -829,7 +830,6 @@ static int csi2rx_probe(struct platform_device *pdev)
>> return -ENOMEM;
>> platform_set_drvdata(pdev, csi2rx);
>> csi2rx->dev = &pdev->dev;
>> - mutex_init(&csi2rx->lock);
>>
>> ret = csi2rx_get_resources(csi2rx, pdev);
>> if (ret)
next prev parent reply other threads:[~2025-11-21 7:02 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 11:54 [PATCH v8 00/18] media: cadence,ti: CSI2RX Multistream Support Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 01/18] media: ti: j721e-csi2rx: Remove word size alignment on frame width Rishikesh Donadkar
2025-11-20 11:58 ` Tomi Valkeinen
2025-11-12 11:54 ` [PATCH v8 02/18] dt-bindings: media: ti,j721e-csi2rx-shim: Support 32 dma chans Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 03/18] media: ti: j721e-csi2rx: separate out device and context Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 04/18] media: ti: j721e-csi2rx: prepare SHIM code for multiple contexts Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 05/18] media: ti: j721e-csi2rx: allocate DMA channel based on context index Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 06/18] media: ti: j721e-csi2rx: add a subdev for the core device Rishikesh Donadkar
2025-11-20 12:39 ` Sakari Ailus
2025-11-21 6:59 ` Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 07/18] media: cadence: csi2rx: Move to .enable/disable_streams API Rishikesh Donadkar
2025-11-20 13:00 ` Tomi Valkeinen
2025-11-21 7:02 ` Rishikesh Donadkar [this message]
2025-11-12 11:54 ` [PATCH v8 08/18] media: ti: j721e-csi2rx: " Rishikesh Donadkar
2025-11-20 12:40 ` Sakari Ailus
2025-11-21 7:04 ` Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 09/18] media: ti: j721e-csi2rx: get number of contexts from device tree Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 10/18] media: cadence: csi2rx: add get_frame_desc wrapper Rishikesh Donadkar
2025-11-20 12:40 ` Tomi Valkeinen
2025-12-02 9:03 ` Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 11/18] media: ti: j721e-csi2rx: add support for processing virtual channels Rishikesh Donadkar
2025-11-20 12:32 ` Tomi Valkeinen
2025-12-01 9:25 ` Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 12/18] media: cadence: csi2rx: add multistream support Rishikesh Donadkar
2025-11-20 12:53 ` Sakari Ailus
2025-12-09 9:43 ` Rishikesh Donadkar
2025-12-29 11:14 ` Sakari Ailus
2025-11-20 13:14 ` Tomi Valkeinen
2025-12-09 9:45 ` Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 13/18] media: ti: j721e-csi2rx: " Rishikesh Donadkar
2025-12-01 13:03 ` Tomi Valkeinen
2025-12-09 10:08 ` Rishikesh Donadkar
2025-12-09 10:36 ` Jai Luthra
2025-12-09 11:52 ` Tomi Valkeinen
2025-12-09 12:06 ` Jai Luthra
2025-11-12 11:54 ` [PATCH v8 14/18] media: ti: j721e-csi2rx: Submit all available buffers Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 15/18] media: ti: j721e-csi2rx: Change the drain architecture for multistream Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 16/18] media: cadence: csi2rx: Support runtime PM Rishikesh Donadkar
2025-12-01 13:11 ` Tomi Valkeinen
2025-12-18 5:35 ` Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 17/18] media: ti: j721e-csi2rx: Support runtime suspend Rishikesh Donadkar
2025-11-20 13:16 ` Sakari Ailus
2025-12-08 7:47 ` Jai Luthra
2025-12-08 9:39 ` Sakari Ailus
2025-12-01 13:22 ` Tomi Valkeinen
2025-12-08 7:36 ` Jai Luthra
2025-12-29 10:07 ` Rishikesh Donadkar
2025-11-12 11:54 ` [PATCH v8 18/18] media: ti: j721e-csi2rx: Support system suspend using pm_notifier Rishikesh Donadkar
2025-12-01 13:46 ` Tomi Valkeinen
2025-12-08 8:01 ` Jai Luthra
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=0ef7834f-5efc-4cd3-91ac-482937debc3e@ti.com \
--to=r-donadkar@ti.com \
--cc=changhuang.liang@starfivetech.com \
--cc=conor+dt@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=devarsht@ti.com \
--cc=devicetree@vger.kernel.org \
--cc=hverkuil+cisco@kernel.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jack.zhu@starfivetech.com \
--cc=jai.luthra@ideasonboard.com \
--cc=jai.luthra@linux.dev \
--cc=krzk+dt@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mripard@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=s-jain1@ti.com \
--cc=sakari.ailus@linux.intel.com \
--cc=sjoerd@collabora.com \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=vigneshr@ti.com \
--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
all inboxes | Powered by JetHome®