Re: [PATCH net-next 11/11] net: macb: use context swapping in .ndo_change_mtu()

Nicolai Buchwitz
2026-04-02T11:30:07Z

On 1.4.2026 18:39, Théo Lebrun wrote:
> Use newly introduced context buffer management to implement
> .ndo_change_mtu() as a context swap: allocate new context ->
> reconfigure HW -> free old context.
>
> This resists memory pressure well by failing without closing the
> interface and it is much faster by avoiding PHY reinit.
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
> ---
> drivers/net/ethernet/cadence/macb_main.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb_main.c
> b/drivers/net/ethernet/cadence/macb_main.c
> index 543356554c11..e10791bf1f4d 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -3438,11 +3438,25 @@ static int macb_close(struct net_device
> *netdev)
>
> static int macb_change_mtu(struct net_device *netdev, int new_mtu)
> {
> - if (netif_running(netdev))
> - return -EBUSY;
> + struct macb *bp = netdev_priv(netdev);
> + bool running = netif_running(netdev);
> + struct macb_context *new_ctx;
> +
> + if (running) {
> + new_ctx = macb_context_alloc(bp, new_mtu,
> + bp->configured_rx_ring_size,
> + bp->configured_tx_ring_size);
> + if (IS_ERR(new_ctx))
> + return PTR_ERR(new_ctx);
> +
> + macb_context_swap_start(bp);
> + }
>
> WRITE_ONCE(netdev->mtu, new_mtu);
>
> + if (running)
> + macb_context_swap_end(bp, new_ctx);

Same issues from patch 10 apply here, plus:

macb_context_swap_end() never calls macb_configure_dma(). The
new context has a different rx_buffer_size (derived from new_mtu),
but the DMACFG register's RXBS field still reflects the old
value. If new MTU > old MTU, the hardware will DMA past the end
of the new buffers using the old (smaller) RXBS. Shouldn't
macb_configure_dma() be called after the swap?

> +
> return 0;
> }