* [PATCH net 0/6] tg3: fix reset and NAPI ordering and reject empty RX rings
@ 2026-12-04 18:54 Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 1/6] tg3: defer reset work when RTNL is busy Magnus Lindholm
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Magnus Lindholm @ 2026-12-04 18:54 UTC (permalink / raw)
To: netdev
Cc: pavan.chebbi, michael.chan, andrew+netdev, davem, edumazet, kuba,
pabeni, Magnus Lindholm
This is a series for the tg3 driver, which I stared working on while
adding support for M3000 sparc VII+. The box uses the tg3 driver.
My main objective was to get Linux running on the M3000.
Close and suspend can wait under RTNL for a reset worker that also needs
RTNL. Reset producers can also queue work after teardown has drained it,
and NAPI poll callbacks can still access registers after reset masks
interrupts.
The first three patches let the worker retry if RTNL is busy, gate new
reset work during teardown and unregister the netdevice before freeing
its resources. Patches 4 and 5 honor the result of napi_complete_done()
and wait for poll callbacks to finish their final register accesses. The
ringparam selftest also showed that tg3 accepted an empty standard RX
ring and stopped receiving traffic. Patch 6 rejects that setting before
stopping the interface and can also be applied directly to net.
I tested GLAN2 on a Fujitsu M3000 with a BCM5718 and three MSI-X
vectors. The hardware kernels carried Oberon MSI-X support and a tg3
delivery-loss callback [1]. The recovery code gates reset enable and TX
restart after a terminal MSI failure. These tests used normal MSI-X
delivery. The series applies in order to net without those changes.
With patch 6, requesting zero RX entries returned EINVAL and preserved
the settings and carrier. On all three runs of ring_reconfig.py,
channels passed, reconfig_tx_stall skipped (no combined channels), and
ringparam failed to start traffic at one RX entry and 31 TX entries.
On this 5717-class ASIC, tg3_set_ringparam() resets the PHY on a ring
change while the interface is up. The test starts traffic immediately
and samples RX packets 50 times at 100 ms intervals. Carrier was down
during part of that window. In separate runs, two consecutive pings
succeeded after 8.7 seconds at 1 RX / 31 TX and 8.9 seconds at 2047 RX /
511 TX. Starting the same traffic generator then delivered over 10,000
packets at each size. TCP passed in both directions with one RX entry.
On the same BCM5718, stopping an idle TX queue triggered the real
watchdog. Close and PCI unbind each canceled delayed reset work. With a
reset already in progress, two closes and two unbinds requested RTNL
after the first chip-reset flush and acquired it after hardware
reinitialization. Nine transfer pairs passed SHA-256 checks in both
directions across the watchdog tests.
I also reran the earlier x86-64 QEMU fixture. It runs both tg3 poll
callbacks on a synthetic netdevice and records writes to memory-backed
registers. All 22 cases passed with both lazy and full preemption,
including busy-poll completion refusal and mailbox and heartbeat
ordering around the modeled reset mask. I have not measured an IRQ-rate
change on the BCM5718 or exercised hardware suspend/resume or PCI error
recovery.
Each patch built tg3.o with W=1 and -Werror for x86-64 allmodconfig and
SPARC64. I used Codex to help audit the driver, prepare the patches and
run the tests.
[1] https://github.com/linmag7/linux-sparc/commit/5b6eaad22926a8158e04f0d209900f666a293382
Magnus Lindholm (6):
tg3: defer reset work when RTNL is busy
tg3: gate reset work across device teardown
tg3: unregister the netdevice before releasing its resources
tg3: honor NAPI completion before rearming interrupts
tg3: wait for NAPI poll callbacks before resetting hardware
tg3: reject an empty standard RX ring
drivers/net/ethernet/broadcom/tg3.c | 98 +++++++++++++++++++++--------
drivers/net/ethernet/broadcom/tg3.h | 5 +-
2 files changed, 77 insertions(+), 26 deletions(-)
base-commit: af6737b9066832a2017c281159950ba92385ce00
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net 1/6] tg3: defer reset work when RTNL is busy
2026-12-04 18:54 [PATCH net 0/6] tg3: fix reset and NAPI ordering and reject empty RX rings Magnus Lindholm
@ 2026-12-04 18:54 ` Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 2/6] tg3: gate reset work across device teardown Magnus Lindholm
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Magnus Lindholm @ 2026-12-04 18:54 UTC (permalink / raw)
To: netdev
Cc: pavan.chebbi, michael.chan, andrew+netdev, davem, edumazet, kuba,
pabeni, Magnus Lindholm, Prashant Sreedharan
Close and suspend cancel reset work under RTNL. If the worker waits for
RTNL, the caller cannot finish canceling it. Use delayed work and retry
one jiffy later when rtnl_trylock() fails.
A driver audit with Codex identified the lock cycle. The reproducer
queued the worker under RTNL and canceled it before releasing RTNL. On a
BCM5718 the worker deferred and cancellation finished in ten trials. In
a separate trial, releasing RTNL let the worker reset the port. The
deadlock in the original code was inferred from the locking order.
With all six patches on a BCM5718, ring_reconfig.py passed channels and
skipped reconfig_tx_stall (no combined channels). Changing ring sizes
resets the PHY on this 5717-class ASIC. The ringparam traffic check
timed out at 1 RX / 31 TX with a nominal five-second startup window.
Peer reachability took 8.7 seconds at that depth in a separate run. TCP
then passed in both directions.
Fixes: db84bf43ef23 ("tg3: tg3_reset_task() needs to use rtnl_lock to synchronize")
Cc: Prashant Sreedharan <prashant@broadcom.com>
Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
drivers/net/ethernet/broadcom/tg3.c | 16 ++++++++++------
drivers/net/ethernet/broadcom/tg3.h | 2 +-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 95827df4cf6a..86ef8e438988 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -7238,13 +7238,13 @@ static int tg3_poll_work(struct tg3_napi *tnapi, int work_done, int budget)
static inline void tg3_reset_task_schedule(struct tg3 *tp)
{
if (!test_and_set_bit(TG3_FLAG_RESET_TASK_PENDING, tp->tg3_flags))
- schedule_work(&tp->reset_task);
+ schedule_delayed_work(&tp->reset_task, 0);
}
static inline void tg3_reset_task_cancel(struct tg3 *tp)
{
if (test_and_clear_bit(TG3_FLAG_RESET_TASK_PENDING, tp->tg3_flags))
- cancel_work_sync(&tp->reset_task);
+ cancel_delayed_work_sync(&tp->reset_task);
tg3_flag_clear(tp, TX_RECOVERY_PENDING);
}
@@ -11262,10 +11262,14 @@ static int tg3_restart_hw(struct tg3 *tp, bool reset_phy)
static void tg3_reset_task(struct work_struct *work)
{
- struct tg3 *tp = container_of(work, struct tg3, reset_task);
+ struct tg3 *tp = container_of(work, struct tg3, reset_task.work);
int err;
- rtnl_lock();
+ /* Close and suspend can cancel this work while holding RTNL. */
+ if (!rtnl_trylock()) {
+ schedule_delayed_work(&tp->reset_task, 1);
+ return;
+ }
tg3_full_lock(tp, 0);
if (tp->pcierr_recovery || !netif_running(tp->dev) ||
@@ -11299,7 +11303,7 @@ static void tg3_reset_task(struct work_struct *work)
tp->irq_sync = 0;
tg3_napi_enable(tp);
/* Clear this flag so that tg3_reset_task_cancel() will not
- * call cancel_work_sync() and wait forever.
+ * call cancel_delayed_work_sync() and wait forever.
*/
tg3_flag_clear(tp, RESET_TASK_PENDING);
netdev_unlock(tp->dev);
@@ -17829,7 +17833,7 @@ static int tg3_init_one(struct pci_dev *pdev,
#endif
spin_lock_init(&tp->lock);
spin_lock_init(&tp->indirect_lock);
- INIT_WORK(&tp->reset_task, tg3_reset_task);
+ INIT_DELAYED_WORK(&tp->reset_task, tg3_reset_task);
tp->regs = pci_ioremap_bar(pdev, BAR_0);
if (!tp->regs) {
diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
index a9e7f88fa26d..e5716a969e00 100644
--- a/drivers/net/ethernet/broadcom/tg3.h
+++ b/drivers/net/ethernet/broadcom/tg3.h
@@ -3372,7 +3372,7 @@ struct tg3 {
struct tg3_hw_stats *hw_stats;
dma_addr_t stats_mapping;
- struct work_struct reset_task;
+ struct delayed_work reset_task;
struct sk_buff *tx_tstamp_skb;
u64 pre_tx_ts;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net 2/6] tg3: gate reset work across device teardown
2026-12-04 18:54 [PATCH net 0/6] tg3: fix reset and NAPI ordering and reject empty RX rings Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 1/6] tg3: defer reset work when RTNL is busy Magnus Lindholm
@ 2026-12-04 18:54 ` Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 3/6] tg3: unregister the netdevice before releasing its resources Magnus Lindholm
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Magnus Lindholm @ 2026-12-04 18:54 UTC (permalink / raw)
To: netdev
Cc: pavan.chebbi, michael.chan, andrew+netdev, davem, edumazet, kuba,
pabeni, Magnus Lindholm, Matt Carlson
Reset producers can queue work after teardown has canceled it. The
worker can then access suspended hardware or run after free_netdev().
Close the scheduling gate before draining the work. Reopen it after a
successful start or resume, and disable it permanently on removal and
shutdown. A boolean accommodates repeated stops and failed starts. Skip
self-cancellation on reset failure.
A driver audit with Codex found the race. A modified BCM5718 kernel
delayed watchdog work for three seconds. Close and PCI unbind each
canceled a pending reset. An earlier diagnostic injected -EIO during
reinitialization and exercised the worker's own close. The suspend and
post-free outcomes are inferred.
With all six patches on a BCM5718, ring_reconfig.py passed channels and
skipped reconfig_tx_stall (no combined channels). Changing ring sizes
resets the PHY on this 5717-class ASIC. The ringparam traffic check
timed out at 1 RX / 31 TX with a nominal five-second startup window.
Peer reachability took 8.7 seconds at that depth in a separate run. TCP
then passed in both directions.
Fixes: db2199737990 ("tg3: Schedule at most one tg3_reset_task run")
Cc: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
drivers/net/ethernet/broadcom/tg3.c | 70 ++++++++++++++++++++++-------
drivers/net/ethernet/broadcom/tg3.h | 3 ++
2 files changed, 57 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 86ef8e438988..1cd7fc92aa96 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -7237,17 +7237,52 @@ static int tg3_poll_work(struct tg3_napi *tnapi, int work_done, int budget)
static inline void tg3_reset_task_schedule(struct tg3 *tp)
{
- if (!test_and_set_bit(TG3_FLAG_RESET_TASK_PENDING, tp->tg3_flags))
+ guard(spinlock_irqsave)(&tp->reset_lock);
+ if (tp->reset_enabled &&
+ !test_and_set_bit(TG3_FLAG_RESET_TASK_PENDING, tp->tg3_flags))
schedule_delayed_work(&tp->reset_task, 0);
}
-static inline void tg3_reset_task_cancel(struct tg3 *tp)
+static void tg3_reset_task_retry(struct tg3 *tp)
{
- if (test_and_clear_bit(TG3_FLAG_RESET_TASK_PENDING, tp->tg3_flags))
+ guard(spinlock_irqsave)(&tp->reset_lock);
+ if (tp->reset_enabled)
+ schedule_delayed_work(&tp->reset_task, 1);
+}
+
+static void tg3_reset_task_cancel(struct tg3 *tp)
+{
+ ASSERT_RTNL();
+ scoped_guard(spinlock_irqsave, &tp->reset_lock)
+ tp->reset_enabled = false;
+
+ /* A failed reset closes the device from its own callback. */
+ if (current_work() == &tp->reset_task.work)
+ cancel_delayed_work(&tp->reset_task);
+ else
cancel_delayed_work_sync(&tp->reset_task);
+
+ guard(spinlock_irqsave)(&tp->reset_lock);
+ tg3_flag_clear(tp, RESET_TASK_PENDING);
tg3_flag_clear(tp, TX_RECOVERY_PENDING);
}
+static void tg3_reset_task_enable(struct tg3 *tp)
+{
+ ASSERT_RTNL();
+ guard(spinlock_irqsave)(&tp->reset_lock);
+ if (!tp->reset_stopping)
+ tp->reset_enabled = true;
+}
+
+static void tg3_reset_task_stop(struct tg3 *tp)
+{
+ ASSERT_RTNL();
+ scoped_guard(spinlock_irqsave, &tp->reset_lock)
+ tp->reset_stopping = true;
+ tg3_reset_task_cancel(tp);
+}
+
static int tg3_poll_msix(struct napi_struct *napi, int budget)
{
struct tg3_napi *tnapi = container_of(napi, struct tg3_napi, napi);
@@ -11267,12 +11302,13 @@ static void tg3_reset_task(struct work_struct *work)
/* Close and suspend can cancel this work while holding RTNL. */
if (!rtnl_trylock()) {
- schedule_delayed_work(&tp->reset_task, 1);
+ tg3_reset_task_retry(tp);
return;
}
tg3_full_lock(tp, 0);
- if (tp->pcierr_recovery || !netif_running(tp->dev) ||
+ if (!tp->reset_enabled || tp->pcierr_recovery ||
+ !netif_running(tp->dev) ||
tp->pdev->error_state != pci_channel_io_normal) {
tg3_flag_clear(tp, RESET_TASK_PENDING);
tg3_full_unlock(tp);
@@ -11302,10 +11338,6 @@ static void tg3_reset_task(struct work_struct *work)
tg3_full_unlock(tp);
tp->irq_sync = 0;
tg3_napi_enable(tp);
- /* Clear this flag so that tg3_reset_task_cancel() will not
- * call cancel_delayed_work_sync() and wait forever.
- */
- tg3_flag_clear(tp, RESET_TASK_PENDING);
netdev_unlock(tp->dev);
dev_close(tp->dev);
goto out;
@@ -11727,6 +11759,8 @@ static int tg3_start(struct tg3 *tp, bool reset_phy, bool test_irq,
}
}
+ tg3_reset_task_enable(tp);
+
tg3_phy_start(tp);
tg3_hwmon_open(tp);
@@ -17833,6 +17867,7 @@ static int tg3_init_one(struct pci_dev *pdev,
#endif
spin_lock_init(&tp->lock);
spin_lock_init(&tp->indirect_lock);
+ spin_lock_init(&tp->reset_lock);
INIT_DELAYED_WORK(&tp->reset_task, tg3_reset_task);
tp->regs = pci_ioremap_bar(pdev, BAR_0);
@@ -18156,12 +18191,14 @@ static void tg3_remove_one(struct pci_dev *pdev)
if (dev) {
struct tg3 *tp = netdev_priv(dev);
+ rtnl_lock();
+ tg3_reset_task_stop(tp);
+ rtnl_unlock();
+
tg3_ptp_fini(tp);
release_firmware(tp->fw);
- tg3_reset_task_cancel(tp);
-
if (tg3_flag(tp, USE_PHYLIB)) {
tg3_phy_fini(tp);
tg3_mdio_fini(tp);
@@ -18241,6 +18278,8 @@ static int tg3_resume(struct device *device)
if (err)
goto out;
+ tg3_reset_task_enable(tp);
+
tg3_timer_start(tp);
tg3_netif_start(tp);
@@ -18285,9 +18324,8 @@ static void tg3_shutdown(struct pci_dev *pdev)
struct net_device *dev = pci_get_drvdata(pdev);
struct tg3 *tp = netdev_priv(dev);
- tg3_reset_task_cancel(tp);
-
rtnl_lock();
+ tg3_reset_task_stop(tp);
netif_device_detach(dev);
@@ -18336,10 +18374,8 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev,
netdev_info(netdev, "PCI I/O error detected\n");
- /* Want to make sure that the reset task doesn't run */
- tg3_reset_task_cancel(tp);
-
rtnl_lock();
+ tg3_reset_task_cancel(tp);
/* Could be second call or maybe we don't have netdev yet */
if (!netdev || tp->pcierr_recovery || !netif_running(netdev))
@@ -18462,6 +18498,8 @@ static void tg3_io_resume(struct pci_dev *pdev)
netif_device_attach(netdev);
+ tg3_reset_task_enable(tp);
+
tg3_timer_start(tp);
tg3_netif_start(tp);
diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
index e5716a969e00..c0f2cbab1b53 100644
--- a/drivers/net/ethernet/broadcom/tg3.h
+++ b/drivers/net/ethernet/broadcom/tg3.h
@@ -3373,6 +3373,9 @@ struct tg3 {
struct tg3_hw_stats *hw_stats;
dma_addr_t stats_mapping;
struct delayed_work reset_task;
+ /* Serialize reset publication against gate transitions. */
+ spinlock_t reset_lock;
+ bool reset_enabled, reset_stopping;
struct sk_buff *tx_tstamp_skb;
u64 pre_tx_ts;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net 3/6] tg3: unregister the netdevice before releasing its resources
2026-12-04 18:54 [PATCH net 0/6] tg3: fix reset and NAPI ordering and reject empty RX rings Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 1/6] tg3: defer reset work when RTNL is busy Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 2/6] tg3: gate reset work across device teardown Magnus Lindholm
@ 2026-12-04 18:54 ` Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 4/6] tg3: honor NAPI completion before rearming interrupts Magnus Lindholm
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Magnus Lindholm @ 2026-12-04 18:54 UTC (permalink / raw)
To: netdev
Cc: pavan.chebbi, michael.chan, andrew+netdev, davem, edumazet, kuba,
pabeni, Magnus Lindholm, Benjamin Li, Matt Carlson,
Jaswinder Singh Rajput, Ivan Vecera, Prashant Sreedharan
Removal releases PTP, firmware and PHY resources while the netdevice can
still be opened. Unregister it first so ndo_stop and outstanding netdev
operations finish while those resources are available.
A driver audit with Codex identified the teardown order. A modified
BCM5718 kernel paused removal before unregister. Concurrent opens and
closes completed before the driver released its resources. This port
uses neither PTP, PHYLIB nor host-loaded firmware, so the resource race
itself was not reproduced. PCI unbind also completed during watchdog
recovery.
With all six patches on a BCM5718, ring_reconfig.py passed channels and
skipped reconfig_tx_stall (no combined channels). Changing ring sizes
resets the PHY on this 5717-class ASIC. The ringparam traffic check
timed out at 1 RX / 31 TX with a nominal five-second startup window.
Peer reachability took 8.7 seconds at that depth in a separate run. TCP
then passed in both directions.
Fixes: 158d7abdae85 ("tg3: Add mdio bus registration")
Fixes: 077f849de42e ("firmware: convert tg3 driver to request_firmware()")
Fixes: 20d14a5d377a ("tg3: move init/deinit from open/close to probe/remove")
Cc: Benjamin Li <benli@broadcom.com>
Cc: Matt Carlson <mcarlson@broadcom.com>
Cc: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Cc: Ivan Vecera <ivecera@redhat.com>
Cc: Prashant Sreedharan <prashant@broadcom.com>
Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
drivers/net/ethernet/broadcom/tg3.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 1cd7fc92aa96..d267d1e94322 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -18195,6 +18195,8 @@ static void tg3_remove_one(struct pci_dev *pdev)
tg3_reset_task_stop(tp);
rtnl_unlock();
+ unregister_netdev(dev);
+
tg3_ptp_fini(tp);
release_firmware(tp->fw);
@@ -18204,7 +18206,6 @@ static void tg3_remove_one(struct pci_dev *pdev)
tg3_mdio_fini(tp);
}
- unregister_netdev(dev);
if (tp->aperegs) {
iounmap(tp->aperegs);
tp->aperegs = NULL;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net 4/6] tg3: honor NAPI completion before rearming interrupts
2026-12-04 18:54 [PATCH net 0/6] tg3: fix reset and NAPI ordering and reject empty RX rings Magnus Lindholm
` (2 preceding siblings ...)
2026-12-04 18:54 ` [PATCH net 3/6] tg3: unregister the netdevice before releasing its resources Magnus Lindholm
@ 2026-12-04 18:54 ` Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 5/6] tg3: wait for NAPI poll callbacks before resetting hardware Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 6/6] tg3: reject an empty standard RX ring Magnus Lindholm
5 siblings, 0 replies; 7+ messages in thread
From: Magnus Lindholm @ 2026-12-04 18:54 UTC (permalink / raw)
To: netdev
Cc: pavan.chebbi, michael.chan, andrew+netdev, davem, edumazet, kuba,
pabeni, Magnus Lindholm
Both tg3 poll callbacks rearm the interrupt mailbox when
napi_complete_done() returns false. This can defeat interrupt deferral
during busy polling or software IRQ coalescing. Honor the completion
result before rearming or kicking the MSI-X refill path, as described in
Documentation/networking/napi.rst under "Scheduling and IRQ masking".
The Broadcom NetXtreme/NetLink BCM5718 Family Programmer's Guide
(5718-PG107-R), pp. 232 and 234, describes returning the status tag to
the mailbox after RX and TX processing finishes.
A driver audit with Codex identified the unconditional rearm. In a QEMU
guest the reproducer ran both tg3 poll callbacks on empty rings with the
NAPI busy-poll state set. Each callback wrote the interrupt mailbox once
before the fix and left it untouched afterwards. I tested traffic on an
M3000 BCM5718 with three MSI-X vectors. I did not measure a change in
hardware IRQ rate.
With all six patches on a BCM5718, ring_reconfig.py passed channels and
skipped reconfig_tx_stall (no combined channels). Changing ring sizes
resets the PHY on this 5717-class ASIC. The ringparam traffic check
timed out at 1 RX / 31 TX with a nominal five-second startup window.
Peer reachability took 8.7 seconds at that depth in a separate run. TCP
then passed in both directions.
Fixes: 364b6055738b ("net: busy-poll: return busypolling status to drivers")
Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
drivers/net/ethernet/broadcom/tg3.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index d267d1e94322..88f2062f062a 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -7317,7 +7317,8 @@ static int tg3_poll_msix(struct napi_struct *napi, int budget)
if (tnapi == &tp->napi[1] && tp->rx_refill)
continue;
- napi_complete_done(napi, work_done);
+ if (!napi_complete_done(napi, work_done))
+ break;
/* Reenable interrupts. */
tw32_mailbox(tnapi->int_mbox, tnapi->last_tag << 24);
@@ -7410,8 +7411,8 @@ static int tg3_poll(struct napi_struct *napi, int budget)
sblk->status &= ~SD_STATUS_UPDATED;
if (likely(!tg3_has_work(tnapi))) {
- napi_complete_done(napi, work_done);
- tg3_int_reenable(tnapi);
+ if (napi_complete_done(napi, work_done))
+ tg3_int_reenable(tnapi);
break;
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net 5/6] tg3: wait for NAPI poll callbacks before resetting hardware
2026-12-04 18:54 [PATCH net 0/6] tg3: fix reset and NAPI ordering and reject empty RX rings Magnus Lindholm
` (3 preceding siblings ...)
2026-12-04 18:54 ` [PATCH net 4/6] tg3: honor NAPI completion before rearming interrupts Magnus Lindholm
@ 2026-12-04 18:54 ` Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 6/6] tg3: reject an empty standard RX ring Magnus Lindholm
5 siblings, 0 replies; 7+ messages in thread
From: Magnus Lindholm @ 2026-12-04 18:54 UTC (permalink / raw)
To: netdev
Cc: pavan.chebbi, michael.chan, andrew+netdev, davem, edumazet, kuba,
pabeni, Magnus Lindholm, Satish Baddipadige, Siva Reddy Kallam,
Prashant Sreedharan
After NAPI completion a poll callback can still write the interrupt
mailbox or the APE heartbeat. As described under "Call sequence" in
Documentation/networking/napi.rst, napi_disable() waits for release of
NAPI ownership. A callback can therefore still be running when reset
masks interrupts. Wait for a network grace period after disabling NAPI
and stopping TX.
The Broadcom NetXtreme/NetLink BCM5718 Family Programmer's Guide
(5718-PG107-R), pp. 148-149, describes masking interrupts at the start
of device close. Pages 232 and 234 describe tagged mailbox rearm.
A driver audit with Codex identified the window. A modified QEMU guest
used memory-backed device registers to record write order. Holding a
poll callback after NAPI completion let mailbox and heartbeat writes
follow the modeled reset mask. With the fix the writes preceded the
mask. Loaded watchdog resets on a BCM5718 showed no late writes on
either build.
With all six patches on a BCM5718, ring_reconfig.py passed channels and
skipped reconfig_tx_stall (no combined channels). Changing ring sizes
resets the PHY on this 5717-class ASIC. The ringparam traffic check
timed out at 1 RX / 31 TX with a nominal five-second startup window.
Peer reachability took 8.7 seconds at that depth in a separate run. TCP
then passed in both directions.
Fixes: 38f3843ed6bd ("[TG3]: Use status tag to check for new events")
Fixes: 506b0a395f26 ("tg3: APE heartbeat changes")
Cc: Satish Baddipadige <satish.baddipadige@broadcom.com>
Cc: Siva Reddy Kallam <siva.kallam@broadcom.com>
Cc: Prashant Sreedharan <prashant.sreedharan@broadcom.com>
Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
drivers/net/ethernet/broadcom/tg3.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 88f2062f062a..7ccb78222518 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -7500,6 +7500,9 @@ static inline void tg3_netif_stop(struct tg3 *tp)
tg3_napi_disable(tp);
netif_carrier_off(tp->dev);
netif_tx_disable(tp->dev);
+
+ /* Let pollers that completed NAPI finish their last MMIO. */
+ synchronize_net();
}
/* tp->lock must be held */
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net 6/6] tg3: reject an empty standard RX ring
2026-12-04 18:54 [PATCH net 0/6] tg3: fix reset and NAPI ordering and reject empty RX rings Magnus Lindholm
` (4 preceding siblings ...)
2026-12-04 18:54 ` [PATCH net 5/6] tg3: wait for NAPI poll callbacks before resetting hardware Magnus Lindholm
@ 2026-12-04 18:54 ` Magnus Lindholm
5 siblings, 0 replies; 7+ messages in thread
From: Magnus Lindholm @ 2026-12-04 18:54 UTC (permalink / raw)
To: netdev
Cc: pavan.chebbi, michael.chan, andrew+netdev, davem, edumazet, kuba,
pabeni, Magnus Lindholm
tg3_set_ringparam() accepts zero standard RX entries. Ring setup then
skips the RX allocation loop and posts no standard receive buffers.
Reject zero before stopping the interface.
The ringparam case of ring_reconfig.py exposed this on a BCM5718. With
the preceding fixes, its traffic check failed at zero RX and 31 TX
entries. At the same TX depth, 64 RX entries carried traffic in both
directions. The missing lower bound is present in the initial Git
import.
With this fix the same BCM5718 returned EINVAL for zero RX entries and
kept its ring settings and carrier. Changing ring sizes resets the PHY
on this 5717-class ASIC. The ringparam traffic check timed out at 1 RX /
31 TX within its nominal five-second startup window. In a separate run,
peer reachability took 8.7 seconds at that depth. TCP then passed in
both directions.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
drivers/net/ethernet/broadcom/tg3.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 7ccb78222518..0f4343a79cb7 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -12585,7 +12585,8 @@ static int tg3_set_ringparam(struct net_device *dev,
int i, irq_sync = 0, err = 0;
bool reset_phy = false;
- if ((ering->rx_pending > tp->rx_std_ring_mask) ||
+ if (!ering->rx_pending ||
+ (ering->rx_pending > tp->rx_std_ring_mask) ||
(ering->rx_jumbo_pending > tp->rx_jmb_ring_mask) ||
(ering->tx_pending > TG3_TX_RING_SIZE - 1) ||
(ering->tx_pending <= MAX_SKB_FRAGS) ||
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-04 18:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 18:54 [PATCH net 0/6] tg3: fix reset and NAPI ordering and reject empty RX rings Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 1/6] tg3: defer reset work when RTNL is busy Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 2/6] tg3: gate reset work across device teardown Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 3/6] tg3: unregister the netdevice before releasing its resources Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 4/6] tg3: honor NAPI completion before rearming interrupts Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 5/6] tg3: wait for NAPI poll callbacks before resetting hardware Magnus Lindholm
2026-12-04 18:54 ` [PATCH net 6/6] tg3: reject an empty standard RX ring Magnus Lindholm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox