From patchwork Thu Mar 25 13:42:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11716 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 3382DC32E9 for ; Thu, 25 Mar 2021 13:42:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E66BB68D7E; Thu, 25 Mar 2021 14:42:47 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="A7soGS87"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 17F9668D66 for ; Thu, 25 Mar 2021 14:42:38 +0100 (CET) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AC2F7560; Thu, 25 Mar 2021 14:42:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1616679757; bh=3phRjmHWCr/7dGInyNkMdaCLwsrOcGcBRQnA3ggRd3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A7soGS874I1jwxt6MIfuTt6rh51m4qieuJKGwB6HzqwfIUq0KXlg7Wkp8iW1ww7dc dnLQ/EvrnhtWnqbgKjkDNAiishOlzjOsn2GQtML9Wc4VBrvsRbj0PCfcuHd01cnVku 2teM3a8kMpfxk/HCBm7ZEtAskUqSOtX9kTvmX4Q4= From: Kieran Bingham To: libcamera devel Date: Thu, 25 Mar 2021 13:42:26 +0000 Message-Id: <20210325134231.1400051-9-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325134231.1400051-1-kieran.bingham@ideasonboard.com> References: <20210325134231.1400051-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 06/11] libcamera: camera: Validate requests are completed in Running state 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" All requests must have completed before the Camera has fully stopped. Requests completing when the camera is not running represent an internal pipeline handler bug. Trap this event with a fatal error. Reviewed-by: Niklas Söderlund Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/camera.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 84edbb8f494d..b86bff4745b2 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -1062,11 +1062,11 @@ int Camera::stop() LOG(Camera, Debug) << "Stopping capture"; - d->setState(Private::CameraConfigured); - d->pipe_->invokeMethod(&PipelineHandler::stop, ConnectionTypeBlocking, this); + d->setState(Private::CameraConfigured); + return 0; } @@ -1079,6 +1079,13 @@ int Camera::stop() */ void Camera::requestComplete(Request *request) { + Private *const d = LIBCAMERA_D_PTR(); + + /* Disconnected cameras are still able to complete requests. */ + int ret = d->isAccessAllowed(Private::CameraRunning); + if (ret < 0 && ret != -ENODEV) + LOG(Camera, Fatal) << "Trying to complete a request when stopped"; + requestCompleted.emit(request); }