Re: [PATCH v2 2/2] media: nxp: imx8-isi: Prioritize pending buffers over discard buffers
From: Laurent Pinchart
Date: Thu Mar 19 2026 - 18:00:11 EST
Hi Guoniu,
Thank you for the patch.
On Thu, Mar 12, 2026 at 11:12:35AM +0800, Guoniu Zhou wrote:
> From: Guoniu Zhou <guoniu.zhou@xxxxxxx>
>
> Change the buffer selection logic to use pending buffers first (up to the
> number available), and only use discard buffers to fill remaining slots
> when insufficient pending buffers are queued. Ensure user buffers are
> utilized as soon as possible, improving efficiency and reducing the number
> of discarded frames at stream start.
The commit message should explain *why* the change is good. How does
this improve the behaviour ?
I'll queue 1/2 in my tree already.
> Signed-off-by: Guoniu Zhou <guoniu.zhou@xxxxxxx>
> ---
> Changes in v2:
> - Replace "This ensures" with "ensure"
> - Put example from commit message to comment in driver suggested by Frank
> https://lore.kernel.org/linux-media/20260311-isi_min_buffers-v1-0-c9299d6e8ae6@xxxxxxx/T/#m2774912ed31553ef1fdcc840bd6eae53a03ecccd
> ---
> drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
> index 1be3a728f32f89338a75ddcc4e96e7501ed954e1..77ebff03323ace50ff039c8333d25a9c3dd44880 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
> @@ -792,7 +792,14 @@ static void mxc_isi_video_queue_first_buffers(struct mxc_isi_video *video)
> struct mxc_isi_buffer *buf;
> struct list_head *list;
>
> - list = i < discard ? &video->out_discard : &video->out_pending;
> + /*
> + * Queue buffers: prioritize pending buffers, then discard buffers
> + * For example:
> + * - 2 pending buffers: both slots use pending buffers
> + * - 1 pending buffer: first slot uses pending, second uses discard
> + * - 0 pending buffers: both slots use discard buffers
> + */
> + list = (i < 2 - discard) ? &video->out_pending : &video->out_discard;
> buf = list_first_entry(list, struct mxc_isi_buffer, list);
>
> mxc_isi_channel_set_outbuf(video->pipe, buf->dma_addrs, buf_id);
>
--
Regards,
Laurent Pinchart