Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: aiyengar1990@gmail.com
Cc: maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, wens@kernel.org, jernej.skrabec@gmail.com,
	samuel@sholland.org, mcoquelin.stm32@gmail.com,
	alexandre.torgue@foss.st.com, clabbe.montjoie@gmail.com,
	netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, rmk+kernel@armlinux.org.uk,
	nb@tipi-net.de, stable@vger.kernel.org
Subject: Re: [PATCH net v2 2/2] net: stmmac: dwmac-sun8i: Limit the MTU to 2018
Date: Mon, 23 Nov 2026 10:06:59 +0000	[thread overview]
Message-ID: <179542841933.3135.13344268634308620175@kernel.org> (raw)
In-Reply-To: <20261122-sun8i-emac-mtu-limit-v2-2-c4081e5b83cf@gmail.com>

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

Critical: 0 · High: 0 · Medium: 1 · 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).

- [Medium] The patch hard-codes a 2044-byte limit as an MTU cap in one
  glue driver.
- [Low] The commit message and the code do not cover the same hardware.
- [Low] The 2044-byte fill limit was measured on the H616, an arm64 SoC
  where NET_IP_ALIGN is 0 (arch/arm64/include/asm/processor.h:17).

--

net: stmmac: dwmac-sun8i: Limit the MTU to 2018

This commit caps the maximum MTU of the dwmac-sun8i glue driver by setting
plat_dat->maxmtu in sun8i_dwmac_probe(). The cap makes a frame with two
VLAN tags and the FCS fit in 2044 bytes. According to the commit message,
the H616 RX DMA fills only 2044 bytes of a buffer.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 2ece7ba9dd73b..ec401cae8187b 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -1208,6 +1208,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
>  	plat_dat->mac_setup = sun8i_dwmac_setup;
>  	plat_dat->tx_fifo_size = 4096;
>  	plat_dat->rx_fifo_size = 16384;
> +	plat_dat->maxmtu = 2044 - ETH_HLEN - 2 * VLAN_HLEN - ETH_FCS_LEN;

[Severity: Low]
The commit message says:

  The H616 RX DMA fills only 2044 bytes of a buffer, so frames of 2045 to
  2047 bytes, allowed by the previous patch, are dropped.

This assignment in sun8i_dwmac_probe() does not check gmac->variant. So
it applies to every entry in sun8i_dwmac_match[]:

  allwinner,sun8i-h3-emac
  allwinner,sun8i-v3s-emac
  allwinner,sun8i-a83t-emac
  allwinner,sun8i-r40-gmac
  allwinner,sun50i-a64-emac
  allwinner,sun50i-h6-emac
  allwinner,sun50i-h616-emac1

H616 EMAC0 is covered too, through the a64-emac fallback. On all of these
max_mtu drops from 2021 to 2018.

Has the 2044 byte limit been seen on the non-H616 parts as well? If it
belongs to the whole sun8i EMAC IP, could the commit message say so? If
not, should the cap be per variant, for example kept in struct
emac_variant?

