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 6/7] net: lan743x: reset the device on TX timeout
Date: Tue, 24 Nov 2026 09:33:21 -0500 [thread overview]
Message-ID: <a6d08d5760ecabea5c77d6001a8281c820873512.1795027003.git.cbabroski@nvidia.com> (raw)
In-Reply-To: <cover.1795027003.git.cbabroski@nvidia.com>
The driver does not implement ndo_tx_timeout, so the core TX watchdog is
never started. If a TX DMA channel stops completing descriptors, its
queue stays stopped and the interface cannot transmit again until it is
brought down and back up.
Add an ndo_tx_timeout handler that schedules a work item to reset the
device. Under rtnl_lock(), the work detaches the netdev, closes it,
soft-resets the DMA controller, opens it again and reattaches it. This
is the sequence suspend and resume already use, with the DMA controller
reset taking the place of the full hardware init.
Because everything is reopened, the RX path, PTP and the PHY link are
restarted along with TX. For PTP, the reset has the same effect as
bringing the interface down and up. As on suspend and resume, the PTP
clock is unregistered and registered again, and its time is reset to the
system time. Applications that have the old clock open get -ENODEV
from it, and the new clock can come up as a different /dev/ptpN, so PTP
applications such as ptp4l have to be restarted. The hardware
timestamping state is also reset, so the RX filter returns to none and
one-step sync insertion is disabled, while the driver keeps its TX
timestamping flags.
lan743x_dmac_init() did not check that the DMA controller soft reset
completed, so the work could reopen a controller whose reset timed out.
Return the error from the poll so the work can tell. Probe already fails
when lan743x_dmac_init() returns an error, so a controller that does not
come out of reset now also fails probe. On resume, it now leaves the
device detached.
If lan743x_dmac_init() fails, the interface is taken down with
dev_close() and the device is left detached, so it cannot be opened
again on a DMA controller that is still in reset. A later resume resets
the controller again and attaches the device. If the reopen fails, the
interface is taken down the same way, but the device is attached again
so it can be brought back up later. In both cases the device is still
detached when dev_close() runs, so lan743x_netdev_stop() skips the
hardware close, which has already been done.
As on resume, the RX filter is programmed again after the device is
attached, since ndo_set_rx_mode is not called while it is detached.
ndo_stop is called with rtnl held and cannot wait for the work, so it
only cancels a pending one. A work that is already waiting for rtnl
returns if the device is still down when it gets the lock. If the device
was opened again in the meantime, it is reset once more, which only
costs an extra link flap. On remove, the work is cancelled synchronously
after the netdev is unregistered.
Signed-off-by: Chris Babroski <cbabroski@nvidia.com>
---
drivers/net/ethernet/microchip/lan743x_main.c | 68 ++++++++++++++++++-
drivers/net/ethernet/microchip/lan743x_main.h | 2 +
2 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index 228b6ab539a1..3f129a22921e 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -1516,10 +1516,14 @@ static void lan743x_rfe_set_multicast(struct lan743x_adapter *adapter)
static int lan743x_dmac_init(struct lan743x_adapter *adapter)
{
u32 data = 0;
+ int ret;
lan743x_csr_write(adapter, DMAC_CMD, DMAC_CMD_SWR_);
- lan743x_csr_wait_for_bit(adapter, DMAC_CMD, DMAC_CMD_SWR_,
- 0, 1000, 20000, 100);
+ ret = lan743x_csr_wait_for_bit(adapter, DMAC_CMD, DMAC_CMD_SWR_,
+ 0, 1000, 20000, 100);
+ if (ret)
+ return ret;
+
switch (DEFAULT_DMA_DESCRIPTOR_SPACING) {
case DMA_DESCRIPTOR_SPACING_16:
data = DMAC_CFG_MAX_DSPACE_16_;
@@ -3381,6 +3385,12 @@ static int lan743x_netdev_close(struct net_device *netdev)
struct lan743x_adapter *adapter = netdev_priv(netdev);
int index;
+ /* lan743x_reset_work() takes rtnl, so it cannot be waited for here.
+ * A running one returns if the device is still down when it gets
+ * rtnl, otherwise it resets the reopened device once more.
+ */
+ cancel_work(&adapter->reset_work);
+
lan743x_phylink_disconnect(adapter);
synchronize_net();
@@ -3485,6 +3495,57 @@ static int lan743x_netdev_stop(struct net_device *netdev)
return lan743x_netdev_close(netdev);
}
+static void lan743x_reset_work(struct work_struct *work)
+{
+ struct lan743x_adapter *adapter =
+ container_of(work, struct lan743x_adapter, reset_work);
+ struct net_device *netdev = adapter->netdev;
+ int ret;
+
+ rtnl_lock();
+
+ if (!netif_running(netdev) || !netif_device_present(netdev))
+ goto unlock;
+
+ netdev_warn(netdev, "resetting after TX timeout\n");
+
+ netif_device_detach(netdev);
+ lan743x_netdev_close(netdev);
+
+ ret = lan743x_dmac_init(adapter);
+ if (ret) {
+ /* Stay detached to prevent open on a DMAC that failed reset */
+ netdev_err(netdev, "DMA controller reset failed: %d\n", ret);
+ dev_close(netdev);
+ goto unlock;
+ }
+
+ ret = lan743x_netdev_open(netdev);
+ if (ret) {
+ netdev_err(netdev, "failed to reopen after reset: %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);
+ }
+unlock:
+ rtnl_unlock();
+}
+
+static void lan743x_netdev_tx_timeout(struct net_device *netdev,
+ unsigned int txqueue)
+{
+ struct lan743x_adapter *adapter = netdev_priv(netdev);
+
+ schedule_work(&adapter->reset_work);
+}
+
static netdev_tx_t lan743x_netdev_xmit_frame(struct sk_buff *skb,
struct net_device *netdev)
{
@@ -3593,6 +3654,7 @@ static const struct net_device_ops lan743x_netdev_ops = {
.ndo_open = lan743x_netdev_open,
.ndo_stop = lan743x_netdev_stop,
.ndo_start_xmit = lan743x_netdev_xmit_frame,
+ .ndo_tx_timeout = lan743x_netdev_tx_timeout,
.ndo_eth_ioctl = lan743x_netdev_ioctl,
.ndo_set_rx_mode = lan743x_netdev_set_multicast,
.ndo_change_mtu = lan743x_netdev_change_mtu,
@@ -3621,6 +3683,7 @@ static void lan743x_destroy_phylink(struct lan743x_adapter *adapter)
static void lan743x_full_cleanup(struct lan743x_adapter *adapter)
{
unregister_netdev(adapter->netdev);
+ cancel_work_sync(&adapter->reset_work);
lan743x_destroy_phylink(adapter);
lan743x_mdiobus_cleanup(adapter);
@@ -3815,6 +3878,7 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
NETIF_MSG_LINK | NETIF_MSG_IFUP |
NETIF_MSG_IFDOWN | NETIF_MSG_TX_QUEUED;
netdev->max_mtu = LAN743X_MAX_FRAME_SIZE;
+ INIT_WORK(&adapter->reset_work, lan743x_reset_work);
of_get_mac_address(pdev->dev.of_node, adapter->mac_address);
diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
index d9495cf96b41..2697f0a2a83b 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.h
+++ b/drivers/net/ethernet/microchip/lan743x_main.h
@@ -6,6 +6,7 @@
#include <linux/phy.h>
#include <linux/phylink.h>
+#include <linux/workqueue.h>
#include "lan743x_ptp.h"
#define DRIVER_AUTHOR "Bryan Whitehead <Bryan.Whitehead@microchip.com>"
@@ -1075,6 +1076,7 @@ struct lan743x_adapter {
struct lan743x_phy phy;
struct lan743x_tx tx[PCI11X1X_USED_TX_CHANNELS];
struct lan743x_rx rx[LAN743X_USED_RX_CHANNELS];
+ struct work_struct reset_work;
bool is_pci11x1x;
bool is_sgmii_en;
bool is_rmii_en;
--
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 ` [PATCH net-next v2 5/7] net: lan743x: handle a failed reopen on resume Chris Babroski
2026-11-24 14:33 ` Chris Babroski [this message]
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=a6d08d5760ecabea5c77d6001a8281c820873512.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®