From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795941603; b=ljpW/Yj3d8ELLODyVVuI5gJEpo/CTof19UpvD8G92cLsT5JslqKfi03D0LuFnB7NuLft aaaBDlVrofYMYPzFWdLfBp+PXbQtk2OBPP0Z2Q8qAYw8np/G9zSTcTKqaNOduaKc4ctdW 4eEkEShCbHyYKy+8ol/rXyD4OMfReBQuK13ZoDL+/ZYksiDt/JhjZECUKGC9/rz7aiXAE Bl/LgvRosNciXmeCP9CmT4kGKMcjonLUIg86S2cQT6e2CPWQlpmbYSiMq7tiJb229xPEX vDkwocnU5ZOyBj6VpnjajYFVIVytWZqWg03kJMTPiyIg49WPJlCU7xTcGFssc7Syg6w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795941603; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=27dnuC8D4LTcE8GOnYCJZwINu1/IRl7LoHmEYeBOLYo=; b=cxMd4s8mBQvAj+Sc0aCugTTfocGtxVKJl6Zt7q6SCcsdLbLLF3P9GZOTYKIAfi9e20CQ oJYnn82b83tcCiuxztWOMs3pPwBU+8C0j1k2/VE7oBoBEr1guFMwLvjG9Jz5kuIoCv2iB wlnJ8wYHZ4WSb6hJZI6DaNzc6cDLSbIBc3/zOHYxMfM/v5+8XPRk1klrwYsSM7UhVivSS tzk4Eiv69Cbey79jRB0oo36DRZy03l0vQq3aPUvoax6bI8MwTfAbIE4STJMlFvf/GvuQ+ 3AbF59KPxDn9FSB0r8wlS7kBu0glKd+bfmJcIPpPr4hHfqvzodU9YyPclZ6JM4K52fQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZuPvEWwp; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED315606A325 for ; Sun, 29 Nov 2026 08:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZuPvEWwp Received: by smtp.kernel.org (Postfix) with ESMTPSA id 460221F000C1; Sun, 29 Nov 2026 08:40:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795941602; bh=27dnuC8D4LTcE8GOnYCJZwINu1/IRl7LoHmEYeBOLYo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=ZuPvEWwp8ha2qO2m47ivB2nEWDwgkzkCK7BMp4UF88fxaD3nEfqFAyvuZex0E4o+u Rn/SdaWNVQA6R9iom4f09zrZkOfADvTK9z3ejwgay3Z+dHe/5j6kgB9nWSUCz4ArOc pTo60embYGd8ek9vCcQHmpnGinNt7DnJyvkt0p+k5r7P1N3jiBnB9UG5INgDrN6A4q J9wyW9QI4eIrZNFyWC0YDmoo/RE07G6vGGaHXumewR7++YK5CXQMUyVJfU9rLWpglT 9Y+8Nod5bqGQSbXaPxolgsKSd9RGbOpvCPvoNtB9Ys05/0xI7IBKIFWI7Vs1U+gTMx HuJVf6I3+uhZA== Subject: Re: [PATCH v2] net: phy: defer PHY probe when running in async probe context From: netdev-bot+sashiko@kernel.org To: 18255117159@163.com Cc: andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, netdev@vger.kernel.org, 503536682@qq.com Date: Sun, 29 Nov 2026 08:40:01 +0000 Message-ID: <179594160178.3146.13454099280646190968@kernel.org> In-Reply-To: <20261125080939.176096-1-18255117159@163.com> References: <20261125080939.176096-1-18255117159@163.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 2 · Medium: 1 · Low: 1 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The commit message assumes the deferred retry runs synchronously from the deferred probe workqueue. - [High] get_phy_device(), and through it phy_device_create(), can now return -EPROBE_DEFER. - [Medium] The current_is_async() check in phy_request_driver_module() (phy_device.c:643-644) runs before, and regardless of, the… - [Low] The block comment in phy_device_create() (phy_device.c:720-729) still says "Request the appropriate module unconditionally". -- net: phy: defer PHY probe when running in async probe context This commit makes phy_request_driver_module() return -EPROBE_DEFER when it is called from an async worker, instead of calling request_module() synchronously. The idea is that the parent device probe is retried later from the deferred probe workqueue, where request_module() can run synchronously. > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > index b39e945cebd73..9f88da87df971 100644 > --- a/drivers/net/phy/phy_device.c > +++ b/drivers/net/phy/phy_device.c [ ... ] > @@ -639,6 +640,9 @@ static int phy_request_driver_module(struct phy_device *dev, u32 phy_id) > { > int ret; > > + if (current_is_async()) > + return -EPROBE_DEFER; > + [Severity: High] The commit message says the retry happens "from the deferred probe workqueue, where request_module() can run synchronously". Does that hold when the driver that registers the MDIO bus is itself allowed to probe asynchronously? The deferred retry path is: deferred_probe_work_func() bus_probe_device_deferred() __bus_probe_device() device_initial_probe() __device_attach(dev, true) In the synchronous pass, __device_attach_driver() skips drivers that allow async probing: drivers/base/dd.c:__device_attach_driver() { ... if (async_allowed) data->have_async = true; if (data->check_async && async_allowed != data->want_async) return 0; ... } __device_attach() then queues the probe through async_schedule_dev_nocall(__device_attach_async_helper, dev). The retry runs inside async_run_entry_fn again, so current_is_async() is true again and -EPROBE_DEFER comes back again. driver_allows_async_probing() returns true in several cases: PROBE_PREFER_ASYNCHRONOUS driver_async_probe= or driver_async_probe=* on the command line the per-module async_probe parameter, or module.async_probe=1 In any of these setups, could a driver like r8169 stay deferred forever and never bind? It scans PHYs through devm_mdiobus_register()->mdiobus_scan_bus_c22()->get_phy_device(). With module.async_probe=1, do_init_module() already skips the synchronization: kernel/module/main.c:do_init_module() { ... if (!mod->async_probe_requested) async_synchronize_full(); ... } So the old code could not deadlock in that configuration. Before this patch those systems got a WARN_ON_ONCE() and a working NIC. With this patch, wouldn't the NIC stay stuck in deferred probe for good? [Severity: High] With this change, get_phy_device() and phy_device_create() can return -EPROBE_DEFER. The get_phy_device() kernel-doc only lists -ENODEV and -EIO. Do all callers pass the new error up? fixed_phy_register() in drivers/net/phy/fixed_phy.c rewrites it: phy = get_phy_device(fmb_mii_bus, phy_addr, false); if (IS_ERR(phy)) { fixed_phy_del(phy_addr); return ERR_PTR(-EINVAL); } swphy_read_reg() returns 0 for MII_PHYSID1 and MII_PHYSID2. That makes phy_id 0, so phy_device_create() always reaches phy_request_driver_module(). In async context that now returns -EPROBE_DEFER, and fixed_phy_register() turns it into -EINVAL. Some MAC probes call of_phy_register_fixed_link() or fixed_phy_register() from an async worker, for example fec, gianfar, bcmgenet, ravb, cpsw, ftgmac100 and hibmcge. Wouldn't those now fail with -EINVAL and never be retried? Before this patch, __request_module() only did WARN_ON_ONCE(wait && current_is_async()), and the fixed PHY was still created. Other callers collapse the error in a similar way: xgbe_phy_find_phy_device() maps it to -ENODEV hns_mac_register_phydev() maps it to -EIO xgene_enet_phy_register() maps it to NULL It hasn't been checked whether these three can run in async context. > ret = request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT, > MDIO_ID_ARGS(phy_id)); > /* We only check for failures in executing the usermode binary, [Severity: Medium] Should the new check apply only when a module load can actually happen? With CONFIG_MODULES=n, include/linux/kmod.h has: static inline int request_module(const char *name, ...) { return -ENOSYS; } The existing IS_ENABLED(CONFIG_MODULES) && ret < 0 test then makes phy_request_driver_module() return 0. In that configuration nothing is loaded, there is no warning, and async_synchronize_full() can't deadlock. current_is_async() is always built in. So non-modular kernels now also defer every PHY creation in async context, and they hit the permanent deferral and fixed_phy -EINVAL cases above. The same is true when the PHY driver is built in or already loaded. The commit message only covers the modular case. [Severity: Low] This isn't a bug, but the block comment in phy_device_create() still says: /* Request the appropriate module unconditionally; don't * bother trying to do so only if it isn't already loaded, ... * enough for the driver to get loaded. With MDIO, the NIC * driver will get bored and give up as soon as it finds that * there's no driver _already_ loaded. */ After this change the module request is skipped in async context, and PHY creation returns -EPROBE_DEFER instead. Should the comment mention the async restriction and the reliance on deferred probing? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125080939.176096-1-18255117159%40163.com