From patchwork Tue Jun 25 09:35:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1952018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W7fpH5V55z20X1 for ; Tue, 25 Jun 2024 19:35:51 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sM2aX-0001vj-UU; Tue, 25 Jun 2024 09:35:45 +0000 Received: from mail-pl1-f175.google.com ([209.85.214.175]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sM2aX-0001up-6f for kernel-team@lists.ubuntu.com; Tue, 25 Jun 2024 09:35:45 +0000 Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1f9fb3ca81bso21352175ad.3 for ; Tue, 25 Jun 2024 02:35:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719308143; x=1719912943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pfXOtQI6AMEZTvUGyMEMpWt/K79Qg+9ByfHdoJb+9oA=; b=V6TkGy8DvkqJ946ADKO5gVy2oQUYvLFxm6NqqNVk6XW48QiKBlUJcOcHAi6g1WloFL obdnf4sYO8makSnqUrZ+EljIVP/PJk1cRXGQCsI3FVLZs54+heiPxFsnAsbwHZnaJ9R7 erstY/K35nmaHW3I4k4ZcZVL805mA6crIjbkDWhzySRMGzL3VBh5Vi3rOHcTCnDrLlX3 o/JYoRfH4HnCX4Kr620OdJNCrpuzGHUGy9VNVcybg0jAcShMh031IEuWSZpNQN75zNHE nkjgQztfaH767q//OZ+pb2dCYK/YVyjulETUkTMt6e5nNHSv6JcyA65kd5kkHRfkagSe 5r9w== X-Gm-Message-State: AOJu0YzBVNF/aSf/YaKWvzrKUuuH8d7zfOGbjfvoUWy8yt78EizjWlBM F5IcJOl5KZP3tYiLG5Ay/MI9ytUySm0nyp/q9jSV54JqP5XiJ3bZtEJa4ta2 X-Google-Smtp-Source: AGHT+IFu3jVipbsiT045unZOZFu2ncrIHlmZtE3yceYLG4IPkSKoKmHz5L2wzrCObWh1DpoJXSQNmg== X-Received: by 2002:a17:90b:4c8f:b0:2c2:f2f9:a121 with SMTP id 98e67ed59e1d1-2c8614911e8mr5316203a91.39.1719308143013; Tue, 25 Jun 2024 02:35:43 -0700 (PDT) Received: from localhost.localdomain (125-229-129-140.hinet-ip.hinet.net. [125.229.129.140]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c819db9803sm8176683a91.45.2024.06.25.02.35.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 02:35:42 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/7][Unstable] UBUNTU: SAUCE: media: ivsc: csi: add separate lock for v4l2 control handler Date: Tue, 25 Jun 2024 17:35:15 +0800 Message-ID: <20240625093520.3804382-3-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625093520.3804382-1-vicamo.yang@canonical.com> References: <20240625093520.3804382-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.175; envelope-from=vicamo@gmail.com; helo=mail-pl1-f175.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Wentong Wu BugLink: https://bugs.launchpad.net/bugs/2067364 There're possibilities that privacy status change notification happens in the middle of the ongoing mei command which already takes the command lock, but v4l2_ctrl_s_ctrl() would also need the same lock prior to this patch, so this may results in circular locking problem. This patch adds one dedicated lock for v4l2 control handler to avoid described issue. Reported-by: Hao Yao Signed-off-by: Wentong Wu Tested-by: Jason Chen (cherry picked from https://lore.kernel.org/r/all/20240607132547.2820515-3-wentong.wu@intel.com) Signed-off-by: You-Sheng Yang --- drivers/media/pci/intel/ivsc/mei_csi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/intel/ivsc/mei_csi.c b/drivers/media/pci/intel/ivsc/mei_csi.c index 24060ac2c3a0..16791a7f4f15 100644 --- a/drivers/media/pci/intel/ivsc/mei_csi.c +++ b/drivers/media/pci/intel/ivsc/mei_csi.c @@ -126,6 +126,8 @@ struct mei_csi { struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *freq_ctrl; struct v4l2_ctrl *privacy_ctrl; + /* lock for v4l2 controls */ + struct mutex ctrl_lock; unsigned int remote_pad; /* start streaming or not */ int streaming; @@ -563,11 +565,13 @@ static int mei_csi_init_controls(struct mei_csi *csi) u32 max; int ret; + mutex_init(&csi->ctrl_lock); + ret = v4l2_ctrl_handler_init(&csi->ctrl_handler, 2); if (ret) return ret; - csi->ctrl_handler.lock = &csi->lock; + csi->ctrl_handler.lock = &csi->ctrl_lock; max = ARRAY_SIZE(link_freq_menu_items) - 1; csi->freq_ctrl = v4l2_ctrl_new_int_menu(&csi->ctrl_handler, @@ -759,6 +763,7 @@ static int mei_csi_probe(struct mei_cl_device *cldev, err_ctrl_handler: v4l2_ctrl_handler_free(&csi->ctrl_handler); + mutex_destroy(&csi->ctrl_lock); v4l2_async_nf_unregister(&csi->notifier); v4l2_async_nf_cleanup(&csi->notifier); @@ -778,6 +783,7 @@ static void mei_csi_remove(struct mei_cl_device *cldev) v4l2_async_nf_unregister(&csi->notifier); v4l2_async_nf_cleanup(&csi->notifier); v4l2_ctrl_handler_free(&csi->ctrl_handler); + mutex_destroy(&csi->ctrl_lock); v4l2_async_unregister_subdev(&csi->subdev); v4l2_subdev_cleanup(&csi->subdev); media_entity_cleanup(&csi->subdev.entity);