[{"id":5305,"web_url":"https://patchwork.libcamera.org/comment/5305/","msgid":"<20200620023314.GC5823@pendragon.ideasonboard.com>","date":"2020-06-20T02:33:14","subject":"Re: [libcamera-devel] [PATCH v2 17/17] v4l2: v4l2_camera_proxy: Fix\n\tbuffer flags related to queueing","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Fri, Jun 19, 2020 at 02:41:23PM +0900, Paul Elder wrote:\n> Fix buffer flags related to queueing and dequeueing:\n> - don't allow a buffer with the same index that is already in the queue\n>   to be enqueued again\n> - don't set the done flag on dequeueing\n\nWhy ? V4L2_BUF_FLAG_DONE is never set anymore, that doesn't seem right.\n\n> - set the mapped flag on enqueueing\n\nWhy ? Isn't it valid to queued an unmapped buffer ?\n\n> - set the flags in V4L2CameraProxy's internal buffers, and not just in\n>   the buffers returned from qbuf\n\nIt's really tempting to bundle multiple changes in the last patch, right\n? :-) It would be nice to split this, especially given that for the\nsecond and third fixes a rationale should be given in the commit message\n(assuming the fixes are correct).\n\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> ---\n> New in v2\n> - split from \"Fix v4l2-compliance streaming tests\"\n> ---\n>  src/v4l2/v4l2_camera_proxy.cpp | 9 +++++++--\n>  1 file changed, 7 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index 2eb2fcc..3e5fb7c 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -221,7 +221,6 @@ void V4L2CameraProxy::updateBuffers()\n>  \t\t\tbuf.timestamp.tv_usec = fmd.timestamp % 1000000;\n>  \t\t\tbuf.sequence = fmd.sequence;\n>  \n> -\t\t\tbuf.flags |= V4L2_BUF_FLAG_DONE;\n>  \t\t\tbreak;\n>  \t\tcase FrameMetadata::FrameError:\n>  \t\t\tbuf.flags |= V4L2_BUF_FLAG_ERROR;\n> @@ -569,6 +568,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *cf, struct v4l2_buffer *arg)\n>  \tif (arg->index >= bufferCount_)\n>  \t\treturn -EINVAL;\n>  \n> +\tif (buffers_[arg->index].flags & V4L2_BUF_FLAG_QUEUED)\n> +\t\treturn -EINVAL;\n> +\n>  \tint ret = lock(cf);\n>  \tif (ret < 0)\n>  \t\treturn ret;\n> @@ -582,9 +584,12 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *cf, struct v4l2_buffer *arg)\n>  \tif (ret < 0)\n>  \t\treturn ret;\n>  \n> -\targ->flags |= V4L2_BUF_FLAG_QUEUED;\n> +\targ->flags |= V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED;\n>  \targ->flags &= ~V4L2_BUF_FLAG_DONE;\n>  \n> +\tbuffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED;\n> +\tbuffers_[arg->index].flags &= ~V4L2_BUF_FLAG_DONE;\n\nMaybe\n\n\tbuffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED;\n\tbuffers_[arg->index].flags &= ~V4L2_BUF_FLAG_DONE;\n  \targ->flags = buffers_[arg->index].flags;\n\nto avoid duplicating the logic ?\n\n> +\n>  \treturn ret;\n>  }\n>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 A019A609A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 20 Jun 2020 04:33:38 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 22371552;\n\tSat, 20 Jun 2020 04:33:38 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ZFn+2vAA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592620418;\n\tbh=43EpFp8vir1j8ehp2ffaO7R1MHKUHESLNWSGPCYo/BM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ZFn+2vAAYJAjM8/33rl/yg9XMWb0qIVCIu4xacIIkePDQOZQ+U4Me5fK277R9fSYl\n\tYs4b7zssu3vhlRMdCVAIf1g/YcbA8d0X0eCzsWLQC/VivDD6aUiBVrFSHCiWA7nBmB\n\tCfIprgwFxGLSP3X5AJg3WIxK+Mnm3SysdC/2qqlw=","Date":"Sat, 20 Jun 2020 05:33:14 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200620023314.GC5823@pendragon.ideasonboard.com>","References":"<20200619054123.19052-1-paul.elder@ideasonboard.com>\n\t<20200619054123.19052-18-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200619054123.19052-18-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 17/17] v4l2: v4l2_camera_proxy: Fix\n\tbuffer flags related to queueing","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>","X-List-Received-Date":"Sat, 20 Jun 2020 02:33:38 -0000"}},{"id":5344,"web_url":"https://patchwork.libcamera.org/comment/5344/","msgid":"<20200623063710.GC2843@jade.amanokami.net>","date":"2020-06-23T06:37:10","subject":"Re: [libcamera-devel] [PATCH v2 17/17] v4l2: v4l2_camera_proxy: Fix\n\tbuffer flags related to queueing","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Sat, Jun 20, 2020 at 05:33:14AM +0300, Laurent Pinchart wrote:\n> Hi Paul,\n> \n> Thank you for the patch.\n> \n> On Fri, Jun 19, 2020 at 02:41:23PM +0900, Paul Elder wrote:\n> > Fix buffer flags related to queueing and dequeueing:\n> > - don't allow a buffer with the same index that is already in the queue\n> >   to be enqueued again\n> > - don't set the done flag on dequeueing\n> \n> Why ? V4L2_BUF_FLAG_DONE is never set anymore, that doesn't seem right.\n\nIt is. It's set in V4L2CameraProxy::updateBuffers(), in the first patch\nthat added the compatibility layer.\n\n> > - set the mapped flag on enqueueing\n> \n> Why ? Isn't it valid to queued an unmapped buffer ?\n\nThat's what I thought too. Anyway looks like it complies fine without it\nso I'll get rid of it.\n\n> > - set the flags in V4L2CameraProxy's internal buffers, and not just in\n> >   the buffers returned from qbuf\n> \n> It's really tempting to bundle multiple changes in the last patch, right\n\nWell they're related and small soo... :p\n\n> ? :-) It would be nice to split this, especially given that for the\n> second and third fixes a rationale should be given in the commit message\n> (assuming the fixes are correct).\n\nI'll expand the rationale then.\n\n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > \n> > ---\n> > New in v2\n> > - split from \"Fix v4l2-compliance streaming tests\"\n> > ---\n> >  src/v4l2/v4l2_camera_proxy.cpp | 9 +++++++--\n> >  1 file changed, 7 insertions(+), 2 deletions(-)\n> > \n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > index 2eb2fcc..3e5fb7c 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -221,7 +221,6 @@ void V4L2CameraProxy::updateBuffers()\n> >  \t\t\tbuf.timestamp.tv_usec = fmd.timestamp % 1000000;\n> >  \t\t\tbuf.sequence = fmd.sequence;\n> >  \n> > -\t\t\tbuf.flags |= V4L2_BUF_FLAG_DONE;\n> >  \t\t\tbreak;\n> >  \t\tcase FrameMetadata::FrameError:\n> >  \t\t\tbuf.flags |= V4L2_BUF_FLAG_ERROR;\n> > @@ -569,6 +568,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *cf, struct v4l2_buffer *arg)\n> >  \tif (arg->index >= bufferCount_)\n> >  \t\treturn -EINVAL;\n> >  \n> > +\tif (buffers_[arg->index].flags & V4L2_BUF_FLAG_QUEUED)\n> > +\t\treturn -EINVAL;\n> > +\n> >  \tint ret = lock(cf);\n> >  \tif (ret < 0)\n> >  \t\treturn ret;\n> > @@ -582,9 +584,12 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *cf, struct v4l2_buffer *arg)\n> >  \tif (ret < 0)\n> >  \t\treturn ret;\n> >  \n> > -\targ->flags |= V4L2_BUF_FLAG_QUEUED;\n> > +\targ->flags |= V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED;\n> >  \targ->flags &= ~V4L2_BUF_FLAG_DONE;\n> >  \n> > +\tbuffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED;\n> > +\tbuffers_[arg->index].flags &= ~V4L2_BUF_FLAG_DONE;\n> \n> Maybe\n> \n> \tbuffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED;\n> \tbuffers_[arg->index].flags &= ~V4L2_BUF_FLAG_DONE;\n>   \targ->flags = buffers_[arg->index].flags;\n> \n> to avoid duplicating the logic ?\n> \n> > +\n> >  \treturn ret;\n> >  }\n> >  \n\n\nThanks,\n\nPaul","headers":{"Return-Path":"<paul.elder@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 92CF0603B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Jun 2020 08:37:21 +0200 (CEST)","from jade.amanokami.net (unknown\n\t[IPv6:2400:4051:61:600:8147:f2a2:a8c6:9087])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 04DDF2A9;\n\tTue, 23 Jun 2020 08:37:18 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"AxDzWd27\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592894240;\n\tbh=VgUt+xrNiIS1LnY5q3x/esUXH7+xBXPDdM5GOz/7cZA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AxDzWd27Ogsedlw1U9rvzh/yO/EeaFvAzs3cFwrLjZyPCKtyr0LLG38IADRs6hMzZ\n\txV5kjob/n7tEZ9B+yDH1/2XJatxXA+sXe89q/cbOi3OfLqAkbVa1e1BeZWarqPAcGZ\n\tepv6XszFY/RdAj9XaAy7MhzFrpDdjrL08o14jTiA=","Date":"Tue, 23 Jun 2020 15:37:10 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200623063710.GC2843@jade.amanokami.net>","References":"<20200619054123.19052-1-paul.elder@ideasonboard.com>\n\t<20200619054123.19052-18-paul.elder@ideasonboard.com>\n\t<20200620023314.GC5823@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20200620023314.GC5823@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 17/17] v4l2: v4l2_camera_proxy: Fix\n\tbuffer flags related to queueing","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>","X-List-Received-Date":"Tue, 23 Jun 2020 06:37:21 -0000"}}]