From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C59273E5A31 for ; Mon, 25 May 2026 09:53:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779702796; cv=none; b=flk6lDDRhUZjcTrLUQ1PWZQgX9V8657PPiR2/zRyiXq+cHi2qh0e861ZVP1jPdUGVxmjqDWoyIUD10kDv+3c19OWrIOUw42qlQUikkd1A52snFU8sUxgx4VLb0WYUvRDFRkExIQzaOglADgcscpbdcuFm5E9KGf9Sy+ExbMkS1Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779702796; c=relaxed/simple; bh=Mdlv4jporUZmlLf4lx7rproUzpgtFGaAxxp4Y+lMBaY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RP/wrBwTbhNPCVxNUaDHR/6pdck+Rl4uWoQN145U9HK3TO9bHAY75u5VA4CeBz8CcddHy9wzzSvNXN6VrRKmgw4KrwPKFa0TQOMCDkwV6HQ9G6FH5o4LNseuD3bghXG28Gc96OCTS0ZuDIaSHWCVcmjNBCIk4XxD9XbBAJMdqJs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Gy4iUtU8; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Gy4iUtU8" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-367cbac9cb1so9197284a91.3 for ; Mon, 25 May 2026 02:53:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779702794; x=1780307594; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ez92gLCG1+yJIQjG46e8Hvs9v1kkCpJ4jicfjTVkky4=; b=Gy4iUtU8TgUq2ggD09CiuB+YALvZU6JbW/+IrnNzx4xBwvlTjjrBzVO7TOlUM0Bpzr PspLApYpWnNM4CfFYygh/smiomrCR6ExBcZ8vkr9t+YWr+dj1zq/o6L0h7gStgTcwOth caZ/OM74edl3el9wzXnpUexsgGWeCDkW0toGmZP3z6kKPGbA4E+ViF5CFmDttVIhfoIi KNHbbsZXyO2P9JKgOpUtlEoJKxvde02GKIdu0tXfX4ev3db2/FZhpauNoncYVSk6tM2l w7Cyf3pAzyCbz+njgpy1zLOs7m0BxGVe2Vm4r0m77ndvSSBC26A6m3lipwtlLZlB5Yuk 076Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779702794; x=1780307594; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ez92gLCG1+yJIQjG46e8Hvs9v1kkCpJ4jicfjTVkky4=; b=MyaZPi4Iudq7atH5rsEDJQTb4oGK0uiBkdskXmbbkNXNHhyQp/0odeRmdQWt/u1eb+ ozllo2T8yoZEWeUONRGS/fuEfJE3XGZb8dZCNGF9RQk3EHms+INTwU1aEZi9GSGRppXC Mc27DDJfZNsqZDB4146MXysP92goYZVnkH0jOzRytC16lxB7b1++6Dbt47aR9jsB6Xpc UazhqHCApWbmgjE1UryCMX1wQ2eIGv4/xkK/mqRIieNDtmp5nBRG1+1TUK64Arn5xXQE YuJCUDK38fqEnH1PhrtLFmeTTbuqrpvi45DDpLUqepyJNG21crC0onttmTwks8BUAZ9Y Z7QQ== X-Forwarded-Encrypted: i=1; AFNElJ/r8piPqq3MaVaWNbIugAu0oiLKu4m/d6tRNlRg/1ePxkv1mR/CJBCbb5GINPH1/V5I22PnquinaZlSM9s=@vger.kernel.org X-Gm-Message-State: AOJu0YxsPVBr2AGhom19eYrxZN0yqJbSJM0iCul0P5Jc9xAYUbDPjFL8 y9fK/LGAW9y+rAhv2a81rYbzlyqg5M7CyJgvLyrxsvRLJ8LXLdrCtl1n X-Gm-Gg: Acq92OF3JROFiyC2KAI49Tvxd0sEISc36rTp5nrO2KnZGhvPHup1lqNlOoZytD66Do+ cfyeUePTF69vJnx4758iR6HTtu91+Gf4WTmidzZUnmaAqUEaPVKRjtvfbPEnJD5BGhRPXhZhGLE ftP9DvJUzlLR3lRkDLJHlsfJ4iXPXREz9jKV0mCLHtjp4+A3Da4hlfItMM6ZaOkhonLN9c5xzSp K5Q5a1vmHAjpKgwhZfAbBujHgmzhUUpGTe4XzPW0cB6B7NtrR8tTptTCaWz0SCWY59Orf6iZQ8m 3gC0OPzrCPvvJ0+h7TNOVVVieywWlKElpciKsska/z8ZzeDYN6s1mqaYwwAFQhBs14s1Rco0UGb m5j1rCRazwVYFhHBaH0Xo3Zpgnt3tgX+wsWGEyh940ZZ5QntASYv+9LjrFcoBvhquM8lrUfBF2D ImKzF6ZN+jkOiPbAM8+J1G9Zuia9A7NLmrBwb72l4WFA== X-Received: by 2002:a17:902:e548:b0:2ba:78a6:7dec with SMTP id d9443c01a7336-2beb05c07aemr160215525ad.13.1779702794227; Mon, 25 May 2026 02:53:14 -0700 (PDT) Received: from rockpi-5b ([45.112.0.230]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2beb58b2cd6sm92533615ad.52.2026.05.25.02.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 02:53:13 -0700 (PDT) From: Anand Moon To: Neil Armstrong , Mauro Carvalho Chehab , Greg Kroah-Hartman , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Hans Verkuil , Maxime Jourdan , linux-media@vger.kernel.org (open list:MESON VIDEO DECODER DRIVER FOR AMLOGIC SOCS), linux-amlogic@lists.infradead.org (open list:MESON VIDEO DECODER DRIVER FOR AMLOGIC SOCS), linux-staging@lists.linux.dev (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Amlogic Meson SoC support), linux-kernel@vger.kernel.org (open list) Cc: Anand Moon , Nicolas Dufresne , Sashiko Subject: [PATCH v5 5/6] media: meson: vdec: Isolate error path buffer flush to the active queue Date: Mon, 25 May 2026 15:21:53 +0530 Message-ID: <20260525095216.12078-6-linux.amoon@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260525095216.12078-1-linux.amoon@gmail.com> References: <20260525095216.12078-1-linux.amoon@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When vdec_start_streaming() fails, the error path clears buffers from both the source and destination queues unconditionally. If one queue was already streaming successfully from a prior invocation, flushing its buffers behind its back leaves videobuf2 deadlocked waiting for completions. Fix this by only sweeping buffers from the specific queue type container that failed to initialize. Cc: Nicolas Dufresne Reported-by: Sashiko Closes: https://lore.kernel.org/all/20260521090944.F35401F00A3D@smtp.kernel.org/ Fixes: 3e7f51bd9607 ("media: meson: add v4l2 m2m video decoder driver") Signed-off-by: Anand Moon --- v5: This is a pre-existing issue, but will returning buffers for both queues upon a single-queue failure orphan active queue buffers? If the CAPTURE queue was successfully started in a previous call, returning its buffers puts them back into the vb2 queued list while the driver discards its references. Because the CAPTURE queue remains active, userspace calling DQBUF will hang indefinitely waiting for frames that the driver will never process. --- drivers/staging/media/meson/vdec/vdec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c index b31bf08af88e..925537bd4d0b 100644 --- a/drivers/staging/media/meson/vdec/vdec.c +++ b/drivers/staging/media/meson/vdec/vdec.c @@ -372,15 +372,15 @@ static int vdec_start_streaming(struct vb2_queue *q, unsigned int count) dma_free_coherent(sess->core->dev, sess->vififo_size, sess->vififo_vaddr, sess->vififo_paddr); bufs_done: - while ((buf = v4l2_m2m_src_buf_remove(sess->m2m_ctx))) - v4l2_m2m_buf_done(buf, VB2_BUF_STATE_QUEUED); - while ((buf = v4l2_m2m_dst_buf_remove(sess->m2m_ctx))) - v4l2_m2m_buf_done(buf, VB2_BUF_STATE_QUEUED); - - if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { sess->streamon_out = 0; - else + while ((buf = v4l2_m2m_src_buf_remove(sess->m2m_ctx))) + v4l2_m2m_buf_done(buf, VB2_BUF_STATE_QUEUED); + } else { sess->streamon_cap = 0; + while ((buf = v4l2_m2m_dst_buf_remove(sess->m2m_ctx))) + v4l2_m2m_buf_done(buf, VB2_BUF_STATE_QUEUED); + } return ret; } -- 2.50.1