{"id":14908,"url":"https://patchwork.libcamera.org/api/patches/14908/?format=json","web_url":"https://patchwork.libcamera.org/patch/14908/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20211130155600.2203123-12-hiroh@chromium.org>","date":"2021-11-30T15:55:59","name":"[libcamera-devel,v3,11/12] android: camera_device: Add thread safety annotation","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"dee1a1866e9e1383734938ead1410d467600b9bb","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14908/mbox/","series":[{"id":2785,"url":"https://patchwork.libcamera.org/api/series/2785/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2785","date":"2021-11-30T15:55:48","name":"Introduce clang thread safety annotations","version":3,"mbox":"https://patchwork.libcamera.org/series/2785/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14908/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14908/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 807FFBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 15:56:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1B83260721;\n\tTue, 30 Nov 2021 16:56:32 +0100 (CET)","from mail-pl1-x634.google.com (mail-pl1-x634.google.com\n\t[IPv6:2607:f8b0:4864:20::634])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B61560723\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 16:56:29 +0100 (CET)","by mail-pl1-x634.google.com with SMTP id p18so15242885plf.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 07:56:28 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:c90a:5a53:b139:1336])\n\tby smtp.gmail.com with ESMTPSA id\n\tpc10sm3510283pjb.9.2021.11.30.07.56.25\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 30 Nov 2021 07:56:26 -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=\"Wj7dn/VB\"; 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=eSIHoo+cZo+7Eu+mUseGv7nouggocX5mQcNX6VZPt/o=;\n\tb=Wj7dn/VBoCkyK3OdSafLMwafDC4WgV8+iw1QWl08AuXtVZvjumsYNsrJxN1IoTrLm/\n\ty3BHLjlswxroyQstVczyCwJre6G49EQacDa7hv6Ayh7gnk2gzS7D6eVeT9zMVxi8nMs/\n\tP/frg9PPUo/5c9FsSzuZZGk7dG/4vlEd09n/s=","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=eSIHoo+cZo+7Eu+mUseGv7nouggocX5mQcNX6VZPt/o=;\n\tb=KaOG1u4GqKvIVlYjuZ80MW/86tbt+LoqNPcd5OIatmLdV2Hi936WZJmvnbY1u1XOt8\n\tOPTT9FHshDEtkCIT5TDiR3503Pb4eNe3y8RIq3tcD9hRUdwZQdbHQqKxNnumdgbc5ts/\n\tBD9CBux19oB253KD5sn/GNDT5juuLj6pY4VGBhoTkUDxrjXNs10U8Q2hAk37O39Sz+iT\n\tBo1oI3Xvh6sNb4e9v96ttq6qHRtrVJUFtFU7Lq+pN+iEPrbjLCOV0+yXpRf9+17VnydZ\n\tOd7yuwVOjl6RGpmQz+Gk5sTIjIoRFn6xEszbYT7mNRGGaAuNewTm1NbWdivu0kAK4V8/\n\tHagA==","X-Gm-Message-State":"AOAM531XL04rFbWrTZbDzDqYDN0YLs5492XOpDThPrYkogEhgyxmlyA0\n\trEoOi4eBJsGXU3kf9idlm2XUmeW01B3tcA==","X-Google-Smtp-Source":"ABdhPJxNogVXR9khvBK4dPKzDiC3vv63LZ92qyVpSVYnE0mO7T9fZmea5mGGUUES3hSa0RI+3fZqRQ==","X-Received":"by 2002:a17:90b:164c:: with SMTP id\n\til12mr241908pjb.241.1638287787387; \n\tTue, 30 Nov 2021 07:56:27 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  1 Dec 2021 00:55:59 +0900","Message-Id":"<20211130155600.2203123-12-hiroh@chromium.org>","X-Mailer":"git-send-email 2.34.0.rc2.393.gf8c9666880-goog","In-Reply-To":"<20211130155600.2203123-1-hiroh@chromium.org>","References":"<20211130155600.2203123-1-hiroh@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 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 | 15 +++++++++------\n 1 file changed, 9 insertions(+), 6 deletions(-)","diff":"diff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex a945f5de..2083dac1 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -18,6 +18,7 @@\n #include <libcamera/base/log.h>\n #include <libcamera/base/message.h>\n #include <libcamera/base/mutex.h>\n+#include <libcamera/base/thread_annotations.h>\n \n #include <libcamera/camera.h>\n #include <libcamera/framebuffer.h>\n@@ -82,7 +83,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 +95,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 +109,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 +120,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","v3","11/12"]}