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 <sati…@broadcom.com>
Cc: Siva Reddy Kallam <siva…@broadcom.com>
Cc: Prashant Sreedharan <pras…@broadcom.com>
Signed-off-by: Magnus Lindholm <linm…@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