All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arun Iyengar" <aiyengar1990@gmail.com>
Cc: linux-sunxi@lists.linux.dev
Subject: Re: [PATCH net v2 1/2] net: stmmac: Limit the MTU of normal descriptors to one buffer
Date: Mon, 23 Nov 2026 09:13:54 +0000	[thread overview]
Message-ID: <sashiko-outbox-228951@kernel.org> (raw)
In-Reply-To: <20261122-sun8i-emac-mtu-limit-v2-1-c4081e5b83cf@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: stmmac: unaligned 2047-byte RX buffer limit in
  __stmmac_dvr_probe()
--

commit 1afb1c292cbb61be8075f08aa85d66c725abdea3
Author: Arun Iyengar <aiyengar1990@gmail.com>

net: stmmac: Limit the MTU of normal descriptors to one buffer

This commit limits ndev->max_mtu for normal descriptors (ndesc_ops) so
that an Ethernet frame with two VLAN tags and the FCS fits within a
single 2047-byte buffer.

Link: https://lore.kernel.org/r/E1vLJcL-0000000ExBL-0GFe@rmk-PC.armlinux.org.uk [1]

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index a685ce4638f61..2a27e1e7f9b9f 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -8247,6 +8247,9 @@ static int __stmmac_dvr_probe(struct device *device,
>  		ndev->max_mtu = XGMAC_JUMBO_LEN;
>  	else if (priv->plat->enh_desc || priv->synopsys_id >= DWMAC_CORE_4_00)
>  		ndev->max_mtu = JUMBO_LEN;
> +	else if (priv->hw->desc == &ndesc_ops)
> +		ndev->max_mtu = BUF_SIZE_2KiB - 1 - ETH_HLEN - 2 * VLAN_HLEN -
> +				ETH_FCS_LEN;
>  	else
>  		ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN);

[Severity: Medium]
Can RX DMA fill all 2047 bytes (BUF_SIZE_2KiB - 1) of a normal descriptor
buffer when ndev->max_mtu is set to 2021?

As noted in common.h ("RX Buffer size must be multiple of 4/8/16 bytes"),
DWMAC RX DMA transfers bus-width words, so a buffer programmed to
BUF_SIZE_2KiB - 1 in ndesc_init_rx_desc() can hold at most 2044, 2040, or
2032 bytes depending on the 32/64/128-bit DMA bus width.  When a frame of
2045..2047 bytes arrives, Buffer 1 fills without setting
RDES0_LAST_DESCRIPTOR, causing the frame to be dropped in chain mode or
to spill into Buffer 2 in ring mode (where ndesc_rx_set_on_ring() sets
RBS2 to 1 while p->des3 is 0).

Also, allowing an MTU in 2001..2021 causes dwmac1000_core_init() to set
GMAC_CONTROL_JE (mtu > 2000), enabling reception of 9018-byte jumbo
frames that cannot fit in a single normal descriptor buffer.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261122-sun8i-emac-mtu-limit-v2-0-c4081e5b83cf@gmail.com?part=1

  parent reply	other threads:[~2026-11-23  9:13 UTC|newest]

Thread overview: 19+ 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 ` Arun Iyengar
2026-11-22  9:13 ` [PATCH net v2 1/2] " Arun Iyengar via B4 Relay
2026-11-22  9:13   ` Arun Iyengar
2026-11-22 16:27   ` Nicolai Buchwitz
2026-11-22 16:56     ` Chen-Yu Tsai
2026-11-23  9:13   ` sashiko-bot [this message]
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  9:13   ` Arun Iyengar
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-24 14:51       ` Maxime Chevallier
2026-11-22 18:56     ` Andrew Lunn
2026-11-22 16:33   ` Nicolai Buchwitz
2026-11-23 10:06   ` netdev-bot+sashiko
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=sashiko-outbox-228951@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aiyengar1990@gmail.com \
    --cc=linux-sunxi@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.