[{"id":11757,"web_url":"https://patchwork.libcamera.org/comment/11757/","msgid":"<20200731211354.GD24315@pendragon.ideasonboard.com>","date":"2020-07-31T21:13:54","subject":"Re: [libcamera-devel] [PATCH v2 2/4] libcamera: ipa: raspberrypi:\n\tALSC: Improve locking in a few places","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Fri, Jul 31, 2020 at 03:07:59PM +0100, David Plowman wrote:\n> Fix up a few locations where we call notify_one() with the lock\n> held. In particular, restartAsync does not need to be called with the\n> lock held for its entire duration.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/ipa/raspberrypi/controller/rpi/alsc.cpp | 10 ++++++----\n>  1 file changed, 6 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp\n> index 76e2f04..12359dc 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp\n> @@ -32,8 +32,8 @@ Alsc::~Alsc()\n>  \t{\n>  \t\tstd::lock_guard<std::mutex> lock(mutex_);\n>  \t\tasync_abort_ = true;\n> -\t\tasync_signal_.notify_one();\n>  \t}\n> +\tasync_signal_.notify_one();\n>  \tasync_thread_.join();\n>  }\n>  \n> @@ -268,8 +268,11 @@ void Alsc::restartAsync(StatisticsPtr &stats, Metadata *image_metadata)\n>  \tframe_phase_ = 0;\n>  \t// copy the camera mode so it won't change during the calculations\n>  \tasync_camera_mode_ = camera_mode_;\n> -\tasync_start_ = true;\n>  \tasync_started_ = true;\n> +\t{\n> +\t\tstd::lock_guard<std::mutex> lock(mutex_);\n> +\t\tasync_start_ = true;\n> +\t}\n>  \tasync_signal_.notify_one();\n>  }\n>  \n> @@ -315,7 +318,6 @@ void Alsc::Process(StatisticsPtr &stats, Metadata *image_metadata)\n>  \tRPI_LOG(\"Alsc: frame_phase \" << frame_phase_);\n>  \tif (frame_phase_ >= (int)config_.frame_period ||\n>  \t    frame_count2_ < (int)config_.startup_frames) {\n> -\t\tstd::unique_lock<std::mutex> lock(mutex_);\n>  \t\tif (async_started_ == false) {\n>  \t\t\tRPI_LOG(\"ALSC thread starting\");\n>  \t\t\trestartAsync(stats, image_metadata);\n> @@ -339,8 +341,8 @@ void Alsc::asyncFunc()\n>  \t\t{\n>  \t\t\tstd::lock_guard<std::mutex> lock(mutex_);\n>  \t\t\tasync_finished_ = true;\n> -\t\t\tsync_signal_.notify_one();\n>  \t\t}\n> +\t\tsync_signal_.notify_one();\n>  \t}\n>  }\n>","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 D3B7EBD878\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 Jul 2020 21:14:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4F4E261F1F;\n\tFri, 31 Jul 2020 23:14:06 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 92C8560398\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Jul 2020 23:14:04 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1670853C;\n\tFri, 31 Jul 2020 23:14:04 +0200 (CEST)"],"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=\"c0Ry6CUJ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1596230044;\n\tbh=LJt03Y07xKdouVA5hm/ps2UY0FmGdW0rzETkXqLoYeU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=c0Ry6CUJTGeS5Sr5QDCz7f5wzUqIsw0HdUmaPH3fKz7QKHUR4oDhm2JzRG1S6iZNh\n\tCTxc3TgCwkmh3CG7Iqt9HMTfagkV01CeURt4ulJX0iwouRcirf1edIliKY0d/l4ZdB\n\tPZw2Tkn//si5aN2xGsu+pptiYrCFg3VC39KdFvPw=","Date":"Sat, 1 Aug 2020 00:13:54 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<20200731211354.GD24315@pendragon.ideasonboard.com>","References":"<20200731140801.13253-1-david.plowman@raspberrypi.com>\n\t<20200731140801.13253-3-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200731140801.13253-3-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2 2/4] libcamera: ipa: raspberrypi:\n\tALSC: Improve locking in a few places","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","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]