From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 607D251CF6F for ; Tue, 13 Oct 2026 13:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791897445; cv=none; b=RWTbPAmDRB17uhZntV5W/iwf3mfp1wwkkn9hWcC/sYufJ/d78Cp78MPGf4NPBVb3IrnvpBwtH57spLKAiF9NZOhJ49OdteuEtdAxZz1ZSq129Up9z/sSHVG7Y9oMLhASieIFzYo1av81pkT15bUHRNVJedn5ewN+oa1zzzTuaZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791897445; c=relaxed/simple; bh=Y2g6FYFbg4SoUd7Lte7y5l1+lGhMg31jzgWlIk4Ie4g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Mx8yiG1WEwi7b9K5HuHwoNYNZO+L0oQ1pCxINss1Y9ILwpkni2tF/Rl3B/w+NLPUTwAEuUvjgQwzUem4z1VOjm7CFFkVdw3oMi7herCoAizPgPkRPEU3qbwKDzxv/Ep27C4DtIOT/sAQN1qMIUSV9aryXG04Owo6TNI3bHx3tBw= 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=U0+3FzcN; arc=none smtp.client-ip=185.171.202.116 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="U0+3FzcN" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 65A3CC653ED; Tue, 13 Oct 2026 13:18:17 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D9EDF60362; Tue, 13 Oct 2026 13:17:21 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4F03E11D713F1; Tue, 13 Oct 2026 15:17:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1791897440; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=+pDMpK4r/RgjFjmJUy9RXdPHOlPlNSL+byaGSghb5iA=; b=U0+3FzcNLPJp7xtCfz5mskmEF6yO3xODuDRJ7U4361pgLIeWg1+hAN9Y5PKrMAmIM+4HpM MZErxS4a4GVkTIk+N2kMTiqmsT50t7wyLabkQc2/vMNI1x6Shn6wi4dFl64IrZ+RxE0kMr 57n93l/dH2UrY4cmFmwlopRFC/1CzV3/IxVENzcPIAFIuRMrEEf4CRkMvN435OvP3IGPwt +EN7QWviq8s6PuIhTInsfmA47j/LHPugLv7g7w8ejwpdcp35sFyf3hcMdZ17HSR2jGYP+H bBsp9mdtSW+uU6iyCmdTdfs7swqVUMLg1KgAIY0b5K5zouxIioTfLPz0i5V7uQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Tue, 13 Oct 2026 15:16:47 +0200 Subject: [PATCH net-next v11 9/9] net: macb: use context swapping in .ndo_change_mtu() Precedence: bulk X-Mailing-List: linux-kernel@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: <20261013-macb-context-v11-9-b27785167566@bootlin.com> References: <20261013-macb-context-v11-0-b27785167566@bootlin.com> In-Reply-To: <20261013-macb-context-v11-0-b27785167566@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, Paolo Valerio , Nicolai Buchwitz , Vladimir Kondratiev , Gregory CLEMENT , =?utf-8?q?Beno=C3=AEt_Monin?= , Tawfik Bayouk , Thomas Petazzoni 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. They cannot land in macb_change_mtu as they use a different ndo struct. We still defensively protect against it in code. Reviewed-by: Nicolai Buchwitz 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 6bacf3e3caab..f087f278f9e5 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -3658,11 +3658,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.56.0