]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
media: nxp: imx8-isi: Prioritize pending buffers over discard buffers
authorGuoniu Zhou <guoniu.zhou@nxp.com>
Fri, 20 Mar 2026 06:42:02 +0000 (14:42 +0800)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 21 May 2026 05:41:32 +0000 (07:41 +0200)
commit75a54af91f33084c0cef11b3cb2f89765af78920
tree98a97a8f4e0fbee688e7fb063380e99aaf324683
parentd970b27cc48ec42f8a72bc3a4a4ad2e5c7a36395
media: nxp: imx8-isi: Prioritize pending buffers over discard buffers

The number of times to use the discard buffer is determined by the
out_pending list size:

  discard = list_empty(&video->out_pending) ? 2
            : list_is_singular(&video->out_pending) ? 1
    : 0;

In the current buffer selection logic, when both discard and pending
buffers are available, the driver fills hardware slots with discard
buffers first which results in an unnecessary frame drop even though
a user buffer was queued and ready.

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 improves behavior by:
- Reducing discarded frames at stream start when user buffers are ready
- Decreasing latency in delivering captured frames to user-space
- Ensuring user buffers are utilized as soon as they are queued
- Improving overall buffer utilization efficiency

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patch.msgid.link/20260320-isi_min_buffers-v3-2-66e0fabccca3@oss.nxp.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c