[{"id":20307,"web_url":"https://patchwork.libcamera.org/comment/20307/","msgid":"<20211019121302.7rh5tseenkkay2r6@uno.localdomain>","date":"2021-10-19T12:13:02","subject":"Re: [libcamera-devel] [PATCH v2 10/12] android: camera_stream:\n\tDon't close fence if wait fails","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Umang,\n\nOn Tue, Oct 19, 2021 at 05:18:00PM +0530, Umang Jain wrote:\n> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> The camera HAL APIs requires that any acquire fence that hasn't been\n> waited on to be sent back to the framework as a release fence. The\n> CameraDevice already copies the acquire fence to the release fence when\n> signaling request completion, but the CameraStream incorrectly closes\n> the fence when a wait fails and sets it to -1. Fix it.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Umang Jain<umang.jain@ideasonboard.com>\n\nGood catch!\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> ---\n>  src/android/camera_stream.cpp | 12 ++++++------\n>  1 file changed, 6 insertions(+), 6 deletions(-)\n>\n> diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\n> index 9b5cd0c4..8e6ccb83 100644\n> --- a/src/android/camera_stream.cpp\n> +++ b/src/android/camera_stream.cpp\n> @@ -147,16 +147,16 @@ int CameraStream::process(const FrameBuffer &source,\n>  \t\t\t  Camera3RequestDescriptor *request)\n>  {\n>  \t/* Handle waiting on fences on the destination buffer. */\n> -\tint fence = dest.fence;\n> -\tif (fence != -1) {\n> -\t\tint ret = waitFence(fence);\n> -\t\t::close(fence);\n> -\t\tdest.fence = -1;\n> +\tif (dest.fence != -1) {\n> +\t\tint ret = waitFence(dest.fence);\n>  \t\tif (ret < 0) {\n>  \t\t\tLOG(HAL, Error) << \"Failed waiting for fence: \"\n> -\t\t\t\t\t<< fence << \": \" << strerror(-ret);\n> +\t\t\t\t\t<< dest.fence << \": \" << strerror(-ret);\n>  \t\t\treturn ret;\n>  \t\t}\n> +\n> +\t\t::close(dest.fence);\n> +\t\tdest.fence = -1;\n>  \t}\n>\n>  \tif (!postProcessor_)\n> --\n> 2.31.0\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 1B577C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Oct 2021 12:12:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DE76A604FF;\n\tTue, 19 Oct 2021 14:12:13 +0200 (CEST)","from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3532A604FE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Oct 2021 14:12:13 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay4-d.mail.gandi.net (Postfix) with ESMTPSA id AE330E0011;\n\tTue, 19 Oct 2021 12:12:12 +0000 (UTC)"],"Date":"Tue, 19 Oct 2021 14:13:02 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<20211019121302.7rh5tseenkkay2r6@uno.localdomain>","References":"<20211019114802.665980-1-umang.jain@ideasonboard.com>\n\t<20211019114802.665980-11-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211019114802.665980-11-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 10/12] android: camera_stream:\n\tDon't close fence if wait fails","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":20311,"web_url":"https://patchwork.libcamera.org/comment/20311/","msgid":"<CAO5uPHMz+hDeQktZGf4d+UYChURCP3+8NmXRZRJDiGu_OOgK2Q@mail.gmail.com>","date":"2021-10-20T02:15:11","subject":"Re: [libcamera-devel] [PATCH v2 10/12] android: camera_stream:\n\tDon't close fence if wait fails","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Laurent and Umang, thank you for the patch.\n\nOn Tue, Oct 19, 2021 at 9:12 PM Jacopo Mondi <jacopo@jmondi.org> wrote:\n>\n> Hi Umang,\n>\n> On Tue, Oct 19, 2021 at 05:18:00PM +0530, Umang Jain wrote:\n> > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> >\n> > The camera HAL APIs requires that any acquire fence that hasn't been\n> > waited on to be sent back to the framework as a release fence. The\n> > CameraDevice already copies the acquire fence to the release fence when\n> > signaling request completion, but the CameraStream incorrectly closes\n> > the fence when a wait fails and sets it to -1. Fix it.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > Reviewed-by: Umang Jain<umang.jain@ideasonboard.com>\n>\n\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\n\n> Good catch!\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n>\n> Thanks\n>   j\n>\n> > ---\n> >  src/android/camera_stream.cpp | 12 ++++++------\n> >  1 file changed, 6 insertions(+), 6 deletions(-)\n> >\n> > diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\n> > index 9b5cd0c4..8e6ccb83 100644\n> > --- a/src/android/camera_stream.cpp\n> > +++ b/src/android/camera_stream.cpp\n> > @@ -147,16 +147,16 @@ int CameraStream::process(const FrameBuffer &source,\n> >                         Camera3RequestDescriptor *request)\n> >  {\n> >       /* Handle waiting on fences on the destination buffer. */\n> > -     int fence = dest.fence;\n> > -     if (fence != -1) {\n> > -             int ret = waitFence(fence);\n> > -             ::close(fence);\n> > -             dest.fence = -1;\n> > +     if (dest.fence != -1) {\n> > +             int ret = waitFence(dest.fence);\n> >               if (ret < 0) {\n> >                       LOG(HAL, Error) << \"Failed waiting for fence: \"\n> > -                                     << fence << \": \" << strerror(-ret);\n> > +                                     << dest.fence << \": \" << strerror(-ret);\n> >                       return ret;\n> >               }\n> > +\n> > +             ::close(dest.fence);\n> > +             dest.fence = -1;\n> >       }\n> >\n> >       if (!postProcessor_)\n> > --\n> > 2.31.0\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 B09A5BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Oct 2021 02:15:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6748868F56;\n\tWed, 20 Oct 2021 04:15:23 +0200 (CEST)","from mail-ed1-x530.google.com (mail-ed1-x530.google.com\n\t[IPv6:2a00:1450:4864:20::530])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AD27460125\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Oct 2021 04:15:21 +0200 (CEST)","by mail-ed1-x530.google.com with SMTP id t16so20189244eds.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Oct 2021 19:15:21 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"TMdEKooz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=Iv28FtISFX6+pMCw4Q1GUIKoknul/LECfmjt+6n+CTc=;\n\tb=TMdEKoozEbHYh+lRJmavNNETtZdOdkQe8p7AMtiQzUd5HzLR3+E3l81UAzVYGHudJH\n\trHb5nea7kfh7xqaBgWW30uNv3ravzGO+EhXl58YvYsaDNsnyt7MziJ8WghW+zMupa5v4\n\ttvE92LHmBYjU7Um0KtLZ50E79EYpxuC73wOfg=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=Iv28FtISFX6+pMCw4Q1GUIKoknul/LECfmjt+6n+CTc=;\n\tb=DUEt3L1rOnOaYwUKwiLwkklXM1dTCKRNrseOMX74yWFmnvufRypGTwAiCsaWvxtkuM\n\tCxBZ1esydSbvriC0pxZjUtrasRcEJ3CzGmOLl2GoW1oR8eCIrBKr5jumcL4QajWRE4Gd\n\tXvcyM7Sx9jacSo7FA2CgguM1q+kPqJdS8I32oiN57o1ZGC7gr7vkj9AViBMOMSQ5LXOj\n\tb+qQ/X13nWy4aoX+x8lTaBOEuCStx12Q6BDhO3CzUAfBP17mLdVhgs6/fWiy5Xv2lG0p\n\tHAvTE1eJUNhzX4quXMfXllAlBMw1VjQPez17eDdnm54T71US8syDxTLOW1xKKkUMquL9\n\tw+qQ==","X-Gm-Message-State":"AOAM532wmZFT/Blw9hsBWIV1747kywcdiKJJYonT0ReWDLXiT5hL8CMC\n\t15S0XdREz6r+Zj40gDsSF/MrBDj/oFErSW2d3j+DNZt8zyc=","X-Google-Smtp-Source":"ABdhPJwVlFNil1++OM4YRDBxMN01DylMh8RSwWMtPDce2I6ecFL+G0y38aBiTQqVWoxapb+kukyEwDBjqhQKXr1MFJ0=","X-Received":"by 2002:a17:906:5801:: with SMTP id\n\tm1mr42217970ejq.296.1634696121368; \n\tTue, 19 Oct 2021 19:15:21 -0700 (PDT)","MIME-Version":"1.0","References":"<20211019114802.665980-1-umang.jain@ideasonboard.com>\n\t<20211019114802.665980-11-umang.jain@ideasonboard.com>\n\t<20211019121302.7rh5tseenkkay2r6@uno.localdomain>","In-Reply-To":"<20211019121302.7rh5tseenkkay2r6@uno.localdomain>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Wed, 20 Oct 2021 11:15:11 +0900","Message-ID":"<CAO5uPHMz+hDeQktZGf4d+UYChURCP3+8NmXRZRJDiGu_OOgK2Q@mail.gmail.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 10/12] android: camera_stream:\n\tDon't close fence if wait fails","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]