From patchwork Tue Jun 14 22:41:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 12881700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85CF4C43334 for ; Tue, 14 Jun 2022 23:37:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=i5GcfRjAAE/ZPKDKhkxxyGcTpMSes4BXFQRpwNlH8z8=; b=CKAwJuhOy/uzNx AexPHgIpmPq5KgXgkcY4lX7TsDfC4X2+ZGIw088Qx81/PGpetk002cdr1xjxAOBtznUxUhvlm4CUj 2gDn5/oS0683x3Zjs8gcxpEld7llgaKpNgU8ic2sjIzG/W3EcpqeKtc8LwP/AogANYQNRfxFjAFAa hzv1kAK/Yefe65j6SPv7EUYPoPAD+2ifXAs/l4s7ISKxcjKh6ib10/T4szATDRciLOkwn3w5GGfAX XR5w4WkLt5bSh4SM3xtBgbOOSnRfIqIrVzTgk1gTtU0dawqUlHQcjB55EzXBgDkF+xFhM6P80IoJ2 RAYWVFGBpe4nK4YrZwAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1G4K-00BnP8-QG; Tue, 14 Jun 2022 23:35:32 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1G4H-00BnOk-NP for linux-arm-kernel@lists.infradead.org; Tue, 14 Jun 2022 23:35:31 +0000 Received: by mail-ed1-x535.google.com with SMTP id o10so13758558edi.1 for ; Tue, 14 Jun 2022 16:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RwCVoV8orfnRgwChCK+rAQA3GeHEe/lWNU6fYCZRqrw=; b=HyiUT/C87YjhHKbLwF0EpWK4PnzBxNE7YV3xYCMN6FXpXh0QlIyDfuJgfsugtwpqlX tQDc8/Zn/FB68kwisUD4c0VvIiYwGfK9OOgwXguq7LGkq9hFmDC/Zkth0yxXjj2arsgw 4Eki4svotj9voOUf7t4ZSB0B9XGnLFeSe9Tr9cUOVkTxJxRyvNuBDOdFeZKXqs+MPusV QPF8ZUHjUAfQ7acYBcdGg8axP2nZ7grUER14ruqPHai/wJ2pHsxEs1G0PgizLHEVpeMe YswVuykcSw75MCZc2s5J5IKPQN+zg5NCbeIv63s/RQlhh/JJp9TzgVgtDYZ8fkAjzC3g 0K5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RwCVoV8orfnRgwChCK+rAQA3GeHEe/lWNU6fYCZRqrw=; b=MVGK5Psc1JaLst4xdxr5E4i+eCd6HrcjOEQ08FqGL3zwPCxxSzcoyLKS0vT3LmKRJ+ Khg91Pr4giyaGr1e3Wn2qIqTikPHSYNXxxAhAdvkhx9ZfKEgVbbE5lcibDWk6TP9yi3r Sb7evDsByN4a/ToCITIQ42voVki6d18OIB3pksQnF3SP617TIt82Wweai3BZpzBipYVj h3xYGwh+6hWq4ZyQB83kNJfBaC0aO0b8XuL6s2gFU0vtsSQrtcAMcR1l1Q3mCmmdIGbA g3iuRxOJuP6xaWliGWtR7PaPEDfo2M52CTP/QxEnLiLHzegSUnuhAbJNb3nVnlW3lTS/ 4aRQ== X-Gm-Message-State: AOAM531YbrKzWtIMo1wz05+fBiWF0h3uFRTA8LNIH2CxOFo2bdmr21xR sJ8BLh0zygexC9Kym8WlVLI= X-Google-Smtp-Source: AGRyM1s7yi8SKYgGonC6z+fB20MLO4Xt5CUZ8FDxi2I5kdemGH1a5Zybz5MQqTbnia8UfoicrJMPTA== X-Received: by 2002:aa7:ce84:0:b0:42d:ce51:8c6e with SMTP id y4-20020aa7ce84000000b0042dce518c6emr9386188edv.10.1655249726709; Tue, 14 Jun 2022 16:35:26 -0700 (PDT) Received: from localhost.localdomain (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.googlemail.com with ESMTPSA id l23-20020a17090612d700b006f3ef214daesm5572956ejb.20.2022.06.14.16.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 16:35:25 -0700 (PDT) From: Christian 'Ansuel' Marangi To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Christian 'Ansuel' Marangi Subject: [net-next PATCH] net: ethernet: stmicro: stmmac: permit MTU change with interface up Date: Wed, 15 Jun 2022 00:41:41 +0200 Message-Id: <20220614224141.23576-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220614_163529_835395_CE5BD4A3 X-CRM114-Status: GOOD ( 15.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Remove the limitation where the interface needs to be down to change MTU by releasing and opening the stmmac driver to set the new MTU. Also call the set_filter function to correctly init the port. This permits to remove the EBUSY error while the ethernet port is running permitting a correct MTU change if for example a DSA request a MTU change for a switch CPU port. Signed-off-by: Christian 'Ansuel' Marangi --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index d1a7cf4567bc..a968a13b3183 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5448,11 +5448,6 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu) txfifosz /= priv->plat->tx_queues_to_use; - if (netif_running(dev)) { - netdev_err(priv->dev, "must be stopped to change its MTU\n"); - return -EBUSY; - } - if (stmmac_xdp_is_enabled(priv) && new_mtu > ETH_DATA_LEN) { netdev_dbg(priv->dev, "Jumbo frames not supported for XDP\n"); return -EINVAL; @@ -5466,6 +5461,14 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu) dev->mtu = mtu; + if (netif_running(dev)) { + netdev_dbg(priv->dev, "restarting interface to change its MTU\n"); + stmmac_release(dev); + + stmmac_open(dev); + stmmac_set_filter(priv, priv->hw, dev); + } + netdev_update_features(dev); return 0;