Skip to contentSkip to conversation

eth: bnxt: fix the wake condition

PATCH Applied Jakub Kicinski 4 participants 5 messages Jun 7, 2023 – Jun 8, 2023

Subsystems (4)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/2 eth: bnxt: fix the wake condition

The down condition should be the negation of the wake condition, IOW when I moved it from:

if (cond && wake())
to
if (__netif_txq_completed_wake(cond))

Cond should have been negated. Flip it now.

This bug leads to occasional crashes with netconsole.
It may also lead to queue never waking up in case BQL is not enabled.

Fixes 08a096780d92 ("bnxt: use new queue try_stop/try_wake macros")

---
CC: [email protected]

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -1
index dcd9367f05af..1f04cd4cfab9 100644
@@ -692,7 +692,7 @@ static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts)
 
 	__netif_txq_completed_wake(txq, nr_pkts, tx_bytes,
 				   bnxt_tx_avail(bp, txr), bp->tx_wake_thresh,
-				   READ_ONCE(txr->dev_state) != BNXT_DEV_STATE_CLOSING);
+				   READ_ONCE(txr->dev_state) == BNXT_DEV_STATE_CLOSING);
 }
 
 static struct page *__bnxt_alloc_rx_page(struct bnxt *bp, dma_addr_t *mapping,
Signature · 1 line
2.40.1
author maintainer
#1 lore raw

PATCH 2/2 eth: ixgbe: fix the wake condition

Flip the netif_carrier_ok() condition in queue wake logic. When I moved it to inside __netif_txq_completed_wake() I missed negating it.

This made the condition ineffective and could probably lead to crashes.

Fixes 301f227fc860 ("net: piggy back on the memory barrier in bql when waking queues")

---
CC: [email protected]
CC: [email protected]

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 -1
index 5d83c887a3fc..1726297f2e0d 100644
@@ -1256,7 +1256,7 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector,
 	if (!__netif_txq_completed_wake(txq, total_packets, total_bytes,
 					ixgbe_desc_unused(tx_ring),
 					TX_WAKE_THRESHOLD,
-					netif_carrier_ok(tx_ring->netdev) &&
+					!netif_carrier_ok(tx_ring->netdev) ||
 					test_bit(__IXGBE_DOWN, &adapter->state)))
 		++tx_ring->tx_stats.restart_queue;
 
Signature · 1 line
2.40.1
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH net 2/2] eth: ixgbe: fix the wake condition

Quoted 9 lines · Jakub Kicinski

Flip the netif_carrier_ok() condition in queue wake logic. When I moved it to inside __netif_txq_completed_wake() I missed negating it.

This made the condition ineffective and could probably lead to crashes.

Fixes 301f227fc860 ("net: piggy back on the memory barrier in bql when waking queues")

LGTM

maintainer Reviewed-by on v1 1/2
#3 lore raw
In reply to Jakub Kicinski
Quoted 8 lines · Jakub Kicinski

The down condition should be the negation of the wake condition, IOW when I moved it from:

if (cond && wake())
to
if (__netif_txq_completed_wake(cond))

Quoted 8 lines

Cond should have been negated. Flip it now.

This bug leads to occasional crashes with netconsole.
It may also lead to queue never waking up in case BQL is not enabled.

Fixes 08a096780d92 ("bnxt: use new queue try_stop/try_wake macros")

Thanks.

#4 lore raw
In reply to Jakub Kicinski
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Tue, 6 Jun 2023 18:08:25 -0700 you wrote:

The down condition should be the negation of the wake condition, IOW when I moved it from:

if (cond && wake())
to
if (__netif_txq_completed_wake(cond))

[...]

Here is the summary with links:
- [net,1/2] eth: bnxt: fix the wake condition

    https://git.kernel.org/netdev/net/c/649c3fed3673
  - [net,2/2] eth: ixgbe: fix the wake condition
    https://git.kernel.org/netdev/net/c/f0d751973f73

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html