]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
amd-xgbe: optimize TX shutdown on link-down
authorRaju Rangoju <Raju.Rangoju@amd.com>
Thu, 19 Mar 2026 16:32:50 +0000 (22:02 +0530)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 24 Mar 2026 09:48:07 +0000 (10:48 +0100)
commit0898849ad9715d163555b8f8bfd13b7691a2b3b8
treef9cb637c4b079544293308526b9ea32bc9b4ae8b
parent31b2d4e00260ae3fca50779ac416dd9acaacbfb9
amd-xgbe: optimize TX shutdown on link-down

Optimize the TX shutdown sequence when link goes down by skipping
futile hardware wait operations and immediately stopping TX queues.

Current behavior creates delays and resource issues during link-down:

1. xgbe_txq_prepare_tx_stop() waits up to XGBE_DMA_STOP_TIMEOUT for
   TX queues to drain, but when link is down, hardware will never
   complete the pending descriptors. This causes unnecessary delays
   during interface shutdown.

2. TX queues remain active after link-down, allowing the network stack
   to continue queuing packets that cannot be transmitted. This leads
   to resource buildup and complicates recovery.

This patch adds two optimizations:

Optimization 1: Skip TX queue drain when link is down
  In xgbe_txq_prepare_tx_stop(), detect link-down state and return
  immediately instead of waiting for hardware. Abandoned descriptors
  will be cleaned up by the force-cleanup mechanism (next patch).

Optimization 2: Immediate TX queue stop on link-down
  In xgbe_phy_adjust_link(), call netif_tx_stop_all_queues() as soon
  as link-down is detected. Also wake TX queues on link-up to resume
  transmission.

Benefits:
  - Faster interface shutdown (no pointless timeout waits)
  - Prevents packet queue buildup in network stack
  - Cleaner state management during link transitions
  - Enables orderly descriptor cleanup by NAPI poll

Note: We do not call netdev_tx_reset_queue() on link-down because
NAPI poll may still be running, which would trigger BQL assertions.
BQL state is cleaned up naturally during descriptor reclamation.

Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
Link: https://patch.msgid.link/20260319163251.1808611-3-Raju.Rangoju@amd.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/amd/xgbe/xgbe-dev.c
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c