* [PATCH net] net: usb: lan78xx: resume phylink on non-reset USB resume
@ 2026-11-02 23:51 Stefano Munari
2026-11-03 7:37 ` Oleksij Rempel
0 siblings, 1 reply; 2+ messages in thread
From: Stefano Munari @ 2026-11-02 23:51 UTC (permalink / raw)
To: Thangaraj Samynathan
Cc: UNGLinuxDriver, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Russell King, Oleksij Rempel,
Russell King (Oracle), netdev, linux-usb, linux-kernel
lan78xx_suspend() calls phylink_suspend(dev->phylink, false) on an open
interface, which always stops phylink and halts the PHY. The matching
phylink_resume() is only called from lan78xx_reset_resume().
When the USB device stays powered across system sleep (e.g. s2idle) and
the USB core calls .resume instead, the link stays down until the interface
is brought down and up by hand. The ifdown triggers:
WARNING: drivers/net/phy/phy.c:1670 at phy_stop+0x44/0xc8
called from state HALTED
Move phylink_resume() to the end of lan78xx_resume(), which both resume
paths go through, and call it only if the resume succeeded and the
interface was open, mirroring lan78xx_suspend(). As a side effect,
lan78xx_reset_resume() no longer starts phylink on a closed interface.
Tested on a Raspberry Pi 3B+ (LAN7515) with s2idle: the link now comes
back up on its own after resume and ifdown no longer warns.
Fixes: e110bc825897 ("net: usb: lan78xx: Convert to PHYLINK for improved PHY and MAC management")
Signed-off-by: Stefano Munari <stefanomunari.sm@gmail.com>
---
ftrace on unpatched kernel (s2idle, woken from PL011 UART IRQ):
lan78xx_suspend <- usb_suspend_both
phylink_suspend <- lan78xx_suspend
phylink_stop <- phylink_suspend
phy_stop <- phylink_stop
lan78xx_resume <- usb_resume_interface
No lan78xx_reset_resume() or phylink_resume() on the resume path.
ftrace on patched kernel:
lan78xx_resume <- usb_resume_interface
phylink_resume <- lan78xx_resume
phylink_start <- lan78xx_resume
phy_start <- lan78xx_resume
phylink_start + phy_start report lan78xx_resume as parent
since both are tail calls. On tested kernel phylink_start is tail call
optimized since with CONFIG_SFP=n sfp_upstream_start() is an empty stub.
---
drivers/net/usb/lan78xx.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 181e8c087655..0136818e8cb0 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -5371,6 +5371,12 @@ static int lan78xx_resume(struct usb_interface *intf)
out:
mutex_unlock(&dev->dev_mutex);
+ if (!ret && dev_open) {
+ rtnl_lock();
+ phylink_resume(dev->phylink);
+ rtnl_unlock();
+ }
+
return ret;
}
@@ -5385,15 +5391,7 @@ static int lan78xx_reset_resume(struct usb_interface *intf)
if (ret < 0)
return ret;
- ret = lan78xx_resume(intf);
- if (ret < 0)
- return ret;
-
- rtnl_lock();
- phylink_resume(dev->phylink);
- rtnl_unlock();
-
- return 0;
+ return lan78xx_resume(intf);
}
static const struct usb_device_id products[] = {
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] net: usb: lan78xx: resume phylink on non-reset USB resume
2026-11-02 23:51 [PATCH net] net: usb: lan78xx: resume phylink on non-reset USB resume Stefano Munari
@ 2026-11-03 7:37 ` Oleksij Rempel
0 siblings, 0 replies; 2+ messages in thread
From: Oleksij Rempel @ 2026-11-03 7:37 UTC (permalink / raw)
To: Stefano Munari
Cc: Thangaraj Samynathan, UNGLinuxDriver, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Russell King, Russell King (Oracle), netdev, linux-usb,
linux-kernel
Hi Stefano,
On Tue, Nov 03, 2026 at 12:51:33AM +0100, Stefano Munari wrote:
> lan78xx_suspend() calls phylink_suspend(dev->phylink, false) on an open
> interface, which always stops phylink and halts the PHY. The matching
> phylink_resume() is only called from lan78xx_reset_resume().
> When the USB device stays powered across system sleep (e.g. s2idle) and
> the USB core calls .resume instead, the link stays down until the interface
> is brought down and up by hand. The ifdown triggers:
>
> WARNING: drivers/net/phy/phy.c:1670 at phy_stop+0x44/0xc8
> called from state HALTED
>
> Move phylink_resume() to the end of lan78xx_resume(), which both resume
> paths go through, and call it only if the resume succeeded and the
> interface was open, mirroring lan78xx_suspend(). As a side effect,
> lan78xx_reset_resume() no longer starts phylink on a closed interface.
>
> Tested on a Raspberry Pi 3B+ (LAN7515) with s2idle: the link now comes
> back up on its own after resume and ifdown no longer warns.
>
> Fixes: e110bc825897 ("net: usb: lan78xx: Convert to PHYLINK for improved PHY and MAC management")
> Signed-off-by: Stefano Munari <stefanomunari.sm@gmail.com>
Partially tested on net-next (4dd16e31135e) with a LAN7850 on an
i.MX8MP. The USB host is reinitialized across s2idle here, so only
.reset_resume is used. With the interface closed, s2idle resume no
longer shows "multicast write failed -EACCES" and the WARNING at
phy.c:1352 in _phy_state_machine() (4/4 without, 0/4 with this patch).
An open interface still comes back after resume. The plain .resume
path, which is the main case of this patch, is not tested.
Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>
Thank you!
Best Regards,
Oleksij
--
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 |
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-03 7:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 23:51 [PATCH net] net: usb: lan78xx: resume phylink on non-reset USB resume Stefano Munari
2026-11-03 7:37 ` Oleksij Rempel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox