[{"id":22253,"web_url":"https://patchwork.libcamera.org/comment/22253/","msgid":"<CAHW6GY+oaS7VgWu0xBp4SXK=mqsDKiDWW=ZqZqCXdNVhVzhfsQ@mail.gmail.com>","date":"2022-03-10T10:40:49","subject":"Re: [libcamera-devel] [PATCH v1 3/6] pipeline: raspberrypi: Free\n\tbuffers in the RPiCamera destructor and re-configure","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Naush\n\nThanks for this patch.\n\nOn Mon, 7 Mar 2022 at 12:46, Naushir Patuck via libcamera-devel\n<libcamera-devel@lists.libcamera.org> wrote:\n>\n> Currently, all framebuffer allocations get freed and cleared on a stop in\n> PipelineHandlerRPi::stopDevice(). If PipelineHandlerRPi::start() is then called\n> without an intermediate PipelineHandlerRPi::configure(), it will re-allocate and\n> prepare all the buffers again, which is unnecessary.\n>\n> Fix this by not freeing the buffer in PipelineHandlerRPi::stopDevice(), but\n> insted doing it in PipelineHandlerRPi::configure(), as the buffers might have\n> to be resized.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 +++++++---\n>  1 file changed, 7 insertions(+), 3 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 3781e4e0e3c4..8bb9fc429912 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -189,6 +189,11 @@ public:\n>         {\n>         }\n>\n> +       ~RPiCameraData()\n> +       {\n> +               freeBuffers();\n> +       }\n> +\n>         void freeBuffers();\n>         void frameStarted(uint32_t sequence);\n>\n> @@ -681,7 +686,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n>         RPiCameraData *data = cameraData(camera);\n>         int ret;\n>\n> -       /* Start by resetting the Unicam and ISP stream states. */\n> +       /* Start by freeing all buffers and resetting the Unicam and ISP stream states. */\n> +       data->freeBuffers();\n>         for (auto const stream : data->streams_)\n>                 stream->reset();\n>\n> @@ -1048,8 +1054,6 @@ void PipelineHandlerRPi::stopDevice(Camera *camera)\n>\n>         /* Stop the IPA. */\n>         data->ipa_->stop();\n> -\n> -       data->freeBuffers();\n>  }\n>\n>  int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)\n> --\n> 2.25.1\n>\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nTested-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks!\nDavid","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 F142DBE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 10 Mar 2022 10:41:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 46DBE604ED;\n\tThu, 10 Mar 2022 11:41:03 +0100 (CET)","from mail-wr1-x430.google.com (mail-wr1-x430.google.com\n\t[IPv6:2a00:1450:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4234D601FF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 10 Mar 2022 11:41:01 +0100 (CET)","by mail-wr1-x430.google.com with SMTP id t11so7238492wrm.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 10 Mar 2022 02:41:01 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1646908863;\n\tbh=7nQmbw1njIS7t7tCafB24Kaj5QqoPoK6tbdfavGlECE=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=s4C/pqtFUf5KI13rPXXF9vg1M9VJ/quUL//wxEnhhyibGIEHq1sLeFf8YrRb3QW9q\n\tlm+Atfd7sTE4R7iSstfojVjCxzexMba5LVtjhnPVBFhac7FaE5dtL4VNUyVBhOeDdQ\n\tz0uap4vuyl65GMABC2re6cwF2/f78TJ7nRBl+Af46ra4OPLMSXw00mmZGLeF+42Itv\n\tMVzHSgX4zG1haeykaeACZFo67qYwkaZ796fc8pwKVnedmd78CD0ywUpboYnC9PMVdb\n\t/EO7k1dsl7LN32GoJtnJqPBLOYocxwsKiSgJxe8ZETgTJot/XHdBB0lWNro7ISPPdk\n\tLgF1KsR5h2oqQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=63mzILn/YOxVMTLvgLuBj/4u6B/5PK4sakMq/RQ809E=;\n\tb=F/fyxKXllCNyyYaaYJ25s27pA9OI9+/k4Zb50OoJf12WDRGOfoh6Ql4DFpKrk+XNs1\n\tI0cPXCB76zlA6li/ADYeGPOmXYVQv9NTRkPgE1tjd7bq3BTqd9PELyBvAL6jWvgjZwfh\n\tBp+LVwIyE1RRHnuLEay11W85y2OilYXx2H+R1eky4oer+esZvOF/hfOhx5VB9JgDGKrq\n\tSB5DxFKA+Q5l4l6PgHrWcxuMh92o7y9coSoqdyJtAoMjQaK3JnbnzTe5zbBRj0WH2gqc\n\t6h9ucU1+jc67Sl6zQaeVu6h191WY+epa1sp0q3wKrzWMGp0+l84hbmmt/dDtzESJMUkv\n\txWJA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"F/fyxKXl\"; dkim-atps=neutral","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=63mzILn/YOxVMTLvgLuBj/4u6B/5PK4sakMq/RQ809E=;\n\tb=NBMT8lx0bbHyPegfCx9iSS0QbQFEQKbwbHjf8hAfAKDJs1Z2VYuheCCuPv+AS5o279\n\tVS+rb9opy9NiTL4F4yVDRUYfaP3qYKwW5KV+XZMWa3eFDfJpSKNTUSh92Yt3n4+yDnDL\n\tJ8uH7SvMXoemZ/TwPdt3vMJjpZEiG2nSe9MMh0JnxOsOVK+B7iBNo36H9SUf/pV9fdH6\n\tYl2WvYNE7nQGUEibLu8uj7058z/c/USnjhoFMAGJvBcYC2wE4Aah28rEG4+L2XrwA+Ds\n\tvuFNRi+x7NcW0XrSI2T+wK4guNgMYenU/HSCxDfaHEZfPMh5zOZSEZyPX2UwUrdz+fvD\n\txhQw==","X-Gm-Message-State":"AOAM530z+/MXoxsuMk2nr5GqvGyV+a3gDQB/F60+2N0ylGuCpUkJ1gND\n\tXfsWM6a4xcPwsQPdjV0W1vLNiSDBdBiwIg33+0REulN/1L0=","X-Google-Smtp-Source":"ABdhPJyFDBqTmAScmNRyAyCtlwSfRv5xRUXX1vimEeyqsmzFhRxaMqX0kzMqNC6SdkGVnZU/7F55wtzM3kOoWLmVU50=","X-Received":"by 2002:a5d:5746:0:b0:1ea:9643:92ac with SMTP id\n\tq6-20020a5d5746000000b001ea964392acmr3015864wrw.597.1646908860875;\n\tThu, 10 Mar 2022 02:41:00 -0800 (PST)","MIME-Version":"1.0","References":"<20220307124633.115452-1-naush@raspberrypi.com>\n\t<20220307124633.115452-4-naush@raspberrypi.com>","In-Reply-To":"<20220307124633.115452-4-naush@raspberrypi.com>","Date":"Thu, 10 Mar 2022 10:40:49 +0000","Message-ID":"<CAHW6GY+oaS7VgWu0xBp4SXK=mqsDKiDWW=ZqZqCXdNVhVzhfsQ@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v1 3/6] pipeline: raspberrypi: Free\n\tbuffers in the RPiCamera destructor and re-configure","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>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","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>"}},{"id":22265,"web_url":"https://patchwork.libcamera.org/comment/22265/","msgid":"<Yi4ViQO88WQYT0Wo@pendragon.ideasonboard.com>","date":"2022-03-13T16:02:17","subject":"Re: [libcamera-devel] [PATCH v1 3/6] pipeline: raspberrypi: Free\n\tbuffers in the RPiCamera destructor and re-configure","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"H Naush,\n\nThank you for the patch.\n\nOn Mon, Mar 07, 2022 at 12:46:30PM +0000, Naushir Patuck via libcamera-devel wrote:\n> Currently, all framebuffer allocations get freed and cleared on a stop in\n> PipelineHandlerRPi::stopDevice(). If PipelineHandlerRPi::start() is then called\n> without an intermediate PipelineHandlerRPi::configure(), it will re-allocate and\n> prepare all the buffers again, which is unnecessary.\n> \n> Fix this by not freeing the buffer in PipelineHandlerRPi::stopDevice(), but\n> insted doing it in PipelineHandlerRPi::configure(), as the buffers might have\n> to be resized.\n\nI see where you're going, but doesn't this mean that buffers will stay\nallocated forever ? If an application uses a camera for some time and\nthen stops it, memory won't be released until the application\nterminates. That's trading an issue for another one, and which one is\nworse really depends on the use case.\n\nThere are (at least) two ways to address this. The simplest one would be\nto fire a timer at stop() time, and free buffers when it elapses. The\ntimer would be cancelled if the camera is restarted first.\n\nThe second option is to make this controllable by the application. We\ncould hook it up to the Camera::release() call for instance, adding a\nnew pipeline handler operation to handle it. release() may not be the\nbest option though, maybe we need a new cleanup function. Or maybe an\nargument to stop(), to tell if the camera is expected to be restarted\nsoon ? I haven't really thought about the pros and cons of the different\noptions, I'm just brainstorming here.\n\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 +++++++---\n>  1 file changed, 7 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 3781e4e0e3c4..8bb9fc429912 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -189,6 +189,11 @@ public:\n>  \t{\n>  \t}\n>  \n> +\t~RPiCameraData()\n> +\t{\n> +\t\tfreeBuffers();\n> +\t}\n> +\n>  \tvoid freeBuffers();\n>  \tvoid frameStarted(uint32_t sequence);\n>  \n> @@ -681,7 +686,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n>  \tRPiCameraData *data = cameraData(camera);\n>  \tint ret;\n>  \n> -\t/* Start by resetting the Unicam and ISP stream states. */\n> +\t/* Start by freeing all buffers and resetting the Unicam and ISP stream states. */\n> +\tdata->freeBuffers();\n>  \tfor (auto const stream : data->streams_)\n>  \t\tstream->reset();\n>  \n> @@ -1048,8 +1054,6 @@ void PipelineHandlerRPi::stopDevice(Camera *camera)\n>  \n>  \t/* Stop the IPA. */\n>  \tdata->ipa_->stop();\n> -\n> -\tdata->freeBuffers();\n>  }\n>  \n>  int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)","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 154E3BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 13 Mar 2022 16:02:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7224F6118A;\n\tSun, 13 Mar 2022 17:02:35 +0100 (CET)","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 7A25B604E7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 13 Mar 2022 17:02:34 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 044A9475;\n\tSun, 13 Mar 2022 17:02:33 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647187355;\n\tbh=OsWFSGoapS/OnbwEmG5C1xnaqx3cwz5EK5QmrJxL7Hw=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=b+UjhvxM+ifGzr6A3f+J5iAiZx73bQB3H2flNkfqOsiSPgMhp7YglcAWCrLYjATNj\n\t8jSaxC1ZkdCUVv3x27H4v4VU9/CUvENa1fNd6aT6K3qh7fgsdPgPf+mhQbfcPDKgAX\n\t74rcffU4kCADFn0z2xsL7TdkDfUxnJ30+eFNIXdx9/l62aSVCrfpPedUVMfsfgZATH\n\tY92gPOH17se626srKcHhQQnw4WR/ByoFxoZRK2KYDr1hQ6E0aqpZl7nRekmYNuDQUX\n\tDMyNqNKcFpxlXuZVlDIGj45X4yF6TDhkd37ODxHbYUOU8fvDIoUXq+O4Bqq8UcsVhA\n\tqbUzyDEfK/I4g==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1647187354;\n\tbh=OsWFSGoapS/OnbwEmG5C1xnaqx3cwz5EK5QmrJxL7Hw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=k0LYhzGQ3qsY+0qOKkPm4JZPJSzewVXVmTvcak7rpLxhA7uWXk7uz6Of3zHjC/wZ1\n\t6IfkvHva1kGmJXEDoPdwX17wt7lTvjnZD3UqPYZTFeKDOamxmKdLhGyGd2s/WtvU53\n\t9g1nWsWVLQqMS0w0Fi7A/33OYXEln1thVreJ4VMY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"k0LYhzGQ\"; dkim-atps=neutral","Date":"Sun, 13 Mar 2022 18:02:17 +0200","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<Yi4ViQO88WQYT0Wo@pendragon.ideasonboard.com>","References":"<20220307124633.115452-1-naush@raspberrypi.com>\n\t<20220307124633.115452-4-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220307124633.115452-4-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v1 3/6] pipeline: raspberrypi: Free\n\tbuffers in the RPiCamera destructor and re-configure","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22269,"web_url":"https://patchwork.libcamera.org/comment/22269/","msgid":"<CAEmqJPqTgqfSs5jPuWNoUHA5V5ksPY-SWxok8bDPU95UAX4+Gg@mail.gmail.com>","date":"2022-03-14T11:13:44","subject":"Re: [libcamera-devel] [PATCH v1 3/6] pipeline: raspberrypi: Free\n\tbuffers in the RPiCamera destructor and re-configure","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Laurent,\n\nThank you for your feedback!\n\nOn Sun, 13 Mar 2022 at 16:02, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> H Naush,\n>\n> Thank you for the patch.\n>\n> On Mon, Mar 07, 2022 at 12:46:30PM +0000, Naushir Patuck via\n> libcamera-devel wrote:\n> > Currently, all framebuffer allocations get freed and cleared on a stop in\n> > PipelineHandlerRPi::stopDevice(). If PipelineHandlerRPi::start() is then\n> called\n> > without an intermediate PipelineHandlerRPi::configure(), it will\n> re-allocate and\n> > prepare all the buffers again, which is unnecessary.\n> >\n> > Fix this by not freeing the buffer in PipelineHandlerRPi::stopDevice(),\n> but\n> > insted doing it in PipelineHandlerRPi::configure(), as the buffers might\n> have\n> > to be resized.\n>\n> I see where you're going, but doesn't this mean that buffers will stay\n> allocated forever ? If an application uses a camera for some time and\n> then stops it, memory won't be released until the application\n> terminates. That's trading an issue for another one, and which one is\n> worse really depends on the use case.\n>\n> There are (at least) two ways to address this. The simplest one would be\n> to fire a timer at stop() time, and free buffers when it elapses. The\n> timer would be cancelled if the camera is restarted first.\n>\n> The second option is to make this controllable by the application. We\n> could hook it up to the Camera::release() call for instance, adding a\n> new pipeline handler operation to handle it. release() may not be the\n> best option though, maybe we need a new cleanup function. Or maybe an\n> argument to stop(), to tell if the camera is expected to be restarted\n> soon ? I haven't really thought about the pros and cons of the different\n> options, I'm just brainstorming here.\n>\n\nYes, I do see a possible issue here with holding onto buffers for longer\nthan\nexpected.  My preferred option would be to have a Camera::release() call\nthat explicitly requests the pipeline handler to remove all buffer\nallocations.\nThat way, the application controls the intended behavior if it chooses to,\nbut\nthe pipeline handler keeps buffers allocated otherwise.\n\nRegards,\nNaush\n\n\n>\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > ---\n> >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 +++++++---\n> >  1 file changed, 7 insertions(+), 3 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > index 3781e4e0e3c4..8bb9fc429912 100644\n> > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > @@ -189,6 +189,11 @@ public:\n> >       {\n> >       }\n> >\n> > +     ~RPiCameraData()\n> > +     {\n> > +             freeBuffers();\n> > +     }\n> > +\n> >       void freeBuffers();\n> >       void frameStarted(uint32_t sequence);\n> >\n> > @@ -681,7 +686,8 @@ int PipelineHandlerRPi::configure(Camera *camera,\n> CameraConfiguration *config)\n> >       RPiCameraData *data = cameraData(camera);\n> >       int ret;\n> >\n> > -     /* Start by resetting the Unicam and ISP stream states. */\n> > +     /* Start by freeing all buffers and resetting the Unicam and ISP\n> stream states. */\n> > +     data->freeBuffers();\n> >       for (auto const stream : data->streams_)\n> >               stream->reset();\n> >\n> > @@ -1048,8 +1054,6 @@ void PipelineHandlerRPi::stopDevice(Camera *camera)\n> >\n> >       /* Stop the IPA. */\n> >       data->ipa_->stop();\n> > -\n> > -     data->freeBuffers();\n> >  }\n> >\n> >  int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request\n> *request)\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\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 A183DBE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 14 Mar 2022 11:14:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0400C6118A;\n\tMon, 14 Mar 2022 12:14:03 +0100 (CET)","from mail-lj1-x234.google.com (mail-lj1-x234.google.com\n\t[IPv6:2a00:1450:4864:20::234])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 285B1604E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Mar 2022 12:14:01 +0100 (CET)","by mail-lj1-x234.google.com with SMTP id u7so21245171ljk.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Mar 2022 04:14:01 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647256443;\n\tbh=1IK5yew6v8NdhidO0GV3WlbcPnXmNqv6OXglr/RiWKQ=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=q3XNcCFANqoBBw2M4rJ3I3jWddyAA7r2LSJtCguerQVvb9UCv3Jgjh7MixCexjIXT\n\t9ZQqOas3F0b5HxgD4RhIDyye9IBcj26aUQN6o5/cLx70X+2OzXeVX7qoDhJb3/6X0j\n\t8h7x4o6in3osoqzVsGaY0kY853v8kVWjsT5bqbtZNUuuSxdoSkRWmddjn0k759Ydwl\n\tvsmqx7Nf5KYW2pA9Vh1y3IZyeCJHnkEgrhVNGS8y/HfoQLaTqe/PKc0Fm74gkW80Km\n\tUXuF4p68VRUOel2E3v2S7JdSe5SeUVevD4/XMHodugj9WPnVKO8VW6jQfdbgx8kpyH\n\tJOM/kRYpXnypQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=8W0ODxM58veKAOJSjmMF8FbYUFshMFlrdy0ocFuPUGs=;\n\tb=p3nvr9JhdCg7oDZGJl558TBfk9GGfmfta3fBdfKoqF12JM0ziJy5Y1U30LcoXVGtTt\n\t+kzcEcYiB1hLPAm5BBFQiHbyhJKsnUBMcg6ETqZjX3RMV1c66gSkc1XQvivleL+bm89X\n\tGlFTOBpM+6Ki7EakNjDAH27erLv/W/YsOGEOrOtB/WMB9Hwd2UBhN90bhZUGCeiaWYLV\n\tX19wLMvwU3bacJhdXKKNyE/5K68znmd5hLSBkmTx/oNIYJSQnIIEqWHulGRV1QiMcHEr\n\tkarW19MDVs9aJuMXu9yVMkjx9PxPfJX36QEsNFEjvDLf1OtQ7XlhywyGLXleBTpMsOIl\n\tmnDQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"p3nvr9Jh\"; dkim-atps=neutral","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=8W0ODxM58veKAOJSjmMF8FbYUFshMFlrdy0ocFuPUGs=;\n\tb=Ywm8pwL4g60T/2Sz2kA0ElA/tAXBcUFVnIJrL74BkugxXkMztC5SOaqnzh5s1igkbG\n\toboJUunB3wvNErb0JEbUFchnGpu0KQtCJeXeP+zi1qvLWLD6LxGZDr1FExaon32wLTdz\n\tLF2QA4HUTaJmg+HpqQuRygeAINOXvh4TPvRgtqGEklwHZ8XlvKZUVDuIISd5NXMA1+GE\n\tO8zhPYnfoTnkkgRM0zj9EiWorq30r97SkBDWkjbqzzOmiibyeh+iB8NU3lgGZXCZ650W\n\t0v6JTBK1Svw5ef3+ivu//jg067ecemYsowdQJpW9bU2fp9Br+UPw8u8lvQ4356tkxTuH\n\tPvXA==","X-Gm-Message-State":"AOAM530E5TiGp5pGqntiFVqjajfjsx6H0FEj6QuzMdvUu55stw6fYMlE\n\t2ebaqGuBhYTW/iHlWJteZ4nA2dzXIc08HWwYVRrzs8asPfkS+g==","X-Google-Smtp-Source":"ABdhPJyxM2JjzYOAHViLM3JRKIeEL3XkPCjawhtfhJrt0LaicrmrZqErjRuOQ5La60nq04k3ybO3HjwAKcf3JodFGNg=","X-Received":"by 2002:a2e:a552:0:b0:249:34da:15e4 with SMTP id\n\te18-20020a2ea552000000b0024934da15e4mr3904979ljn.372.1647256439996;\n\tMon, 14 Mar 2022 04:13:59 -0700 (PDT)","MIME-Version":"1.0","References":"<20220307124633.115452-1-naush@raspberrypi.com>\n\t<20220307124633.115452-4-naush@raspberrypi.com>\n\t<Yi4ViQO88WQYT0Wo@pendragon.ideasonboard.com>","In-Reply-To":"<Yi4ViQO88WQYT0Wo@pendragon.ideasonboard.com>","Date":"Mon, 14 Mar 2022 11:13:44 +0000","Message-ID":"<CAEmqJPqTgqfSs5jPuWNoUHA5V5ksPY-SWxok8bDPU95UAX4+Gg@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"000000000000f5d60105da2bc612\"","Subject":"Re: [libcamera-devel] [PATCH v1 3/6] pipeline: raspberrypi: Free\n\tbuffers in the RPiCamera destructor and re-configure","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","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>"}},{"id":22272,"web_url":"https://patchwork.libcamera.org/comment/22272/","msgid":"<YjBIWy3rMlOQDsx2@pendragon.ideasonboard.com>","date":"2022-03-15T08:03:39","subject":"Re: [libcamera-devel] [PATCH v1 3/6] pipeline: raspberrypi: Free\n\tbuffers in the RPiCamera destructor and re-configure","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Naush,\n\nOn Mon, Mar 14, 2022 at 11:13:44AM +0000, Naushir Patuck wrote:\n> On Sun, 13 Mar 2022 at 16:02, Laurent Pinchart wrote:\n> > On Mon, Mar 07, 2022 at 12:46:30PM +0000, Naushir Patuck via\n> > libcamera-devel wrote:\n> > > Currently, all framebuffer allocations get freed and cleared on a stop in\n> > > PipelineHandlerRPi::stopDevice(). If PipelineHandlerRPi::start() is then called\n> > > without an intermediate PipelineHandlerRPi::configure(), it will re-allocate and\n> > > prepare all the buffers again, which is unnecessary.\n> > >\n> > > Fix this by not freeing the buffer in PipelineHandlerRPi::stopDevice(), but\n> > > insted doing it in PipelineHandlerRPi::configure(), as the buffers might have\n> > > to be resized.\n> >\n> > I see where you're going, but doesn't this mean that buffers will stay\n> > allocated forever ? If an application uses a camera for some time and\n> > then stops it, memory won't be released until the application\n> > terminates. That's trading an issue for another one, and which one is\n> > worse really depends on the use case.\n> >\n> > There are (at least) two ways to address this. The simplest one would be\n> > to fire a timer at stop() time, and free buffers when it elapses. The\n> > timer would be cancelled if the camera is restarted first.\n> >\n> > The second option is to make this controllable by the application. We\n> > could hook it up to the Camera::release() call for instance, adding a\n> > new pipeline handler operation to handle it. release() may not be the\n> > best option though, maybe we need a new cleanup function. Or maybe an\n> > argument to stop(), to tell if the camera is expected to be restarted\n> > soon ? I haven't really thought about the pros and cons of the different\n> > options, I'm just brainstorming here.\n> \n> Yes, I do see a possible issue here with holding onto buffers for longer than\n> expected.  My preferred option would be to have a Camera::release() call\n> that explicitly requests the pipeline handler to remove all buffer allocations.\n> That way, the application controls the intended behavior if it chooses to, but\n> the pipeline handler keeps buffers allocated otherwise.\n\nThe downside of tying this to Camera::release() is that the application\nwill need to let go of exclusive ownership of the camera to free the\nbuffers. Someone else could then acquire() it. It's probably a corner\ncase, but I'd prefer not hardcoding this limitation in the API.\n\nI'm also wondering if adding a hint flag to stop() to tell if streaming\nwill soon tbe restarted could also have other use cases. A pipeline\nhandler could avoid powering down hardware for instance, to decrease the\ntime needed when restarting (although with recent drivers PM is handled\nusing runtime PM in the sensor driver, with auto-suspend, so the sensor\nitself won't benefit much).\n\nWhile brainstorming on this topic, would it be useful to have a mean to\nallocate internal buffers large enough for different resolutions, and\nuse them in different capture cycles instead of reallocating ?\n\n> > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > ---\n> > >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 +++++++---\n> > >  1 file changed, 7 insertions(+), 3 deletions(-)\n> > >\n> > > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > index 3781e4e0e3c4..8bb9fc429912 100644\n> > > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > @@ -189,6 +189,11 @@ public:\n> > >       {\n> > >       }\n> > >\n> > > +     ~RPiCameraData()\n> > > +     {\n> > > +             freeBuffers();\n> > > +     }\n> > > +\n> > >       void freeBuffers();\n> > >       void frameStarted(uint32_t sequence);\n> > >\n> > > @@ -681,7 +686,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n> > >       RPiCameraData *data = cameraData(camera);\n> > >       int ret;\n> > >\n> > > -     /* Start by resetting the Unicam and ISP stream states. */\n> > > +     /* Start by freeing all buffers and resetting the Unicam and ISP stream states. */\n> > > +     data->freeBuffers();\n> > >       for (auto const stream : data->streams_)\n> > >               stream->reset();\n> > >\n> > > @@ -1048,8 +1054,6 @@ void PipelineHandlerRPi::stopDevice(Camera *camera)\n> > >\n> > >       /* Stop the IPA. */\n> > >       data->ipa_->stop();\n> > > -\n> > > -     data->freeBuffers();\n> > >  }\n> > >\n> > >  int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)","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 52954BDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 15 Mar 2022 08:03:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 96FC8604E9;\n\tTue, 15 Mar 2022 09:03:58 +0100 (CET)","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 07BF2601F8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Mar 2022 09:03:57 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7472351C;\n\tTue, 15 Mar 2022 09:03:56 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647331438;\n\tbh=TsdOQ28FN3wwI/aACpxv+hSiz9n3E4xhBUm9bUtW1aI=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=WN4bHH9AUTZE9mNHVoRRTB8VEWTKYK2kE3wnYZaLuu5IRXJzp0yqc52jVenhfy4rh\n\tt4ssUr/mX60Bvl1nK/J8m+PNVjVUTB/VjKMu4YFBHVkQwg1OSdAYy0nCkETbWJMkDF\n\tBbvcxCXuv6lTJb1yo0yHvFKAsO4UapYlSndGj3F++b/yRktXo7wivPimTTq9O/t7JO\n\t3pljQNR8LiFaJhf/1okehpyemrb8HT7yG6QPeh5e3Mn29VcqZKQvrDqh7lxLnoVhKN\n\tlxChlbL1qjM8hbxzt4bfmd5AojXn8siK5B/2a7+tJgr+/qKn8HTrucENPmpqDNSZGV\n\tgMf3etoAD38CQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1647331436;\n\tbh=TsdOQ28FN3wwI/aACpxv+hSiz9n3E4xhBUm9bUtW1aI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=PtvBqxjWAt8Q1Wl6Vsd8r8d0TNuEDcPXjZdv43jbBvji9wolmfb5n855B64FSGeIy\n\tmgaRSpXy8U3atzpJO1vMozyfJsuWrFIZ3dY9zaenQTgRAmBABRrbv54J5DdxoRIKwD\n\twf4e0rsIXug3jEgG1ZQ+jt00/VCRPboEaNcP9js8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"PtvBqxjW\"; dkim-atps=neutral","Date":"Tue, 15 Mar 2022 10:03:39 +0200","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YjBIWy3rMlOQDsx2@pendragon.ideasonboard.com>","References":"<20220307124633.115452-1-naush@raspberrypi.com>\n\t<20220307124633.115452-4-naush@raspberrypi.com>\n\t<Yi4ViQO88WQYT0Wo@pendragon.ideasonboard.com>\n\t<CAEmqJPqTgqfSs5jPuWNoUHA5V5ksPY-SWxok8bDPU95UAX4+Gg@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAEmqJPqTgqfSs5jPuWNoUHA5V5ksPY-SWxok8bDPU95UAX4+Gg@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v1 3/6] pipeline: raspberrypi: Free\n\tbuffers in the RPiCamera destructor and re-configure","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","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>"}},{"id":22311,"web_url":"https://patchwork.libcamera.org/comment/22311/","msgid":"<CAEmqJPqLYXxp0eDVMHA1UkkDv61jMXWk-jwJY=V5m1h8ttFpSg@mail.gmail.com>","date":"2022-03-17T11:16:28","subject":"Re: [libcamera-devel] [PATCH v1 3/6] pipeline: raspberrypi: Free\n\tbuffers in the RPiCamera destructor and re-configure","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Laurent,\n\n\nOn Tue, 15 Mar 2022 at 08:03, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> Hi Naush,\n>\n> On Mon, Mar 14, 2022 at 11:13:44AM +0000, Naushir Patuck wrote:\n> > On Sun, 13 Mar 2022 at 16:02, Laurent Pinchart wrote:\n> > > On Mon, Mar 07, 2022 at 12:46:30PM +0000, Naushir Patuck via\n> > > libcamera-devel wrote:\n> > > > Currently, all framebuffer allocations get freed and cleared on a\n> stop in\n> > > > PipelineHandlerRPi::stopDevice(). If PipelineHandlerRPi::start() is\n> then called\n> > > > without an intermediate PipelineHandlerRPi::configure(), it will\n> re-allocate and\n> > > > prepare all the buffers again, which is unnecessary.\n> > > >\n> > > > Fix this by not freeing the buffer in\n> PipelineHandlerRPi::stopDevice(), but\n> > > > insted doing it in PipelineHandlerRPi::configure(), as the buffers\n> might have\n> > > > to be resized.\n> > >\n> > > I see where you're going, but doesn't this mean that buffers will stay\n> > > allocated forever ? If an application uses a camera for some time and\n> > > then stops it, memory won't be released until the application\n> > > terminates. That's trading an issue for another one, and which one is\n> > > worse really depends on the use case.\n> > >\n> > > There are (at least) two ways to address this. The simplest one would\n> be\n> > > to fire a timer at stop() time, and free buffers when it elapses. The\n> > > timer would be cancelled if the camera is restarted first.\n> > >\n> > > The second option is to make this controllable by the application. We\n> > > could hook it up to the Camera::release() call for instance, adding a\n> > > new pipeline handler operation to handle it. release() may not be the\n> > > best option though, maybe we need a new cleanup function. Or maybe an\n> > > argument to stop(), to tell if the camera is expected to be restarted\n> > > soon ? I haven't really thought about the pros and cons of the\n> different\n> > > options, I'm just brainstorming here.\n> >\n> > Yes, I do see a possible issue here with holding onto buffers for longer\n> than\n> > expected.  My preferred option would be to have a Camera::release() call\n> > that explicitly requests the pipeline handler to remove all buffer\n> allocations.\n> > That way, the application controls the intended behavior if it chooses\n> to, but\n> > the pipeline handler keeps buffers allocated otherwise.\n>\n> The downside of tying this to Camera::release() is that the application\n> will need to let go of exclusive ownership of the camera to free the\n> buffers. Someone else could then acquire() it. It's probably a corner\n> case, but I'd prefer not hardcoding this limitation in the API.\n>\n\nI agree, this may not be the best approach then.\n\n\n>\n> I'm also wondering if adding a hint flag to stop() to tell if streaming\n> will soon tbe restarted could also have other use cases. A pipeline\n> handler could avoid powering down hardware for instance, to decrease the\n> time needed when restarting (although with recent drivers PM is handled\n> using runtime PM in the sensor driver, with auto-suspend, so the sensor\n> itself won't benefit much).\n>\n\nI'm actually coming round to the idea that the pipeline handler has an\ninternal\ntimeout that is used to free the buffers.  Partly because I need a timeout\nfunctionality for something entirely unrelated :)  But it does remove the\ndecision\nfrom the application side. I'll prototype something along these lines to\nsee\nhow it works.\n\n\n>\n> While brainstorming on this topic, would it be useful to have a mean to\n> allocate internal buffers large enough for different resolutions, and\n> use them in different capture cycles instead of reallocating ?\n>\n\nIt would certainly help, but is the extra complexity worth the savings on\nallocation\ntime, I can't say...\n\nRegards,\nNaush\n\n\n>\n> > > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > > ---\n> > > >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 +++++++---\n> > > >  1 file changed, 7 insertions(+), 3 deletions(-)\n> > > >\n> > > > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > > index 3781e4e0e3c4..8bb9fc429912 100644\n> > > > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > > @@ -189,6 +189,11 @@ public:\n> > > >       {\n> > > >       }\n> > > >\n> > > > +     ~RPiCameraData()\n> > > > +     {\n> > > > +             freeBuffers();\n> > > > +     }\n> > > > +\n> > > >       void freeBuffers();\n> > > >       void frameStarted(uint32_t sequence);\n> > > >\n> > > > @@ -681,7 +686,8 @@ int PipelineHandlerRPi::configure(Camera\n> *camera, CameraConfiguration *config)\n> > > >       RPiCameraData *data = cameraData(camera);\n> > > >       int ret;\n> > > >\n> > > > -     /* Start by resetting the Unicam and ISP stream states. */\n> > > > +     /* Start by freeing all buffers and resetting the Unicam and\n> ISP stream states. */\n> > > > +     data->freeBuffers();\n> > > >       for (auto const stream : data->streams_)\n> > > >               stream->reset();\n> > > >\n> > > > @@ -1048,8 +1054,6 @@ void PipelineHandlerRPi::stopDevice(Camera\n> *camera)\n> > > >\n> > > >       /* Stop the IPA. */\n> > > >       data->ipa_->stop();\n> > > > -\n> > > > -     data->freeBuffers();\n> > > >  }\n> > > >\n> > > >  int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request\n> *request)\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\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 84AFCBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Mar 2022 11:16:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 44A786118A;\n\tThu, 17 Mar 2022 12:16:47 +0100 (CET)","from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com\n\t[IPv6:2a00:1450:4864:20::12a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 83685601F8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Mar 2022 12:16:45 +0100 (CET)","by mail-lf1-x12a.google.com with SMTP id n19so8395388lfh.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Mar 2022 04:16:45 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647515807;\n\tbh=8Cb+ZwZkDulxLD/ADHwJIUgZtUoGjpFmoOWSlziu0gU=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=PsCDvb+DsHeOn1gaVsIXByHTan4pyABcyUL+VBoZRr2EW4pT/5qiUqw6dBFhaOauG\n\tmzwVBGIrEVaIZCBhB0nQBugSsxXklN8atW09hrpm3htmOWQc923Izb818cUyT9YDUR\n\tWplKTlpT3/x6XV6sGCyYkC7r2anCFVgbVdiwXMbdS1C+wH6gYXhZoy0OWrIjAIwQmZ\n\tRYPADYhVX17iLHuFSaWHqBnYc4PXIcTY+w5mHzTJZl1GEgK08b9jl5utiG0EDnVHHg\n\tO1FN0EDbajBPrnht9ZLi/nmUEU+AF94uUAc6h97LJNEKv/C+5LWaUayZJH/ZUUvCl5\n\tU8pTqhslspdOQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=vHMA7SmWwdT+nF79QFE7yV0xQRAUF/Dnbxlf8RT4wYo=;\n\tb=lcR+1Z70weVHwkOwLbj6F7gIPdgwH+Pg0hp7LdU/+HPNrXbE1GHS7LxeXSKom/2p6s\n\t0Lz4Hylzcdbs/jRCwgRyX5RyyLwsEKlmuP5CIltgfwWGX34v95iV74VNogwfmov5Ehke\n\t3ii36O3Ele5pkxhVwd+MYG9u4ohSlkntAF1xGghzwveMu1dSb8fjgz30wyGLl2GAFm+q\n\tt6T05oKBsAkb00jBJjGJPR+zRlHbev2lOaXrB/3UFBqi7zYuCEdr/RBkV0UQ7yZvnK1d\n\tz3CYh2TQFTFnHCQ16QkhTmSvPXMJ1tqTlrByCoPTw+KHsMppJqrir+b+gHq1Jcg4rpvD\n\ttsWg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"lcR+1Z70\"; dkim-atps=neutral","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=vHMA7SmWwdT+nF79QFE7yV0xQRAUF/Dnbxlf8RT4wYo=;\n\tb=yXdteOuSUOwUvPne/gE3xHKxTkhZA2c23jGAlT90xv8akM59SqnzDOI73UZ/lbz35y\n\tL6O3lAJgbl6OdDEx+Ar9lMnqIzuTx1GlCRB8L/kQGhgujXdq5mBZ8l2y3niGaAmTTkaV\n\tWyv4WPRj2LIWmnYfiw6ivqimhiBLbgAPVmBuKLUd86eq3I+gE1cZMrbZCpM5RHWwozEp\n\tom2Rl550ZgVNVrZidy0wN2oIKXsxPpy1ZSxycN7dagfKiDuHRVbbHTjx2fY4hfKbqkO9\n\tefTwm4vAgQPo1I9pTU/6hKnF0H2GJOUMvXq/SW8Uo3h6b16rmIvSyKwa/IyblsMUgzR9\n\tcGGw==","X-Gm-Message-State":"AOAM530fQyotN6pqIewKVThX2qSTygiOmz5MD/hM44+kAyUWCP0Qvs9A\n\tKnYrByaT3SwaQwSyb4jy0eZb1xD+BxTJPRRrrzSNVs86faY=","X-Google-Smtp-Source":"ABdhPJwE28Gb+hqTNOqZFJGR+ynf3J8M7pqxENtau5ejDqOYkpX7CnN5ML9JaldMu4M2ZGhZHBhIyK9p7eT5AFEkH9I=","X-Received":"by 2002:a05:6512:3d0a:b0:448:83b9:bcdc with SMTP id\n\td10-20020a0565123d0a00b0044883b9bcdcmr2526018lfv.122.1647515804867;\n\tThu, 17 Mar 2022 04:16:44 -0700 (PDT)","MIME-Version":"1.0","References":"<20220307124633.115452-1-naush@raspberrypi.com>\n\t<20220307124633.115452-4-naush@raspberrypi.com>\n\t<Yi4ViQO88WQYT0Wo@pendragon.ideasonboard.com>\n\t<CAEmqJPqTgqfSs5jPuWNoUHA5V5ksPY-SWxok8bDPU95UAX4+Gg@mail.gmail.com>\n\t<YjBIWy3rMlOQDsx2@pendragon.ideasonboard.com>","In-Reply-To":"<YjBIWy3rMlOQDsx2@pendragon.ideasonboard.com>","Date":"Thu, 17 Mar 2022 11:16:28 +0000","Message-ID":"<CAEmqJPqLYXxp0eDVMHA1UkkDv61jMXWk-jwJY=V5m1h8ttFpSg@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"0000000000004fbb9b05da682a9a\"","Subject":"Re: [libcamera-devel] [PATCH v1 3/6] pipeline: raspberrypi: Free\n\tbuffers in the RPiCamera destructor and re-configure","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","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>"}}]