🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24090

Re: [PATCH v2] net: phy: defer PHY probe when running in async probe context

#24090
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 08:40
176 lines
14177 bytes
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=<name> 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
Technical Details
Message-ID: <179594160178.3146.13454099280646190968@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373418-linux-kernel-netdev=dewy.ru
References: <20261125080939.176096-1-18255117159@163.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373418-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v2] net: phy: defer PHY probe when running in async probe context
Date: Sun, 29 Nov 2026 08:40:01 +0000
Organization: Usenet Network
Message-ID: <179594160178.3146.13454099280646190968@kernel.org>
References: <20261125080939.176096-1-18255117159@163.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1134458"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IMY+4+ZajoDFOvA7Ux1xW2t/1fo= sha256:ZsY7pDIKaDAiFFjQO2oSugNIYfkN3skCErZeRShBxqE=
	sha1:QeEylFzrWzmS4QcfEbcziIzxHDU= sha256:Ydp/sBata/A+WgB3n4wuPTHyo+mBhUw4NFNgg6r+D6E=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 72715125F96; Sun, 29 Nov 2026 11:40:24 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id rgLh0JudkZyY;
	Sun, 29 Nov 2026 11:40:20 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373418-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 98346125F94; Sun, 29 Nov 2026 11:40:09 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id F051B25A2F; Sun, 29 Nov 2026 08:40:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795941603;
	b=r3De+FDp2zuUhQu/PEMrba4kK43B6RX9UnM7Y9ILSk0O4AluNR7Cuoen8JOTrVKT36qk
	 ycHLqoqStiZn1ECnPKK9nw3gEim/abV43x9BRlc8rD7yG9VynhzZanKlvsQ/yQAIYrG2R
	 BwOcK3u5pd/iH1wCDJTBBS0NxtHrdjBXtBLTjdURX+tsCqrA3Zu9MI56Vhf1SgQBlqgYw
	 k7P6wCAUiVHFzZgSZhJucyaJEVpFHGOUMzt5vwIsdnWy4Y7YUVFD3bWDYYt6tSNhc9VM+
	 akpHqTnz2JuTtLeb8H/jh/ZNVyudPf2KumHmF0bXsmtSyEWGLlKBw/5ew4gAoMwExAQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795941603;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=27dnuC8D4LTcE8GOnYCJZwINu1/IRl7LoHmEYeBOLYo=;
	b=EuVQ0pYf9t+X6/t16+tV5Pp1zrJ7DCKZONqvREPhhq5Epn9LUOSjDcHoHEW8nbK3PONr
	 zEQO0HnciM4LEJLMC25pt1ZaAUWxmy4++zLikIQjWNp5/p5nS7gCi8bfvx1Q+XXdlVtpH
	 l3x8xfpQLwgwRvBve59eGf5sZOUCYPsobcFslPv11zmmz5MQ3VVsiE5ylvEf70IaBW9In
	 KFJBwBmBCXW/j0NmUkMeWCaImm7Sa/SSaw7NKPJt/ClaRHOLpIqONFLOaS+mYTN+IpSGx
	 7LqaUH6Mr8P0SITcSH09UEhp3FTzLGsGx6RMxQCP/nNCRIjcFhlWg+ZLrcTxkH4A1NQ==
X-ARC-Authentication-Results: i=2; 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=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D1ED5606A330;
	Sun, 29 Nov 2026 08:40:03 +0000 (UTC)
X-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
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-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==
X-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==
X-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
X-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 <netdev@vger.kernel.org>; Sun, 29 Nov 2026 08:40:02 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 460221F000C1;
	Sun, 29 Nov 2026 08:40:02 +0000 (UTC)
X-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==
X-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
X-In-Reply-To: <20261125080939.176096-1-18255117159@163.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list