{"id":2603,"url":"https://patchwork.libcamera.org/api/1.1/patches/2603/?format=json","web_url":"https://patchwork.libcamera.org/patch/2603/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200112010212.2609025-22-niklas.soderlund@ragnatech.se>","date":"2020-01-12T01:02:01","name":"[libcamera-devel,v4,21/32] libcamera: pipeline: rkisp1: Destroy frame information before completing request","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"a2e4b4de3dcaec70314b5d2e7d4a5253fd04eb86","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2603/mbox/","series":[{"id":617,"url":"https://patchwork.libcamera.org/api/1.1/series/617/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=617","date":"2020-01-12T01:01:40","name":"libcamera: Rework buffer API","version":4,"mbox":"https://patchwork.libcamera.org/series/617/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2603/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2603/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0888F606F1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 12 Jan 2020 02:03:17 +0100 (CET)","from bismarck.berto.se (p54ac5d7b.dip0.t-ipconnect.de\n\t[84.172.93.123]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 4ea7f0f4-34d7-11ea-b6d8-005056917f90;\n\tSun, 12 Jan 2020 02:03:13 +0100 (CET)"],"X-Halon-ID":"4ea7f0f4-34d7-11ea-b6d8-005056917f90","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Sun, 12 Jan 2020 02:02:01 +0100","Message-Id":"<20200112010212.2609025-22-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.24.1","In-Reply-To":"<20200112010212.2609025-1-niklas.soderlund@ragnatech.se>","References":"<20200112010212.2609025-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 21/32] libcamera: pipeline: rkisp1:\n\tDestroy frame information before completing request","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":"Sun, 12 Jan 2020 01:03:17 -0000"},"content":"It's common for applications to create and queue a new request in a\nprevious request completion handler. When the new request gets queued to\nthe RkISP1 pipeline handler it tries to find a parameters and statistic\nbuffer to be used with the request. The problem is if the pipeline depth\nis already filled there are no internal buffers free to be used by the\nnew request.\n\nThis was solved by allocation one more parameters and statistic buffer\nthen the pipeline depth, this is waste full. Instead free the resources\nof the request that has completed before it is signaled to the\napplication, this way if the pipeline depth is full it can reuse the\ninternal resources and the wasteful allocation can be removed.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n* Changes since v2\n- Rewrote commit message.\n- Actually remove the wasteful allocation of extra buffers in this\n  commit instead of depending on the switch to FrameBuffer to do it for\n  us.\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 979b670e4cb75512..607ff85539a22324 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -671,14 +671,14 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera,\n \tif (ret)\n \t\treturn ret;\n \n-\tparamPool_.createBuffers(stream->configuration().bufferCount + 1);\n+\tparamPool_.createBuffers(stream->configuration().bufferCount);\n \tret = param_->exportBuffers(&paramPool_);\n \tif (ret) {\n \t\tvideo_->releaseBuffers();\n \t\treturn ret;\n \t}\n \n-\tstatPool_.createBuffers(stream->configuration().bufferCount + 1);\n+\tstatPool_.createBuffers(stream->configuration().bufferCount);\n \tret = stat_->exportBuffers(&statPool_);\n \tif (ret) {\n \t\tparam_->releaseBuffers();\n@@ -686,13 +686,13 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera,\n \t\treturn ret;\n \t}\n \n-\tfor (unsigned int i = 0; i < stream->configuration().bufferCount + 1; i++) {\n+\tfor (unsigned int i = 0; i < stream->configuration().bufferCount; i++) {\n \t\tdata->ipaBuffers_.push_back({ .id = RKISP1_PARAM_BASE | i,\n \t\t\t\t\t      .planes = paramPool_.buffers()[i].planes() });\n \t\tparamBuffers_.push(new Buffer(i));\n \t}\n \n-\tfor (unsigned int i = 0; i < stream->configuration().bufferCount + 1; i++) {\n+\tfor (unsigned int i = 0; i < stream->configuration().bufferCount; i++) {\n \t\tdata->ipaBuffers_.push_back({ .id = RKISP1_STAT_BASE | i,\n \t\t\t\t\t      .planes = statPool_.buffers()[i].planes() });\n \t\tstatBuffers_.push(new Buffer(i));\n@@ -981,9 +981,9 @@ void PipelineHandlerRkISP1::tryCompleteRequest(Request *request)\n \tif (!info->paramDequeued)\n \t\treturn;\n \n-\tcompleteRequest(activeCamera_, request);\n-\n \tdata->frameInfo_.destroy(info->frame);\n+\n+\tcompleteRequest(activeCamera_, request);\n }\n \n void PipelineHandlerRkISP1::bufferReady(Buffer *buffer)\n","prefixes":["libcamera-devel","v4","21/32"]}