[{"id":4963,"web_url":"https://patchwork.libcamera.org/comment/4963/","msgid":"<20200602114516.xmblulp5befnrqxg@uno.localdomain>","date":"2020-06-02T11:45:16","subject":"Re: [libcamera-devel] [PATCH 05/10] libcamera: ipu3: Calculate\n\tnumber of buffers for ImgU","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Tue, Jun 02, 2020 at 03:39:04AM +0200, Niklas Söderlund wrote:\n> Decouple the number of buffers to allocate for the ImgU from the number\n> of buffers allocated for the CIO2. Instead of blindly following the CIO2\n> pick the maximum number of buffers requested for any stream facing\n> applications.\n>\n> This is potentially wasteful, as each stream could allocate just as many\n> buffers as requested by the application instead of the maximum from the\n> set. But this is not more wasteful then whats already used by the\n> pipeline and should be fixed on top after the decoupling of the two\n> processing units.\n>\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 6 ++++--\n>  1 file changed, 4 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 0e7555c716b36749..f4759715c6ae7572 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -729,14 +729,16 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera)\n>  \tIPU3CameraData *data = cameraData(camera);\n>  \tCIO2Device *cio2 = &data->cio2_;\n>  \tImgUDevice *imgu = data->imgu_;\n> -\tunsigned int bufferCount;\n> +\tunsigned int bufferCount = 0;\n>  \tint ret;\n>\n>  \tret = cio2->allocateBuffers();\n>  \tif (ret < 0)\n>  \t\treturn ret;\n>\n> -\tbufferCount = ret;\n> +\tbufferCount = std::max<unsigned int>(data->outStream_.configuration().bufferCount, bufferCount);\n> +\tbufferCount = std::max<unsigned int>(data->vfStream_.configuration().bufferCount, bufferCount);\n> +\tbufferCount = std::max<unsigned int>(data->rawStream_.configuration().bufferCount, bufferCount);\n\nI don't have a strong opinion on the underlying idea, I think it's\nbetter than assuming we should report the number of buffer needed by\nthe CIO2 unit.\n\nOn the patch itself, could you shorten it by\n        buffercount = max(outstream, vfStream);\n        buffercounf = max(buffercount, rawStream)\n\nThat apart\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n>\n>  \tret = imgu->allocateBuffers(data, bufferCount);\n>  \tif (ret < 0) {\n> --\n> 2.26.2\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F438603CB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Jun 2020 13:41:56 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 8A7B2C0009;\n\tTue,  2 Jun 2020 11:41:55 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Tue, 2 Jun 2020 13:45:16 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200602114516.xmblulp5befnrqxg@uno.localdomain>","References":"<20200602013909.3170593-1-niklas.soderlund@ragnatech.se>\n\t<20200602013909.3170593-6-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200602013909.3170593-6-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH 05/10] libcamera: ipu3: Calculate\n\tnumber of buffers for ImgU","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, 02 Jun 2020 11:41:56 -0000"}},{"id":5004,"web_url":"https://patchwork.libcamera.org/comment/5004/","msgid":"<20200604032318.GQ27695@pendragon.ideasonboard.com>","date":"2020-06-04T03:23:18","subject":"Re: [libcamera-devel] [PATCH 05/10] libcamera: ipu3: Calculate\n\tnumber of buffers for ImgU","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Tue, Jun 02, 2020 at 03:39:04AM +0200, Niklas Söderlund wrote:\n> Decouple the number of buffers to allocate for the ImgU from the number\n> of buffers allocated for the CIO2. Instead of blindly following the CIO2\n> pick the maximum number of buffers requested for any stream facing\n> applications.\n> \n> This is potentially wasteful, as each stream could allocate just as many\n> buffers as requested by the application instead of the maximum from the\n> set. But this is not more wasteful then whats already used by the\n\ns/then/than/\ns/whats/what is/\n\n> pipeline and should be fixed on top after the decoupling of the two\n> processing units.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 6 ++++--\n>  1 file changed, 4 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 0e7555c716b36749..f4759715c6ae7572 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -729,14 +729,16 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera)\n>  \tIPU3CameraData *data = cameraData(camera);\n>  \tCIO2Device *cio2 = &data->cio2_;\n>  \tImgUDevice *imgu = data->imgu_;\n> -\tunsigned int bufferCount;\n> +\tunsigned int bufferCount = 0;\n>  \tint ret;\n>  \n>  \tret = cio2->allocateBuffers();\n>  \tif (ret < 0)\n>  \t\treturn ret;\n>  \n> -\tbufferCount = ret;\n> +\tbufferCount = std::max<unsigned int>(data->outStream_.configuration().bufferCount, bufferCount);\n> +\tbufferCount = std::max<unsigned int>(data->vfStream_.configuration().bufferCount, bufferCount);\n> +\tbufferCount = std::max<unsigned int>(data->rawStream_.configuration().bufferCount, bufferCount);\n\nMaybe\n\n\tbufferCount = std::max({\n\t\tdata->outStream_.configuration().bufferCount,\n\t\tdata->vfStream_.configuration().bufferCount,\n\t\tdata->rawStream_.configuration().bufferCount\n\t});\n\n?\n\nWe definitely need to handle the issue of buffer count configuration\nsooner than later. I'm not opposed to this change if it helps within the\ncontext of the whole series, but I wonder why the raw stream needs to be\nincluded here.\n\n>  \n>  \tret = imgu->allocateBuffers(data, bufferCount);\n>  \tif (ret < 0) {","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 BD58E6115D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Jun 2020 05:23:34 +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 2EC2629B;\n\tThu,  4 Jun 2020 05:23:34 +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=\"ZFnb16rg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1591241014;\n\tbh=xcu+/9MjICl+XGFZe07Zne41CuZmYvPc23zvFSthM7c=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ZFnb16rgS1bZw7qnfG+Hkn3+V5T3SXG4+TcMQ/tvpo3ectADjFmQuviIY3eQ6E/dV\n\tyaGKlJZEYTaPe7tH+/cUIujfC+4hEWIekAiG1+uPOZeUYg58BRkeVLrNfXdfClm9Vx\n\tB2segkDTcbDePGnY0TiWfk066MbTAcwKNFw3xId4=","Date":"Thu, 4 Jun 2020 06:23:18 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200604032318.GQ27695@pendragon.ideasonboard.com>","References":"<20200602013909.3170593-1-niklas.soderlund@ragnatech.se>\n\t<20200602013909.3170593-6-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200602013909.3170593-6-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH 05/10] libcamera: ipu3: Calculate\n\tnumber of buffers for ImgU","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":"Thu, 04 Jun 2020 03:23:35 -0000"}}]