Article View: linux.kernel.netdev
Article #16489Re: [PATCH net-next v6 2/3] net: ethernet: mtk_eth_soc: skip page_pool
From: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 00:45
Date: Sun, 15 Nov 2026 00:45
184 lines
14453 bytes
14453 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 (2) · Low: 1
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] mtk_rx_alloc() (drivers/net/ethernet/mediatek/mtk_eth_soc.c)
now creates the page_pool only when `ring->buf_size <=…
- [Low] The new comment in mtk_rx_alloc() and this commit's message both
name `mtk_max_buf_alloc()` as the fallback allocator.
Pre-existing issues:
- [Medium] This problem wasn't introduced by this patch, but
mtk_rx_alloc() leaks ring->data on two error paths.
- [Medium] This problem wasn't introduced by this patch, but
mtk_rx_clean() calls `dma_unmap_single(eth->dma_dev, rxd1|addr64,…
--
net: ethernet: mtk_eth_soc: skip page_pool
This patch makes mtk_rx_alloc() create a page_pool only when the ring's
descriptor length (ring->buf_size) fits within MTK_PP_MAX_BUF_SIZE. Larger
rings fall back to the netdev_alloc_frag() path. With the current MTU
limits the gate always passes. It is meant to take effect with the 9K
jumbo support that follows.
Link: https://github.com/mediatek/mtk-openwrt-feeds
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index 6c8b039fad415..16c3e4157085b 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -2824,7 +2824,13 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)
> if (!ring->data)
> return -ENOMEM;
>
> - if (mtk_page_pool_enabled(eth)) {
> + /* A page_pool hands out order-0 pages and is created with
> + * MTK_PP_MAX_BUF_SIZE, so it can only back a ring whose descriptor
> + * length fits. Larger rings use the netdev_alloc_frag()/
> + * mtk_max_buf_alloc() path below instead.
> + */
[Severity: Low]
This isn't a bug, but mtk_max_buf_alloc() doesn't exist yet at this commit.
The fallback below still calls the LRO-sized allocator:
if (ring->frag_size <= PAGE_SIZE)
data = netdev_alloc_frag(ring->frag_size);
else
data = mtk_max_lro_buf_alloc(GFP_KERNEL);
The commit message has the same forward reference:
Gate the pool on ring->buf_size <= MTK_PP_MAX_BUF_SIZE and let larger
rings use the netdev_alloc_frag()/mtk_max_buf_alloc() path that already
exists.
mtk_max_buf_alloc() comes from the next patch, "net: ethernet:
mtk_eth_soc: add 9K jumbo". That patch renames mtk_max_lro_buf_alloc() and
sizes the buffer from ring->frag_size.
Could this patch name mtk_max_lro_buf_alloc() instead, or leave the
reference to the later patch?
> + if (mtk_page_pool_enabled(eth) &&
> + ring->buf_size <= MTK_PP_MAX_BUF_SIZE) {
[Severity: Medium]
When this condition is false on a netsys v2+ SoC, ring->page_pool stays
NULL and ring->xdp_q is never registered. XDP only runs inside the
page_pool branch of mtk_poll_rx():
mtk_poll_rx() {
...
if (ring->page_pool) {
...
ret = mtk_xdp_run(eth, ring, &xdp, netdev);
...
} else {
...
}
At this commit, the XDP admission checks still compare only the per-device
MTU against MTK_PP_MAX_BUF_SIZE:
mtk_xdp_setup() {
...
if (dev->mtu > MTK_PP_MAX_BUF_SIZE) {
...
}
mtk_change_mtu() {
int length = new_mtu + MTK_RX_ETH_HLEN;
...
if (rcu_access_pointer(eth->prog) &&
length > MTK_PP_MAX_BUF_SIZE) {
...
}
Once the shared rings can grow past MTK_PP_MAX_BUF_SIZE, could an XDP
program attach successfully and then never run? Every packet would then be
handled as if the program returned XDP_PASS.
This can't trigger at this commit. Non-LRO rings have a buf_size of about
2110, and HW-LRO rings only exist on netsys v1, where the page_pool is
disabled.
The next patch, "net: ethernet: mtk_eth_soc: add 9K jumbo", changes
mtk_xdp_setup() and mtk_change_mtu() to check the shared rx_buf_len. That
appears to make the admission checks match this gate.
Would it be cleaner to make the admission checks use the same length as
this gate in this patch, so each step of the series stays consistent?
> struct page_pool *pp;
>
> pp = mtk_create_page_pool(eth, &ring->xdp_q, ring_no,
[Severity: Medium]
This isn't a bug introduced by this patch, but does mtk_rx_alloc() leak
ring->data on the error paths right after this?
if (IS_ERR(pp))
return PTR_ERR(pp);
...
ring->dma = mtk_dma_ring_alloc(eth,
rx_dma_size * eth->soc->rx.desc_size,
&ring->phys,
rx_flag == MTK_RX_FLAGS_NORMAL);
if (!ring->dma)
return -ENOMEM;
Both paths return with ring->data allocated and ring->dma still NULL. The
cleanup through mtk_start_dma()->mtk_dma_free()->mtk_rx_clean() only frees
the array when both pointers are set:
mtk_rx_clean() {
...
if (ring->data && ring->dma) {
...
kfree(ring->data);
ring->data = NULL;
}
...
}
The next mtk_rx_alloc() then overwrites ring->data. So each time ndo_open
fails at either step, the old array of rx_dma_size pointers is lost.
[Severity: Medium]
This is a pre-existing issue, but now that the page_pool decision is made
per ring, should mtk_rx_clean() follow it too? It unmaps every live RX
buffer unconditionally:
mtk_rx_clean() {
...
dma_unmap_single(eth->dma_dev, ((u64)rxd->rxd1 | addr64),
ring->buf_size, DMA_FROM_DEVICE);
mtk_rx_put_buff(ring, ring->data[i], false);
...
}
For page_pool rings, the pool owns the mapping (PP_FLAG_DMA_MAP), and
rxd1 holds page_pool_get_dma_addr(page) + MTK_PP_HEADROOM from
mtk_page_pool_get_buff().
Doesn't this unmap an offset address with ring->buf_size, and then have
the pool unmap the same page again with PAGE_SIZE when it is destroyed?
With CONFIG_DMA_API_DEBUG this would be reported. With an IOMMU or swiotlb
bouncing, it could corrupt the mapping state.
mtk_rx_put_buff() already checks ring->page_pool to decide how to free the
buffer. Should dma_unmap_single() be skipped under the same condition?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/patch-4b4c5003bcf028fafd094e719c5e910b%40loljews.com
Technical Details
Message-ID:
<179470350538.2199510.6670148874523069932@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.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-363507-linux-kernel-netdev=dewy.ruReferences:
<patch-2a89212e66b84e37783e0d2ebdaa0a75@loljews.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.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-363507-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v6 2/3] net: ethernet: mtk_eth_soc: skip page_pool Date: Sun, 15 Nov 2026 00:45:05 +0000 Organization: Usenet Network Message-ID: <179470350538.2199510.6670148874523069932@kernel.org> References: <patch-2a89212e66b84e37783e0d2ebdaa0a75@loljews.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1697074"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:i7hXQ0DrDyu4usUsO5N4JdhDGxo= sha256:dWjMkuSjkcP/zNv3gcBJBNrN/H8Ogw7Fm16t0ntLNMo= sha1:BIRQfTX9n+Hv/yOaCTTNvqU0iqM= sha256:3BcXBjqYZkEd/T0yT+qQoMgLeyJXME03Wz3WRce0teI= 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 0A0D4114910; Sun, 15 Nov 2026 03:45:34 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, 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] 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 4KWD2vfnDHqA; Sun, 15 Nov 2026 03:45:25 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-363507-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 56A6F114891; Sun, 15 Nov 2026 03:45:16 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 5D4E535A5B; Sun, 15 Nov 2026 00:45:10 +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=1794703508; b=YakhEueFiA8dugwNN8OQTnoAD+ZrKqCCpmkbeE0sHNtQ7lwg+Q2jyMKqxoKht64v6VgC qnER0kfGKGg6uOu2+mrcId/G26fgevdiEohyrifeBEgOFT7XJf58mP3eYUcmjLFKCD+pH evknelUkVB7A6hFyFnZ7VsyMpxW2Zlw+zLBkM1mThKK/Y3f7zeq7rDqrdiSTAztt908s4 gWIXK7YiNs2hzqihLvho9X4hf3chZPz3YEmZZBvm2KaavS3ampDCsgZa2peZXzQf1YLkl nse+r8/eE4He9fvynzb3SYXUEKaVouBKb+tp6HHSIJkwxy3qi9YfcWssxaaNZ6pCEzQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794703508; 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=RiNYzztBiVox2P9vASzVZ5SqLcQATUvhICdg6qPjINc=; b=sxgoefFo3K52FL2axoJmu8ZDEapCwehqL5vbS25AXYACEH1Z2yCck1drgXm9kX1Pi66Q Rl16lCEgn5mEi7EAYEjlQQ4nMtXmGgQNxHRunkezbIrBCcjzL1AShkV6mEDKhG7J7GMtb l3Gw+vud8fLma6kQJOs+rJwkawjt/IYb3qsJOswt3K0NTxEJbpRptqWX/rgmVUkfMSiuv jPv/UOlT1AjAhAIhbrPpkxnltWN7eIWNvoFgkxHmcLLqmusiLgCHOcQ28wsBPjhAVHOSS gZlMOi1N8bxpT9GM2qRd1vIMFitmpuNAj9SkWy5yExA3+c2wElaVbifyOHHSoR/py3w== 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=B9oIFjIp; 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 1D344606A32C; Sun, 15 Nov 2026 00:45:08 +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=B9oIFjIp 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=1794703507; b=PqwvUisL9W150wvZQVM0LxfT7+x+Yde2UICgJ/cUkGs2MSO32tPpHpboFBX7tpLCf5CX ueFHR8uvRihbu+iARhurLvNUXTO1lMV8lO1TiokAiA2eesP9liRz7ETLeunQ9HagIAbx7 lrkm0ozSIghrYbYFeF5kcYS9jSUL+Jw4DG+jvJ0FROkrPrpeFp8Wv7tshC9WY5q3XmS3b 3GITbzt2PFMFuCR/n+kuD8mqFhAkyxia3YVLLLPe0x1XRoNfRDI2L9R8DziVbdkYUbedU d+FLpSlMPBKpFmbLdOMH+ZsxvcJio5COQhNr0djRLwYdeLlzane2/sQcNoK455G0G6w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794703507; 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=RiNYzztBiVox2P9vASzVZ5SqLcQATUvhICdg6qPjINc=; b=bEvGR7IsJC8IkAVL0p2QwYghgRVywWDo91nFraBHqIUaGzVFSGfQv2J3zjh6lgJOwLf/ knTMA7LCIQBgWkY5xB+NSj6LAYA+tWjqRikNQ3DKMmW1kZamBSiztEhY+T3uB8XpRAgeE 0aZ/CmUlJFsz/OVD0L2anoH1ZD36AzyHW+ZHs+ezrfEztiVMykRXNDueUgzdQpzBrNX8t DAHGLisDLethz5SHfqMXLHCTMgA0rmKS1ZXk2MqTJQmPuKKbsQ4AxUKnT4s84eAA678TS uyvmELTvkv7MKqXDndYWr80mUVYN4qeCH23NglAuAyJoQ4q2xhUFuioFcGvdKyjOXGg== 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=B9oIFjIp; 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 3E432606A332; Sun, 15 Nov 2026 00:45:06 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D23961F000C6; Sun, 15 Nov 2026 00:45:05 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794703506; bh=RiNYzztBiVox2P9vASzVZ5SqLcQATUvhICdg6qPjINc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=B9oIFjIpjbmmPQ+cWOXhJq27CVqHZyMqMXeRl0v0fIqJUPmhOAKcHMx5KH964FbWa JytEmlvgcb06DNNDmXNvsxW/WOMXVjUudSCAK5fQ4Jtu5+GyhhihJFhh0+E5aD4LSV GaJFmAHqKaIbM1KMdJBgQ9Hq2ROYo2jjX/M5VJSWP6chZdXE+7rbkiwIJ895jBD+qN UyCp8lni+zNkBTTa+HlbEkZHOd6VH5KMo/UFGeZoJC6gVA+Z1fRzW6wT4zc+4JCPmW vqPG7LqdsN3DWUOVrzq6jos3lFVumqCw/LyUVHmGJFeJQ3aWG6CUEm0Mz5iZnjHkmp T1arq23Wx508Q== X-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 X-In-Reply-To: <patch-2a89212e66b84e37783e0d2ebdaa0a75@loljews.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