From nobody Sat Oct 4 15:52:54 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB965222566 for ; Thu, 14 Aug 2025 11:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755170717; cv=none; b=W66E26MesKhZVHB7sc5VySYyMMHdNPNDoYW9ZhahyqXPh9zlS1e8GfkuslRf3iRDzkwRuzPilShfLPdbbiWleNkaWFAc7GdbO7eFhfe1pazm61U93qOtfVK5lcjvshsqvEexnJKyi2ggzaJoKzPkJfSz1wEApRDTZCg8mt891f8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755170717; c=relaxed/simple; bh=wp3rwYwUgjRyjVgaK+Ct89o2TRJ1NLg5QDHGpD5DFg4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gfDiRbSnUeLXMdKgp/ntB/UyDY8QesFbmwkM0Mo7xJtdm8NEDY6FdCoJfcSbuDRyrSC/7PsKuKR5VZoy5BSqdKSmfbK/c639MAeutzCcGpQS9IV80I8pxBeuzaAql2tGEoajxwhe51j9NTR0jaXG+HvGWHbfpnam50BusTbgHKo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4c2jYm0b7yztTFw; Thu, 14 Aug 2025 19:24:12 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 17AD8180B51; Thu, 14 Aug 2025 19:25:12 +0800 (CST) Received: from kwepemq200012.china.huawei.com (7.202.194.183) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 14 Aug 2025 19:25:11 +0800 Received: from huawei.com (10.175.112.208) by kwepemq200012.china.huawei.com (7.202.194.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 14 Aug 2025 19:25:11 +0800 From: Wang Wensheng To: , , , , , , , CC: , Subject: [PATCH 1/3] driver core: Fix concurrent problem of deferred_probe_extend_timeout() Date: Thu, 14 Aug 2025 19:10:21 +0800 Message-ID: <20250814111023.2693-2-wangwensheng4@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20250814111023.2693-1-wangwensheng4@huawei.com> References: <20250814111023.2693-1-wangwensheng4@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemq200012.china.huawei.com (7.202.194.183) Content-Type: text/plain; charset="utf-8" The deferred_probe_timeout_work may be canceled forever unexpected when deferred_probe_extend_timeout() executes concurrently. Start with deferred_probe_timeout_work pending, and the problem would occur after the following sequence. CPU0 CPU1 deferred_probe_extend_timeout -> cancel_delayed_work =3D> true deferred_probe_extend_timeout -> cancel_delayed_wrok -> __cancel_work -> try_grab_pending -> schedule_delayed_work -> queue_delayed_work_on since pending bit is grabbed, just return without doing anything -> set_work_pool_and_clear_pending this __cancel_work return false and the work would never be queued again The root cause is that the PENDING_BIT of the work_struct would be set temporaily in __cancel_work and this bit could prevent the work_struct to be queued in another CPU. Use deferred_probe_mutex to protect the cancel and queue operations for the deferred_probe_timeout_work to fix this problem. Fixes: 2b28a1a84a0e ("driver core: Extend deferred probe timeout on driver = registration") Signed-off-by: Wang Wensheng --- drivers/base/dd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 13ab98e033ea..1983919917e0 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -323,6 +323,7 @@ static DECLARE_DELAYED_WORK(deferred_probe_timeout_work= , deferred_probe_timeout_ =20 void deferred_probe_extend_timeout(void) { + mutex_lock(&deferred_probe_mutex); /* * If the work hasn't been queued yet or if the work expired, don't * start a new one. @@ -333,6 +334,7 @@ void deferred_probe_extend_timeout(void) pr_debug("Extended deferred probe timeout by %d secs\n", driver_deferred_probe_timeout); } + mutex_unlock(&deferred_probe_mutex); } =20 /** --=20 2.22.0 From nobody Sat Oct 4 15:52:54 2025 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D9B42BCF6C for ; Thu, 14 Aug 2025 11:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755170717; cv=none; b=r0FVqgTmpW7OXxlvIjbl2lRWPq+hVoJI/8ZMxtAdtXy9lO208YIpkz/CylOvx56JHxaw18q2IiG9nz2Aq0bvShwLZaRAhTwb73mYak3en1Izlu5o0sNGxPLN1iKVpxzdaihjLkUfVY20Hbz8Czxu8BQhRVaJi02NNqPwDWPuvh4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755170717; c=relaxed/simple; bh=Dym3AigYZnVrcbC3pWJy5w5ItCrJMvVKhC8G0fiaXCM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=I+z3vRaSOAAH0IUh5x2Zp06SegP9x9x32/E3cGIu0wwjIwut2sfS4Nlpkyl+LeYY7JBTtP4k5P3Y1E/Gwpb3LyAxLt1CUK0YxSvrHVX67SucsBFSePlekKah1TpfQznW9j2DkwKCi7LjIUZ5aA/IUdyrH9MtEQ5W2gRZ4/ixLoU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4c2jWq0R16z2TT8X; Thu, 14 Aug 2025 19:22:31 +0800 (CST) Received: from dggemv706-chm.china.huawei.com (unknown [10.3.19.33]) by mail.maildlp.com (Postfix) with ESMTPS id 9856E1800B2; Thu, 14 Aug 2025 19:25:12 +0800 (CST) Received: from kwepemq200012.china.huawei.com (7.202.194.183) by dggemv706-chm.china.huawei.com (10.3.19.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 14 Aug 2025 19:25:12 +0800 Received: from huawei.com (10.175.112.208) by kwepemq200012.china.huawei.com (7.202.194.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 14 Aug 2025 19:25:11 +0800 From: Wang Wensheng To: , , , , , , , CC: , Subject: [PATCH 2/3] driver core: Introduce fw_devlink_relax_consumers helper Date: Thu, 14 Aug 2025 19:10:22 +0800 Message-ID: <20250814111023.2693-3-wangwensheng4@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20250814111023.2693-1-wangwensheng4@huawei.com> References: <20250814111023.2693-1-wangwensheng4@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemq200012.china.huawei.com (7.202.194.183) Content-Type: text/plain; charset="utf-8" Some devices are added during its parent's probe and will never get bound to a driver. In this case, with fw_devlink set to "rpm", which is the default value, its consumers will be deferred probe until deferred_probe_timeout when fw_devlink_drivers_done() would relax the devlinks to the suplier. Use this function to relax the consumer devlinks, just like what we do for the unmatched devices in fw_devlink_drivers_done(), so that the consumer devices would be probed not that later. Signed-off-by: Wang Wensheng --- drivers/base/core.c | 22 ++++++++++++++++++++++ include/linux/device.h | 1 + 2 files changed, 23 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index d22d6b23e758..2f7101ad9d11 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1754,6 +1754,28 @@ static void fw_devlink_relax_link(struct device_link= *link) dev_name(link->supplier)); } =20 +/** + * fw_devlink_relax_consumers - Relax the devlinks with all its consumers + * @dev: Device whose consumer devlinks will be relaxed + * + * Some devices are added during its parent's probe and will never get bou= nd + * to a driver. In this case its consumers will be deferred probe until + * deferred_probe_timeout. + * + * Use this function to relax the consumer devlinks so that the consumers + * device would be probed not that later. + */ +void fw_devlink_relax_consumers(struct device *dev) +{ + struct device_link *link; + + device_links_write_lock(); + list_for_each_entry(link, &dev->links.consumers, s_node) + fw_devlink_relax_link(link); + device_links_write_unlock(); +} +EXPORT_SYMBOL_GPL(fw_devlink_relax_consumers); + static int fw_devlink_no_driver(struct device *dev, void *data) { struct device_link *link =3D to_devlink(dev); diff --git a/include/linux/device.h b/include/linux/device.h index 0470d19da7f2..a451c0eb2ffa 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1201,6 +1201,7 @@ void device_link_remove(void *consumer, struct device= *supplier); void device_links_supplier_sync_state_pause(void); void device_links_supplier_sync_state_resume(void); void device_link_wait_removal(void); +void fw_devlink_relax_consumers(struct device *dev); =20 static inline bool device_link_test(const struct device_link *link, u32 fl= ags) { --=20 2.22.0 From nobody Sat Oct 4 15:52:54 2025 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEF192EAB6A for ; Thu, 14 Aug 2025 11:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755170717; cv=none; b=Ow5736BWbyf2EovIuBgg36RpBm1ftNdYAwgTGN8w+PNq8yGAZyueU2tgdtMSLzcn7DMFS6rsIg5Felpw9hkS5l+n60D+dKatT/86c9wAOLceMKJqu48byLhElECALyN6jmW6eI+StECpx9JoG3kqbrE0CTh0s2UGiuceIDRxhKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755170717; c=relaxed/simple; bh=t78vSFuZXseEJ8um9x1LZbLR/KNoX6EoIVymTqIzf2c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jcqtJFZrl2+D2n+dLI8FvJQ+zfZ2GYzb+0qVYZpTPCjSyfDNsTrxEZyO2RldOqgFypfAkUkiwTjCt0VWrL170Bo16NyW7s3wGVxCxerOPgVzFG34A7nQ/ylgBaM9VsMotetRFyDj9qlEr9YFGPpfMLT490y9+O7gzvbJ2XuHshc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4c2jc93c8mz2dMJh; Thu, 14 Aug 2025 19:26:17 +0800 (CST) Received: from dggemv712-chm.china.huawei.com (unknown [10.1.198.32]) by mail.maildlp.com (Postfix) with ESMTPS id 412681A016C; Thu, 14 Aug 2025 19:25:13 +0800 (CST) Received: from kwepemq200012.china.huawei.com (7.202.194.183) by dggemv712-chm.china.huawei.com (10.1.198.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 14 Aug 2025 19:25:13 +0800 Received: from huawei.com (10.175.112.208) by kwepemq200012.china.huawei.com (7.202.194.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 14 Aug 2025 19:25:12 +0800 From: Wang Wensheng To: , , , , , , , CC: , Subject: [PATCH 3/3] irqchip/mbigen: Use fw_devlink_relax_consumers() helper Date: Thu, 14 Aug 2025 19:10:23 +0800 Message-ID: <20250814111023.2693-4-wangwensheng4@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20250814111023.2693-1-wangwensheng4@huawei.com> References: <20250814111023.2693-1-wangwensheng4@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemq200012.china.huawei.com (7.202.194.183) Content-Type: text/plain; charset="utf-8" Use this to prevernt the consumer devices of mbigen to be probed too later. Signed-off-by: Wang Wensheng --- drivers/irqchip/irq-mbigen.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c index 6f69f4e5dbac..4e96eb9b6a6a 100644 --- a/drivers/irqchip/irq-mbigen.c +++ b/drivers/irqchip/irq-mbigen.c @@ -252,6 +252,8 @@ static int mbigen_of_create_domain(struct platform_devi= ce *pdev, =20 if (!mbigen_create_device_domain(&child->dev, num_pins, mgn_chip)) return -ENOMEM; + + fw_devlink_relax_consumers(&child->dev); } =20 return 0; --=20 2.22.0