From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 5F70647DD76 for ; Wed, 1 Apr 2026 16:39:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775061597; cv=none; b=T3DnNPwG5UrXPw+aWBY84cOzPv50opMGyNSkGwEhS4ARzKcd1jEUpuZQAaqeLZio7whO5gt75ZiOgCNxDuR95p9lfKUWFCD51knn4e3b5UT9Caj1QqeM7VM1BdNxM88vuACVSTsLJHcQ1wOuaLKZ58zxvi3RG9mMSMoYVZJ6fH0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775061597; c=relaxed/simple; bh=vsBwCme8KJvf6E7ASjBFpFWkYjm4KVrMJftP/zq2PjM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pV/K64nmitQAuj2p7YbXn2LNrO1LliAn9rWAGbVFNfeOOU/eipZobW2Cpw7dstY6yIprngvQhjrAPLAVUnt1KY4ZP3czlk9agDNS2PRPAJJRk1ZVjFUkTlKqkPZ+Ie9G0kkCsjiOZ1RPePKnucr1qkDybIgO2xNegUfpSVitaqc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=V/8bmKlK; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="V/8bmKlK" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 758941A30B4; Wed, 1 Apr 2026 16:39:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 497E6602BF; Wed, 1 Apr 2026 16:39:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DEE7610450A10; Wed, 1 Apr 2026 18:39:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1775061589; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=4y1czYbIcSgISGAdHVLbVNE8ycNyrwxMXKBVsQfa3wE=; b=V/8bmKlKCoUKoRRtGcCeocLSmadXKqohQL/hSgyTEBhjNJ6JAoJwm27zuwEV6nEzk7EfTe VFU9OuUN7R0M2amBgr2S6TXudMmUWSCPLo3iuKk8GOZXiweh+Pvd/wQYUYSt++g1Jqu/pA NVs9esUAwJk8yu9Fw5HHeub/4DO57Rw7AVaWwSspHw/mY+cLkF2XVXmL0C6AIazVqy3Ng1 MJDuilhOTP8lt1MPjrjoj/63Jiz+dbSKzFEm//6+VCi6CUvLgZc+SmnQiWrSAl2UpzbAEv E0+A/YIEUK1Iycfs5Nsbx6ssSXCDMisxpepmzAVwUDiKu3VKSxlp1Lt523/KPQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Wed, 01 Apr 2026 18:39:14 +0200 Subject: [PATCH net-next 11/11] net: macb: use context swapping in .ndo_change_mtu() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260401-macb-context-v1-11-9590c5ab7272@bootlin.com> References: <20260401-macb-context-v1-0-9590c5ab7272@bootlin.com> In-Reply-To: <20260401-macb-context-v1-0-9590c5ab7272@bootlin.com> To: Nicolas Ferre , Claudiu Beznea , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Russell King Cc: Paolo Valerio , Conor Dooley , Nicolai Buchwitz , 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, =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.15.0 X-Last-TLS-Session-Version: TLSv1.3 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); + return 0; } -- 2.53.0