From patchwork Mon Jun 29 16:29:37 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: 27092 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 4360DC3261 for ; Mon, 29 Jun 2026 16:30:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5AD3B65F43; Mon, 29 Jun 2026 18:30:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="r4xXrRYc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2DE7F65F3C for ; Mon, 29 Jun 2026 18:30:24 +0200 (CEST) Received: from pb-laptop.local (185.221.140.128.nat.pool.zt.hu [185.221.140.128]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E54C2E91; Mon, 29 Jun 2026 18:29:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1782750581; bh=/I+305mhXmeCxdVs2UFxxx9WQBByNicLPjGO++BMevY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r4xXrRYcSasJuXzXkGjIXiF9RO2r7AWHCqNQC3owlPBhmKhImboLMJosyxUkCNMsX GmCjALX/uWq7Tpdp5mPpKrwW22pKcr8LwnHKJl/bBRix3VqngczG6BlKwATUs//A8q 5SMb8iAC6Pl/cut4piARHj4sguTHlN7Ag/00cvP4= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Laurent Pinchart , Paul Elder Subject: [RFC PATCH v1 14/54] v4l2: v4l2_camera: Always clear pending requests Date: Mon, 29 Jun 2026 18:29:37 +0200 Message-ID: <20260629163017.863145-15-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260629163017.863145-1-barnabas.pocze@ideasonboard.com> References: <20260629163017.863145-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 Sender: "libcamera-devel" 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 e72b73a22a..8c7de8e92b 100644 --- a/src/v4l2/v4l2_camera.cpp +++ b/src/v4l2/v4l2_camera.cpp @@ -226,6 +226,8 @@ int V4L2Camera::streamOn() int V4L2Camera::streamOff() { + pendingRequests_.clear(); + if (!isRunning_) { for (std::unique_ptr &req : requestPool_) req->reuse(); @@ -233,8 +235,6 @@ int V4L2Camera::streamOff() return 0; } - pendingRequests_.clear(); - int ret = camera_->stop(); if (ret < 0) return ret == -EACCES ? -EBUSY : ret;