From patchwork Fri Jun 3 13:22:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16140 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 66F08C326E for ; Fri, 3 Jun 2022 13:23:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0FDFB6563B; Fri, 3 Jun 2022 15:23:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1654262590; bh=rkzOhxHUJ/ogiiZQc37sw1q9ERNpAiHJGLINDSyqm78=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=cU/OgmlSeu1rsW/lrpFVhf3j27njZkiMd6hlxxnjg+npejv1uzA9kDGTteLVZD1TE 0jzqaA6lWB2qMoZlvKw8/33fGMKvyk0SdMTEEaCm9T2q0jEWL/FmkGIqxSHK+ybiWe RlE3ajln6WLMKuTe1K1OMPl5sEfBwVjYNH2A15P81lHdGT27dSP4usIHRJlSUjoXS0 aL5UiR9J+qP8vGfuHNXa46apaAmHHbZW/dODNU6XEKNupsGmQpJKRg6wDEU6T884Mg I1vsL0ida3LOoM6FHuYkbhYcwTAiOMCociZMPMUw7V3PFtbe6FcPnXks6UHvQ3ygLn GVzeSheQ0/MKA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7037D60105 for ; Fri, 3 Jun 2022 15:23:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nY64hAan"; dkim-atps=neutral Received: from perceval.ideasonboard.com (static-127-186-62-95.ipcom.comunitel.net [95.62.186.127]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 01B5810DD; Fri, 3 Jun 2022 15:23:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1654262587; bh=rkzOhxHUJ/ogiiZQc37sw1q9ERNpAiHJGLINDSyqm78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nY64hAankXJXeU0mBAhGo8WWt4nMOSoA1unPBc9Epl9JX+cxm0yQ2GShsXDYHWaoT xa32VVKKRrJTq1mHFziYSnEaWKBGWUX55mhsHrhIv7SqWBesUmqyW+2SHkAqgHXieB b/AZeHHyaDWONA/fAa37rR2Ba/EHN8B9+UAC3v34= To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Jun 2022 15:22:58 +0200 Message-Id: <20220603132259.188845-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220603132259.188845-1-umang.jain@ideasonboard.com> References: <20220603132259.188845-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 3/4] ipa: ipu3: Prevent over queuing of requests 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-Patchwork-Original-From: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The IPAIPU3 processes each IPAFrameContext present in the FCQueue ring buffer. If the application queues the requests at a pace where IPAFrameContext(s) can get potentially over-written without getting processed by the IPA, it would lead to un-desirable effects. Hence, inspect the FCQueue if it is full and reject any further queuing of requests. This requires changes to the IPAIPU3 mojom interface. The IPAIPU3::queueRequest() cannot be [async] anymore since we need to return a success/failure value. The rejection by the IPA doesn't mean it cannot be queued later. The request is still preserved in IPU3CameraData::pendingRequests_. It shall be queued sequentially on subsequent calls to IPU3CameraData::queuePendingRequests(). Signed-off-by: Umang Jain --- I am not super-happy with changing the interface and dropping [async] but this is what I've for now. Would appreciate any other ideas... --- include/libcamera/ipa/ipu3.mojom | 2 +- src/ipa/ipu3/ipu3.cpp | 11 +++++++++-- src/libcamera/pipeline/ipu3/ipu3.cpp | 10 +++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/libcamera/ipa/ipu3.mojom b/include/libcamera/ipa/ipu3.mojom index d1b1c6b8..3faffd9c 100644 --- a/include/libcamera/ipa/ipu3.mojom +++ b/include/libcamera/ipa/ipu3.mojom @@ -30,7 +30,7 @@ interface IPAIPU3Interface { mapBuffers(array buffers); unmapBuffers(array ids); - [async] queueRequest(uint32 frame, libcamera.ControlList controls); + queueRequest(uint32 frame, libcamera.ControlList controls) => (int32 ret); [async] fillParamsBuffer(uint32 frame, uint32 bufferId); [async] processStatsBuffer(uint32 frame, int64 frameTimestamp, uint32 bufferId, libcamera.ControlList sensorControls); diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 1d6ee515..63aa9b56 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -145,7 +145,7 @@ public: void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; - void queueRequest(const uint32_t frame, const ControlList &controls) override; + int queueRequest(const uint32_t frame, const ControlList &controls) override; void fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) override; void processStatsBuffer(const uint32_t frame, const int64_t frameTimestamp, const uint32_t bufferId, @@ -616,11 +616,18 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, * * Parse the request to handle any IPA-managed controls that were set from the * application such as manual sensor settings. + * + * \return 0 if successful, -EPERM otherwise. */ -void IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls) +int IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls) { + if (context_.frameContexts.isFull()) + return -EPERM; + /* \todo Start processing for 'frame' based on 'controls'. */ *context_.frameContexts.get(frame) = { frame, controls }; + + return 0; } /** diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index fd989e61..d69e28d4 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -874,7 +874,15 @@ void IPU3CameraData::queuePendingRequests() info->rawBuffer = rawBuffer; - ipa_->queueRequest(info->id, request->controls()); + /* + * Queueing request to the IPA can fail in cases like over-flowing + * its queue. Hence, keep the request preserved in pendingRequests_ + * if a failure occurs. + */ + if (ipa_->queueRequest(info->id, request->controls()) != 0) { + frameInfos_.remove(info); + break; + } pendingRequests_.pop(); processingRequests_.push(request);