From: Chris Babroski <cbabroski@nvidia.com>
To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <bryan.whitehead@microchip.com>, <UNGLinuxDriver@microchip.com>,
<andrew+netdev@lunn.ch>, <davem@davemloft.net>,
<edumazet@kernel.org>, <kuba@kernel.org>, <pabeni@redhat.com>,
<richardcochran@gmail.com>, <linux@armlinux.org.uk>,
<Raju.Lakkaraju@microchip.com>, <maxime.chevallier@bootlin.com>,
<yuiko.oshino@microchip.com>, <cbabroski@nvidia.com>,
<nb@tipi-net.de>, <woojung.huh@microchip.com>
Subject: [PATCH net-next v2 5/7] net: lan743x: handle a failed reopen on resume
Date: Tue, 24 Nov 2026 09:33:20 -0500 [thread overview]
Message-ID: <614c536edbd2cf29e8a53076612404d1091d18c5.1795027003.git.cbabroski@nvidia.com> (raw)
In-Reply-To: <cover.1795027003.git.cbabroski@nvidia.com>
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@nvidia.com>
---
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
next prev parent reply other threads:[~2026-11-24 14:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 14:33 [PATCH net-next v2 0/7] net: lan743x: automatically recover from TX hang Chris Babroski
2026-11-24 14:33 ` [PATCH net-next v2 1/7] net: lan743x: check DMA channel stop and reset results Chris Babroski
2026-11-24 14:33 ` [PATCH net-next v2 2/7] net: lan743x: quiesce TX before freeing the rings Chris Babroski
2026-11-24 14:33 ` [PATCH net-next v2 3/7] net: lan743x: start phylink last and stop it first Chris Babroski
2026-11-24 14:33 ` [PATCH net-next v2 4/7] net: lan743x: keep the fixed link across reopen Chris Babroski
2026-11-24 14:33 ` Chris Babroski [this message]
2026-11-24 14:33 ` [PATCH net-next v2 6/7] net: lan743x: reset the device on TX timeout Chris Babroski
2026-11-24 14:33 ` [PATCH net-next v2 7/7] net: lan743x: add byte queue limits support Chris Babroski
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=614c536edbd2cf29e8a53076612404d1091d18c5.1795027003.git.cbabroski@nvidia.com \
--to=cbabroski@nvidia.com \
--cc=Raju.Lakkaraju@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew+netdev@lunn.ch \
--cc=bryan.whitehead@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=nb@tipi-net.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=woojung.huh@microchip.com \
--cc=yuiko.oshino@microchip.com \
/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®