From patchwork Thu Apr 8 08:51:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11869 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 D7FD4BD16B for ; Thu, 8 Apr 2021 08:51:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 913C5687F6; Thu, 8 Apr 2021 10:51:15 +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="ZgJOGWmy"; dkim-atps=neutral Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AA38D687F3 for ; Thu, 8 Apr 2021 10:51:13 +0200 (CEST) Received: by mail-pl1-x634.google.com with SMTP id y2so672557plg.5 for ; Thu, 08 Apr 2021 01:51:13 -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=mQqZcpFm3UO7FM2H86Vrjewz6c/Xzh1LXMTgj5/NsN4=; b=ZgJOGWmye3XJ2bJSQKPNxpp++dn2EEUIrzOo9xXGdSuYsl2Uv5jDl+yE2at2YaD//j /3oM2xhQpVtULseI6n8zUekOBBiPsacSyM7k3xjcDP55/a+ghHqVEtqMluvXOewq7KsF jl5AyL/hW3EIy8C0bNx2gHUVIhiNfvbMLhEC0= 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=mQqZcpFm3UO7FM2H86Vrjewz6c/Xzh1LXMTgj5/NsN4=; b=ZvKkxj71jw3sWMrZNEhnXL+WUpekT45rqj7yUsnl4g8kCyqYnSBUKbMbSa/4nh3xbJ LE02fuAG7srh02A7V/sbPzkyEjXePrWc5P2LRovSlpzxHMyiGMurvnl1zI5sCrk2/ETE MVfVUZB60BIlDXI77uZFTv8eF61GeKo2xkQ6Rnu24RTpeNHiL6RC5+Pm+oQuZ4RWYY+E sZ/RD1oipOhFjAwN7VS5ROc0fokAuOTCoC/LeGNG0hU97Z8An0pTNuwJZLZ33irc6uuR xzeTP0uxXAUhRjw4C7pmsVBKCtwyMftFvZn0tFpBQsrs1LVEudqwqb1xOuLDYqso40iB tJRw== X-Gm-Message-State: AOAM530MKY4IjHh+MX8+KdyPJ6DhdapT9Yjj8G7a/AAfBg0jcrp1RmgT 9qSx9hpcVIcp+z0Lg1YBZwiU1iRmJOSePQ== X-Google-Smtp-Source: ABdhPJyLDLerA6PMhDotUtv3n4BjwQMaNYWbjtGg6W6MOwZ5Y7dxj97gUs5SYsxXZ4MuvgRbprdIgQ== X-Received: by 2002:a17:902:b201:b029:e8:bf9e:990a with SMTP id t1-20020a170902b201b02900e8bf9e990amr6781413plr.56.1617871871983; Thu, 08 Apr 2021 01:51:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 01:51:11 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 8 Apr 2021 17:51:01 +0900 Message-Id: <20210408085101.1691729-4-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 3/3] libcamera: ipu3: Cancel pending requests correctly 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" IPU3CameraData stores requests that are not queued yet to a camera node. They should be reported as cancel upon PipelineHandlerIPU3::stop(). Signed-off-by: Hirokazu Honda --- include/libcamera/buffer.h | 3 +++ src/libcamera/pipeline/ipu3/ipu3.cpp | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index 620f8a66..72c62144 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -58,6 +58,9 @@ private: friend class V4L2VideoDevice; /* Needed to update metadata_. */ + /*! HACK! */ + friend class IPU3CameraData; /* Needed to update metadata_. */ + std::vector planes_; Request *request_; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 462a0d9b..f89b8f3f 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); + void cancelPendingRequests(); int queuePendingRequests(); CIO2Device cio2_; @@ -768,7 +769,7 @@ void PipelineHandlerIPU3::stop(Camera *camera) IPU3CameraData *data = cameraData(camera); int ret = 0; - data->pendingRequests_ = {}; + data->cancelPendingRequests(); data->ipa_->stop(); @@ -780,6 +781,22 @@ void PipelineHandlerIPU3::stop(Camera *camera) freeBuffers(camera); } +void IPU3CameraData::cancelPendingRequests() +{ + while (!pendingRequests_.empty()) { + Request *request = pendingRequests_.front(); + + for (auto it : request->buffers()) { + FrameBuffer *buffer = it.second; + buffer->metadata_.status = FrameMetadata::FrameCancelled; + pipe_->completeBuffer(request, buffer); + } + + pipe_->completeRequest(request); + pendingRequests_.pop(); + } +} + int IPU3CameraData::queuePendingRequests() { while (!pendingRequests_.empty()) {