From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E99753A4F27; Thu, 2 Apr 2026 11:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.13.80.246 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775129418; cv=none; b=FAjA7yHXlyS/eYlC5aaW/uBnoaBEbMRvHDdVOFx2VZGNlp53MfBS5kgAcQiYh0TLCw4vc2ri1o7ZQyfz7e4klqgbB+PQ32EUxC6TcrFWhP7thuJ5+37tLb+IbILvF2B1j884t268NySR1q8Fyfl+3J/ow2Uhseftc8qGk15M3xM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775129418; c=relaxed/simple; bh=28q/qCK+gXZEGqjCyA3H3EaAd/1c+2kSz/DGqlu2Uzk=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type; b=Hm2/xaKPK0XLDRy/A5qntg4p1ehLWtXX3Lf/GdM7w08YZDmRuRLsDbZ1KvktMPS1/69r0FqhaAc9wqN6LRZs+tIj62JmaF2/IdifJB7v34BxhYQJLBigNqlq+i/wKGLkiEn2pPMEBe6mueCPs5BCW37IP4ZElp18eyHj8lB8Ras= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b=y7TTmySF; arc=none smtp.client-ip=194.13.80.246 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b="y7TTmySF" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 06D10A5889; Thu, 2 Apr 2026 13:30:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1775129405; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Gs4YsqLpgH7F2095RsCXRJucsAAhFfMRogLbPZ89ycI=; b=y7TTmySF6jcNFRMgzyX01wlgeVzF/IRZvL42jVKVHpjXITht7IIwgCHk0in1nhQTrXAsZ+ 89pPrAYS9czgHPR56xURaVbKrxLFf3OH5Jb3bjxHzAeaiZ++iTGX/3lhK3AYRhUYGDKDnf 321Oj/TrOvqrjdsxsdojljUhI+eLKH30Eqtx1+mIU3q1F8NDoYcb26zSGFqHC8lTXud/3W SXUOD+hCHHIQzKt+94HyN6bFjcwy+zZ/PhEkkf8tLeBYdRH/XOkqND0gp25Fu32JvbyIOi VxDVBftOIBH17kXb/Tg5Blts0mjLzwJX2QK3TS2rTom4ObLxy6kUFOWIMt6YLg== Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 02 Apr 2026 13:30:05 +0200 From: Nicolai Buchwitz To: =?UTF-8?Q?Th=C3=A9o_Lebrun?= Cc: Nicolas Ferre , Claudiu Beznea , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Russell King , Paolo Valerio , Conor Dooley , Vladimir Kondratiev , Gregory CLEMENT , =?UTF-8?Q?Beno=C3=AEt_Monin?= , Tawfik Bayouk , Thomas Petazzoni , Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 11/11] net: macb: use context swapping in .ndo_change_mtu() In-Reply-To: <20260401-macb-context-v1-11-9590c5ab7272@bootlin.com> References: <20260401-macb-context-v1-0-9590c5ab7272@bootlin.com> <20260401-macb-context-v1-11-9590c5ab7272@bootlin.com> Message-ID: <450f62fea63766cd21e57b3a63a39d0c@tipi-net.de> X-Sender: nb@tipi-net.de Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 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 > --- > 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; > }