[PATCH net-next v2 5/7] net: lan743x: handle a failed reopen on resume
From: Chris Babroski
Date: Tue Nov 24 2026 - 09:34:48 EST
lan743x_pm_resume() ignores the return value of lan743x_netdev_open().
If the reopen fails, its error path has already closed the channels and
freed the rings, but netif_device_attach() still wakes the TX queues. A
later ndo_stop then runs lan743x_netdev_close() a second time, and
napi_disable() on a NAPI that is already disabled never returns, with
rtnl held.
If the reopen fails, take the interface down with dev_close() before
attaching the device again, so it can be brought back up later. The
hardware is already closed at that point, so route ndo_stop through a
wrapper that skips the hardware close while the device is detached.
If lan743x_hardware_init() fails on resume, the device is left detached
with the hardware already closed by suspend. Skip the close in
lan743x_pcidev_shutdown() in that case as well, so a later suspend or
shutdown does not close it a second time. Also stop releasing the PCI
resources on that error path. They are taken in probe and released in
remove, which still runs later and would release them a second time.
While the device is detached, the core does not call ndo_set_rx_mode, so
address list changes made in that window, such as IPv6 multicast joins,
which do not take rtnl, never reach the RX filter. Program the filter
again after the device is attached.
Fixes: 4d94282afd95 ("lan743x: Add power management support")
Fixes: d6423d2ec39c ("net: ethernet: microchip: lan743x: Fix driver crash when lan743x_pm_resume fails")
Signed-off-by: Chris Babroski <cbabroski@xxxxxxxxxx>
---
drivers/net/ethernet/microchip/lan743x_main.c | 35 ++++++++++++++++---
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index b226078bf3a9..228b6ab539a1 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -3477,6 +3477,14 @@ static int lan743x_netdev_open(struct net_device *netdev)
return ret;
}
+static int lan743x_netdev_stop(struct net_device *netdev)
+{
+ if (!netif_device_present(netdev))
+ return 0;
+
+ return lan743x_netdev_close(netdev);
+}
+
static netdev_tx_t lan743x_netdev_xmit_frame(struct sk_buff *skb,
struct net_device *netdev)
{
@@ -3583,7 +3591,7 @@ static int lan743x_netdev_set_mac_address(struct net_device *netdev,
static const struct net_device_ops lan743x_netdev_ops = {
.ndo_open = lan743x_netdev_open,
- .ndo_stop = lan743x_netdev_close,
+ .ndo_stop = lan743x_netdev_stop,
.ndo_start_xmit = lan743x_netdev_xmit_frame,
.ndo_eth_ioctl = lan743x_netdev_ioctl,
.ndo_set_rx_mode = lan743x_netdev_set_multicast,
@@ -3885,15 +3893,20 @@ static void lan743x_pcidev_shutdown(struct pci_dev *pdev)
{
struct net_device *netdev = pci_get_drvdata(pdev);
struct lan743x_adapter *adapter = netdev_priv(netdev);
+ bool present;
rtnl_lock();
+ present = netif_device_present(netdev);
netif_device_detach(netdev);
/* close netdev when netdev is at running state.
* For instance, it is true when system goes to sleep by pm-suspend
* However, it is false when system goes to sleep by suspend GUI menu
+ *
+ * If the device is not present then netdev has already been closed.
+ * This can be true if a previous resume failed.
*/
- if (netif_running(netdev))
+ if (present && netif_running(netdev))
lan743x_netdev_close(netdev);
rtnl_unlock();
@@ -4076,7 +4089,6 @@ static int lan743x_pm_resume(struct device *dev)
if (ret) {
netif_err(adapter, probe, adapter->netdev,
"lan743x_hardware_init returned %d\n", ret);
- lan743x_pci_cleanup(adapter);
return ret;
}
@@ -4109,10 +4121,23 @@ static int lan743x_pm_resume(struct device *dev)
* For instance, it is true when system wakesup after pm-suspend
* However, it is false when system wakes up after suspend GUI menu
*/
- if (netif_running(netdev))
- lan743x_netdev_open(netdev);
+ if (netif_running(netdev)) {
+ ret = lan743x_netdev_open(netdev);
+ if (ret) {
+ netdev_err(netdev, "failed to reopen after resume: %d\n",
+ ret);
+ dev_close(netdev);
+ }
+ }
netif_device_attach(netdev);
+
+ /* ndo_set_rx_mode is skipped while the device is detached */
+ if (netif_running(netdev)) {
+ netif_addr_lock_bh(netdev);
+ lan743x_rfe_set_multicast(adapter);
+ netif_addr_unlock_bh(netdev);
+ }
rtnl_unlock();
return 0;
--
2.34.1