Skip to contentSkip to conversation

igc: Fix infinite initialization loop with early XDP redirect

PATCH In review Vinicius Costa Gomes 2 participants 2 messages Sep 7, 2023 – Sep 13, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 igc: Fix infinite initialization loop with early XDP redirect

When a XDP redirect happens before the link is ready, that transmission will not finish and will timeout, causing an adapter reset. If the redirects do not stop, the adapter will not stop resetting.

Wait for the driver to signal that there's a carrier before allowing transmissions to proceed.

Previous code was relying that when __IGC_DOWN is cleared, the NIC is ready to transmit as all the queues are ready, what happens is that the carrier presence will only be signaled later, after the watchdog workqueue has a chance to run. And during this interval (between clearing __IGC_DOWN and the watchdog running) if any transmission happens the timeout is emitted (detected by igc_tx_timeout()) which causes the reset, with the potential for the inifite loop.

---
v1 -> v2:
- Added more information to the commit message (Maciej Fijalkowski)

 drivers/net/ethernet/intel/igc/igc_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc_main.c +1 -1
index 293b45717683..98de34d0ce07 100644
@@ -6491,7 +6491,7 @@ static int igc_xdp_xmit(struct net_device *dev, int num_frames,
 	struct igc_ring *ring;
 	int i, drops;
 
-	if (unlikely(test_bit(__IGC_DOWN, &adapter->state)))
+	if (unlikely(!netif_carrier_ok(dev)))
 		return -ENETDOWN;
 
 	if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
Signature · 1 line
2.41.0
Tested-by on v2 1/1
#1 lore raw
Quoted 22 lines · Vinicius Costa Gomes

When a XDP redirect happens before the link is ready, that transmission will not finish and will timeout, causing an adapter reset. If the redirects do not stop, the adapter will not stop resetting.

Wait for the driver to signal that there's a carrier before allowing transmissions to proceed.

Previous code was relying that when __IGC_DOWN is cleared, the NIC is ready to transmit as all the queues are ready, what happens is that the carrier presence will only be signaled later, after the watchdog workqueue has a chance to run. And during this interval (between clearing __IGC_DOWN and the watchdog running) if any transmission happens the timeout is emitted (detected by igc_tx_timeout()) which causes the reset, with the potential for the inifite loop.

Quoted 7 lines

---
v1 -> v2:
- Added more information to the commit message (Maciej Fijalkowski)

  drivers/net/ethernet/intel/igc/igc_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)