[PATCH v2 01/13] media: iris: apply the capture buffer minimum in queue_setup

From: Dmitry Baryshkov

Date: Fri Dec 04 2026 - 13:25:13 EST


Decoding a small VP8 stream with FFmpeg fails with -ENOMEM from the
first VIDIOC_REQBUFS on the capture queue. The sequence change handler
sets min_reqbufs_allocation on the capture queue from the firmware's
buffer count, but it runs from the HFI response path without the queue
lock. When the event arrives while REQBUFS is in progress, vb2 sizes the
request with the old minimum and then checks the allocation against the
new, larger one, and fails.

Leave min_reqbufs_allocation alone and raise the requested count to the
firmware minimum in queue_setup instead, which runs with the instance
lock held, the same lock the sequence change handler holds while it
updates that minimum.

Fixes: 84e17adae3e3 ("media: iris: add support for dynamic resolution change")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxxxxxxxx>
---
drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c | 3 ---
drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c | 3 ---
drivers/media/platform/qcom/iris/iris_vb2.c | 4 ++++
3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c b/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c
index ffa98139f0eb..a1167ce524ff 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c
@@ -32,7 +32,6 @@ static void iris_hfi_gen1_read_changed_params(struct iris_inst *inst,
struct hfi_bit_depth *pixel_depth;
struct hfi_pic_struct *pic_struct;
struct hfi_framesize *frame_sz;
- struct vb2_queue *dst_q;
struct v4l2_ctrl *ctrl;
u32 full_range, ptype;

@@ -162,8 +161,6 @@ static void iris_hfi_gen1_read_changed_params(struct iris_inst *inst,
if (ctrl)
v4l2_ctrl_s_ctrl(ctrl, inst->buffers[BUF_OUTPUT].min_count);

- dst_q = v4l2_m2m_get_dst_vq(inst->m2m_ctx);
- dst_q->min_reqbufs_allocation = inst->buffers[BUF_OUTPUT].min_count;

if (event.bit_depth || !event.pic_struct) {
dev_err(core->dev, "unsupported content, bit depth: %x, pic_struct = %x\n",
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
index f0782c4b1e6e..69d5f0639fae 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
@@ -532,7 +532,6 @@ static void iris_hfi_gen2_read_input_subcr_params(struct iris_inst *inst)
u32 video_signal_type_present_flag;
struct iris_core *core = inst->core;
u32 full_range, width, height;
- struct vb2_queue *dst_q;
struct v4l2_ctrl *ctrl;

subsc_params = inst_hfi_gen2->src_subcr_params;
@@ -660,8 +659,6 @@ static void iris_hfi_gen2_read_input_subcr_params(struct iris_inst *inst)
if (ctrl)
v4l2_ctrl_s_ctrl(ctrl, inst->buffers[BUF_OUTPUT].min_count);

- dst_q = v4l2_m2m_get_dst_vq(inst->m2m_ctx);
- dst_q->min_reqbufs_allocation = inst->buffers[BUF_OUTPUT].min_count;
}

static int iris_hfi_gen2_handle_src_change(struct iris_inst *inst,
diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/platform/qcom/iris/iris_vb2.c
index 8faf709c26c1..2d5052782975 100644
--- a/drivers/media/platform/qcom/iris/iris_vb2.c
+++ b/drivers/media/platform/qcom/iris/iris_vb2.c
@@ -145,6 +145,10 @@ int iris_vb2_queue_setup(struct vb2_queue *q,
goto unlock;
}

+ if (inst->domain == DECODER && !V4L2_TYPE_IS_OUTPUT(q->type))
+ *num_buffers = clamp(*num_buffers, inst->buffers[BUF_OUTPUT].min_count,
+ q->max_num_buffers);
+
*num_planes = 1;
sizes[0] = f->fmt.pix_mp.plane_fmt[0].sizeimage;


--
2.47.3