{"id":14951,"url":"https://patchwork.libcamera.org/api/1.1/patches/14951/?format=json","web_url":"https://patchwork.libcamera.org/patch/14951/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211201075348.3121186-12-hiroh@chromium.org>","date":"2021-12-01T07:53:47","name":"[libcamera-devel,v5,11/12] android: camera_device: Add thread safety annotation","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"522e3de9e964027cb628ee6cdd057d6b98accc3d","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14951/mbox/","series":[{"id":2791,"url":"https://patchwork.libcamera.org/api/1.1/series/2791/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2791","date":"2021-12-01T07:53:36","name":"Introduce clang thread safety annotations","version":5,"mbox":"https://patchwork.libcamera.org/series/2791/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14951/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14951/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6BAFCBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Dec 2021 07:54:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 21F6960727;\n\tWed,  1 Dec 2021 08:54:17 +0100 (CET)","from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com\n\t[IPv6:2607:f8b0:4864:20::1030])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 838AD60720\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Dec 2021 08:54:15 +0100 (CET)","by mail-pj1-x1030.google.com with SMTP id\n\tcq22-20020a17090af99600b001a9550a17a5so20378892pjb.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 23:54:15 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:3892:a049:59ba:c772])\n\tby smtp.gmail.com with ESMTPSA id\n\tl9sm3500848pfu.55.2021.11.30.23.54.12\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 30 Nov 2021 23:54:13 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Ixaxy3Gu\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=t1EdNmb2krgv/F9K2Ewspd25zRV1hwTxg1Jn4yjsZWU=;\n\tb=Ixaxy3GuVLG803pXWFsSj724qX0bH9FhLluVkALfzhW9pbT0U4cams0KYhBsmn7Du6\n\tvfRCRFLkNWozkHmze3CjNCrjGvBXTrQvIrcSXFufF6/xykwUgpd3h/jKIZrZFbYSkxqR\n\tRMqjh2sU2btC04rZd7MQbmcVWJMWlxlgH9HBA=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=t1EdNmb2krgv/F9K2Ewspd25zRV1hwTxg1Jn4yjsZWU=;\n\tb=bicwEAYSA6R5UGbGr/Ke2QN8IeuKEQb/zk6hvmSll82s1JsREu0OSygLzjKiTD8e+f\n\tub+nOBYNGu17zugrHkwka0cVfpk4neVr/XH4pQM6tjd8KE7y80f5d425zfHDMja8fBnu\n\tBNg1mD5jZX9JdotDnZqtPevO9jbWWBZ5f/imuHPSGKt5hdkE9dXh0abGOzt2YCIxFj7n\n\tZCcJ1nSK/N+JrUKpgVmLuGIQVNRIQPrw6k9ufXkPvbpBgJoLLbplVpMVuwr8ldDA1mjH\n\tAvaij7eRdecriE7YV1V5jflQSA/8QeqGyf6eSeorHEzscNVRK4cYFhtN2tWwkVP3aNqX\n\tvGWQ==","X-Gm-Message-State":"AOAM532fOb6Qw1ogge5kTqQ9Jx/jw1U7tDyMAK33lZBtZ9MBD+d8e1aN\n\tkmtV0e7AHzokuB9Oy0eVX09770xAx2ziPg==","X-Google-Smtp-Source":"ABdhPJzSrtaVr5SrRdbdJrScoHOaCe/Aw6S5bombvA/O2/lVNTLIqYUSwHe5HsEtTE4agx7uRVKAnQ==","X-Received":"by 2002:a17:903:4053:b0:143:6d84:984c with SMTP id\n\tn19-20020a170903405300b001436d84984cmr5582218pla.37.1638345253909; \n\tTue, 30 Nov 2021 23:54:13 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  1 Dec 2021 16:53:47 +0900","Message-Id":"<20211201075348.3121186-12-hiroh@chromium.org>","X-Mailer":"git-send-email 2.34.0.rc2.393.gf8c9666880-goog","In-Reply-To":"<20211201075348.3121186-1-hiroh@chromium.org>","References":"<20211201075348.3121186-1-hiroh@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 11/12] android: camera_device: Add\n\tthread safety annotation","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This applies clang thread safety annotation to CameraDevice.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/android/camera_device.h | 14 ++++++++------\n 1 file changed, 8 insertions(+), 6 deletions(-)","diff":"diff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex a945f5de..e5d9cda2 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -82,7 +82,7 @@ private:\n \t\tRunning,\n \t};\n \n-\tvoid stop();\n+\tvoid stop() LIBCAMERA_TSA_EXCLUDES(stateMutex_);\n \n \tstd::unique_ptr<libcamera::FrameBuffer>\n \tcreateFrameBuffer(const buffer_handle_t camera3buffer,\n@@ -94,8 +94,9 @@ private:\n \tvoid notifyError(uint32_t frameNumber, camera3_stream_t *stream,\n \t\t\t camera3_error_msg_code code) const;\n \tint processControls(Camera3RequestDescriptor *descriptor);\n-\tvoid completeDescriptor(Camera3RequestDescriptor *descriptor);\n-\tvoid sendCaptureResults();\n+\tvoid completeDescriptor(Camera3RequestDescriptor *descriptor)\n+\t\tLIBCAMERA_TSA_EXCLUDES(descriptorsMutex_);\n+\tvoid sendCaptureResults() LIBCAMERA_TSA_REQUIRES(descriptorsMutex_);\n \tvoid setBufferStatus(Camera3RequestDescriptor::StreamBuffer &buffer,\n \t\t\t     Camera3RequestDescriptor::Status status);\n \tstd::unique_ptr<CameraMetadata> getResultMetadata(\n@@ -107,7 +108,7 @@ private:\n \tCameraWorker worker_;\n \n \tlibcamera::Mutex stateMutex_; /* Protects access to the camera state. */\n-\tState state_;\n+\tState state_ LIBCAMERA_TSA_GUARDED_BY(stateMutex_);\n \n \tstd::shared_ptr<libcamera::Camera> camera_;\n \tstd::unique_ptr<libcamera::CameraConfiguration> config_;\n@@ -118,8 +119,9 @@ private:\n \n \tstd::vector<CameraStream> streams_;\n \n-\tlibcamera::Mutex descriptorsMutex_; /* Protects descriptors_. */\n-\tstd::queue<std::unique_ptr<Camera3RequestDescriptor>> descriptors_;\n+\tlibcamera::Mutex descriptorsMutex_ LIBCAMERA_TSA_ACQUIRED_AFTER(stateMutex_);\n+\tstd::queue<std::unique_ptr<Camera3RequestDescriptor>> descriptors_\n+\t\tLIBCAMERA_TSA_GUARDED_BY(descriptorsMutex_);\n \n \tstd::string maker_;\n \tstd::string model_;\n","prefixes":["libcamera-devel","v5","11/12"]}