Subject: Re: [PATCH net-next] net: macb: allow MTU changes while the interface is running

From: Breno Leitao <[email-masked]>
Date: Tue, 17 Mar 2026 12:47:26 -0700

On Tue, Mar 17, 2026 at 12:42:04PM -0700, Breno Leitao wrote:
> On Mon, Mar 16, 2026 at 10:27:20AM +0100, Nicolai Buchwitz wrote:
> > macb_change_mtu() currently returns -EBUSY if the interface is running,
> > requiring users to bring the interface down before changing the MTU. This
> > is unnecessarily restrictive.
> > 
> > Instead, close and reopen the interface around the MTU change so that RX
> > DMA buffers are reallocated for the new MTU. This is the same approach
> > used by many other network drivers (e.g. igb, tg3, stmmac).
> > 
> > Signed-off-by: Nicolai Buchwitz <[email-masked]>
> > ---
> >  drivers/net/ethernet/cadence/macb_main.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> > index 5e27e0e87a55..8dd01031250d 100644
> > --- a/drivers/net/ethernet/cadence/macb_main.c
> > +++ b/drivers/net/ethernet/cadence/macb_main.c
> > @@ -3262,11 +3262,16 @@ static int macb_close(struct net_device *dev)
> >  
> >  static int macb_change_mtu(struct net_device *dev, int new_mtu)
> >  {
> > -	if (netif_running(dev))
> > -		return -EBUSY;
> > +	bool was_running = netif_running(dev);
> > +
> > +	if (was_running)
> > +		macb_close(dev);
> >  
> >  	WRITE_ONCE(dev->mtu, new_mtu);
> >  
> > +	if (was_running)
> > +		return macb_open(dev);
> 
> Would you like to keep the new_mtu set, even if macb_open() fails?

Looking a bit further, I found that macb_set_ringparam() doesn't return
failure if macb_open() fails. Should it be fixed also?

Should we have something similar to your code above?

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 5bc35f651ebd2..3c43fc85af79d 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3516,7 +3516,7 @@ static int macb_set_ringparam(struct net_device *netdev,
        bp->tx_ring_size = new_tx_size;

        if (reset)
-               macb_open(bp->dev);
+               return macb_open(bp->dev);

        return 0;
 }