From: netdev-bot+sashiko@kernel.org
To: sagar.cheluvegowda@oss.qualcomm.com
Cc: j.raczynski@samsung.com, maxime.chevallier@bootlin.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com,
alexandre.torgue@foss.st.com, netdev@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
cs0617.lee@samsung.com, k.domagalski@samsung.com,
k.tegowski@samsung.com, abhishek.chauhan@oss.qualcomm.com,
lorenzo.bianconi@oss.qualcomm.com, sarosh.hasan@oss.qualcomm.com,
hongmei.xu@oss.qualcomm.com
Subject: Re: [PATCH net-next v2 2/3] net/stmmac/dwxgmac: Extend MTL/DMA support to 16 queues
Date: Wed, 25 Nov 2026 00:09:22 +0000 [thread overview]
Message-ID: <179556536283.3135.8042221243416854963@kernel.org> (raw)
In-Reply-To: <20261124000415.4067701-3-sagar.cheluvegowda@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 2
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] dwxgmac2_tx_queue_prio() in
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c still only handles…
- [Low] The commit message says "The only caller,
stmmac_rx_queue_dma_chan_map(), walks the queues below…
- [Low] The commit body of "net/stmmac/dwxgmac: Extend MTL/DMA support to
16 queues" contains revision history that only makes sense on the…
--
net/stmmac/dwxgmac: Extend MTL/DMA support to 16 queues
This commit extends dwxgmac2_map_mtl_to_dma() to cover 16 MTL/DMA queues.
It adds the XGMAC_MTL_RXQ_DMA_MAP2 and XGMAC_MTL_RXQ_DMA_MAP3 registers
ahead of raising the maximum queue count. Queue indices that are out of
range now trigger a WARN_ON() and return.
> The only caller, stmmac_rx_queue_dma_chan_map(), walks the queues
> below rx_queues_to_use, which the devicetree parser limits to
> MTL_MAX_RX_QUEUES. A queue above 15 is therefore a driver bug, not
> bad input.
[Severity: Low]
Is stmmac_rx_queue_dma_chan_map() really the only caller?
dwxgmac2_rss_configure() in dwxgmac2_core.c also calls
dwxgmac2_map_mtl_to_dma() directly. It does not go through the
stmmac_map_mtl_to_dma() callback:
dwxgmac2_rss_configure() {
...
for (i = 0; i < num_rxq; i++)
dwxgmac2_map_mtl_to_dma(hw, i, XGMAC_QDDMACH);
...
}
Here num_rxq is rx_queues_to_use. That value can also come from ethtool
set_channels, not only from the devicetree parser.
By the end of the series both paths are limited to at most 16 queues, so
the WARN_ON() still can't fire from either one. The reasoning in the
message is what is off, not the behaviour.
Could the commit message mention this second caller, given that the
WARN_ON() justification rests on the single-caller argument?
> bad input. v2 reported it with netdev_err() through hw->priv_data,
> but that back-pointer was only added by v2 1/3, which this series
> replaces, and a log line from a void callback does not stop the
> caller from carrying on. Use WARN_ON() instead: it needs no
> net_device and its backtrace points at the caller.
[Severity: Low]
This isn't a bug, but this text refers to "v2 1/3" and to an
hw->priv_data back-pointer. Neither will exist in the tree once the
patch is merged.
Could the version history go below the --- separator? The technical
reason for WARN_ON() (it needs no net_device and the backtrace points at
the caller) can stay in the message.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
> index e50c0f4c482d0..8aa69647a207d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
> @@ -259,9 +259,26 @@ static void dwxgmac2_map_mtl_to_dma(struct mac_device_info *hw, u32 queue,
> void __iomem *ioaddr = hw->pcsr;
> u32 value, reg;
>
> - reg = (queue < 4) ? XGMAC_MTL_RXQ_DMA_MAP0 : XGMAC_MTL_RXQ_DMA_MAP1;
> - if (queue >= 4)
> + switch (queue) {
> + case 0 ... 3:
> + reg = XGMAC_MTL_RXQ_DMA_MAP0;
> + break;
> + case 4 ... 7:
> + reg = XGMAC_MTL_RXQ_DMA_MAP1;
> queue -= 4;
> + break;
> + case 8 ... 11:
> + reg = XGMAC_MTL_RXQ_DMA_MAP2;
> + queue -= 8;
> + break;
> + case 12 ... 15:
> + reg = XGMAC_MTL_RXQ_DMA_MAP3;
> + queue -= 12;
> + break;
> + default:
> + WARN_ON(1);
> + return;
> + }
[Severity: High]
The commit message says the dwxgmac functions are being prepared for 16
queues before the macro is raised. However, dwxgmac2_tx_queue_prio() in
the same file still handles only 8 entries:
dwxgmac2_tx_queue_prio() {
...
reg = (queue < 4) ? XGMAC_TC_PRTY_MAP0 : XGMAC_TC_PRTY_MAP1;
if (queue >= 4)
queue -= 4;
value = readl(ioaddr + reg);
value &= ~XGMAC_PSTC(queue);
value |= (prio << XGMAC_PSTC_SHIFT(queue)) & XGMAC_PSTC(queue);
...
}
At this patch ARRAY_SIZE(tx_queues_cfg) is still 8. The later patch
"include/stmmac: Increase max DMA/MTL channel count from 8 to 16" makes
it 16. After that, can the mqprio paths in stmmac_tc.c call this
function with queue indices 8 to 15?
Both tc_mqprio_config_queue_prio() and stmmac_reset_tc_mqprio() run this
loop:
for (i = 0; i < ARRAY_SIZE(priv->plat->tx_queues_cfg); i++) {
...
if (i < priv->plat->tx_queues_to_use)
stmmac_tx_queue_prio(priv, priv->hw, prio, i);
}
tx_queues_to_use can be 16 there. The devicetree limit is
MTL_MAX_TX_QUEUES, and XGMAC_HWFEAT_TXQCNT is a 4-bit field plus 1.
Neither loop is bounded by qopt->num_tc or dma_cap.numtc.
For i = 8 to 15, queue is 4 to 11 after the subtraction. The expression
prio << XGMAC_PSTC_SHIFT(queue) then shifts a u32 by 32 to 88 bits. For
i >= 12, XGMAC_PSTC(queue) expands to GENMASK() with bit positions of 64
and above. Both shifts are undefined behaviour, and UBSAN reports them
as shift-out-of-bounds.
The hardware also ends up programmed wrongly:
- For i = 8 to 11, the mask truncates to 0 in the u32, so nothing is
written.
- For i = 12 to 15 on x86-64 and arm64, the shift counts wrap. The
write then likely lands on the PSTC4 to PSTC7 fields of
XGMAC_TC_PRTY_MAP1 and overwrites the priorities already set for
TCs 4 to 7, usually with 0.
A CAP_NET_ADMIN user triggers this by adding an mqprio qdisc with
hardware offload:
ndo_setup_tc
-> tc_setup_dwmac510_mqprio()
-> tc_mqprio_config_queue_prio()
-> stmmac_tx_queue_prio()
-> dwxgmac2_tx_queue_prio()
XGMAC uses dwmac510_tc_ops, whose setup_mqprio is
tc_setup_dwmac510_mqprio(). Removing the qdisc runs the same loop
through stmmac_reset_tc_mqprio().
The earlier patch "net: stmmac: separate the TC count from the queue
count on XGMAC" bounds the rx_queue_prio callers and
stmmac_mac_config_tx_queues_prio(). These two mqprio callers seem to
have been missed, so writes to TC_PRTY fields for TCs that don't exist
can still happen on XGMAC.
Should these loops be bounded by the TC count? Alternatively, should
dwxgmac2_tx_queue_prio() reject queue >= 8?
>
> value = readl(ioaddr + reg);
> value &= ~XGMAC_QxMDMACH(queue);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124000415.4067701-1-sagar.cheluvegowda%40oss.qualcomm.com
next prev parent reply other threads:[~2026-11-25 0:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 0:04 [PATCH net-next v2 0/3] net: stmmac: support up to 16 MTL/DMA queues on XGMAC Sagar Cheluvegowda
2026-11-24 0:04 ` [PATCH net-next v2 1/3] net: stmmac: separate the TC count from the queue count " Sagar Cheluvegowda
2026-11-25 0:09 ` netdev-bot+sashiko
2026-11-24 0:04 ` [PATCH net-next v2 2/3] net/stmmac/dwxgmac: Extend MTL/DMA support to 16 queues Sagar Cheluvegowda
2026-11-25 0:09 ` netdev-bot+sashiko [this message]
2026-11-24 0:04 ` [PATCH net-next v2 3/3] include/stmmac: Increase max DMA/MTL channel count from 8 to 16 Sagar Cheluvegowda
2026-11-25 0:09 ` netdev-bot+sashiko
-- strict thread matches above, loose matches on Subject: below --
2026-06-01 16:25 [PATCH net-next v2 0/3] xgmac: Support for 16 MTL/DMA queues Jakub Raczynski
[not found] ` <CGME20260601162618eucas1p14be36902c4948647448160da08aaebc5@eucas1p1.samsung.com>
2026-06-01 16:25 ` [PATCH net-next v2 2/3] net/stmmac/dwxgmac: Extend MTL/DMA support to 16 queues Jakub Raczynski
2026-06-03 14:23 ` Larysa Zaremba
2026-10-02 18:40 ` Sagar Cheluvegowda
2026-10-05 12:13 ` Jakub Raczynski
2026-10-05 18:50 ` Sagar Cheluvegowda
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=179556536283.3135.8042221243416854963@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=abhishek.chauhan@oss.qualcomm.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=cs0617.lee@samsung.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hongmei.xu@oss.qualcomm.com \
--cc=j.raczynski@samsung.com \
--cc=k.domagalski@samsung.com \
--cc=k.tegowski@samsung.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=lorenzo.bianconi@oss.qualcomm.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sagar.cheluvegowda@oss.qualcomm.com \
--cc=sarosh.hasan@oss.qualcomm.com \
/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
all inboxes | Powered by JetHome®