From: Oleksij Rempel <o.rempel@pengutronix.de>
To: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: sashiko-bot@kernel.org,
Thangaraj Samynathan <Thangaraj.S@microchip.com>,
UNGLinuxDriver@microchip.com, netdev@vger.kernel.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Andrew Lunn <andrew+netdev@lunn.ch>,
Russell King <linux@armlinux.org.uk>,
stable@vger.kernel.org, Bin Yu <byu@xidian.edu.cn>,
Cheng Wen <wencheng@xidian.edu.cn>
Subject: Re: [PATCH net] net: usb: lan78xx: only stop phylink if the interface is running
Date: Mon, 2 Nov 2026 11:05:37 +0100 [thread overview]
Message-ID: <auhgcS6p-HDFYd7x@pengutronix.de> (raw)
In-Reply-To: <179346555447.2831.9240931140716315096@stu.xidian.edu.cn>
Hi,
Thank you for your patch, i'm testing it right now on my HW.
On Sun, Nov 01, 2026 at 12:52:34AM +0800, YuanZhe Liu wrote:
> On Fri, Oct 30, 2026 at 04:02:36PM +0000, sashiko-bot@kernel.org wrote:
> > Does calling phylink_stop() and phylink_disconnect_phy() before
> > unregister_netdev(net) in drivers/net/usb/lan78xx.c:lan78xx_disconnect()
> > cause out-of-order teardown, a duplicate phylink_stop() call, and a race
> > window when rtnl_lock() is dropped?
>
> Yes, the ordering is wrong. v2 drops the explicit phylink_stop() from the
> disconnect path and unregisters the net device first:
>
> unregister_netdev(net);
>
> rtnl_lock();
> phylink_disconnect_phy(dev->phylink);
> rtnl_unlock();
>
> unregister_netdev() closes a running device, so phylink_stop() is done by
> lan78xx_stop() with dev->dev_mutex held and after the TX/RX URBs have been
> terminated, which is the same sequence as a normal ifdown. When the
> interface was never started no phylink_stop() happens at all, and that is
> exactly the case phy_stop() complains about with "called from state READY".
>
> This also removes the second phylink_stop() invocation and the window in
> which the net device was still registered with no PHY attached.
>
> On the remaining points:
>
> - The duplicate phylink_stop() was harmless in practice, because after
> phylink_disconnect_phy() pl->phydev is NULL and PHYLINK_DISABLE_STOPPED
> is already set. It is gone now anyway.
>
> - The PHY interrupt is not released by phylink_disconnect_phy(). The virq
> created by irq_create_mapping() is disposed in lan78xx_remove_irq_domain(),
> called from lan78xx_unbind(), which also clears dev->domain_data.phyirq;
> lan78xx_status() tests that field before generic_handle_irq_safe(). The
> intr URB is killed later in lan78xx_disconnect(), and that ordering is
> unchanged by this patch.
If I see it correctly, in the practices it is a dead code, please see:
30a41ed32d30 ("net: phy: microchip: force IRQ polling mode for lan88xx")
> - Andrew also asked why the Fixes tag points at e110bc825897: that commit
> added both the phylink instance and the unconditional phylink_stop() call
> in lan78xx_disconnect(), and
>
> git log -S'phylink_stop(dev->phylink)' -- drivers/net/usb/lan78xx.c
>
> shows that the line has not been touched since.
Re-testing it right now.
Do you have access to a real hw or you testing it on QEMU?
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2026-11-02 10:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 16:02 YuanZhe Liu
2026-10-30 17:38 ` YuanZhe Liu
2026-10-30 19:23 ` Andrew Lunn
2026-10-30 20:02 ` Andrew Lunn
[not found] ` <sashiko-outbox-191206@kernel.org>
2026-10-31 16:52 ` YuanZhe Liu
2026-11-02 10:05 ` Oleksij Rempel [this message]
2026-11-02 11:29 ` YuanZhe Liu
2026-11-02 15:40 ` Oleksij Rempel
2026-11-02 16:42 ` [PATCH net] net: usb: lan78xx: only stop phylink if the network device " Yuanzhe Liu
2026-11-02 16:20 ` [PATCH net] net: usb: lan78xx: only stop phylink if the interface " netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auhgcS6p-HDFYd7x@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=25031212351@stu.xidian.edu.cn \
--cc=Thangaraj.S@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew+netdev@lunn.ch \
--cc=byu@xidian.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=stable@vger.kernel.org \
--cc=wencheng@xidian.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®