From patchwork Fri Jul 31 14:07:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 9093 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 54472BD86F for ; Fri, 31 Jul 2020 14:08:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 61F2A61DCF; Fri, 31 Jul 2020 16:08:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Lx111BbB"; dkim-atps=neutral Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 434B061DCF for ; Fri, 31 Jul 2020 16:08:09 +0200 (CEST) Received: by mail-wm1-x342.google.com with SMTP id q76so8148412wme.4 for ; Fri, 31 Jul 2020 07:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZqilBsLzMKmrddlWmS1RYYMDXLW+mCOVb0l3nhtKIeU=; b=Lx111BbBtf8qRqWTyaeYITHlokM6pliFuuNahUllbWTZov0iS0geMNURRpAm/q4qMD bcunSkfooCmEjrvVjou7md/fja5XsBZiWcQExLuog4BkpBijB3dVG/KSVS7moLIABn5i fnnRzhANKrW/8Slr4vYZHDf0XF7ZuRUcZmw/evOmUUhPd/jcXYuEuJwe1oDV44Tw+vK5 Mo75cn3Ii1Ds9GxHlc2D3jcRQJB7+DtJfU6Mtg2rBIryIhTW86hA8+i82vq271jtTsIN BSDgWHZNj5IB15uLcCBhKVgNFCbpD1gtCOgQQqjmcxE7Dpg27L0v9XkYuBn+kyX/8aCI rlow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZqilBsLzMKmrddlWmS1RYYMDXLW+mCOVb0l3nhtKIeU=; b=cVFabsKgxBP9jEU43XagAgXjZ0lzCRU1lEs1toVX8+7lhY4PbXQQIaX6phmGmUIEDW MbW0/x9t+PC5NG2IlCX1Z/ms/s2+AsUMfy4oPzFRSsWO6tnIMGq2ugdVoBAYA3YeWKI2 ooHnBqaKAuAIK/3gmdfxH+PZ/NvASayQAuTnHOv3SiHTJ0coBXgf8L5DGTxHgsXtVxX+ 6U60yF3qt/DUIszqu/qO6eEQgZIS0BUxXwich/QRWqUUCCk2n7qWos9QyLa5NVhxM5s5 /PzErJE3dLQo5xbZZuxmTjVZO1syqlJvM8EGYbjTvXlaryCt3yiCeKbbetxqlKNvI1A8 DDxQ== X-Gm-Message-State: AOAM533h4q4oQhfBZ/9SLUYxjmwdThWv7r0TQSQz2YSdEOIzwWzrt0Bw c5LNhDuhfcl+ZFlWzSpFkJb9dDk9j6yb+A== X-Google-Smtp-Source: ABdhPJz0mkurWtkGrIjMfJI/a6zySzd+mb5ktcPSRgr8Cgju9qsILQPLI8K2HnBNbLTxIxm6VV0Tlw== X-Received: by 2002:a7b:c40a:: with SMTP id k10mr3849860wmi.127.1596204488580; Fri, 31 Jul 2020 07:08:08 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id g126sm12815084wme.16.2020.07.31.07.08.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 07:08:08 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Fri, 31 Jul 2020 15:07:59 +0100 Message-Id: <20200731140801.13253-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200731140801.13253-1-david.plowman@raspberrypi.com> References: <20200731140801.13253-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] libcamera: ipa: raspberrypi: ALSC: Improve locking in a few places 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" Fix up a few locations where we call notify_one() with the lock held. In particular, restartAsync does not need to be called with the lock held for its entire duration. Signed-off-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/rpi/alsc.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index 76e2f04..12359dc 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp @@ -32,8 +32,8 @@ Alsc::~Alsc() { std::lock_guard lock(mutex_); async_abort_ = true; - async_signal_.notify_one(); } + async_signal_.notify_one(); async_thread_.join(); } @@ -268,8 +268,11 @@ void Alsc::restartAsync(StatisticsPtr &stats, Metadata *image_metadata) frame_phase_ = 0; // copy the camera mode so it won't change during the calculations async_camera_mode_ = camera_mode_; - async_start_ = true; async_started_ = true; + { + std::lock_guard lock(mutex_); + async_start_ = true; + } async_signal_.notify_one(); } @@ -315,7 +318,6 @@ void Alsc::Process(StatisticsPtr &stats, Metadata *image_metadata) RPI_LOG("Alsc: frame_phase " << frame_phase_); if (frame_phase_ >= (int)config_.frame_period || frame_count2_ < (int)config_.startup_frames) { - std::unique_lock lock(mutex_); if (async_started_ == false) { RPI_LOG("ALSC thread starting"); restartAsync(stats, image_metadata); @@ -339,8 +341,8 @@ void Alsc::asyncFunc() { std::lock_guard lock(mutex_); async_finished_ = true; - sync_signal_.notify_one(); } + sync_signal_.notify_one(); } }