From patchwork Fri Jan 10 19:37:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 2568 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2ED3760696 for ; Fri, 10 Jan 2020 20:38:55 +0100 (CET) X-Halon-ID: d43e60d2-33e0-11ea-b6d8-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p54ac5d7b.dip0.t-ipconnect.de [84.172.93.123]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id d43e60d2-33e0-11ea-b6d8-005056917f90; Fri, 10 Jan 2020 20:38:51 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 10 Jan 2020 20:37:56 +0100 Message-Id: <20200110193808.2266294-22-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200110193808.2266294-1-niklas.soderlund@ragnatech.se> References: <20200110193808.2266294-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 21/33] libcamera: pipeline: rkisp1: Destroy frame information before completing request X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 19:38:55 -0000 It's common for applications to create and queue a new request in a previous request completion handler. When the new request gets queued to the RkISP1 pipeline handler it tries to find a parameters and statistic buffer to be used with the request. The problem is if the pipeline depth is already filled there are no internal buffers free to be used by the new request. This was solved by allocation one more parameters and statistic buffer then the pipeline depth, this is waste full. Instead free the request that is about to be completed resources before it is signaled to the application, this way if the pipeline depth is full it can reuse the internal resources and the waste full allocation can be removed. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- * Changes since v2 - Rewrote commit message. - Actually remove the wasteful allocation of extra buffers in this commit instead of depending on the switch to FrameBuffer to do it for us. --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 979b670e4cb75512..607ff85539a22324 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -671,14 +671,14 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera, if (ret) return ret; - paramPool_.createBuffers(stream->configuration().bufferCount + 1); + paramPool_.createBuffers(stream->configuration().bufferCount); ret = param_->exportBuffers(¶mPool_); if (ret) { video_->releaseBuffers(); return ret; } - statPool_.createBuffers(stream->configuration().bufferCount + 1); + statPool_.createBuffers(stream->configuration().bufferCount); ret = stat_->exportBuffers(&statPool_); if (ret) { param_->releaseBuffers(); @@ -686,13 +686,13 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera, return ret; } - for (unsigned int i = 0; i < stream->configuration().bufferCount + 1; i++) { + for (unsigned int i = 0; i < stream->configuration().bufferCount; i++) { data->ipaBuffers_.push_back({ .id = RKISP1_PARAM_BASE | i, .planes = paramPool_.buffers()[i].planes() }); paramBuffers_.push(new Buffer(i)); } - for (unsigned int i = 0; i < stream->configuration().bufferCount + 1; i++) { + for (unsigned int i = 0; i < stream->configuration().bufferCount; i++) { data->ipaBuffers_.push_back({ .id = RKISP1_STAT_BASE | i, .planes = statPool_.buffers()[i].planes() }); statBuffers_.push(new Buffer(i)); @@ -981,9 +981,9 @@ void PipelineHandlerRkISP1::tryCompleteRequest(Request *request) if (!info->paramDequeued) return; - completeRequest(activeCamera_, request); - data->frameInfo_.destroy(info->frame); + + completeRequest(activeCamera_, request); } void PipelineHandlerRkISP1::bufferReady(Buffer *buffer)