๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20876

Re: [PATCH net v2 2/2] net: stmmac: dwmac-sun8i: Limit the MTU to 2018

#20876
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 10:06
137 lines
13647 bytes
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
Technical Details
Message-ID: <179542841933.3135.13344268634308620175@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369216-linux-kernel-netdev=dewy.ru
References: <20261122-sun8i-emac-mtu-limit-v2-2-c4081e5b83cf@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369216-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179542841933.3135.13344268634308620175@kernel.org>
References: <20261122-sun8i-emac-mtu-limit-v2-2-c4081e5b83cf@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3847875"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:jyD3CzXUqI7vajZGnmpcQXkIKho= sha256:ysZTaGEeVsMTfMZchh5GWAUSB84xZ/YCGQYLcngWY5Y=
	sha1:QRxp/IZ6YyzVsgZ3CeY1C44Fg18= sha256:Alq3sAPva1xMw+FIM0/Yube57GrYjqAGJTmrRZ3EiVo=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id E03F9125D99; Mon, 23 Nov 2026 13:07:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id ZiY1DpvsJTNe;
	Mon, 23 Nov 2026 13:07:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-369216-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id DF62C125D9A; Mon, 23 Nov 2026 13:07:07 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id DC3E1603682; Mon, 23 Nov 2026 10:07:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795428422;
	b=w8I4feZGOzppTkCM9tU8kZCHU0N4YC8T9/5ne5i+aTgqyd9OFjJOrPOH84v6afN+F/tc
	 CMVxfW67BL2BxGz+W/jwEe/oPjLmvJkx6+39Y2f4RmI0g6P0Mqg0fOxoVYY8aWSLkz3Jz
	 E0l6Xw3jnUGFF4qkT40Ka+SAiqudZXpFSxaWON8eZRlSa3bvSytEeviVqMiQ/IqpqqGgY
	 PvSgCqhNXGO1HQHFYrSBQSwcl3+HNr6RWDxmkJe2o4HdRWkGvlUDWq9FwqPeygJlUe+H6
	 9Z5XFn589mxIdAYTW9RevtqdKAPLv4oe9/fzUguVDZ9YuLlgQVMGZomce7eP5VfsrQQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795428422;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=6dWrzTEqrK6nKc1TJcUidD5GK19M6KlUED1psMXUX8s=;
	b=mjPNyZ97s967ph1K9vhlDV1uy/bm19tJJK12r68FWZ4YjwUWrFF9NaBLouxFc+lB/IKB
	 CMaYLycje9gNsJshRiDWWdfjeU2aa9qnWq3EQ3rLECW678Z+ithTCo+A2Kv2iDk1VsvNR
	 IdCjRapOn1QZxn4vWONFmFsF+ufc3zYP6J4/nGsymdPSdRKn72qiWsbi4/fWTuGwnj5EH
	 5mU7whHQghjz5cW+MW2enGqujkfwLANSL07copvFEeFYKTjweDtXFTM7HiiAhoTOx0TFl
	 VkLhk0Sc3AYpUKCshXDU77pJI91Qng3IlCGVNR4F5LQYz/XZwKVS3h1SDmrBBTUocbA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Dsrkcxhg;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id F3878606A32C;
	Mon, 23 Nov 2026 10:07:01 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Dsrkcxhg
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795428421;
	b=b28qYGLYXaQtzv+PGpoB1otEYuOY4RT97ZGfkozXqDRRsmWaD8DhZBVmN2RXGORavjFv
	 vE98YnjozeWrF8yzS+ks+nGKJb1/Ve1Um5/D5FHu+6n8YKj0x3Zhk83pN7eXsOAlsoNU4
	 htjCvY7gSf9ZsiFcmxbmAB0u4rWijsdPWsGwHj1ihXyqYaQ325zOLBHnZAvJyT5RvvllX
	 WZyPBBmT2nfrMDnxRDn+WTWwPRAFz+u4T/+ilyTEPMVNUE6N+bNMpsugaOOMzanuYHDo1
	 nZgNye7HY7C42PzPcRn5sSMYvUTe2nstXSy2jmsWZrd4pWF/ANO7tiaTHj2jxGqLDPA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795428421;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=6dWrzTEqrK6nKc1TJcUidD5GK19M6KlUED1psMXUX8s=;
	b=w7XYKvWE9KY474PjntLdJszjUKauXQ2oD0tQLhO4ehcd4hEU1tUT9Xt1SnZdh2eIwKSK
	 9nnBP+U0UIqU2yvRjGqZiXWaVJDsiyrevWOjrigHvpQHcNaN6thFZQ084wa5gg9vUJ1+H
	 VNoMt0I+RIVoyYe58KNYrwgv1rwZSIyi/Y/7rd97HqLwmtGKiaJnwhSOOBoDNjrbT0VgO
	 Bl8j199BxWif3pMwgy/xnKewTI7dGy3rRuSrmYv16StWk8zj2iKrX523iyHlxvWdS2K1c
	 jXXiwMLBn05UEmEn8hNlE00VG0LoIVYXgexdfH/qQFn1AJsOo4CUpVWc8fjzIpahEHw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Dsrkcxhg;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2048D606A336;
	Mon, 23 Nov 2026 10:07:01 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8E551F000D8;
	Mon, 23 Nov 2026 10:06:59 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795428420;
	bh=6dWrzTEqrK6nKc1TJcUidD5GK19M6KlUED1psMXUX8s=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Dsrkcxhg1JctUS6kzFQxFlyk5X67Z+ZI3nDmladFozerpVBrQpgk9Sy12Ec05yQ6Z
	 Nz80e8sE9yrbv0SpzoPuusPH3f0gkuQDAuYYz9gWv8vmMUkdX4Vlcn7kxfVASgeDF+
	 lGFtldgSDVgsGG+ts9EiN0O6EpuT40RHaN4F03ix8sQf8zNWzh76Ndu4s2EBeFnWBn
	 XqHMVsnLzjl50UIrFqDGL5tzwgSfFimzMLZEw7hlTlyKBENHbPkPWaNujOKAB+x/cx
	 zZ7lPl1ffVVWTVMyLuZEhmxPRoVytWlmDpyaGNrUcNVFrJq3qLg9qTzsAeE3zwBB3Q
	 mxYTFXlNGjYKA==
X-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
X-In-Reply-To: <20261122-sun8i-emac-mtu-limit-v2-2-c4081e5b83cf@gmail.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list