From patchwork Thu Apr 8 08:50:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11867 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 E291FBD16B for ; Thu, 8 Apr 2021 08:51:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9D173687F5; Thu, 8 Apr 2021 10:51:12 +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="ZedJYsVd"; dkim-atps=neutral Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D174F687F3 for ; Thu, 8 Apr 2021 10:51:10 +0200 (CEST) Received: by mail-pj1-x1036.google.com with SMTP id nh5so750424pjb.5 for ; Thu, 08 Apr 2021 01:51:10 -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=ZedJYsVdw0/R6tucllKAqrcPeETfisZsq9nTfyJwzvF2o4p32aOb0xgppf6ePTT2Ws AarcJOrDyW/wC2bTPkbv9PNjmR6m48mBFMpd0yWE8LxN4pgUcHiLSvkxxGo4+Z/MhMFE SLLZk7pbdKWKzzugXRpHBuYZOwDAd0EbOupDQ= 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=h6ltvNWFnG/aU0eDqZlKd3MuGmpThnHy/+6v/hcVfv+Henwm4o9xxRJsZFmC7SUTGS 5MdpbKq1cRidssHUFp2rCEyL/BW5QDnR36RCKdDO3i/udv7m0YOcVJWl/DEFf+6ZAHCs ZmF5IM/WYXXO/+e8DppaxRG0MptCXkxV6E6q+anl/ye5hgjV29nFQgQw90tlXes3KgC2 qpfNv024VE8QVDzo1uKEwIPFQRvc+0AdtBd6cbdhKhpV2BkZuIf68bk8BD+/JXM+gqTD PgMGkr2oqDT18+5WEtnggWKz9m95v1hJHYhTfjZig3FeZ/FK4GvV2QGAwaaDtRQCJXAl AT2Q== X-Gm-Message-State: AOAM532Tv/tvIJfZOAF4Jv4UYIv0Mu5fEUokkrs2Taz2nRpr5R86rX0I u7mRhpdzjtKTL6xQ9HiE842dM/0TkdLemQ== X-Google-Smtp-Source: ABdhPJyDT5wq/hNwi/rllrKbH1VQB5XhMyMDG5Gyo2aC3QECUBa8d48lsr1MEZKwDN+P9bm9NkmtKA== X-Received: by 2002:a17:902:b783:b029:e9:3a03:2a5c with SMTP id e3-20020a170902b783b02900e93a032a5cmr6758487pls.79.1617871869065; Thu, 08 Apr 2021 01:51:09 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:8822:ec6c:14d8:eea9]) by smtp.gmail.com with ESMTPSA id g80sm1755993pfb.181.2021.04.08.01.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 01:51:08 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 8 Apr 2021 17:50:59 +0900 Message-Id: <20210408085101.1691729-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog In-Reply-To: <20210408085101.1691729-1-hiroh@chromium.org> References: <20210408085101.1691729-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v3 1/3] 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;