From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.3 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796288765; b=ZyVXIRjUZvAwAGl7ry1qvCBBpo98ZBWSu7ls7fv5LdsPFlNyDCmAuOVx4RI1NemXoIhh T5BNljpSy9SwrvzAv5V02KQYbgKY70gDMlQIsIcZ/z/l9J4lbMUp6Mjz0Zu/WxFmlKzl/ FCmY67F3JCK08g+khj9PLHDyzclykZLLF2RQ9zGjmCBzJmeMf0eNI4lIfRO8f9mTOpJwx XkuDZZq+mhaxv2RQRqcq+n453Brtsod2JUI+6XVVb0gDfJbWM5t94iB0G1Svn7pdWar6S ORwwhikuRSZrbac1M4Us8B00MORaWaRRkdwELCl/OLyi+J87goxEP7o5AA/o2pnL2eA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796288765; h=DMARC-Filter:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:From:To:Cc:References:Content-Language:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=4J7UbEgcv1b5ATFmkTUeVFKn8+6HcaYhiXGfL+npoyg=; b=ZZFbmwrjOPZbsx9kgA261E0CCOmq4Ay9zPRHbvIp8684Q/XgGMyP+GOGe+WX3SXjvy80 f10S+jyXoJ9CfHUEWW8/wmgAH3LRQGb77jmmOQXq2lF6/rjFuRBB7yLiXriGOtPRNoiEM y0IoCDHH6ydfoqnmkxGGKQv0CZMvUjKBI7OuU/RVnX9v1DcyIczGDb02UJhV6Qde0zKPV SdQeUIf03iKe0Hn0DmwCdZf7nV393R7yxIJACEd09nDYN6cV4372OEwTcB9wIEA2NIcbe fe3TXNvg1JGWFjFFyT5H5NhzDn3qZTUfSQpgcrWoRD8dusjxuHUy5WT+Ff14i8G008A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=Rq2nS5E8; arc=none smtp.remote-ip=117.135.210.3 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C670B606A32C for ; Thu, 3 Dec 2026 09:06:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C670B606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=Rq2nS5E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:From:To: Content-Type; bh=4J7UbEgcv1b5ATFmkTUeVFKn8+6HcaYhiXGfL+npoyg=; b=Rq2nS5E82ZflrRsDHRdeOQpbXr5Yiyp6ts+7Tf9PPUAZ1kQEusjI8DetjMbJL5 WJCRWrx35xYXZlQmmqMjf32SaIbruVVjjnYk8JyXsbnuzN/YAowKf2dmtYcEoV/a jMzVpqgE2AbhIewuEPxEDzdKwheh+qBflMODCe/K381Ds= Message-ID: Date: Thu, 3 Dec 2026 17:05:11 +0800 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/4] prepare MDIO callers for -EPROBE_DEFER from __mdiobus_register() From: Hans Zhang <18255117159@163.com> To: Andrew Lunn Cc: hkallweit1@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, netdev@vger.kernel.org, netdev-bot+sashiko@kernel.org References: <20261130023745.820141-1-18255117159@163.com> <8e19948b-2376-4913-82cc-281bd924c668@163.com> <8541a0f4-8f25-47ab-89ec-4e37a48358e8@lunn.ch> <0ac68808-10b0-49fd-8057-2f9b0ce35319@163.com> Content-Language: en-US In-Reply-To: <0ac68808-10b0-49fd-8057-2f9b0ce35319@163.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:PygvCgCX6G_HMBFr4ciwJg--.52471S2 X-Coremail-Antispam: 1Uf129KBjvJXoW3JF4UJw4xKFW5Gr4rWrW8Xrb_yoW7GFW5pF Z5JFyYkr4DKrWIvFs7uF47Aa40yw4fZr45Grn5W343uas0kr1xZrWxJr47uFykurs3C3W2 qr4jqayrCFWUAaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zR5xhJUUUUU= X-CM-SenderInfo: rpryjkyvrrlimvzbiqqrwthudrp/xtbC6wldAWsRMMlyVAAA3b On 12/2/26 23:09, Hans Zhang wrote: > > > On 12/1/26 21:40, Andrew Lunn wrote: >> On Tue, Dec 01, 2026 at 12:19:54PM +0800, Hans Zhang wrote: >>> Hi sashiko, >>> >>> >>> Thank you for the review. The High issues are valid. >>> >>> v2 will: >>> - drop the smsc9420 change, since its mdiobus_register() call is in >>>    ndo_open rather than a probe path, and the v1 version could return >>>    success after a PHY probe failure; >> >> You need to be careful here. What context is open called in? Can you >> return EPROBE_DEFER here? Generally no. >> >> What makes this interesting is things like NFS root. You pass on the >> kernel command line all the parameters needed to connect to the NFS >> server. Deep within netdev_register(), generally called from probe, it >> can open the device, and start sending packets in order to connect to >> the NFS server. So the device is alive and running before >> netdev_register() even returns. >> >> If probe was called in async mode, can open be called in async mode, >> resulting in an EPROBE_DEFER from mdiobus_register? What happens then? >> Does it all correctly unwind and the probe is tried again later in >> sync mode? >> > > > Hello Andrew, > > You're right to push on the open path. I traced it: smsc9420 registers > its MDIO bus from smsc9420_open() via smsc9420_mii_init(), and open() > folds any error into -ENODEV. __dev_open() just does ret = ops- > >ndo_open(dev); return ret; with no deferred-probe handling, and NFS > root reaches ndo_open via ip_auto_config() -> dev_change_flags(IFF_UP) - > > dev_open(). So returning -EPROBE_DEFER from open is wrong, and > current_is_async() cannot distinguish probe from open in a leaf like > mdiobus_register(). > > That confirms the defer-from-async approach in phylib does not hold. > Combined with Sashiko's other findings (the deferred retry can be re- > queued async and defer forever, and get_phy_device() callers fold - > EPROBE_DEFER into -EINVAL / -ENODEV / -EIO), I'll drop the phylib core > change. > > For now I've sent v2 as a standalone cleanup: propagate the real > mdiobus_register() errors, and convert the callers in a real probe > context to dev_err_probe() so the existing reset-GPIO -EPROBE_DEFER path > no longer prints a misleading message. Jijie Shao pointed out one hns3 > hclge_mdio.c spot that should be return dev_err_probe(...) instead of > the braces; I'll fold that into v3. > > Since v2 only folds in Sashiko's review comments, I'll hold off on the > next version until I've heard back from you and the other reviewers, > rather than respinning quickly. > > For the original deadlock, I found this exact problem was discussed in > the dw-rockchip async-probe thread [1], where Robin Murphy proposed > fixing it in the driver core: in __device_attach_driver(), defer a child > device whose driver wants a synchronous probe while the parent probes > asynchronously: > > > if (!async_allowed && current_is_async()) { >     driver_deferred_probe_add(dev); >     return 0; > } > > That "fix the context" approach avoids the open-vs-probe and permanent- > deferral problems, since it never lets a sync-request_module caller run > in async context. I'm testing Robin's patch on my Sky1 board now and > will report back with the results. Does that look like the right > direction to pursue with the driver-core maintainers? > > [1] https://lore.kernel.org/driver-core/55c28218-1638-4b90-a9cd- > a177fb5abcb6@arm.com/ > Hello Andrew, Follow-up on the direction question from my last mail: I've now tested Robin Murphy's driver-core patch from the dw-rockchip thread [1] on the Sky1 board — two RTL8126A NICs behind a PCIe controller that sets PROBE_PREFER_ASYNCHRONOUS, i.e. the exact async + request_module() case. Robin's patch as posted doesn't actually work: the child device is silently dropped — never probed and never queued. driver_deferred_probe_add() returns early when dev_can_match() is false, and in this path that flag is only set later in __driver_probe_device(), which the early return in __device_attach_driver() never reaches. So the device ends up neither bound nor on the deferred list. Setting the flag first fixes it: if (!async_allowed && current_is_async()) { dev_set_can_match(dev); driver_deferred_probe_add(dev); return 0; } With that one line, on Sky1 both RTL8126A NICs bind (eth0/eth1 up, link running), the __request_module() WARN_ON_ONCE() is gone, and boot time is unchanged (the NICs probe slightly faster than the splatting baseline). So the driver-core defer is the right fix: it makes the driver core honor a synchronous child even when the parent probes asynchronously, rather than teaching phylib to detect async. I'll take the results and the one-line dev_set_can_match() delta back to the dw-rockchip thread, and see whether Robin wants to post it himself or would like me to — happy to add my Tested-by either way. [1] https://lore.kernel.org/driver-core/55c28218-1638-4b90-a9cd-a177fb5abcb6@arm.com/ Best regards, Hans