Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2868333lqp; Mon, 25 Mar 2024 11:29:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8Sxf/z99BH817OUg3aA+Vdc9KHGMDO7SYJHCA/Hq8qjCBwftPaWpN8XSitSXMV7lf1DBW7M60B3VtK5EipvVH+kiN9bvH3NLQnpm3DA== X-Google-Smtp-Source: AGHT+IFo5MNAUWicZG8aAzi9pCdb6voj7PzT1VZIKRCQcjMeOalt6r9ErKHxypudD4y95KKHPeZ7 X-Received: by 2002:a17:902:ee46:b0:1dd:7da:e0a9 with SMTP id 6-20020a170902ee4600b001dd07dae0a9mr7474315plo.69.1711391359359; Mon, 25 Mar 2024 11:29:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711391359; cv=pass; d=google.com; s=arc-20160816; b=SAGbweQ6hPDcCvHAQOtGD0gajhQ2yeCp6HrhxihY3Ddp9stnNOrHxfn9JnhLH8s089 buYXcM+sRWK+Kdxy4//HAQg4QImVWkuX1dYG/z14X7b0q8fPN/QHu4gXeqc+1HmFCKV0 Q4kE3jrzm1ytLNTYePB8GXztqbGbmmCix1tt8j12SbAtMil4fki/n1DB0zO0fqhHPoi+ jU+bvQFGnUIZkBr41ENhGaK+yRaX/ac5ttuTkXGarj0D2Az6sa2YyxCLWHovnfKHgQSb 7qj3cJIJfANU5FtS0WBb7GmxCOw281OhhIguPKuoVnQoa9QQI9oieg27DbiS6UB0UfOe C/kw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=GfMOxpWRXLDXkXWQTgxb0njMa5htX2S/fZtS26Kk3Z4=; fh=qHgE/MngZtFhhMUoRBSA0+vEW8yoH8c3Gz8SLaOZ5U4=; b=kfgwcV/r7RTRdXM37MP2DKFIQwhn4MqimcdN4P9T/0NLBk2AaWMETmxdqy+Rs9ldpZ 64eLt5/sSiV0+hBQwKG7IjY9nMYLuNbIOycyHHXXXvh+ViVnI8WOuYQZfxWWYuHYg+aa PYy8NCMLnzP36h9OYG2qLf7DpQufFVK/NG8yR/qWTZV2/NvFshK5FF9pODFqbusnbWW2 oHZbSE02VtNzAotVg5YzUb4YwiYRZlvo9/+T7lsccAsFrJ71o56Ct07jbTx56YwjAJ2g 680Lm8ppXT4Q8mgXc1Q7UaME7VcFH0/hWAzVZQTr6bQnAregxJVzq9ldPb1Qk9g6oV93 u9cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UiLdwfHn; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-117363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117363-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d1-20020a170902654100b001e00879706asi5396461pln.473.2024.03.25.11.29.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 11:29:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UiLdwfHn; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-117363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117363-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C3081B3D50F for ; Mon, 25 Mar 2024 16:59:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAD936E61F; Mon, 25 Mar 2024 15:27:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="UiLdwfHn" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 AC7526D1B5; Mon, 25 Mar 2024 15:27:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380463; cv=none; b=ZkAAplME+UZs+xI9Mjgz+hbdVoFf1cpMLw/yb3aIAn2/KqkdgG6FX4RZpKTVmxdsK67MdjCQxjB7J/c3P9zMFxUdRNhMM3QHRPfVGMFNtsTUPu1Ch/mjxVxBz49Ech8kpoMbLJKheRaSAHbSgibDBrQTJ9vYs0Bb822osrHiR/4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380463; c=relaxed/simple; bh=xeCJhhkfOqR0/lYcw66pUQaVeJ2E9uNUlDvPgWtGRRc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dMadZpZUpTJwQzG814vdGiF+UMEJJrEcqtQ7MAvSMTSNzz0o3ED9H0o/ssnQDs08lgdT57q3K2VmeQGcB12RvyI92S1p3vOW/Qsjt81z4EbwCiEP1/PTMebVK2EsxY6FkWTJapVxKFwhidmXv3wfmzr/GmZIkvai44tRbj1glsc= 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=UiLdwfHn; arc=none smtp.client-ip=217.70.183.193 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 Received: by mail.gandi.net (Postfix) with ESMTPSA id 91A6D240008; Mon, 25 Mar 2024 15:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1711380458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=GfMOxpWRXLDXkXWQTgxb0njMa5htX2S/fZtS26Kk3Z4=; b=UiLdwfHnU5NRNZtqPh1TqkAkfPQF0gugqOgtH/H8AiQaVVinunCILHj3NKgsoLsSadibcV He6tvM6WOZR+erZ7BkxlTMHFbOSf7FdhmCm7k1BEWnPKLDrTFsiIVj2NRjxBQjF5gd4ih6 GfcMyBerVaivFUPHtVqPa5+l26W5ltm/1aY72PwUpDH+UH6iIS2R7EbPtnMfa7K1NpDTQo Cu8R4lgatYIQSlYLydh9+YJkHNEriZDeKKRAALs/8kczJOM3Bww16WsMUVkyJOqitRzJyQ 5Gm4bIluNp707Pct5hTvA04IkVVqjz0oyffNOlwCX+8T8Uu1Lwd0FxYqb9YueA== From: thomas.perrot@bootlin.com To: Nicolas Ferre , Claudiu Beznea , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Perrot Subject: [PATCH net-next] net: macb: allow MTU change when the interface is up Date: Mon, 25 Mar 2024 16:27:35 +0100 Message-ID: <20240325152735.1708636-1-thomas.perrot@bootlin.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: thomas.perrot@bootlin.com From: Thomas Perrot The macb_change_mtu callback doesn't allow MTU changes when the interface is up because the MTU is used to set the buffer size on GEM. So, to be able to change the MTU from userspace it is necessary to explicitly down then to up the interface, which is problematic in some cases. Then we suggest to reset the interface when the interface is already up to allow to change the MTU, regardless of if the interface is up or not. Signed-off-by: Thomas Perrot --- drivers/net/ethernet/cadence/macb_main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 898debfd4db3..5c20b162c5da 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -3019,11 +3019,19 @@ 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; + int reset = 0; + + /* On GEM the buffer size is based on the MTU */ + if (netif_running(dev)) { + macb_close(dev); + reset = 1; + } dev->mtu = new_mtu; + if (reset) + macb_open(dev); + return 0; } -- 2.44.0