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 15FBA3A7843 for ; Fri, 17 Jul 2026 19:49:03 +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=1784317744; cv=none; b=t4/9YmDV9+HGdoti7zEA+Np8fYxVvDuLMhDrtmfp/cCkN1mZlV56Ef8G8bzSAlSKkL8tWXIZQeVLQzGWW1FVziAhn+9G8cL2WcCEQDsu4vz4ZXoprhTGAzIHI452HupOU/zXrENE0m9e3QQhdmiMdcdC3u9rXTwhmJIJQYjZ4Kc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784317744; c=relaxed/simple; bh=SMfQ+p6wY8TVJKloo5fm3DexlBaHJs/dO34kRwNPzMw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qFAeNBP8ijumlkCNRUBMA9GF7vsUe0dGZnisrDk6YKkIbshQCIwS/nECEf29lep8H+vDlb9PJodzrxDtR7Nj9j9IaVPDC4oN6aPAU0aL1jadpKwCFKYQi/s0sRgNl5J3ShNWufgqxC48JA2rpY9py3kIohvb/WYoXoYxtwPPzCY= 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=sitoIKRb; 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="sitoIKRb" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id CA8381A1078; Fri, 17 Jul 2026 19:49:01 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 98A0360361; Fri, 17 Jul 2026 19:49:01 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3842011BD2789; Fri, 17 Jul 2026 21:48:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1784317740; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=/bZyMdibmNhn8hYknzAZPzu2XCASXmLuyUZQF+8Puo4=; b=sitoIKRbCuVvTpdRzdr+tuIwhhAQHlaM9sMissXz8MFyqPizzq9jX8th1PskJp1b/gwL7g BTIkvOoyboPVyVpp9QaRLPQ2MVuHTQEI25u1lbRx6lcgei1mn+3FCBKiU2P00YLr/Q4kj4 J9RdFOLfduhhe9H3CbJN5hWTjAgHVyf5kbhuwyrH3suifPEwcoZdhvfdVDFZM/HY8E9JdB LeB0Vxpo9CbiVmCRgN34sWQGoov1CG1zCPq8Ae7EG/29AzfY5H9zAJlwzaK+2PuDAGvgsQ Tzf/HdTt93BvI39Jbhq58JPp6xQFQALhiqzvy0ByLBJvlpuukMmnb3PuiN9wGw== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Fri, 17 Jul 2026 21:48:18 +0200 Subject: [PATCH net-next v4 15/15] 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: <20260717-macb-context-v4-15-0acbe7f10cdb@bootlin.com> References: <20260717-macb-context-v4-0-0acbe7f10cdb@bootlin.com> In-Reply-To: <20260717-macb-context-v4-0-0acbe7f10cdb@bootlin.com> To: =?utf-8?q?Th=C3=A9o_Lebrun?= , Conor Dooley , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolas Ferre , Claudiu Beznea , Paolo Valerio , Nicolai Buchwitz , Vladimir Kondratiev , Gregory CLEMENT , =?utf-8?q?Beno=C3=AEt_Monin?= , Tawfik Bayouk , Thomas Petazzoni , Maxime Chevallier X-Mailer: b4 0.15.2 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. AT91 EMAC is handled differently as their buffer management is separate and they don't do NAPI. We refuse them (-EBUSY) to avoid implementing context swapping for them. Signed-off-by: Théo Lebrun --- drivers/net/ethernet/cadence/macb_main.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 5792647eb0a6..1de66f442c59 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -3493,11 +3493,29 @@ 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) { + /* Context swapping is not supported for AT91. */ + if (bp->caps & MACB_CAPS_MACB_IS_EMAC) + return -EBUSY; + + 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.55.0