[{"id":5304,"web_url":"https://patchwork.libcamera.org/comment/5304/","msgid":"<20200620022743.GB5823@pendragon.ideasonboard.com>","date":"2020-06-20T02:27:43","subject":"Re: [libcamera-devel] [PATCH v2 16/17] v4l2: v4l2_camera_proxy:\n\tDon't allow buffers to be freed if still mmaped","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:22PM +0900, Paul Elder wrote:\n> In VIDIOC_REQBUFS with count = 0, if the buffers are still mmaped, they\n> should not be allowed to be freed. Add a check for this.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\nIs that required by v4l2-compliance ? V4L2 supports buffer orphaning\nsince v5.0.\n\n> ---\n> New in v2\n> - split from \"Fix v4l2-compliance streaming tests\"\n> ---\n>  src/v4l2/v4l2_camera_proxy.cpp | 3 +++\n>  1 file changed, 3 insertions(+)\n> \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index a7f987a..2eb2fcc 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -467,6 +467,9 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *cf, struct v4l2_requestbuffe\n>  \tmemset(arg->reserved, 0, sizeof(arg->reserved));\n>  \n>  \tif (arg->count == 0) {\n> +\t\tif (!mmaps_.empty())\n> +\t\t\treturn -EBUSY;\n> +\n>  \t\tif (vcam_->isRunning()) {\n>  \t\t\tfor (struct v4l2_buffer &buf : buffers_)\n>  \t\t\t\tbuf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);","headers":{"Return-Path":"<laurent.pinchart@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 3FBDE60710\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 20 Jun 2020 04:28:07 +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 CA893592;\n\tSat, 20 Jun 2020 04:28:06 +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=\"n3y8HyVf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592620087;\n\tbh=EHvb94Rm+soUHhgeMlDmW4kK9mlAB5mrpWNr8T4fazk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=n3y8HyVf03Q7HpoWIPhjwUB6e/AYsfbW7HDl2LK9eDhN7EC5IDuaZi6TR6Ze16Du+\n\tgDbusip/r1isejWLACsrQArH0VEvGw8cdbNnBxyo8rBFz0jwwF/+bzJWimrpsq0Qjh\n\t3PsdqMlUpoiXfrAPHQBsdYKF+dbx+EJ//RT7rBrg=","Date":"Sat, 20 Jun 2020 05:27:43 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200620022743.GB5823@pendragon.ideasonboard.com>","References":"<20200619054123.19052-1-paul.elder@ideasonboard.com>\n\t<20200619054123.19052-17-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200619054123.19052-17-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 16/17] v4l2: v4l2_camera_proxy:\n\tDon't allow buffers to be freed if still mmaped","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:28:07 -0000"}},{"id":5343,"web_url":"https://patchwork.libcamera.org/comment/5343/","msgid":"<20200623060222.GB2843@jade.amanokami.net>","date":"2020-06-23T06:02:22","subject":"Re: [libcamera-devel] [PATCH v2 16/17] v4l2: v4l2_camera_proxy:\n\tDon't allow buffers to be freed if still mmaped","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Laurent,\n\nThank you for the review.\n\nOn Sat, Jun 20, 2020 at 05:27:43AM +0300, Laurent Pinchart wrote:\n> Hi Paul,\n> \n> Thank you for the patch.\n> \n> On Fri, Jun 19, 2020 at 02:41:22PM +0900, Paul Elder wrote:\n> > In VIDIOC_REQBUFS with count = 0, if the buffers are still mmaped, they\n> > should not be allowed to be freed. Add a check for this.\n> > \n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> Is that required by v4l2-compliance ? V4L2 supports buffer orphaning\n> since v5.0.\n\nIt's not required, but it's warned.\n\nI think I'll keep it.\n\n> > ---\n> > New in v2\n> > - split from \"Fix v4l2-compliance streaming tests\"\n> > ---\n> >  src/v4l2/v4l2_camera_proxy.cpp | 3 +++\n> >  1 file changed, 3 insertions(+)\n> > \n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > index a7f987a..2eb2fcc 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -467,6 +467,9 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *cf, struct v4l2_requestbuffe\n> >  \tmemset(arg->reserved, 0, sizeof(arg->reserved));\n> >  \n> >  \tif (arg->count == 0) {\n> > +\t\tif (!mmaps_.empty())\n> > +\t\t\treturn -EBUSY;\n> > +\n> >  \t\tif (vcam_->isRunning()) {\n> >  \t\t\tfor (struct v4l2_buffer &buf : buffers_)\n> >  \t\t\t\tbuf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);\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 7877C603B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Jun 2020 08:02:32 +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 D25292A9;\n\tTue, 23 Jun 2020 08:02:30 +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=\"B/GixdnF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592892152;\n\tbh=f2P81DoPUy7pnMTMWKTstgLtGzoTK2Nas2Pc9tHLKLc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=B/GixdnFgf2TirnAK23K1Y/skRMozMFdGHczKbOO44SAXNjQWaiIdqJxOfl2pGDWd\n\tAii5IINw/TkzSrlWwMSdv+AZ63dBmogkYWpY2vQ7XQ3Vg/tZzKGTQ6gBzIP4H8obSc\n\toPM47wQotwa0cpbXTW7szJ3iHp2WzLb3vJqGGPEo=","Date":"Tue, 23 Jun 2020 15:02:22 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200623060222.GB2843@jade.amanokami.net>","References":"<20200619054123.19052-1-paul.elder@ideasonboard.com>\n\t<20200619054123.19052-17-paul.elder@ideasonboard.com>\n\t<20200620022743.GB5823@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20200620022743.GB5823@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 16/17] v4l2: v4l2_camera_proxy:\n\tDon't allow buffers to be freed if still mmaped","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:02:32 -0000"}}]