Skip to content

Commit ba3d9c0

Browse files
Francois Romieubwhacks
authored andcommitted
r8169: fix early queue wake-up.
[ Upstream commit ae1f23f ] With infinite gratitude to Eric Dumazet for allowing me to identify the error. Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Cc: Hayes Wang <hayeswang@realtek.com> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
1 parent 3224414 commit ba3d9c0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • drivers/net/ethernet/realtek

‎drivers/net/ethernet/realtek/r8169.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5561,7 +5561,18 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
55615561
RTL_W8(TxPoll, NPQ);
55625562

55635563
if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) {
5564+
/* Avoid wrongly optimistic queue wake-up: rtl_tx thread must
5565+
* not miss a ring update when it notices a stopped queue.
5566+
*/
5567+
smp_wmb();
55645568
netif_stop_queue(dev);
5569+
/* Sync with rtl_tx:
5570+
* - publish queue status and cur_tx ring index (write barrier)
5571+
* - refresh dirty_tx ring index (read barrier).
5572+
* May the current thread have a pessimistic view of the ring
5573+
* status and forget to wake up queue, a racing rtl_tx thread
5574+
* can't.
5575+
*/
55655576
smp_mb();
55665577
if (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)
55675578
netif_wake_queue(dev);
@@ -5663,6 +5674,13 @@ static void rtl8169_tx_interrupt(struct net_device *dev,
56635674

56645675
if (tp->dirty_tx != dirty_tx) {
56655676
tp->dirty_tx = dirty_tx;
5677+
/* Sync with rtl8169_start_xmit:
5678+
* - publish dirty_tx ring index (write barrier)
5679+
* - refresh cur_tx ring index and queue status (read barrier)
5680+
* May the current thread miss the stopped queue condition,
5681+
* a racing xmit thread can only have a right view of the
5682+
* ring status.
5683+
*/
56665684
smp_mb();
56675685
if (netif_queue_stopped(dev) &&
56685686
(TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)) {

0 commit comments

Comments
 (0)