Re: [PATCH 2/2] media: nxp: imx8-isi: Prioritize pending buffers over discard buffers
From: Frank Li
Date: Wed Mar 11 2026 - 11:34:11 EST
On Wed, Mar 11, 2026 at 04:02:59PM +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. This ensures user buffers
Nit: Ensure user ...
> are utilized as soon as possible, improving efficiency and reducing the
> number of discarded frames at stream start.
>
> 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
>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@xxxxxxx>
> ---
> drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c | 3 ++-
> 1 file changed, 2 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 2405baf21594cd18cf2b349234313c5e103b7802..53f4f74369f7855fe6b6f372294ee569f40a8ae6 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
> @@ -786,13 +786,14 @@ static void mxc_isi_video_queue_first_buffers(struct mxc_isi_video *video)
> : list_is_singular(&video->out_pending) ? 1
> : 0;
>
> + /* Queue buffers: prioritize pending buffers, then discard buffers */
> for (i = 0; i < 2; ++i) {
> enum mxc_isi_buf_id buf_id = i == 0 ? MXC_ISI_BUF1
> : MXC_ISI_BUF2;
> struct mxc_isi_buffer *buf;
> struct list_head *list;
>
> - list = i < discard ? &video->out_discard : &video->out_pending;
> + list = (i < 2 - discard) ? &video->out_pending : &video->out_discard;
Is (2 - discard) the number of pending buffers? put commit's example as
comments here.
Frank
> buf = list_first_entry(list, struct mxc_isi_buffer, list);
>
> mxc_isi_channel_set_outbuf(video->pipe, buf->dma_addrs, buf_id);
>
> --
> 2.34.1
>