From: Rishikesh Donadkar <r-donadkar@ti.com>
To: Sjoerd Simons <sjoerd@collabora.com>, <jai.luthra@linux.dev>,
<laurent.pinchart@ideasonboard.com>, <mripard@kernel.org>,
Julien Massot <jmassot@collabora.com>
Cc: <y-abhilashchandra@ti.com>, <devarsht@ti.com>,
<vaishnav.a@ti.com>, <s-jain1@ti.com>, <vigneshr@ti.com>,
<mchehab@kernel.org>, <robh@kernel.org>, <krzk+dt@kernel.org>,
<conor+dt@kernel.org>, <sakari.ailus@linux.intel.com>,
<hverkuil-cisco@xs4all.nl>, <tomi.valkeinen@ideasonboard.com>,
<jai.luthra@ideasonboard.com>,
<changhuang.liang@starfivetech.com>, <jack.zhu@starfivetech.com>,
<linux-kernel@vger.kernel.org>, <linux-media@vger.kernel.org>,
<devicetree@vger.kernel.org>, "Liu (EP), Bin" <b-liu@ti.com>
Subject: Re: [PATCH v4 11/12] media: ti: j721e-csi2rx: Submit all available buffers
Date: Thu, 21 Aug 2025 11:51:57 +0530 [thread overview]
Message-ID: <9fa2e0ab-fed1-4d19-a735-e5458014f549@ti.com> (raw)
In-Reply-To: <ab421c6f9fc804a6f03833d824d5776c7272e6bb.camel@collabora.com>
On 01/07/25 13:39, Sjoerd Simons wrote:
> Hey,
Hi Sjoerd,
>
> On Wed, 2025-05-14 at 16:55 +0530, Rishikesh Donadkar wrote:
>> From: Jai Luthra <j-luthra@ti.com>
>>
>> We already make sure to submit all available buffers to DMA in each DMA
>> completion callback.
>>
>> Move that logic in a separate function, and use it during stream start
>> as well, as most application queue all their buffers before stream on.
>>
>> Signed-off-by: Jai Luthra <j-luthra@ti.com>
>> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>> Signed-off-by: Rishikesh Donadkar <r-donadkar@ti.com>
>> ---
>> .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 43 +++++++++++--------
>> 1 file changed, 24 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
>> b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
>> index 7986f96c5e11b..ba2a30bfed37d 100644
>> --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
>> +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
>> @@ -651,6 +651,27 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *ctx)
>> return ret;
>> }
>>
>> +static int ti_csi2rx_dma_submit_pending(struct ti_csi2rx_ctx *ctx)
>> +{
>> + struct ti_csi2rx_dma *dma = &ctx->dma;
>> + struct ti_csi2rx_buffer *buf;
>> + int ret = 0;
>> +
>> + /* If there are more buffers to process then start their transfer. */
>> + while (!list_empty(&dma->queue)) {
>> + buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer,
>> list);
>> + ret = ti_csi2rx_start_dma(ctx, buf);
>> + if (ret) {
>> + dev_err(ctx->csi->dev,
>> + "Failed to queue the next buffer for DMA\n");
>> + vb2_buffer_done(&buf->vb.vb2_buf,
>> VB2_BUF_STATE_ERROR);
>> + break;
> The break here seems wrong and does change the previous logic; It means once *a*
> buffer fails to start DMA, you'll no longer try to submit the other (queued)
> buffers. If this was called from the DMA callback of the last submitted buffer
> and userspace doesn't re-queue the error buffer, then capturing will stop, even
> if there were still queued up buffers from a userspace pov.
>
>
> For a potential next iteration you probably also want to wrap in the changes
> from to fix list_del corruption:
> https://lore.kernel.org/all/20250630-j721e-dma-fixup-v1-1-591e378ab3a8@collabora.com/
Thank you for the pointer !
I will make these changes in the next revision
Regards,
Rishikesh
>
>
>
>> + }
>> + list_move_tail(&buf->list, &dma->submitted);
>> + }
>> + return ret;
>> +}
>> +
>> static void ti_csi2rx_dma_callback(void *param)
>> {
>> struct ti_csi2rx_buffer *buf = param;
>> @@ -671,18 +692,7 @@ static void ti_csi2rx_dma_callback(void *param)
>> vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
>> list_del(&buf->list);
>>
>> - /* If there are more buffers to process then start their transfer. */
>> - while (!list_empty(&dma->queue)) {
>> - buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer,
>> list);
>> -
>> - if (ti_csi2rx_start_dma(ctx, buf)) {
>> - dev_err(ctx->csi->dev,
>> - "Failed to queue the next buffer for DMA\n");
>> - vb2_buffer_done(&buf->vb.vb2_buf,
>> VB2_BUF_STATE_ERROR);
>> - } else {
>> - list_move_tail(&buf->list, &dma->submitted);
>> - }
>> - }
>> + ti_csi2rx_dma_submit_pending(ctx);
>>
>> if (list_empty(&dma->submitted))
>> dma->state = TI_CSI2RX_DMA_IDLE;
>> @@ -941,7 +951,6 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq,
>> unsigned int count)
>> struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vq);
>> struct ti_csi2rx_dev *csi = ctx->csi;
>> struct ti_csi2rx_dma *dma = &ctx->dma;
>> - struct ti_csi2rx_buffer *buf;
>> unsigned long flags;
>> int ret = 0;
>>
>> @@ -980,16 +989,13 @@ static int ti_csi2rx_start_streaming(struct vb2_queue
>> *vq, unsigned int count)
>> ctx->sequence = 0;
>>
>> spin_lock_irqsave(&dma->lock, flags);
>> - buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list);
>>
>> - ret = ti_csi2rx_start_dma(ctx, buf);
>> + ret = ti_csi2rx_dma_submit_pending(ctx);
>> if (ret) {
>> - dev_err(csi->dev, "Failed to start DMA: %d\n", ret);
>> spin_unlock_irqrestore(&dma->lock, flags);
>> - goto err_pipeline;
>> + goto err_dma;
>> }
>>
>> - list_move_tail(&buf->list, &dma->submitted);
>> dma->state = TI_CSI2RX_DMA_ACTIVE;
>> spin_unlock_irqrestore(&dma->lock, flags);
>>
>> @@ -1004,7 +1010,6 @@ static int ti_csi2rx_start_streaming(struct vb2_queue
>> *vq, unsigned int count)
>>
>> err_dma:
>> ti_csi2rx_stop_dma(ctx);
>> -err_pipeline:
>> video_device_pipeline_stop(&ctx->vdev);
>> writel(0, csi->shim + SHIM_CNTL);
>> writel(0, csi->shim + SHIM_DMACNTX(ctx->idx));
next prev parent reply other threads:[~2025-08-21 6:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-14 11:25 [PATCH v4 00/12] media: cadence,ti: CSI2RX Multistream Support Rishikesh Donadkar
2025-05-14 11:25 ` [PATCH v4 01/12] dt-bindings: media: ti,j721e-csi2rx-shim: Support 32 dma chans Rishikesh Donadkar
2025-05-14 11:25 ` [PATCH v4 02/12] media: ti: j721e-csi2rx: separate out device and context Rishikesh Donadkar
2025-05-14 11:25 ` [PATCH v4 03/12] media: ti: j721e-csi2rx: prepare SHIM code for multiple contexts Rishikesh Donadkar
2025-05-14 11:25 ` [PATCH v4 04/12] media: ti: j721e-csi2rx: allocate DMA channel based on context index Rishikesh Donadkar
2025-05-14 11:25 ` [PATCH v4 05/12] media: ti: j721e-csi2rx: add a subdev for the core device Rishikesh Donadkar
2025-05-14 11:25 ` [PATCH v4 06/12] media: ti: j721e-csi2rx: get number of contexts from device tree Rishikesh Donadkar
2025-05-14 11:25 ` [PATCH v4 07/12] media: cadence: csi2rx: add get_frame_desc wrapper Rishikesh Donadkar
2025-05-14 11:25 ` [PATCH v4 08/12] media: ti: j721e-csi2rx: add support for processing virtual channels Rishikesh Donadkar
2025-05-14 11:25 ` [PATCH v4 09/12] media: cadence: csi2rx: add multistream support Rishikesh Donadkar
2025-05-14 11:25 ` [PATCH v4 10/12] media: ti: j721e-csi2rx: " Rishikesh Donadkar
2025-05-14 11:25 ` [PATCH v4 11/12] media: ti: j721e-csi2rx: Submit all available buffers Rishikesh Donadkar
2025-07-01 8:09 ` Sjoerd Simons
2025-08-21 6:21 ` Rishikesh Donadkar [this message]
2025-05-14 11:25 ` [PATCH v4 12/12] media: ti: j721e-csi2rx: Change the drain architecture for multistream Rishikesh Donadkar
2025-06-25 1:33 ` Jai Luthra
2025-08-04 10:26 ` Rishikesh Donadkar
2025-06-24 9:52 ` [PATCH v4 00/12] media: cadence,ti: CSI2RX Multistream Support 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=9fa2e0ab-fed1-4d19-a735-e5458014f549@ti.com \
--to=r-donadkar@ti.com \
--cc=b-liu@ti.com \
--cc=changhuang.liang@starfivetech.com \
--cc=conor+dt@kernel.org \
--cc=devarsht@ti.com \
--cc=devicetree@vger.kernel.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jack.zhu@starfivetech.com \
--cc=jai.luthra@ideasonboard.com \
--cc=jai.luthra@linux.dev \
--cc=jmassot@collabora.com \
--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=robh@kernel.org \
--cc=s-jain1@ti.com \
--cc=sakari.ailus@linux.intel.com \
--cc=sjoerd@collabora.com \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=vaishnav.a@ti.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®