[{"id":21397,"web_url":"https://patchwork.libcamera.org/comment/21397/","msgid":"<YaWmeyqn/UXkwnlD@pendragon.ideasonboard.com>","date":"2021-11-30T04:20:11","subject":"Re: [libcamera-devel] [PATCH v2 06/11] android: camera_hal_manager:\n\tAdd thread safety annotation","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\nThank you for the patch.\n\nOn Mon, Nov 29, 2021 at 08:44:48PM +0900, Hirokazu Honda wrote:\n> This applies clang thread safety annotation to CameraHalManager.\n> \n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>  src/android/camera_hal_manager.h | 10 +++++-----\n>  1 file changed, 5 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\n> index c07684a1..5395d419 100644\n> --- a/src/android/camera_hal_manager.h\n> +++ b/src/android/camera_hal_manager.h\n> @@ -8,7 +8,6 @@\n>  #pragma once\n>  \n>  #include <map>\n> -#include <mutex>\n\nI think this belongs to patch 02/11.\n\n>  #include <stddef.h>\n>  #include <tuple>\n>  #include <vector>\n> @@ -18,7 +17,8 @@\n>  #include <system/camera_metadata.h>\n>  \n>  #include <libcamera/base/class.h>\n> -#include <libcamera/base/thread.h>\n> +#include <libcamera/base/mutex.h>\n> +#include <libcamera/base/thread_annotations.h>\n\nGiven that mutex.h includes thread_annotations.h, and that it will\nalways do so (as our mutex.h is there only for the purpose of supporting\nTSA), I wonder if we should include it explicitly here. Same comment for\nthe other patches in this series.\n\n>  \n>  #include <libcamera/camera_manager.h>\n>  \n> @@ -54,14 +54,14 @@ private:\n>  \tvoid cameraAdded(std::shared_ptr<libcamera::Camera> cam);\n>  \tvoid cameraRemoved(std::shared_ptr<libcamera::Camera> cam);\n>  \n> -\tCameraDevice *cameraDeviceFromHalId(unsigned int id);\n> +\tCameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);\n>  \n>  \tstd::unique_ptr<libcamera::CameraManager> cameraManager_;\n>  \tCameraHalConfig halConfig_;\n>  \n>  \tconst camera_module_callbacks_t *callbacks_;\n> -\tstd::vector<std::unique_ptr<CameraDevice>> cameras_;\n> -\tstd::map<std::string, unsigned int> cameraIdsMap_;\n> +\tstd::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> +\tstd::map<std::string, unsigned int> cameraIdsMap_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n>  \tlibcamera::Mutex mutex_;\n>  \n>  \tunsigned int numInternalCameras_;","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 AAC65BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 04:20:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DC4B2605B4;\n\tTue, 30 Nov 2021 05:20:37 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E3939604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 05:20:35 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 553CA8F0;\n\tTue, 30 Nov 2021 05:20:35 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"eqa2RzXj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638246035;\n\tbh=hBQhpWC8AYW4KQxQf4eeUJ0GYSESe7qLxkEQSbE6kbM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=eqa2RzXjjrBv6JLP6R36trAc0FqtWG9fPR7xbYD7wbZkNHotU86UTOrL5/k5f2Jtw\n\tHGlSCozFbPbqUBGvKQQlevP1MxLhJQnSujkZjjyRl6EZD3F4u3FfPFaCj2GquW0kB/\n\taKeuCErGuG2BACqBy6U4zw80Vfnscjpil/RKFmwo=","Date":"Tue, 30 Nov 2021 06:20:11 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YaWmeyqn/UXkwnlD@pendragon.ideasonboard.com>","References":"<20211129114453.3186042-1-hiroh@chromium.org>\n\t<20211129114453.3186042-7-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211129114453.3186042-7-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [PATCH v2 06/11] android: camera_hal_manager:\n\tAdd thread 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]