From patchwork Sun Aug 18 15:43:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 20948 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 4C81DBDB13 for ; Sun, 18 Aug 2024 15:43:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0FAF0633BD; Sun, 18 Aug 2024 17:43:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="J8pQCD5i"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 96B6561955 for ; Sun, 18 Aug 2024 17:43:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723995810; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zQ7iWZKAkL0nItMEYniPwB0IrANQ/j4TZhRCzBK/u+I=; b=J8pQCD5iFwgK2EZOmO4i7JxLxGnwH2XpU1BP5ubGFzgvgS3nT5rqh2ToqQ3lppXjbS96HC 6AR9GPxRL/Hu8EWDdBiI8Os1J649Uwq2AWKYe+6mUgQagccxJZK6JrRcWBmYFfWf57VCd9 9XSoLkjQ4TIkZ9ON3DJF+ca4aWdAB+8= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-25-CwruC7NcOPib2LxPala_bw-1; Sun, 18 Aug 2024 11:43:29 -0400 X-MC-Unique: CwruC7NcOPib2LxPala_bw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4A9DF19560AD for ; Sun, 18 Aug 2024 15:43:28 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.192.60]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2F11D1955DD6; Sun, 18 Aug 2024 15:43:25 +0000 (UTC) From: Hans de Goede To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Maxime Ripard , Hans de Goede Subject: [PATCH] pipeline_handler: Fix unlocking media devices too early when there are multiple cameras Date: Sun, 18 Aug 2024 17:43:24 +0200 Message-ID: <20240818154324.71536-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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" PipelineHandler::acquire() only locks the media devices when the first camera is acquired. If a second camera of a pipeline is acquired only useCount_ is increased and nothing else is done. When releasing cameras PipelineHandler::release() should only unlock the media devices when the last camera is released. But the old code unlocked on every release(). Fix PipelineHandler::release() to only release the media devices when the last camera is released. Signed-off-by: Hans de Goede Reviewed-by: Harvey Yang Signed-off-by: Hans de Goede Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline_handler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 5a6de685..a20cd27d 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -205,7 +205,8 @@ void PipelineHandler::release(Camera *camera) ASSERT(useCount_); - unlockMediaDevices(); + if (useCount_ == 1) + unlockMediaDevices(); releaseDevice(camera);