[{"id":33115,"web_url":"https://patchwork.libcamera.org/comment/33115/","msgid":"<20250121110946.GK9249@pendragon.ideasonboard.com>","date":"2025-01-21T11:09:46","subject":"Re: [PATCH v1] libcamera: request: addBuffer(): Do fence check\n\tearlier","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Barnabás,\n\nThank you for the patch.\n\nOn Mon, Jan 20, 2025 at 02:16:59PM +0000, Barnabás Pőcze wrote:\n> Check if the buffer has a fence before making any modifications because\n> otherwise it is possible for `Request::addBuffer()` to return an error code\n> while at the same time the buffer - for all intents and purposes - is added\n> to the request.\n> \n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/request.cpp | 18 +++++++++---------\n>  1 file changed, 9 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\n> index 5cfafea89..e7eb1c0c8 100644\n> --- a/src/libcamera/request.cpp\n> +++ b/src/libcamera/request.cpp\n> @@ -466,6 +466,15 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer,\n>  \t\treturn -EINVAL;\n>  \t}\n>  \n> +\t/*\n> +\t * Make sure the fence has been extracted from the buffer\n> +\t * to avoid waiting on a stale fence.\n> +\t */\n> +\tif (buffer->_d()->fence()) {\n> +\t\tLOG(Request, Error) << \"Can't add buffer that still references a fence\";\n> +\t\treturn -EEXIST;\n> +\t}\n> +\n>  \tauto it = bufferMap_.find(stream);\n>  \tif (it != bufferMap_.end()) {\n>  \t\tLOG(Request, Error) << \"FrameBuffer already set for stream\";\n> @@ -476,15 +485,6 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer,\n>  \t_d()->pending_.insert(buffer);\n>  \tbufferMap_[stream] = buffer;\n>  \n> -\t/*\n> -\t * Make sure the fence has been extracted from the buffer\n> -\t * to avoid waiting on a stale fence.\n> -\t */\n> -\tif (buffer->_d()->fence()) {\n> -\t\tLOG(Request, Error) << \"Can't add buffer that still references a fence\";\n> -\t\treturn -EEXIST;\n> -\t}\n> -\n>  \tif (fence && fence->isValid())\n>  \t\tbuffer->_d()->setFence(std::move(fence));\n>","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 CB03FBD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Jan 2025 11:09:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E612B68543;\n\tTue, 21 Jan 2025 12:09:55 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BF23E60380\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Jan 2025 12:09:53 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7F15E55A;\n\tTue, 21 Jan 2025 12:08:51 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"mYYPUUfC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1737457731;\n\tbh=hf8pAMjQkbPJXpN+3uRHChKXL9I+zbC1qraZfxqoNEc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=mYYPUUfCZsd1aUQOy2goip9De2GJr1R2dgyyIHA6ep9Z96qSlUgKKkLQm+lfF9Qqz\n\t0lEe8n9a779gZslbkRthiJKqMJyl1+dd6cxsBrr0pXp2NUyMs19hy7FcW0opFh/LUU\n\tYOAX08w76TLpXGDISfKdGoPquLtIDgjLRmpwM35A=","Date":"Tue, 21 Jan 2025 13:09:46 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1] libcamera: request: addBuffer(): Do fence check\n\tearlier","Message-ID":"<20250121110946.GK9249@pendragon.ideasonboard.com>","References":"<20250120141657.95664-1-pobrn@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250120141657.95664-1-pobrn@protonmail.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":33336,"web_url":"https://patchwork.libcamera.org/comment/33336/","msgid":"<173802092768.1762371.12116989147590679420@ping.linuxembedded.co.uk>","date":"2025-01-27T23:35:27","subject":"Re: [PATCH v1] libcamera: request: addBuffer(): Do fence check\n\tearlier","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2025-01-20 14:16:59)\n> Check if the buffer has a fence before making any modifications because\n> otherwise it is possible for `Request::addBuffer()` to return an error code\n> while at the same time the buffer - for all intents and purposes - is added\n> to the request.\n> \n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/libcamera/request.cpp | 18 +++++++++---------\n>  1 file changed, 9 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\n> index 5cfafea89..e7eb1c0c8 100644\n> --- a/src/libcamera/request.cpp\n> +++ b/src/libcamera/request.cpp\n> @@ -466,6 +466,15 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer,\n>                 return -EINVAL;\n>         }\n>  \n> +       /*\n> +        * Make sure the fence has been extracted from the buffer\n> +        * to avoid waiting on a stale fence.\n> +        */\n> +       if (buffer->_d()->fence()) {\n> +               LOG(Request, Error) << \"Can't add buffer that still references a fence\";\n> +               return -EEXIST;\n> +       }\n> +\n>         auto it = bufferMap_.find(stream);\n>         if (it != bufferMap_.end()) {\n>                 LOG(Request, Error) << \"FrameBuffer already set for stream\";\n> @@ -476,15 +485,6 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer,\n>         _d()->pending_.insert(buffer);\n>         bufferMap_[stream] = buffer;\n>  \n> -       /*\n> -        * Make sure the fence has been extracted from the buffer\n> -        * to avoid waiting on a stale fence.\n> -        */\n> -       if (buffer->_d()->fence()) {\n> -               LOG(Request, Error) << \"Can't add buffer that still references a fence\";\n> -               return -EEXIST;\n> -       }\n> -\n>         if (fence && fence->isValid())\n>                 buffer->_d()->setFence(std::move(fence));\n>  \n> -- \n> 2.48.1\n> \n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E0583C3301\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 11 Feb 2025 22:33:24 +0000 (UTC)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net\n\t[86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0ECDF73E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 11 Feb 2025 23:32:07 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1739313127;\n\tbh=VyNYJnREgdxkjw2eOj2M+/DcHNG6D33Z3PsSfxB57ZA=;\n\th=In-Reply-To:References:Subject:From:To:Date:Resent-From:Resent-To:\n\tFrom;\n\tb=PYX7rTJnSDSpJY7z/HJjlvqVtTiy/mZHi5g8yhi9+H+GKpCeaDhvYCWBS7tSvOoZH\n\tHDSMaKkl/p/qF4si5eFKVysoxryPF18lUiHuLYcnYap8zB5szRbz3A+qITA13qPfTT\n\t83J3AKZdobDIzJ/AQTOYiArX0sqWkIHXurbqK+GI=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250120141657.95664-1-pobrn@protonmail.com>","References":"<20250120141657.95664-1-pobrn@protonmail.com>","Subject":"Re: [PATCH v1] libcamera: request: addBuffer(): Do fence check\n\tearlier","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Barnab??s P??cze <pobrn@protonmail.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 27 Jan 2025 23:35:27 +0000","Message-ID":"<173802092768.1762371.12116989147590679420@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","Resent-From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Resent-To":"parsemail@patchwork.libcamera.org"}}]