From: netdev-bot+sashiko@kernel.org
To: nb@tipi-net.de
Cc: opendmb@gmail.com, florian.fainelli@broadcom.com,
bcm-kernel-feedback-list@broadcom.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, f.fainelli@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, pierremarinleclercq88@gmail.com,
dave.stevenson@raspberrypi.com, justin.chen@broadcom.com
Subject: Re: [PATCH net-next v10 7/8] net: bcmgenet: allow the MTU to be changed
Date: Sat, 28 Nov 2026 11:26:07 +0000 [thread overview]
Message-ID: <179586516710.3135.10478962975495152164@kernel.org> (raw)
In-Reply-To: <20261127-nb-genet-mtu-nn-v2-v10-7-749c7cc45d97@tipi-net.de>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
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] In bcmgenet_change_mtu(), if the DMA engine will not halt, the
driver frees RX buffers and page pools that the hardware descriptors…
--
net: bcmgenet: allow the MTU to be changed
This commit sets dev->max_mtu on GENET v5 from the packet ready threshold
and adds bcmgenet_change_mtu(). On a running interface it stops the
datapath, reprograms the MTU registers and restarts DMA while the PHY
keeps running. When the new MTU maps to the same rx_buf_len, the existing
rings are reused.
Link: https://github.com/raspberrypi/linux/issues/5561
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index fc8b8400fcbb5..1307faf135bd4 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
[ ... ]
> @@ -3997,6 +4023,97 @@ static int bcmgenet_change_carrier(struct net_device *dev, bool new_carrier)
> return 0;
> }
>
> +static int bcmgenet_change_mtu(struct net_device *dev, int new_mtu)
> +{
[ ... ]
> + /* The threshold is quantised, so a band of MTUs shares one buffer
> + * length and the running rings can serve the new MTU as they are.
> + */
> + reuse = buf_len == priv->rx_buf_len;
> + if (!reuse) {
> + ret = bcmgenet_alloc_dma(priv, buf_len, &set);
> + if (ret)
> + return ret;
> + }
> +
> + /* The watchdog trips on an idle queue once the rings are gone */
> + netif_device_detach(dev);
> +
> + /* The PHY stays up, hold its lock. A link event would otherwise take
> + * the MAC out of reset and enable it mid rewrite.
> + */
> + mutex_lock(&dev->phydev->lock);
> + bcmgenet_netif_stop(dev, false, reuse ? &set : NULL);
> +
> + WRITE_ONCE(dev->mtu, new_mtu);
> + priv->rx_buf_len = buf_len;
> + bcmgenet_set_mtu_regs(priv, new_mtu);
> +
> + ret = bcmgenet_init_dma(priv, true, &set);
> + if (ret) {
[Severity: Medium]
What happens to the RX buffers here if the DMA engine does not halt?
bcmgenet_netif_stop() ignores the return value of bcmgenet_dma_teardown():
bcmgenet_netif_stop() {
...
bcmgenet_dma_teardown(priv);
...
bcmgenet_tx_reclaim_all(dev);
bcmgenet_fini_dma(priv, keep);
}
On the reuse path, bcmgenet_fini_dma() moves the live rx_cbs, tx_cbs and
page pools into set. The RDMA descriptors still hold the DMA addresses of
those pages.
bcmgenet_init_dma() then checks the halt again with
bcmgenet_tdma_disable() and bcmgenet_rdma_disable(). On a timeout it
jumps to err before it rewrites any descriptor:
err:
bcmgenet_free_dma_set(priv, set);
bcmgenet_free_dma_set() is documented as:
/* Hand back a set that was never installed */
Here the set is the one the hardware is armed with. The helper returns
every page to its pool and calls page_pool_destroy(), which unmaps the
pages and hands them back to the page allocator.
After that, netif_close() runs bcmgenet_close(). Because tx_cbs is NULL,
bcmgenet_close() skips bcmgenet_netif_stop(), and nothing resets RDMA,
UMAC or RBUF. Can an RX engine that never reported halted then write into
pages that have been freed and reused?
The non-reuse path looks similar. bcmgenet_fini_dma(priv, NULL) frees the
old, still-armed rings regardless of what bcmgenet_dma_teardown()
returned. bcmgenet_close() and the resume path already have the same
"teardown failed, free anyway" pattern, but this patch makes it reachable
at runtime through an MTU change on a running v5 interface.
The commit message only says:
Only a DMA that refuses to halt still takes the interface down, because
nothing is left to run on.
It does not cover the hardware still referencing the freed buffers.
On a halt failure, would it be safer to WARN and leak the set rather than
free it? Another option is to reset the block before releasing the
buffers.
As far as I can tell, the later patch "net: bcmgenet: reassemble jumbo
frames from status block fragments" does not change this error path in
bcmgenet_init_dma() or bcmgenet_change_mtu(), so the issue remains at the
end of the series.
> + /* The datapath is gone, do not leave the interface up */
> + netdev_err(dev, "failed to initialize DMA, closing\n");
> + WRITE_ONCE(dev->mtu, old_mtu);
> + priv->rx_buf_len = bcmgenet_rx_buf_len(old_mtu);
> + mutex_unlock(&dev->phydev->lock);
> + /* bcmgenet_close() attaches the device again */
> + netif_close(dev);
> + return ret;
> + }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127-nb-genet-mtu-nn-v2-v10-0-749c7cc45d97%40tipi-net.de
next prev parent reply other threads:[~2026-11-28 11:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 11:25 [PATCH net-next v10 0/8] net: bcmgenet: support larger MTUs Nicolai Buchwitz
2026-11-27 11:25 ` [PATCH net-next v10 1/8] net: bcmgenet: let the caller decide whether to start the PHY Nicolai Buchwitz
2026-11-27 11:25 ` [PATCH net-next v10 2/8] net: bcmgenet: allow a continuation descriptor without the alignment pad Nicolai Buchwitz
2026-11-28 11:26 ` netdev-bot+sashiko
2026-11-27 11:25 ` [PATCH net-next v10 3/8] net: bcmgenet: rename ENET_MAX_MTU_SIZE to ENET_MAX_FRAME_LEN Nicolai Buchwitz
2026-11-28 11:26 ` netdev-bot+sashiko
2026-11-27 11:25 ` [PATCH net-next v10 4/8] net: bcmgenet: derive the receive buffer length from the MTU Nicolai Buchwitz
2026-11-28 11:26 ` netdev-bot+sashiko
2026-11-27 11:25 ` [PATCH net-next v10 5/8] net: bcmgenet: split frames that end just past the transmit threshold Nicolai Buchwitz
2026-11-28 11:26 ` netdev-bot+sashiko
2026-11-28 13:04 ` Nicolai Buchwitz
2026-11-27 11:25 ` [PATCH net-next v10 6/8] net: bcmgenet: build the DMA rings before giving up the running ones Nicolai Buchwitz
2026-11-27 11:25 ` [PATCH net-next v10 7/8] net: bcmgenet: allow the MTU to be changed Nicolai Buchwitz
2026-11-28 11:26 ` netdev-bot+sashiko [this message]
2026-11-28 13:07 ` Nicolai Buchwitz
2026-11-27 11:25 ` [PATCH net-next v10 8/8] net: bcmgenet: reassemble jumbo frames from status block fragments Nicolai Buchwitz
2026-11-28 11:26 ` netdev-bot+sashiko
2026-11-28 13:12 ` Nicolai Buchwitz
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=179586516710.3135.10478962975495152164@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=f.fainelli@gmail.com \
--cc=florian.fainelli@broadcom.com \
--cc=justin.chen@broadcom.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nb@tipi-net.de \
--cc=netdev@vger.kernel.org \
--cc=opendmb@gmail.com \
--cc=pabeni@redhat.com \
--cc=pierremarinleclercq88@gmail.com \
/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