The Fixes: tag points to 9f93ac8d4085 ("net-next: stmmac: Add
dwmac-sun8i"). That commit added H3/A83T/A64 support, and H616 was not
supported at the time. Doesn't the tag contradict the H616-only
explanation?

The phrase "allowed by the previous patch" also seems misleading. Before
"net: stmmac: Limit the MTU of normal descriptors to one buffer", max_mtu
for normal descriptors was SKB_MAX_HEAD(), about 3712. So frames of 2045
to 2047 bytes were allowed long before that patch. Once the series is
merged, "the previous patch" will also mean little to stable backporters.

[Severity: Medium]
Is 2044 really a sun8i-specific limit? It could also come from the RX
buffer size that the shared normal descriptor code programs.

drivers/net/ethernet/stmicro/stmmac/common.h states:

/* RX Buffer size must be multiple of 4/8/16 bytes */
#define BUF_SIZE_16KiB 16368
#define BUF_SIZE_8KiB 8188

But ndesc_init_rx_desc() in norm_desc.c still programs 2047:

	bfsize1 = min(bfsize, BUF_SIZE_2KiB - 1);
	p->des1 |= cpu_to_le32(bfsize1 & RDES1_BUFFER1_SIZE_MASK);

2047 is not a multiple of 4, and 2047 & ~3 is exactly 2044.

__stmmac_dvr_probe() also still sets this for every ndesc_ops platform:

	else if (priv->hw->desc == &ndesc_ops)
		ndev->max_mtu = BUF_SIZE_2KiB - 1 - ETH_HLEN - 2 * VLAN_HLEN -
				ETH_FCS_LEN;

Other normal descriptor users, such as older GMAC 3.x and MAC100 cores
without enhanced descriptors, would still advertise an MTU of 2021. The
largest frames at that MTU need the out-of-spec 2047 byte buffer. If that
hardware handles an unaligned RBS1 the way the H616 does, those frames
would span descriptors and be silently discarded. On 64-bit or 128-bit
buses the aligned size would be 2040 or 2032, so the gap would be larger.

Could ndesc_init_rx_desc() program an aligned RBS1 instead, with the
ndesc max_mtu in __stmmac_dvr_probe() derived from it? That would remove
the need for the hard-coded 2044 here.

Neither the code nor the commit message explains where 2044 comes from.

[Severity: Low]
Was 2044 measured only on the arm64 H616? There NET_IP_ALIGN is 0, so
RX buffers start word-aligned at page + NET_SKB_PAD.

On the 32-bit sun8i SoCs (H3/H2+, V3s, A83T, R40), arch/arm does not
override NET_IP_ALIGN, so the default of 2 applies. stmmac_rx_offset()
includes it in the DMA buffer start:

static unsigned int stmmac_rx_offset(struct stmmac_priv *priv)
{
	if (stmmac_xdp_is_enabled(priv))
		return XDP_PACKET_HEADROOM + NET_IP_ALIGN;

	return NET_SKB_PAD + NET_IP_ALIGN;
}

So every RX buffer on those SoCs starts 2 bytes into a 32-bit word.

Suppose the EMAC DMA rounds its fill relative to the start address and
not only the size field. Could the usable fill on the 32-bit variants
then be below 2044? Maximum-size frames at MTU 2018 would span
descriptors and be silently dropped again.

Could the commit message say which SoCs and buffer alignments the 2044
constant was checked on?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122-sun8i-emac-mtu-limit-v2-0-c4081e5b83cf%40gmail.com

  parent reply	other threads:[~2026-11-23 10:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  9:13 [PATCH net v2 0/2] net: stmmac: Limit the MTU of normal descriptors to one buffer Arun Iyengar via B4 Relay
2026-11-22  9:13 ` [PATCH net v2 1/2] " Arun Iyengar via B4 Relay
2026-11-22 16:27   ` Nicolai Buchwitz
2026-11-22 16:56     ` Chen-Yu Tsai
2026-11-23 10:06   ` netdev-bot+sashiko
2026-11-22  9:13 ` [PATCH net v2 2/2] net: stmmac: dwmac-sun8i: Limit the MTU to 2018 Arun Iyengar via B4 Relay
2026-11-22 11:39   ` Chen-Yu Tsai
2026-11-22 16:31     ` Nicolai Buchwitz
2026-11-22 16:36       ` Maxime Chevallier
2026-11-22 16:40         ` Nicolai Buchwitz
2026-11-22 18:56     ` Andrew Lunn
2026-11-22 16:33   ` Nicolai Buchwitz
2026-11-23 10:06   ` netdev-bot+sashiko [this message]
2026-11-22 10:48 ` [PATCH net v2 0/2] net: stmmac: Limit the MTU of normal descriptors to one buffer Chen-Yu Tsai

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=179542841933.3135.13344268634308620175@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=aiyengar1990@gmail.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=clabbe.montjoie@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=samuel@sholland.org \
    --cc=stable@vger.kernel.org \
    --cc=wens@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox