* [PATCH net] net: stmmac: fix num tx queues in stmmac_xdp_get_tx_queue()
@ 2026-11-17 15:51 Lorenzo Bianconi
2026-11-17 15:57 ` netdev-bot+sinfo
2026-11-18 15:52 ` sashiko-bot
0 siblings, 2 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2026-11-17 15:51 UTC (permalink / raw)
To: Maxime Chevallier, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, Stanislav Fomichev, Vladimir Oltean, Furong Xu
Cc: netdev, linux-arm-kernel, bpf, Lorenzo Bianconi
The TX queue returned by stmmac_xdp_get_tx_queue() is passed to
netdev_get_tx_queue(), so it must be lower than dev->real_num_tx_queues.
Since mqprio offload can reduce real_num_tx_queues below
plat->tx_queues_to_use, wrapping the CPU index by plat->tx_queues_to_use
can select a TX queue that is not part of the real queue set when the
offload is active.
Use priv->xmit_qdisc.num_tx_queues instead, which is the value
stmmac_hw_setup() installs as real_num_tx_queues and is guaranteed to
never exceed plat->tx_queues_to_use.
Fixes: 195e4f409a40 ("net: stmmac: support fp parameter of tc-mqprio")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 25894771e9e9..cf87afd27343 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;
}
---
base-commit: 5e9b2ad9b8384cd3c417cd5e2c3bc7eee4a72791
change-id: 20261117-stmmac-fix-xdp_get_tx_queue-0eda31da641f
Best regards,
--
Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: stmmac: fix num tx queues in stmmac_xdp_get_tx_queue()
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
1 sibling, 1 reply; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-17 15:57 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Maxime Chevallier, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, Stanislav Fomichev, Vladimir Oltean, Furong Xu,
netdev, linux-arm-kernel, bpf
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: stmmac: fix num tx queues in stmmac_xdp_get_tx_queue()
2026-11-17 15:57 ` netdev-bot+sinfo
@ 2026-11-17 20:30 ` Lorenzo Bianconi
0 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2026-11-17 20:30 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: Maxime Chevallier, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, Stanislav Fomichev, Vladimir Oltean, Furong Xu,
netdev, linux-arm-kernel, bpf
[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
I spotted the issue during code development
>
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
This is a theoretical issue found during code inspection
>
> - What hardware the change was tested on. For driver fixes please
> mention the device (and if relevant firmware version) used for
> testing, or say that the change was not tested on real hardware.
I tested it on a Qualcomm rb3-gen2 board.
Regards,
Lorenzo
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
>
> *IMPORTANT*: If you do repost (for other reasons) - please include
> the relevant info in the cover letter or commit messages.
> --
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: stmmac: fix num tx queues in stmmac_xdp_get_tx_queue()
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-18 15:52 ` sashiko-bot
1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-18 15:52 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: bpf
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.
[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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-18 15:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox