From patchwork Tue Apr 6 08:51:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11840 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 26240C0DA3 for ; Tue, 6 Apr 2021 08:52:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AC0D3687A1; Tue, 6 Apr 2021 10:52:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="G7Z3eFdo"; dkim-atps=neutral Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5F4C360517 for ; Tue, 6 Apr 2021 10:52:02 +0200 (CEST) Received: by mail-pg1-x529.google.com with SMTP id t22so2714646pgu.0 for ; Tue, 06 Apr 2021 01:52:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jfeyZ2yvrHTGMVCEciDVuNQQtKjTpqBhEM2MU+DjD78=; b=G7Z3eFdo5SZ1bdUSsW2DK9l7xWVlgOrw/+m/bcqaGqbXatPzltg+GPhXCq//aSCGd5 twfeCTaeKxF25jfhs0FN8kQlKeMakv+ax7WwuusrD2equtGU0VdMocAr0CLGFXOjvGP9 qlYz6Mq8hALb+MUzErVUEEpvCPCoNzKngN0Bc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jfeyZ2yvrHTGMVCEciDVuNQQtKjTpqBhEM2MU+DjD78=; b=rFHaUZKAbZK6fgQbblIvEm+c3MgkNTmshDg2+XJvl2fbMMudvlTx/geIqXyd3WZiVV SMOP7tCILNPB+iV/d0FZT9ZoZpVwENqwtCMlCEzNA7Deyx/Q8YfMx23DYgBWQV1Nc8/B wa8LnQvWZczIlkSrgQXY0/EmFJXRMzRlI9h6Aa8CgJHMboiCxQR0SBCVPpYosQc4EqNI 5iSjBo8oThJrOZpl1WfH1hzSjtR9PxbpPlC7qcjmVsAHszElfohx2wJOUlJyjSwvedUd H6Yz2wng+1/r4CxQS+q5lKSfaF+gWQDPLrPlZ/PTnT3XdfJyT+HowjS+uEkhkb1SGP0W /ViA== X-Gm-Message-State: AOAM531o1KxaDbGwytE/njLjzngWEtWvlaLGs/nbPBCh54MaS/JRB6kc 589pDBAcujTqzqqxqcD9cUc16b4vTkf7RQ== X-Google-Smtp-Source: ABdhPJzHRJ/6cYo8ZQ17dQ2eexqlYq3aiIv9gOBa8nsSfYmCiiecPIZy7zK3gFatn3qmeC6x6reyQA== X-Received: by 2002:aa7:900d:0:b029:230:2d6a:2940 with SMTP id m13-20020aa7900d0000b02902302d6a2940mr24676496pfo.23.1617699120395; Tue, 06 Apr 2021 01:52:00 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:4180:40db:6f79:a143]) by smtp.gmail.com with ESMTPSA id y7sm18070135pfq.70.2021.04.06.01.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 01:52:00 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Apr 2021 17:51:52 +0900 Message-Id: <20210406085153.3818580-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog In-Reply-To: <20210406085153.3818580-1-hiroh@chromium.org> References: <20210406085153.3818580-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/2] pipeline: ipu3: Store requests in the case a buffer shortage 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" PipelineHandlerIPU3 returns -ENOBUFS and -ENOMEM on queueing a request when there are not sufficient buffers for the request. Since the request will be successful if it is queued later when enough buffers are available. The requests failed due to a buffer shortage should be stored and retried later in the FIFO order. This introduces the queue in IPU3CameraData to do that. Signed-off-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/ipu3.cpp | 58 ++++++++++++++++++---------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 519cad4f..c73e4f7c 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -66,6 +66,7 @@ public: void cio2BufferReady(FrameBuffer *buffer); void paramBufferReady(FrameBuffer *buffer); void statBufferReady(FrameBuffer *buffer); + int queuePendingRequests(); CIO2Device cio2_; ImgUDevice *imgu_; @@ -84,6 +85,7 @@ public: std::unique_ptr ipa_; + std::queue pendingRequests_; private: void queueFrameAction(unsigned int id, const ipa::ipu3::IPU3Action &action); @@ -764,6 +766,8 @@ void PipelineHandlerIPU3::stop(Camera *camera) IPU3CameraData *data = cameraData(camera); int ret = 0; + data->pendingRequests_ = {}; + data->ipa_->stop(); ret |= data->imgu_->stop(); @@ -774,36 +778,48 @@ void PipelineHandlerIPU3::stop(Camera *camera) freeBuffers(camera); } -int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request) +int IPU3CameraData::queuePendingRequests() { - IPU3CameraData *data = cameraData(camera); + while (!pendingRequests_.empty()) { + Request *request = pendingRequests_.front(); - IPU3Frames::Info *info = data->frameInfos_.create(request); - if (!info) - return -ENOBUFS; + IPU3Frames::Info *info = frameInfos_.create(request); + if (!info) + break; - /* - * Queue a buffer on the CIO2, using the raw stream buffer provided in - * the request, if any, or a CIO2 internal buffer otherwise. - */ - FrameBuffer *reqRawBuffer = request->findBuffer(&data->rawStream_); - FrameBuffer *rawBuffer = data->cio2_.queueBuffer(request, reqRawBuffer); - if (!rawBuffer) { - data->frameInfos_.remove(info); - return -ENOMEM; - } + /* + * Queue a buffer on the CIO2, using the raw stream buffer + * provided in the request, if any, or a CIO2 internal buffer + * otherwise. + */ + FrameBuffer *reqRawBuffer = request->findBuffer(&rawStream_); + FrameBuffer *rawBuffer = cio2_.queueBuffer(request, reqRawBuffer); + if (!rawBuffer) { + frameInfos_.remove(info); + break; + } - info->rawBuffer = rawBuffer; + info->rawBuffer = rawBuffer; - ipa::ipu3::IPU3Event ev; - ev.op = ipa::ipu3::EventProcessControls; - ev.frame = info->id; - ev.controls = request->controls(); - data->ipa_->processEvent(ev); + ipa::ipu3::IPU3Event ev; + ev.op = ipa::ipu3::EventProcessControls; + ev.frame = info->id; + ev.controls = request->controls(); + ipa_->processEvent(ev); + + pendingRequests_.pop(); + } return 0; } +int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request) +{ + IPU3CameraData *data = cameraData(camera); + data->pendingRequests_.emplace(request); + return data->queuePendingRequests(); +} + bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator) { int ret;