From: Arun Iyengar v4l2_m2m_streamoff() sets TRANS_ABORT before vb2_streamoff(). If that fails, e.g. for a single-planar type on a multi-planar device, the flag stays and no job of the context runs until a successful STREAMOFF. Reject a type the queue doesn't have before cancelling, and if vb2 still fails, clear TRANS_ABORT and reschedule the context. Fixes: 2ad5389b3412 ("[media] v4l2-mem2mem: Don't schedule the context if abort job is called") Cc: stable@vger.kernel.org Signed-off-by: Arun Iyengar --- Tested on an Orange Pi 5 (RK3588S): after a wrong-type STREAMOFF on an RGA context, the next job ran only with this patch. Developed with Claude (Anthropic), which wrote the code and the commit message. I reviewed it. --- drivers/media/v4l2-core/v4l2-mem2mem.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index a65cbb124cfe..03d9f492fbe9 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -874,15 +874,24 @@ int v4l2_m2m_streamoff(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, unsigned long flags_job, flags; int ret; + q_ctx = get_queue_ctx(m2m_ctx, type); + m2m_dev = m2m_ctx->m2m_dev; + + if (type != q_ctx->q.type) + return -EINVAL; + /* wait until the current context is dequeued from job_queue */ v4l2_m2m_cancel_job(m2m_ctx); - q_ctx = get_queue_ctx(m2m_ctx, type); ret = vb2_streamoff(&q_ctx->q, type); - if (ret) + if (ret) { + spin_lock_irqsave(&m2m_dev->job_spinlock, flags_job); + m2m_ctx->job_flags &= ~TRANS_ABORT; + spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job); + v4l2_m2m_try_schedule(m2m_ctx); return ret; + } - m2m_dev = m2m_ctx->m2m_dev; spin_lock_irqsave(&m2m_dev->job_spinlock, flags_job); /* We should not be scheduled anymore, since we're dropping a queue. */ if (m2m_ctx->job_flags & TRANS_QUEUED) --- base-commit: 48fe5a7834cc10081887d7bcd9ff0a4cadc3fa8c change-id: 20261114-b4-m2m-streamoff-abort-dd13d60ea351 Best regards, -- Arun Iyengar