From: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net] net: stmmac: fix num tx queues in stmmac_xdp_get_tx_queue()
Date: Wed, 18 Nov 2026 23:27:24 +0100 [thread overview]
Message-ID: <av4mTCg0yVhGXQdU@lore-qca> (raw)
In-Reply-To: <sashiko-outbox-221383@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 3939 bytes --]
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] net: stmmac: race on num_tx_queues in
> stmmac_xdp_get_tx_queue() skips txtimer
> It also noticed 1 related pre-existing issue this patch does not
> introduce:
> - [High] net: stmmac: unchecked return value of
> netif_set_real_num_tx_queues() [1]
> --
>
> commit f55af370614a4d0bb79d7ac40f036cd36c0c9e78
> Author: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
>
> net: stmmac: fix num tx queues in stmmac_xdp_get_tx_queue()
>
> This commit bounds the CPU-based TX queue selection in
> stmmac_xdp_get_tx_queue() by priv->xmit_qdisc.num_tx_queues instead of
> priv->plat->tx_queues_to_use to stay within dev->real_num_tx_queues when
> tc-mqprio offload is active.
>
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > index 25894771e9e9f..cf87afd273439 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > @@ -5408,13 +5408,14 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
> > static int stmmac_xdp_get_tx_queue(struct stmmac_priv *priv,
> > int cpu)
> > {
> > + unsigned int num_tx_queues = priv->xmit_qdisc.num_tx_queues;
> > int index = cpu;
> >
> > if (unlikely(index < 0))
> > index = 0;
> >
> > - while (index >= priv->plat->tx_queues_to_use)
> > - index -= priv->plat->tx_queues_to_use;
> > + while (index >= num_tx_queues)
> > + index -= num_tx_queues;
> >
> > return index;
> > }
>
> [Severity: Medium]
> Can stmmac_finalize_xdp_rx() arm txtimer on the wrong TX queue if
> priv->xmit_qdisc.num_tx_queues changes during an RX NAPI poll?
>
> Unlike priv->plat->tx_queues_to_use, priv->xmit_qdisc.num_tx_queues is
> updated on a running interface by tc_setup_dwmac510_mqprio() and
> stmmac_reset_tc_mqprio() without stopping RX NAPI:
>
> CPU0 CPU1 (<softirq>)
> stmmac_rx()
> stmmac_xdp_xmit_back()
> q = stmmac_xdp_get_tx_queue()
> stmmac_xdp_xmit_xdpf(..., q, ...)
> tc_setup_dwmac510_mqprio()
> priv->xmit_qdisc.num_tx_queues = n
> stmmac_finalize_xdp_rx()
> q' = stmmac_xdp_get_tx_queue()
> stmmac_tx_timer_arm(..., q')
> <-- q' != q; q's txtimer not armed
>
> Because stmmac_xdp_xmit_xdpf() only sets interrupt-on-completion every
> priv->tx_coal_frames[queue] frames, uncoalesced XDP_TX descriptors queued
> on the old queue can be left without a completion interrupt or timer
> cleanup.
ack, right. I will look into this issue.
Regards,
Lorenzo
>
> [Severity: High]
> This problem wasn't introduced by this patch, but stmmac_hw_setup()
> ignores the return value of netif_set_real_num_tx_queues() [1]:
>
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_hw_setup() {
> ...
> /* Configure real RX and TX queues */
> netif_set_real_num_rx_queues(dev, priv->plat->rx_queues_to_use);
> netif_set_real_num_tx_queues(dev, priv->xmit_qdisc.num_tx_queues);
>
> /* Start the ball rolling... */
> stmmac_start_all_dma(priv);
> ...
> }
>
> Can netif_set_real_num_tx_queues() fail with -ENOMEM during stmmac_open()
> or stmmac_resume(), leaving dev->real_num_tx_queues out of sync with
> priv->xmit_qdisc.num_tx_queues while DMA is started anyway?
>
> [1] https://sashiko.dev/#/bug/linux-1bc77f7b-c8d8-4341-a8a0-49092e607be6
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261117-stmmac-fix-xdp_get_tx_queue-v1-1-4cd74ee7a76c@oss.qualcomm.com?part=1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2026-11-18 22:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 15:51 [PATCH net] net: stmmac: fix num tx queues in stmmac_xdp_get_tx_queue() Lorenzo Bianconi
2026-11-17 15:57 ` netdev-bot+sinfo
2026-11-17 20:30 ` Lorenzo Bianconi
2026-11-18 15:52 ` sashiko-bot
2026-11-18 22:27 ` Lorenzo Bianconi [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=av4mTCg0yVhGXQdU@lore-qca \
--to=lorenzo.bianconi@oss.qualcomm.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.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