Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: dimitri.daskalakis1@gmail.com
Cc: davem@davemloft.net, alexanderduyck@fb.com, kuba@kernel.org,
	kernel-team@meta.com, andrew+netdev@lunn.ch, edumazet@kernel.org,
	pabeni@redhat.com, shuah@kernel.org, hmohsin@meta.com,
	mike.marciniszyn@gmail.com, sdf@fomichev.me,
	bobbyeshleman@meta.com, bjorn@kernel.org, leitao@debian.org,
	horms@kernel.org, almasrymina@google.com,
	vadim.fedorenko@linux.dev, daskald@meta.com,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net v2 1/5] eth: fbnic: wait on the correct queues in fbnic_queue_stop()
Date: Thu, 19 Nov 2026 09:54:21 +0000	[thread overview]
Message-ID: <179508206173.3136.15402623456535892800@kernel.org> (raw)
In-Reply-To: <20261117215416.1901246-2-dimitri.daskalakis1@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] After this patch, fbnic_queue_stop() passes
  nv->qt[t].cmpl.q_idx to fbnic_wait_queue_idle().

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
  fbnic_queue_stop() stops the vector's netdev Tx queues with a bare…

--

eth: fbnic: wait on the correct queues in fbnic_queue_stop()

This patch sets q_idx on Tx completion rings. fbnic_queue_stop() now
passes cmpl.q_idx to fbnic_wait_queue_idle(), so Rx queues no longer
wait on queue 0. It also skips stop and wake of Tx rings that are
marked FBNIC_RING_F_DISABLED.

> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
> index 07d4b2e923627..5efed21e59329 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c

[ ... ]

> @@ -3089,13 +3092,16 @@ static int fbnic_queue_stop(struct net_device *dev, void *qmem, int idx)
>  	napi_disable_locked(&nv->napi);
>  	fbnic_nv_irq_disable(nv);
>  
> -	for (i = 0; i < nv->txt_count; i++)
> +	for (i = 0; i < nv->txt_count; i++) {
> +		if (nv->qt[i].sub0.flags & FBNIC_RING_F_DISABLED)
> +			continue;
>  		netif_stop_subqueue(dev, nv->qt[i].sub0.q_idx);
> +	}
>  	fbnic_nv_disable(fbn, nv);

[Severity: High]
This isn't a bug introduced by this patch, but does anything here wait
for an fbnic_xmit_frame() call that is already running on another CPU?

netif_stop_subqueue() only sets __QUEUE_STATE_DRV_XOFF. Nothing calls
__netif_tx_lock() or synchronize_net() before fbnic_nv_disable(),
fbnic_wait_queue_idle() and fbnic_nv_flush() run. Only the full-down
path in fbnic_pci.c uses netif_tx_disable().

A sender may pass the netif_xmit_frozen_or_stopped() check before the
bit is set. It can then still be inside fbnic_tx_map(), writing
tx_buf[], ring->tail and the BQL state, and ringing the doorbell.

Suppose it sets ring->tail after fbnic_nv_flush() has run:

fbnic_nv_flush()
    fbnic_clean_twq0(nv, 0, &qt->sub0, true, qt->sub0.tail);
    ...
    netdev_tx_reset_queue(tx_queue);

Is the skb and its DMA mapping then leaked once __fbnic_nv_restart()
re-enables the ring and fbnic_enable_twq0() resets head/tail to 0? BQL
would also keep in-flight bytes that never complete, and that can
stall the Tx queue.

Now suppose the sender is delayed until after fbnic_enable_twq0() has
done this:

	twq->tail = 0;
	twq->head = 0;

It would then write a stale ring->tail and ring the doorbell, and the
hardware would fetch old descriptors whose buffers are already
unmapped. Could those completions make fbnic_clean_twq0() read a NULL
ring->tx_buf[] entry and dereference FBNIC_XMIT_CB(skb)->desc_count on
it?

To hit this, a queue restart (netdev bind-rx devmem, io_uring zcrx) has
to run on an Rx queue whose NAPI vector also serves a combined Tx queue,
while another CPU is sending on that Tx queue.

>  
>  	for (t = 0; t < nv->txt_count + nv->rxt_count; t++) {
>  		err = fbnic_wait_queue_idle(fbn, t >= nv->txt_count,
> -					    nv->qt[t].sub0.q_idx);
> +					    nv->qt[t].cmpl.q_idx);

[Severity: Medium]
On an Rx-only vector the Tx triad has sub0 disabled and carries only the
XDP TWQ1 ring, so this call becomes fbnic_wait_queue_idle(fbn, false,
txq_idx). Does fbnic_wait_queue_idle() actually cover TWQ1 of that
queue?

It builds a single bit from the queue index and tests that bit in all
four Tx idle arrays:

fbnic_wait_queue_idle() {
    ...
	off = idx / 32;
	mask = BIT(idx % 32);
    ...
}

The TWQ, TQS and TDE idle arrays are twice as wide as the TCQ one:

#define FBNIC_QM_TWQ_IDLE_CNT			8
#define FBNIC_QM_TCQ_IDLE_CNT			4
#define FBNIC_QM_TQS_IDLE_CNT			8
#define FBNIC_QM_TDE_IDLE_CNT			8

There are 128 queues with two work queues each (TWQ0 and TWQ1), so this
looks like one bit per TWQ. fbnic_wait_all_queues_idle() reads all 8
registers, but fbnic_wait_queue_idle() only reads registers 0 to 3.

If bit idx maps to TWQ0, it is always idle here, because TWQ0 is
FBNIC_RING_F_DISABLED on this triad. The TWQ1 ring that carries XDP_TX
traffic would then never be polled.

Next, fbnic_queue_stop() calls fbnic_nv_flush(), which runs
fbnic_clean_twq1() and unmaps the XDP buffers. Could the hardware still
be fetching TWQ1 descriptors at that point?

The bit layout isn't documented in-tree, so the answer depends on the
hardware. The commit message gives "fbnic_wait_queue_idle(tx, 39)" as
the wait on the vector's XDP Tx queue. Is that wait enough to cover
TWQ1?

>  		if (err)
>  			goto err_restart;
>  	}

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117215416.1901246-1-dimitri.daskalakis1%40gmail.com

  parent reply	other threads:[~2026-11-19  9:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 21:54 [PATCH net v2 0/5] eth: fbnic: miscellaneous driver fixes Dimitri Daskalakis
2026-11-17 21:54 ` [PATCH net v2 1/5] eth: fbnic: wait on the correct queues in fbnic_queue_stop() Dimitri Daskalakis
2026-11-18 13:13   ` Björn Töpel
2026-11-19  9:54   ` netdev-bot+sashiko [this message]
2026-11-17 21:54 ` [PATCH net v2 2/5] eth: fbnic: skip disabled Tx rings when setting the queue NAPI Dimitri Daskalakis
2026-11-18 13:15   ` Björn Töpel
2026-11-17 21:54 ` [PATCH net v2 3/5] eth: fbnic: skip freed Tx rings in fbnic_get_ts_stats() Dimitri Daskalakis
2026-11-18 13:26   ` Björn Töpel
2026-11-17 21:54 ` [PATCH net v2 4/5] netdevsim: report fake timestamping stats Dimitri Daskalakis
2026-11-17 21:54 ` [PATCH net v2 5/5] selftests: drv-net: stats: query timestamping stats while down Dimitri Daskalakis
2026-11-19  9:54   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179508206173.3136.15402623456535892800@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alexanderduyck@fb.com \
    --cc=almasrymina@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjorn@kernel.org \
    --cc=bobbyeshleman@meta.com \
    --cc=daskald@meta.com \
    --cc=davem@davemloft.net \
    --cc=dimitri.daskalakis1@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=hmohsin@meta.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mike.marciniszyn@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=vadim.fedorenko@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox