From patchwork Fri Mar 25 09:09:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15546 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 2829FC0F1B for ; Fri, 25 Mar 2022 09:09:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D2867632E8; Fri, 25 Mar 2022 10:09:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648199354; bh=s5y2qLBZYfMPw4FyQu8zhn3G4H/9ocLISzpueUvx/F0=; 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=fVCNLMqXzmfe3/+8kZcoH3fSNZhjVDRqU9GJgJI9Gzh81XO6C6MRzfVNhy2fGpU+k hqxDIwKw4eBa6zrvWjaJ/Yk2ejtEngGTGEzU63IQldt53aSUyEu/c/LXEzGDNWJdTC FTxu+iT78mjnBUmAJxOvHjTKsJocAs+ibz6eOTbk0h0OQqObwbN1NWOv2CcZXdKVA9 AV7QectAApUJKoyCJWI4KE27Rr2huJdD9dBUsN0Go0bnG+QSjmMPnSlY14qD9B5hnj pZp32zmCBMTGPUOUDhngYcm29nQTUutMvHPuH3E0JNnYfu290/ghQ+EhxmYaOQq0Gm Y4OQcC7L2MHwQ== Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 50B65604C4 for ; Fri, 25 Mar 2022 10:09:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="nnaRRZMl"; dkim-atps=neutral Received: by mail-wr1-x429.google.com with SMTP id h4so9925444wrc.13 for ; Fri, 25 Mar 2022 02:09:12 -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=1H2qLEHnAgihB+y26jW/31zTk3ZzfqSkaZ7pYckt22c=; b=nnaRRZMlOUoWbvD6tqISlRJwOFV9/4pVgR7EuAIblUmXhFzHMcp++YEzlcbf1ZH2FO hzgYYduKPnfu7xNXlMQkMwDEbF2spy+2g6T5yYt20dxnv44YliewxMWiKY3LBItQryk6 /usg4ha/ZkXGC/OJwTzeOQ5nUcbQ29sXDAwiO161vjZl8+POXv/uThMTEw8OLLlOUiTn 3WJCWKQrC5txWIxDoTyiVzM9mhec0dCzj3VNa9nNFQ/5mPagX7wP5fEBg+FafN5KTn7n vFlaK5eg7IBpzVLXyW4eEBZn1Kn0wrTEbTLOZRK0lkUBQ8FlE2O5478EWWNrS9lwkQz5 TC7Q== 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=1H2qLEHnAgihB+y26jW/31zTk3ZzfqSkaZ7pYckt22c=; b=pJDs4sjQGZ+feWmddjJdKJgOKlS1QfCMiyT/s7n+bM6JrY5ySNG6I1wRWEjJtxbPkg MNue/vLuncZPjbxKPoasPTyAkMBeFq4WKwaYk5P7Li1H9YsfQH5oJL4gGomy3wJDSdYX 67L+ZE6pKmJTmSQ1k/x+oFBjLkwISH/Es6W9mI5kxnrP+TiAdgGuvK2Quwi31xgbca5w ZmgqyjDOXZgDwmoprG1Qc1KtohrKEihjuWk0emq1rGHLmkzNjee2qmuObP15kPRJLfzI 9x+AoPFYicpIXjZ9cH1X+2uHtUtwBlczodDR2P9jwU6YWx7FtHychlMFH586DF5aWD62 DyIQ== X-Gm-Message-State: AOAM530AX/hq6Uybnlnm04q76G0T+5qiqIJKbOitHzfOu2So/TmhGC11 VEvywpkP/zBhTpcRJalo7sxUjnESFlLNtw== X-Google-Smtp-Source: ABdhPJyV+dFiZ5TlrUZTRQHUzM5HchpQmf1HehlwKF3p5WL4dwjOm0plp70/tTGz138vPbJou6D2RQ== X-Received: by 2002:adf:e108:0:b0:1ef:97ad:5372 with SMTP id t8-20020adfe108000000b001ef97ad5372mr8037972wrz.658.1648199351812; Fri, 25 Mar 2022 02:09:11 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:478c:773f:4734:d0bc]) by smtp.gmail.com with ESMTPSA id c4-20020a056000184400b0020584c40778sm4915297wri.103.2022.03.25.02.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 02:09:11 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Mar 2022 09:09:01 +0000 Message-Id: <20220325090903.880311-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220325090903.880311-1-naush@raspberrypi.com> References: <20220325090903.880311-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Reviewed-by: Laurent Pinchart --- 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..28f336086b49 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 queueBuffer() will fail if the device is in the process of being + * stopped from a streaming state through streamOff(). + * * \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 -ESHUTDOWN; + } + /* * Pipeline handlers should not requeue buffers after releasing the * buffers on the device. Any occurence of this error should be fixed