From patchwork Mon Nov 29 11:44: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: 14846 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 2D9AEBF415 for ; Mon, 29 Nov 2021 11:45:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D89D0605BB; Mon, 29 Nov 2021 12:45:21 +0100 (CET) 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="AgO1xoFp"; dkim-atps=neutral Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CA61660592 for ; Mon, 29 Nov 2021 12:45:18 +0100 (CET) Received: by mail-pg1-x534.google.com with SMTP id r5so15782194pgi.6 for ; Mon, 29 Nov 2021 03:45:18 -0800 (PST) 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=7N6nOACUKphc6ZSF1ybQg9PRBU9NHpQ5TXKsVKJlUr4=; b=AgO1xoFp0frMy8aSI94cAmJt0kmTcN4Tl0L6qF1b5ssclW+Reu143PVmChGBarWF6X usUWuLldiXUApbcTEQxfstxj4af3adz/IdTI00FNUXkCZ/emc367WO5Rq3Rvnjm0P2ZC XFUWJ2tnJ7U0NES99KBlm8I4Zputhf470N+1E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7N6nOACUKphc6ZSF1ybQg9PRBU9NHpQ5TXKsVKJlUr4=; b=xf00C5i4mC52xzV+iKLXZMybdpPfiNr7UsoofrYmVCClaJfmv/HaJ+U5zkQ5GyfWLB d48Q0jJPc+TKCp+X2BRrirpm4+s3bW/1wBiPLS/TpLecC+DEUgnzvlDQtRHm1zlY72Vd igq6ftkDWIa8aEEY4lY+Ilw8ee9cW/TjtU/Ly2ATgvLH8uYz6hMAHvde5UDUVy1dLWZW QPF4rHre6UekkaPx6xEMhDT+Z2ppbpmRdqK98oiojM6GY47jchcF8Wdu6lHvgB9oFFou mrs43Spms/3kb8314gLJHLAZx8tFz+qgLd5UXiQQRHFu907SLd6LRgpbZeD/cm1YwawC NUJA== X-Gm-Message-State: AOAM531KSQ/te+F/MmGC+YgO2FsL5B+pOl+3R37TvSIHeGDUlosj5CrC FizVaL7y/rd3mj4ireSeBZQZjZ7InG2elg== X-Google-Smtp-Source: ABdhPJw3/2GP/3tKa+EYt+7fTsOt/ZfLcp8B13ejQhg2pd63SdMrjpc2yYOLtWiajnH1sHH14eMFaQ== X-Received: by 2002:a63:8248:: with SMTP id w69mr33777594pgd.342.1638186317093; Mon, 29 Nov 2021 03:45:17 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:f254:cda9:46e8:17b7]) by smtp.gmail.com with ESMTPSA id hg4sm17951966pjb.1.2021.11.29.03.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 03:45:16 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Nov 2021 20:44:52 +0900 Message-Id: <20211129114453.3186042-11-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211129114453.3186042-1-hiroh@chromium.org> References: <20211129114453.3186042-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 10/11] android: camera_device: Add thread safety annotation 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" This applies clang thread safety annotation to CameraDevice. Mutex and MutexLocker there are replaced with Mutex2 and MutexLocer2. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 2 -- src/android/camera_device.h | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 59185e7f..e7365175 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -932,7 +931,6 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques * Request. */ LOG(HAL, Debug) << ss.str() << " (mapped)"; - descriptor->pendingStreamsToProcess_.insert( { cameraStream, &buffer }); continue; diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 51fe7da2..2083dac1 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -18,7 +17,8 @@ #include #include #include -#include +#include +#include #include #include @@ -83,7 +83,7 @@ private: Running, }; - void stop(); + void stop() LIBCAMERA_TSA_EXCLUDES(stateMutex_); std::unique_ptr createFrameBuffer(const buffer_handle_t camera3buffer, @@ -95,8 +95,9 @@ private: void notifyError(uint32_t frameNumber, camera3_stream_t *stream, camera3_error_msg_code code) const; int processControls(Camera3RequestDescriptor *descriptor); - void completeDescriptor(Camera3RequestDescriptor *descriptor); - void sendCaptureResults(); + void completeDescriptor(Camera3RequestDescriptor *descriptor) + LIBCAMERA_TSA_EXCLUDES(descriptorsMutex_); + void sendCaptureResults() LIBCAMERA_TSA_REQUIRES(descriptorsMutex_); void setBufferStatus(Camera3RequestDescriptor::StreamBuffer &buffer, Camera3RequestDescriptor::Status status); std::unique_ptr getResultMetadata( @@ -108,7 +109,7 @@ private: CameraWorker worker_; libcamera::Mutex stateMutex_; /* Protects access to the camera state. */ - State state_; + State state_ LIBCAMERA_TSA_GUARDED_BY(stateMutex_); std::shared_ptr camera_; std::unique_ptr config_; @@ -119,8 +120,9 @@ private: std::vector streams_; - libcamera::Mutex descriptorsMutex_; /* Protects descriptors_. */ - std::queue> descriptors_; + libcamera::Mutex descriptorsMutex_ LIBCAMERA_TSA_ACQUIRED_AFTER(stateMutex_); + std::queue> descriptors_ + LIBCAMERA_TSA_GUARDED_BY(descriptorsMutex_); std::string maker_; std::string model_;