[{"id":22471,"web_url":"https://patchwork.libcamera.org/comment/22471/","msgid":"<YkDuuE0Iq06EnP1f@pendragon.ideasonboard.com>","date":"2022-03-27T23:09:44","subject":"Re: [libcamera-devel] [PATCH v5 6/8] libcamera: v4l2_videodevice:\n\tDo not allow buffer queueing in stopping state","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Fri, Mar 25, 2022 at 09:09:01AM +0000, Naushir Patuck via libcamera-devel wrote:\n> If the device is in the process of being stopped (i.e. Stopping state), any\n> call to queueBuffer() must fail. This is to ensure the integrity of the buffer\n> queue, as it gets cleared at the end of streamOff.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/v4l2_videodevice.cpp | 8 ++++++++\n>  1 file changed, 8 insertions(+)\n> \n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 9cea6a608660..28f336086b49 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -1491,6 +1491,9 @@ int V4L2VideoDevice::releaseBuffers()\n>   * The best available V4L2 buffer is picked for \\a buffer using the V4L2 buffer\n>   * cache.\n>   *\n> + * Note that queueBuffer() will fail if the device is in the process of being\n> + * stopped from a streaming state through streamOff().\n> + *\n>   * \\return 0 on success or a negative error code otherwise\n>   */\n>  int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)\n> @@ -1499,6 +1502,11 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)\n>  \tstruct v4l2_buffer buf = {};\n>  \tint ret;\n>  \n> +\tif (state_ == State::Stopping) {\n> +\t\tLOG(V4L2, Error) << \"Device is in a stopping state.\";\n> +\t\treturn -ESHUTDOWN;\n> +\t}\n> +\n>  \t/*\n>  \t * Pipeline handlers should not requeue buffers after releasing the\n>  \t * buffers on the device. Any occurence of this error should be fixed","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7FDF6C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 27 Mar 2022 23:09:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AF44965631;\n\tMon, 28 Mar 2022 01:09:48 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 83AB8600B0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Mar 2022 01:09:46 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DEBBC2F7;\n\tMon, 28 Mar 2022 01:09:45 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648422588;\n\tbh=FUmRsTGe7qB3193KiH8fRcL5tS9Iy8q7JQOwzXiprTc=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=FAYXnlTCc9StEhpguDOvQhFbN89tBr4aHAMm9SzVQYiD+WKpCmNtNE2pgH7AYzQqe\n\tYfbmGNlHJMy6eGDwrHTb9pYZbiBvNKfOFNljwFt/ZrfzT/WUE9+PM0ro0gc5URnDOJ\n\tsNGLb+t9eiIdcy2thlMFURrs4r/LasBysR+6qXq5+StgVZh303l7kVxrq0OWTpQvsh\n\tq49sCqVlqJ9dRWAVPikvinMhnv5sHP0NHJfowcgpfb67roAPbd/i8T/fkzrUPw+9id\n\txCWqN4EKutKdnEN9Lxn+5M8w8ur5X4+A8EoNU6IvHEh/S29dhVMIffVS7Y6cDSFOzh\n\tgml6c32sJtibg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1648422586;\n\tbh=FUmRsTGe7qB3193KiH8fRcL5tS9Iy8q7JQOwzXiprTc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=LwIb9J8yFwgKfM5W3QMVdLfCGYGHTckFFo8N2HbiM1Rl+K4dIMDt6/c/t9Bd8wEY+\n\tKENB9OWC9EwwTPdWfQpppaaVIZsEWJKCKkY6UvfPrNWA9Up5nsEgYVoBi9C/TIjw6y\n\tBS+F/9/PCMDgAGNml9r45EiNh9ueHU9neujE0jXI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"LwIb9J8y\"; dkim-atps=neutral","Date":"Mon, 28 Mar 2022 02:09:44 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YkDuuE0Iq06EnP1f@pendragon.ideasonboard.com>","References":"<20220325090903.880311-1-naush@raspberrypi.com>\n\t<20220325090903.880311-7-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220325090903.880311-7-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v5 6/8] libcamera: v4l2_videodevice:\n\tDo not allow buffer queueing in stopping state","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]