From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796307513; b=N95dgXbYCdfSnOY8CbQq6dRLE3+Yu/nAuAOR8v4rJ+bVKb5OEAYJyyhbne3z454O5zqb RIj+3bBB9tV0BomCXJSI49oeHCIc5lyPo8pA7tUjQgzhueYzw1mBMLUX/vVKF59+OpSH9 Q3edt5V+6zCQctTPa7cpCsAOpmaVbhdNhaitYvzeLmuYQDnDicsdf8ppHHLYz6q6GB19U LX8eI8ig6gfTeW6Yt81ylrK3ZzdgeiE1Vewnn+mCGiCnHyS2/qTegOHdIEZbcEFGDYV12 tF9MNPESfUIa5uu3cXqY2EvGMmoTd3auS9wXTCgSUcHkJrldIutoM32BTnEw4W6BNNw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796307513; 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=u+veEnAi3CYA+YDhfhTIcKtMSNk7oFruAsOrd7Y7hto=; b=1XD5DEmw8Qhdg3UOzWMVulB0ZfH6izQHndTvfY1pxN0vX95eKZN/HUKN6HY3VEadg7Z9 jwp1ePssMZQgnAk60HEOVkWqzt4Ig3Lo4aUu0XUFTLJMXKx8usZekKP1J7qc3CQCg2s8E Y1/XlyNVqj5h5srZCWp/MNrsKABVtVtzEsS/o4V8/YmfwBLAHKzcTvGG29gHZT5ltAw7c VljeHapz3GR9VIzH7zS4MHjpiFCJ9BgK+GpIIUmHjuSX/+yHWxh6tXLUiZYhDGUMzHJk0 1s3yCcH8WWMcOen9ueIk14aD1we+bEko2NtzZHLt1sMuM5vvaZNZ8uIl6oXGlpTkSMg== 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=deODNlWr; arc=none smtp.remote-ip=100.103.45.18 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 350BF606A32C; Thu, 3 Dec 2026 14:18:32 +0000 (UTC) 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=deODNlWr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58C6D1F0089C; Thu, 3 Dec 2026 14:18:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796307512; bh=u+veEnAi3CYA+YDhfhTIcKtMSNk7oFruAsOrd7Y7hto=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=deODNlWrVVQdkVupcWmuo5sakElPvTuLMPUfYj6/I0QBI/RkXb4cj0nWki6+FBUCC OqHKjVk/VruQvxEwYIoGRFThB9kzk+ZKPwVtXS/LHM7i7AIwCV1mZC4TkysBhyrI++ Se/H5okHypERjKJDLjiF/q7EYRCukyLucwBLchy3hVjYG4IhZNYGE7Ai7ukjGESspp JmOPkEQBj/SmQPixWJnwj8B/HjeTNpf/Fsfc3fUgq7C3EO6daVD8Dlwhz2AJwNUA0E bRpPvlz0ON7RPlDQ2ZzdvaKO1RwGKE2BDgWTBOts0hiMk8NHVj0RiC4flYXqHuV+yk 44cFYsPpgYgxQ== Subject: Re: [PATCH net-next v9 2/2] net: ethernet: mtk_eth_soc: add 9K jumbo From: netdev-bot+sashiko@kernel.org To: sandeeph@loljews.com Cc: netdev@vger.kernel.org, nbd@nbd.name, lorenzo@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, linux@armlinux.org.uk, daniel@makrotopia.org, mason-cw.chang@mediatek.com, frank-w@public-files.de, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Thu, 03 Dec 2026 14:18:30 +0000 Message-ID: <179630751086.3146.15182958236912809367@kernel.org> In-Reply-To: References: X-sashiko-severity: Critical Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider. Critical: 1 · High: 0 · Medium: 3 · Low: 3 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). - [Critical] In mtk_poll_rx(), drivers/net/ethernet/mediatek/mtk_eth_soc.c, `dma_addr` is set to… - [Medium] On MT7988, GMAC1 (phy-mode internal, the built-in switch port) gets max_mtu = MTK_MAX_RX_LENGTH_9K - MTK_RX_ETH_HLEN - VLAN_HLEN =… - [Medium] mtk_pdma_set_sdl() is called at the end of every mtk_dma_init() and is gated only on mtk_is_netsys_v3_or_greater(), not… - [Medium] The only Author/Signed-off-by is 'Sandeep Haemoon ', and the domain reads as a deliberately… - [Low] On MT7988 the MAC receive limit no longer follows each netdev's MTU. - [Low] The MT7988 jumbo-frame feature commit also carries several behaviour changes for every SoC the driver supports, with no Fixes:… - [Low] The commit describes itself as a forward-port of MediaTek downstream patches (Mason Chang's 999-eth-30/31) plus a fix by Frank… -- net: ethernet: mtk_eth_soc: add 9K jumbo This commit adds an MTK_NETSYS_RX_9K capability for MT7988. It advertises a 9194-byte max_mtu on the XGMII MACs and sizes the shared RX rings from the largest MTU of any MAC. It also programs the MAC limits and ADMA_RX_CFG from the shared buffer length, drops over-long RX descriptors, changes rx_errors accounting and reports the real allocation size in skb->truesize. Link: https://github.com/frank-w/BPI-Router-Linux/commit/b4c6cb1d5532 Link: https://github.com/mediatek/mtk-openwrt-feeds > This is a forward-port of the MediaTek downstream jumbo work: Mason > Chang's "change default rx buffer length" and "add 9k jumbo frame > support" (MediaTek OpenWrt feed 999-eth-30/31, carried in > frank-w/BPI-Router-Linux), plus Frank Wunderlich's "try to fix crash > the right way". [ ... ] > The code is credited by reference rather than with > co-author tags, which need the original authors' own Signed-off-by > lines; [Severity: Low] Patches carried in the MediaTek feed and in frank-w's tree usually already have their authors' Signed-off-by lines. If these do, could those lines be kept, together with Co-developed-by (or with From: for the original author)? As it stands, the vendor-derived code is credited only through Link: tags. Its provenance rests only on the submitter's DCO (b) certification. > Signed-off-by: Sandeep Haemoon [Severity: Medium] The DCO depends on a real, contactable identity. This is the only Signed-off-by on the patch. The domain in the address reads as offensive and does not look like an accountable identity. Could the submitter confirm their identity and resend from a real address? This matters more here because the patch forward-ports third-party code without the original authors' sign-offs. > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > index cb05a8e43e301..5affaf7fc4c14 100644 > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c [ ... ] > @@ -554,6 +555,112 @@ static int mtk_mac_prepare(struct phylink_config *config, unsigned int mode, > return 0; > } > [ ... ] > +static void mtk_set_mcr_max_rx(struct mtk_mac *mac, phy_interface_t interface, > + u32 val) > +{ [ ... ] > + /* The bucket encodes at most 2048; the SoCs with the 9K > + * capability need the jumbo field, in 1024-byte units, for > + * anything larger. The MT7988A reference manual defines > + * only 4'h2 (2 Kbytes) for that field and marks the rest > + * reserved, and the MT7988 downstream 9K patch does not > + * raise it for GMAC1 at all; the field is the encoding the [ ... ] > + if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_RX_9K)) { > + u32 jumbo = DIV_ROUND_UP(val, MTK_MAX_RX_LENGTH_UNIT); > + > + jumbo = min(jumbo, MTK_MAX_RX_LENGTH_9K / > + MTK_MAX_RX_LENGTH_UNIT); > + > + mcr_new &= ~MAC_MCR_MAX_RX_JUMBO_MASK; > + > + if (val > 1552) { > + if (mac->id != MTK_GMAC1_ID) > + jumbo = 2; > + mcr_new |= MAC_MCR_MAX_RX_JUMBO(jumbo); > + } > + } [Severity: Medium] Does GMAC1 actually accept frames above 2048 bytes with this encoding? For GMAC1, jumbo is DIV_ROUND_UP(rx_buf_len, 1024), so values 3 through 9 are written to MCR[31:28]. The comment above says the reference manual defines only 4'h2 and marks the other encodings reserved. It also says the downstream MT7988 9K patch never raises the field for GMAC1. Even so, mtk_add_mac() advertises max_mtu 9194 for GMAC1, because PHY_INTERFACE_MODE_INTERNAL counts as xgmii: else if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_RX_9K) && mtk_interface_mode_is_xgmii(eth, phy_mode)) eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH_9K - MTK_RX_ETH_HLEN - VLAN_HLEN; Suppose the hardware ignores or misdecodes the reserved values. A user could then raise the GMAC1/DSA conduit MTU to 9194 and get 16 KiB GFP_ATOMIC ring buffers (about 32 MiB pinned). Wouldn't the MAC still drop every frame above 2048 bytes? Is it safe to write reserved encodings into this register at all? [ ... ] > @@ -1231,37 +1371,51 @@ static void mtk_get_stats64(struct net_device *dev, > storage->collisions = hw_stats->tx_collisions; > storage->rx_length_errors = hw_stats->rx_short_errors + > hw_stats->rx_long_errors; > + storage->rx_errors = hw_stats->rx_checksum_errors + > + hw_stats->rx_fcs_errors + > + storage->rx_length_errors; > storage->rx_over_errors = hw_stats->rx_overflow; > storage->rx_crc_errors = hw_stats->rx_fcs_errors; > - storage->rx_errors = hw_stats->rx_checksum_errors; > storage->tx_aborted_errors = hw_stats->tx_skip; > } while (u64_stats_fetch_retry(&hw_stats->syncp, start)); [Severity: Low] This isn't a bug, but this rx_errors change affects every SoC the driver supports, not only MT7988. It is described as an if_link.h conformance fix. Other parts of this feature patch also reach the other SoCs: - build_skb(data, alloc_size) in mtk_poll_rx() raises skb->truesize on the HW-LRO rings of mt2701, mt7622, mt7623 and mt7629 from about 12.6 KiB to 16 KiB. - The new PLEN0 > buf_size drop runs on all SoCs. - The mtk_set_mcr_max_rx() refactor touches every SoC. Could these be split into separate patches, with Fixes: tags where they correct existing behaviour? They could then be backported or reverted without the jumbo feature. [ ... ] > @@ -2262,6 +2424,16 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, > > pktlen = RX_DMA_GET_PLEN0(trxd.rxd2); > > + /* Never pass a descriptor longer than the posted buffer up > + * the stack: the refill below gives build_skb() the whole > + * allocation as tailroom, so such a length would expose > + * uninitialised memory instead of tripping skb_over_panic(). > + */ > + if (unlikely(pktlen > ring->buf_size)) { > + netdev->stats.rx_length_errors++; > + goto release_desc; > + } [Severity: Critical] On MTK_36BIT_DMA SoCs such as MT7988, can this goto give the PDMA a descriptor with a mismatched address? mtk_poll_rx() initialises dma_addr once per call, not once per descriptor: dma_addr_t dma_addr = DMA_MAPPING_ERROR; If an earlier descriptor in the same poll was refilled, dma_addr still holds that new buffer's address when this goto runs. release_desc then does: release_desc: if (MTK_HAS_CAPS(eth->soc->caps, MTK_36BIT_DMA)) { if (unlikely(dma_addr == DMA_MAPPING_ERROR)) addr64 = FIELD_GET(RX_DMA_ADDR64_MASK, rxd->rxd2); else addr64 = RX_DMA_PREP_ADDR64(dma_addr); } ... rxd->rxd2 = RX_DMA_PREP_PLEN0(ring->buf_size) | addr64; rxd1 still holds the low 32 bits of the buffer kept in this slot. Bits 35:32, however, now come from the previous descriptor's buffer. MT7988 DRAM starts at 0x40000000, so on boards with 4 GiB or more the two buffers can sit in different 4 GiB windows. Would the next frame (now up to about 9 KiB) then be DMA'd into a page the driver does not own? Would the kept buffer later be unmapped with the wrong address and passed up the stack with stale contents? The other direct goto release_desc paths use the same stale value: invalid MAC, MTK_RESETTING, and page_pool or frag refill failure. This patch adds a new path. It also makes the normal-ring refill an order-1 or order-2 GFP_ATOMIC allocation once any MTU reaches about 3051, so this failure path should be hit much more often: new_data = mtk_max_buf_alloc(ring->frag_size, GFP_ATOMIC); ... if (unlikely(!new_data)) { netdev->stats.rx_dropped++; goto release_desc; } Would resetting dma_addr to DMA_MAPPING_ERROR at the start of each loop iteration avoid this? [ ... ] > @@ -3253,6 +3443,75 @@ static int mtk_dma_busy_wait(struct mtk_eth *eth) [ ... ] > +/* Program ADMA_RX_CFG[31:16] from the shared RX buffer length on netsys > + * v3+. The MT7988A reference manual names the field "ADMA LRO free > + * buffer SDL": the size of a buffer handed to the LRO engine, which its > + * LRO chapter requires to be at least the largest frame the MAC accepts. > + * The MediaTek downstream driver encodes it as MTK_PDMA_LRO_SDL plus the > + * frame area, and that is what is written here. It is a buffer size, not > + * a DMA length, so the per-descriptor PLEN0 still bounds every transfer; > + * MT7988 does not use the LRO rings, and the write matches the downstream > + * driver rather than gating the jumbo path. > + */ > +static void mtk_pdma_set_sdl(struct mtk_eth *eth) > +{ > + const struct mtk_reg_map *reg_map = eth->soc->reg_map; > + u32 val; > + > + if (!mtk_is_netsys_v3_or_greater(eth)) > + return; > + > + val = mtk_r32(eth, reg_map->pdma.rx_cfg); > + val &= ~MTK_RX_CFG_SDL_MASK; > + val |= FIELD_PREP(MTK_RX_CFG_SDL_MASK, > + MTK_PDMA_LRO_SDL + eth->rx_buf_len); > + mtk_w32(eth, val, reg_map->pdma.rx_cfg); > +} [Severity: Medium] Is it safe to write this register on every MT7988 configuration? mtk_dma_init() calls mtk_pdma_set_sdl() on every netsys v3+ DMA bring-up. The call does not depend on MTK_NETSYS_RX_9K, hwlro or the MTU. At the default MTU it writes 0x3000 + 2048 = 0x3800 (14336 bytes) into ADMA_RX_CFG[31:16]. That is about seven times the buffer size mtk_rx_alloc() actually posts. Before this patch the driver never wrote this field. The comment calls the field the LRO free buffer size and says MT7988 does not use the LRO rings. It also says PLEN0 still bounds every transfer, but nothing in the tree supports that. What happens if the ADMA engine uses this size for non-LRO rings, for example with MTK_RESV_BUF set in glo_cfg? Could it DMA past the posted buffers? The pktlen > ring->buf_size check in mtk_poll_rx() runs only after the transfer, so it cannot prevent an overrun. [ ... ] > @@ -4207,13 +4459,25 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset) > */ > for (i = 0; i < MTK_MAX_DEVS; i++) { > struct net_device *dev = eth->netdev[i]; > + struct mtk_mac *mac; > > if (!dev) > continue; > > + mac = netdev_priv(dev); > mtk_w32(eth, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(i)); > - mtk_set_mcr_max_rx(netdev_priv(dev), > - dev->mtu + MTK_RX_ETH_HLEN); > + if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_RX_9K)) { > + mtk_set_mcr_max_rx(mac, mac->interface, > + dev->mtu + MTK_RX_ETH_HLEN); > + } else if (mac->interface != PHY_INTERFACE_MODE_NA) { > + /* Before the first mac_config() the interface mode > + * is unknown and the limit would land in the MCR > + * register of an XGMII MAC; that open programs each > + * MAC from its own mac_config() anyway. > + */ > + mtk_set_mcr_max_rx(mac, mac->interface, > + eth->rx_buf_len); > + } > } [Severity: Low] On MT7988 the MAC receive limit no longer follows each netdev's MTU. mtk_hw_init(), mtk_mac_config(), both link-up paths and mtk_set_all_macs_max_rx() all program every MAC from the shared eth->rx_buf_len. mtk_rx_buf_len_from_mtu() never returns less than 2048: if (max_mtu + MTK_RX_ETH_HLEN <= MTK_MAX_RX_LENGTH_2K) return MTK_MAX_RX_LENGTH_2K; At the default MTU of 1500, GMAC1 and the non-XGMII GDM MACs therefore move from the 1518 bucket to the 2048 bucket, with MCR[31:28] = 2. An XGMII MAC that stays at MTU 1500 (GMAC2) is affected as well. Once another MAC's MTU is raised, mtk_set_all_macs_max_rx() sets its XMAC_RX_CFG2 limit as high as 9216. The hardware used to reject frames longer than the MTU and count them in rx_long_errors. Those frames now reach the stack. Is that intended? The commit message says the limits are "a property of the shared rings", but it does not say that MACs now accept frames larger than their MTU even at default settings. [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/patch-957a473dc4caca415acb95d2d6cfa1ab%40loljews.com