From patchwork Tue Mar 22 09:22:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15503 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 E6B3DC3264 for ; Tue, 22 Mar 2022 09:23:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9B7C9632E7; Tue, 22 Mar 2022 10:23:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1647940989; bh=kLdJCoGqn9EWuZ/Y6wCBPOrNjqTq2/GaVdwfFx+Kr1I=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=KCD5bD8LOcgGvwbvpmz9vvAEtfQ/m1YviWUzyWNgYUkOUvk/MLROP0YR5f0PV5ryC 34o32iB5ieUSWTbF+6dv86LpWTsszG1OULwdPDyaYSsC0OrdyqmkrJZ7zecY9AC+QE n9/hlKew/dIG44SB0LAl17+mOBQfwoxf9wTERoyqabCDobVOzRTuGq17gF/C3sjS39 W3zOLwm4Szt+2LfPk2lp/mPo4i2XZKBK756SBrbNxiqd+hSwmT/beW+xQuM3q3aTMa ytgphGvAqAA/aCjTYDQ11OC8GHQvHf2VsCqpu2MUA+VUXCITWSkITj1z+9ke70hhOc xDJvIzRCEubuQ== Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 61206604E9 for ; Tue, 22 Mar 2022 10:23:05 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="C9BJbsT8"; dkim-atps=neutral Received: by mail-wm1-x32d.google.com with SMTP id o7-20020a05600c4fc700b0038c87edc21eso1233729wmq.0 for ; Tue, 22 Mar 2022 02:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XJt33N1ljP6weawLqxc7eqhgx8mv7TXz3ylgqjbNO8U=; b=C9BJbsT8td3C47nEb49XPsJOEHf3FOtqKVB3GteUmCjoo351+M+UuozXXniMePiEBO Ml+ujDOqXj+/2lCf+TKV56ApoTiVzW7qYWLPdcrn2Wv2JgAGvUs+T39IAwzs6lb30rFz JNqDcmUJpWTOSMDuxFxvLgT2i1SnpqOHohUX1W2KLOLf0w2e+5RcihW+aetlEhqfOEp1 vkBDXEA3dNQRTYH07IJ3fKqkrZY10cP1ur/g9NfotN1BHFec0Wr5W3tyExhQD5oj3gWl BWQnjpmhvMXajFrKsJnAbmlZX0KWWyGG7J4TEc7hklIgrK3bzJ4JrgKO7LJl5i7nSw0y j/Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XJt33N1ljP6weawLqxc7eqhgx8mv7TXz3ylgqjbNO8U=; b=tT4eGB48GMaQGGK3cLMP68w0oJxX5t5hnN4DUxbMdeARBw/X3iNVzv+SqQolxpEFO3 fF0bxbBcSNc2t/bEZVOojgVzb66MAnjpjACS1rv2lCcjiG1lUtOjreGg5+w/xwG0Gtet 4qzB2/4iCG6a326iqv3BLMKkfhyLhn6MiTK/bc7j+Vy2Ae3SLzqyWtX63kTxO/q/Cr1j sw8bh+GKCi12i+b7j7l1tqDOOYa2AErWwC8l6osIsFVISk1KkJmvbAaKPl2OHfQy4duF aoBPLvsJvgwwSo3794EnOaSvEoq4H0QeKmUsN89duB3ID55p4buP23s3PAzc41C1za2u G0lg== X-Gm-Message-State: AOAM533D6irdslvduSmQCS8P76XUj/fz+JknWxK4sxbrfWma+oNBs5Tx Z4VO4kq189ctEiNssWtHvaUz2hkneDIn/g== X-Google-Smtp-Source: ABdhPJyCkM3svCV6/nln8mKlclYscMBiJMgYq7HwCclxZO0NMxKNAViXZ/gqU22o3+IjFp6dTMPovw== X-Received: by 2002:a05:600c:4b83:b0:38c:49b5:5bfc with SMTP id e3-20020a05600c4b8300b0038c49b55bfcmr2882952wmp.33.1647940984851; Tue, 22 Mar 2022 02:23:04 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:9e9a:99af:e5a6:319b]) by smtp.gmail.com with ESMTPSA id r14-20020a05600c35ce00b0038c9f469979sm1471695wmq.40.2022.03.22.02.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 02:23:04 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Mar 2022 09:22:55 +0000 Message-Id: <20220322092257.2713521-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220322092257.2713521-1-naush@raspberrypi.com> References: <20220322092257.2713521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 6/8] libcamera: v4l2_videodevice: Do not allow buffer queueing in stopping state 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" If the device is in the process of being stopped (i.e. Stopping state), any call to queueBuffer() must fail. This is to ensure the integrity of the buffer queue, as it gets cleared at the end of streamOff. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham --- src/libcamera/v4l2_videodevice.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 9cea6a608660..1516be129d73 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1491,6 +1491,9 @@ int V4L2VideoDevice::releaseBuffers() * The best available V4L2 buffer is picked for \a buffer using the V4L2 buffer * cache. * + * Note that \a queueBuffer will fail if the device is in the process of being + * stopped from a streaming state through the \a streamOff function. + * * \return 0 on success or a negative error code otherwise */ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) @@ -1499,6 +1502,11 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) struct v4l2_buffer buf = {}; int ret; + if (state_ == State::Stopping) { + LOG(V4L2, Error) << "Device is in a stopping state."; + return -EPERM; + } + /* * Pipeline handlers should not requeue buffers after releasing the * buffers on the device. Any occurence of this error should be fixed