🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Dimitri Daskalakis Sat, 21 Nov 2026 03:32
[PATCH net 4/4] eth: fbnic: wait for both TWQs of a Tx queue to go idle
#20078
Author: Dimitri Daskalakis
Date: Sat, 21 Nov 2026 03:32
88 lines
14179 bytes
From: Dimitri Daskalakis <daskald@meta.com>

TWQ_IDLE, TQS_IDLE and TDE_IDLE have a bit per Tx work queue. Bit 2q
is for TWQ0, and bit 2q+1 is for TWQ1. fbnic_wait_queue_idle() only
tests bit q, which belongs to queue q/2. Thus, the wait covers a TWQ
of the wrong queue (except when q = 0).

Test both of the queue's TWQ bits in those registers.

This bug was found by AI and verified in QEMU.

Forced TWQ1 of Tx queue 3 to never read idle in QEMU, with rx 2 tx 2
(queue 3 is the XDP Tx queue of rxq 1's vector), and bound devmem to
rxq 1:
  before: bind succeeds
  after:  bind fails with ETIMEDOUT:
    wait for queue Tx3 idle failed 0x0800(0): ffffff7f (mask: 000000c0)

Fixes: da43127a8edc ("eth: fbnic: support queue ops / zero-copy Rx")
Signed-off-by: Dimitri Daskalakis <daskald@meta.com>
---
 drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 32 ++++++++++++--------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
index 62b67940c13e..fe769c33b117 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
@@ -2532,36 +2532,44 @@ int fbnic_wait_all_queues_idle(struct fbnic_dev *fbd, bool may_fail)
 	return err;
 }
 
+struct fbnic_queue_idle_reg {
+	u32 reg;
+	u8 bits_per_q;
+};
+
 static int
 fbnic_wait_queue_idle(struct fbnic_net *fbn, bool rx, unsigned int idx)
 {
-	static const unsigned int tx_regs[] = {
-		FBNIC_QM_TWQ_IDLE(0), FBNIC_QM_TQS_IDLE(0),
-		FBNIC_QM_TDE_IDLE(0), FBNIC_QM_TCQ_IDLE(0),
+	static const struct fbnic_queue_idle_reg tx_regs[] = {
+		{ FBNIC_QM_TWQ_IDLE(0), 2 }, { FBNIC_QM_TQS_IDLE(0), 2 },
+		{ FBNIC_QM_TDE_IDLE(0), 2 }, { FBNIC_QM_TCQ_IDLE(0), 1 },
 	}, rx_regs[] = {
-		FBNIC_QM_HPQ_IDLE(0), FBNIC_QM_PPQ_IDLE(0),
-		FBNIC_QM_RCQ_IDLE(0),
+		{ FBNIC_QM_HPQ_IDLE(0), 1 }, { FBNIC_QM_PPQ_IDLE(0), 1 },
+		{ FBNIC_QM_RCQ_IDLE(0), 1 },
 	};
+	const struct fbnic_queue_idle_reg *regs;
 	struct fbnic_dev *fbd = fbn->fbd;
 	unsigned int val, mask, off;
-	const unsigned int *regs;
 	unsigned int reg_cnt;
 	int i, err;
 
 	regs = rx ? rx_regs : tx_regs;
 	reg_cnt = rx ? ARRAY_SIZE(rx_regs) : ARRAY_SIZE(tx_regs);
 
-	off = idx / 32;
-	mask = BIT(idx % 32);
-
 	for (i = 0; i < reg_cnt; i++) {
-		err = read_poll_timeout_atomic(fbnic_rd32, val, val & mask,
+		unsigned int bit = idx * regs[i].bits_per_q;
+
+		off = bit / 32;
+		mask = GENMASK(regs[i].bits_per_q - 1, 0) << (bit % 32);
+
+		err = read_poll_timeout_atomic(fbnic_rd32, val,
+					       (val & mask) == mask,
 					       2, 500000, false,
-					       fbd, regs[i] + off);
+					       fbd, regs[i].reg + off);
 		if (err) {
 			netdev_err(fbd->netdev,
 				   "wait for queue %s%d idle failed 0x%04x(%d): %08x (mask: %08x)\n",
-				   rx ? "Rx" : "Tx", idx, regs[i] + off, i,
+				   rx ? "Rx" : "Tx", idx, regs[i].reg + off, i,
 				   val, mask);
 			return err;
 		}
-- 
2.52.1
Re: [PATCH net 4/4] eth: fbnic: wait for both TWQs of a Tx queue to go idle
#25242
Author: Simon Horman
Date: Tue, 01 Dec 2026 12:41
24 lines
8949 bytes
On Fri, Nov 20, 2026 at 07:32:15PM -0800, Dimitri Daskalakis wrote:
> From: Dimitri Daskalakis <daskald@meta.com>
> 
> TWQ_IDLE, TQS_IDLE and TDE_IDLE have a bit per Tx work queue. Bit 2q
> is for TWQ0, and bit 2q+1 is for TWQ1. fbnic_wait_queue_idle() only
> tests bit q, which belongs to queue q/2. Thus, the wait covers a TWQ
> of the wrong queue (except when q = 0).
> 
> Test both of the queue's TWQ bits in those registers.
> 
> This bug was found by AI and verified in QEMU.
> 
> Forced TWQ1 of Tx queue 3 to never read idle in QEMU, with rx 2 tx 2
> (queue 3 is the XDP Tx queue of rxq 1's vector), and bound devmem to
> rxq 1:
>   before: bind succeeds
>   after:  bind fails with ETIMEDOUT:
>     wait for queue Tx3 idle failed 0x0800(0): ffffff7f (mask: 000000c0)
> 
> Fixes: da43127a8edc ("eth: fbnic: support queue ops / zero-copy Rx")
> Signed-off-by: Dimitri Daskalakis <daskald@meta.com>

Reviewed-by: Simon Horman <horms@kernel.org>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads