From: netdev-bot+sashiko@kernel.org
To: matt@boondocker.io
Cc: anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, ast@kernel.org,
daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
sdf@fomichev.me, intel-wired-lan@lists.osuosl.org,
netdev@vger.kernel.org, bpf@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH net v2] i40e: stop XSK queue pairs in VSI shutdown order
Date: Fri, 04 Dec 2026 23:47:14 +0000 [thread overview]
Message-ID: <179642803419.3146.8192971095663256302@kernel.org> (raw)
In-Reply-To: <20261203-b4-i40e-xsk-queue-order-v2-1-e14b712d5fc2@boondocker.io>
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 1 (1) · Medium: 1 · Low: 3
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).
- [High] If a queue-pair disable times out, the error path still frees
buffers the device may own and leaves the PF stuck in…
- [Medium] i40e: i40e_pf_txq_wait() 20 ms timeout multiplies sequentially
across VFs
- [Low] The patch changes timing for every caller of the shared helper
i40e_pf_txq_wait(), but the commit message only describes the AF_XDP…
- [Low] In the rewritten enable branch of i40e_queue_pair_toggle_rings(),
an Rx enable timeout is now silent.
- [Low] The concern is that the kernel-doc of i40e_pf_txq_wait()
("Returns -ETIMEDOUT in case of failing to reach the requested state…
Pre-existing issues:
- [High] The per-queue-pair disable path never stops the netdev Tx
subqueue before tearing down the regular Tx ring.
--
i40e: stop XSK queue pairs in VSI shutdown order
This commit makes the i40e per-queue-pair disable path follow the
whole-VSI shutdown sequence, and on enable it brings Rx up before Tx. It
also converts i40e_pf_txq_wait() to read_poll_timeout() with a 1ms enable
deadline and a 20ms disable deadline. The per-queue disabled wait moves
into a new helper, i40e_queue_pair_wait_queues_disabled().
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index abbc71e815ae3..555eac07e28b8 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
[ ... ]
> @@ -4660,6 +4661,8 @@ static void i40e_netpoll(struct net_device *netdev)
> #endif
>
> #define I40E_QTX_ENA_WAIT_COUNT 50
> +#define I40E_TXQ_ENABLE_TIMEOUT_US 1000
> +#define I40E_TXQ_DISABLE_TIMEOUT_US 20000
>
> /**
> * i40e_pf_txq_wait - Wait for a PF's Tx queue to be enabled or disabled
> @@ -4674,20 +4677,16 @@ static void i40e_netpoll(struct net_device *netdev)
> **/
> static int i40e_pf_txq_wait(struct i40e_pf *pf, int pf_q, bool enable)
> {
> - int i;
> u32 tx_reg;
>
[Severity: Medium]
Could the longer disable deadline turn into a multi-second stall on
SR-IOV setups?
i40e_reset_all_vfs() walks every VF up to pf->num_alloc_vfs and calls
i40e_vsi_wait_queues_disabled() for each VF VSI. It ignores the return
value. i40e_free_vfs() does the same for VFs without
I40E_VF_STATE_INIT set.
Neither loop stops on the first -ETIMEDOUT, and neither shares one
deadline across VFs. The earlier VPGEN_VFRSTAT wait in
i40e_reset_all_vfs() does share one. i40e_pf_wait_queues_disabled()
stops on the first error.
Before this patch, a Tx queue that never cleared QENA_STAT cost about
100-200us per VSI. With I40E_TXQ_DISABLE_TIMEOUT_US it costs 20ms per
VSI. With I40E_MAX_VF_COUNT (128) VFs, that adds up to about 2.56
seconds.
A surprise removal or PCIe link loss is enough to hit this. rd32() then
returns 0xffffffff, so QENA_STAT reads as set forever and every call
runs for the full 20ms. i40e_control_tx_q(), i40e_control_rx_q() and
the VFRSTAT loop all finish quickly on such reads. That leaves
i40e_pf_txq_wait() as the bottleneck.
When lock_acquired is true, i40e_rebuild() keeps rtnl held across
i40e_reset_all_vfs(). That covers callers such as
i40e_do_reset_safe() and the i40e_io_resume() path, so the whole stall
happens under rtnl.
Should i40e_pf_txq_wait() give up early on an all-ones read? Or should
the VF loops share a single deadline, or stop after the first timeout?
Is the 20ms disable deadline needed for VF queues at all, or only for
the XSK queue-pair path this patch is fixing?
[ ... ]
> + /* QENA_STAT stays set until the disable marker leaves the Tx pipe.
> + * The pipe can take milliseconds to drain even when the ring is empty.
> + */
> + return read_poll_timeout(rd32, tx_reg,
> + enable == !!(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK),
> + 200, enable ? I40E_TXQ_ENABLE_TIMEOUT_US :
> + I40E_TXQ_DISABLE_TIMEOUT_US, false, &pf->hw,
> + I40E_QTX_ENA(pf_q));
> }
[Severity: Low]
i40e_pf_txq_wait() is shared by every Tx queue enable and disable in the
driver, not only the AF_XDP queue-pair path. Before this patch both
directions waited roughly 100-200us (10 x usleep_range(10, 20)). Now
disable waits up to 20ms and enable waits up to 1ms.
Callers include i40e_vsi_enable_tx() via i40e_control_wait_tx_q(),
i40e_vsi_wait_queues_disabled() from i40e_vsi_stop_rings(),
i40e_pf_wait_queues_disabled(), the VF reset paths, and
i40e_ctrl_vf_tx_rings() in i40e_virtchnl_pf.c.
Could the commit message say that queue control timing changes across the
whole driver? Could it also say where the new 1ms enable deadline
(I40E_TXQ_ENABLE_TIMEOUT_US) comes from?
[ ... ]
> @@ -13408,46 +13412,38 @@ static int i40e_queue_pair_toggle_rings(struct i40e_vsi *vsi, int queue_pair,
> bool enable)
> {
> struct i40e_pf *pf = vsi->back;
> - int pf_q, ret = 0;
> + int xdp_q, pf_q, ret;
> + bool has_xdp;
>
> + has_xdp = i40e_enabled_xdp_vsi(vsi);
> pf_q = vsi->base_queue + queue_pair;
[ ... ]
> + if (!enable) {
> + /* Use the same firmware transition as i40e_vsi_stop_rings().
> + * Both TX queues must be announced before RX is stopped.
> + */
> + i40e_pre_tx_queue_cfg(&pf->hw, pf_q, false);
> + if (has_xdp)
> + i40e_pre_tx_queue_cfg(&pf->hw, xdp_q, false);
> + i40e_control_rx_q(pf, pf_q, false);
> + msleep(I40E_DISABLE_TX_GAP_MSEC);
> + wr32(&pf->hw, I40E_QTX_ENA(pf_q), 0);
> + if (has_xdp)
> + wr32(&pf->hw, I40E_QTX_ENA(xdp_q), 0);
[Severity: High]
This is a pre-existing issue and was not introduced by this patch. Since
the patch rewrites this disable sequence, though: what stops
ndo_start_xmit on this queue while the regular Tx ring is torn down?
i40e_queue_pair_disable() only disables the IRQ and NAPI. None of
i40e_queue_pair_disable(), i40e_queue_pair_toggle_rings(),
i40e_xsk_pool_enable() or i40e_xsk_pool_disable() calls
netif_tx_stop_queue() or synchronize_net(). In this driver,
netif_tx_disable() is only called from i40e_down().
For the regular ring, the cleanup then runs with no synchronization
against xmit:
drivers/net/ethernet/intel/i40e/i40e_main.c:i40e_queue_pair_clean_rings() {
i40e_clean_tx_ring(vsi->tx_rings[queue_pair]);
if (i40e_enabled_xdp_vsi(vsi)) {
...
synchronize_rcu();
i40e_clean_tx_ring(vsi->xdp_rings[queue_pair]);
}
...
}
i40e_clean_tx_ring() frees every tx_bi skb, clears tx_bi and the
descriptor ring with memset(), and resets next_to_use. Meanwhile,
i40e_lan_xmit_frame()->i40e_xmit_frame_ring() checks no driver state
before doing this:
first = &tx_ring->tx_bi[tx_ring->next_to_use];
first->skb = skb;
If the cleaner frees that slot, can i40e_tso() or i40e_tx_map() go on to
use a freed skb, or can the skb be freed twice?
The XDP ring is covered by the __I40E_CONFIG_BUSY check in
i40e_xdp_xmit() plus the synchronize_rcu() above. The window is not new
either: the old code already had mdelay(50) before cleanup.
>
[ ... ]
> + return i40e_queue_pair_wait_queues_disabled(vsi, pf_q);
[Severity: High]
What happens when this still returns -ETIMEDOUT? The Tx and XDP Tx
deadline is a fixed 20ms (I40E_TXQ_DISABLE_TIMEOUT_US), and
i40e_pf_rxq_wait() still polls 10 x usleep_range(10, 20). If the regular
Tx queue times out, i40e_queue_pair_wait_queues_disabled() also returns
before it polls the XDP Tx and Rx queues.
The caller does not make cleanup depend on the result:
drivers/net/ethernet/intel/i40e/i40e_main.c:i40e_queue_pair_disable() {
err = i40e_enter_busy_conf(vsi);
...
err = i40e_queue_pair_toggle_rings(vsi, queue_pair, false /* off */);
i40e_clean_rx_ring(vsi->rx_rings[queue_pair]);
i40e_queue_pair_clean_rings(vsi, queue_pair);
i40e_queue_pair_reset_stats(vsi, queue_pair);
return err;
}
So the ring and XSK buffers are released while QENA_STAT may still be
set. __I40E_CONFIG_BUSY is not cleared, and NAPI and the IRQ for the pair
stay disabled.
i40e_xsk_pool_disable() then returns early:
drivers/net/ethernet/intel/i40e/i40e_xsk.c:i40e_xsk_pool_disable() {
if (if_running) {
err = i40e_queue_pair_disable(vsi, qid);
if (err)
return err;
}
clear_bit(qid, vsi->af_xdp_zc_qps);
xsk_pool_dma_unmap(pool, I40E_RX_DMA_ATTR);
...
}
This skips clear_bit(), xsk_pool_dma_unmap() and i40e_queue_pair_enable().
i40e_queue_pair_enable() is the only queue-pair path that clears
__I40E_CONFIG_BUSY. i40e_xsk_pool_enable() has the same early return, and
it leaves the earlier xsk_pool_dma_map() and set_bit(af_xdp_zc_qps) in
place.
xp_disable_drv_zc() only WARNs on this error. xp_release_deferred() then
frees the UMEM, which the device may still reference.
With __I40E_CONFIG_BUSY left set, i40e_watchdog_subtask() and
i40e_reset_subtask() bail out. A later MTU change goes through
i40e_change_mtu()->i40e_vsi_reinit_locked(), which spins forever while
holding rtnl:
while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state))
usleep_range(1000, 2000);
The commit message says the status is polled "before cleaning the rings
and releasing the AF_XDP pool". Nothing makes the cleanup or the pool
release depend on the poll succeeding, though.
Could a link partner sending PAUSE or PFC XOFF frames stall the Tx pipe
for more than 20ms and reach this path? That would give the same
"networking stopped responding" result the commit is trying to fix.
> }
>
> - return ret;
> + /* The whole-VSI enable path brings RX up before TX. */
> + i40e_control_rx_q(pf, pf_q, true);
> + ret = i40e_pf_rxq_wait(pf, pf_q, true);
> + if (ret)
> + return ret;
[Severity: Low]
Is it intended that an Rx enable timeout is now silent here?
i40e_pf_rxq_wait() does not log anything. The old code printed "VSI seid
%d Rx ring %d %sable timeout" in this case. The whole-VSI path in
i40e_vsi_enable_rx() also logs it:
dev_info(&pf->pdev->dev,
"VSI seid %d Rx ring %d enable timeout\n",
vsi->seid, pf_q);
Tx enable failures and all disable failures still log. That makes an XSK
setsockopt failing here with -ETIMEDOUT the only case that leaves nothing
in the kernel log.
> + ret = i40e_control_wait_tx_q(vsi->seid, pf, pf_q, false, true);
> + if (ret || !has_xdp)
> + return ret;
> + return i40e_control_wait_tx_q(vsi->seid, pf, xdp_q, true, true);
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-b4-i40e-xsk-queue-order-v2-1-e14b712d5fc2%40boondocker.io
prev parent reply other threads:[~2026-12-04 23:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 22:53 [PATCH net v2] i40e: stop XSK queue pairs in VSI shutdown order Matt Thompson
2026-12-03 22:53 ` Matt Thompson via B4 Relay
2026-12-04 9:49 ` Maciej Fijalkowski
2026-12-04 14:52 ` Loktionov, Aleksandr
2026-12-04 22:53 ` sashiko-bot
2026-12-04 23:47 ` netdev-bot+sashiko [this message]
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=179642803419.3146.8192971095663256302@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=matt@boondocker.io \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.