From patchwork Tue Dec 1 08:38:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 29124 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 26CF9C3304 for ; Tue, 1 Dec 2026 08:38:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6FED76AABD; Tue, 1 Dec 2026 09:38:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vDmOL5kS"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C9416AAA3 for ; Tue, 1 Dec 2026 09:38:10 +0100 (CET) Received: from pb-laptop.local (185.182.215.119.nat.pool.zt.hu [185.182.215.119]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AE688C36; Tue, 1 Dec 2026 09:35:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1796114132; bh=EhUCANmU4v5jzjJDhXulwflyEhvdUtYxDFUUq2lK5Mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vDmOL5kSphg0lQNohaTQlyrL55t356ctxb2gEx3fK79LlVnGu637qIDdWxy+NL7iO ahQSNk4NdmuSn92Dbv/FUB/S2dV4tMb3+0YgUM/8Z+3XxlCuYf21DbIs9cJgd1qOvQ yWHTNrmiXacS7intVOfcf0fU4drxRZ4q+1cS6Vag= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Laurent Pinchart , Paul Elder Subject: [PATCH v1 7/9] v4l2: v4l2_camera: Always clear pending requests Date: Tue, 1 Dec 2026 09:38:03 +0100 Message-ID: <20261201083805.496809-8-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201083805.496809-1-barnabas.pocze@ideasonboard.com> References: <20261201083805.496809-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Clear the list of pending requests regardless whether the camera is running or not. The list should only contain entries when `!isRunning_`, in which case it was not cleared previously. Consider the following scenario: * STREAMOFF * QBUF(10) * STREAMOFF // at this point buffer 10 should be dequeued; // but `pendingRequests_` would still have the request // that was added due to QBUF * QBUF(10) // `pendingRequests_` would have the same requests twice * STREAMON // the same request would be tried to be queued twice Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder --- src/v4l2/v4l2_camera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp index 71df214e58..c7f227ee09 100644 --- a/src/v4l2/v4l2_camera.cpp +++ b/src/v4l2/v4l2_camera.cpp @@ -227,6 +227,8 @@ int V4L2Camera::streamOn() int V4L2Camera::streamOff() { + pendingRequests_.clear(); + if (!isRunning_) { for (std::unique_ptr &req : requestPool_) req->reuse(); @@ -234,8 +236,6 @@ int V4L2Camera::streamOff() return 0; } - pendingRequests_.clear(); - int ret = camera_->stop(); if (ret < 0) return ret == -EACCES ? -EBUSY : ret;