From patchwork Thu Feb 27 15:05:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13995082 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 D592CC197BF for ; Thu, 27 Feb 2025 19:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PeDwYN+9O7ofBfdGjMQgostKcsW9CtPj8yKA2FA+gnQ=; b=PPn5w9MjWyjc6daN2DCyNDvNWR K/LeR7B75YsuqyX+8shor7H7Z1De/8ldTmp2mIIUpy27mocVBwtXW90DlBBDRC0XXPIzHl31kNOgq ZCwMQgEt6zWhqPOhfQsTl0yPQEVmS9PQQMl0HIiGm6PcqYdG+2mWjIDlpWP3Vom5C4xL+Y99sf096 S3I9ErosNP8TN6vvr7SWvqR5uHT8TgJ9ytp1ZwmTKMMIX/uKPqFjIFY+AJurM7t3aZOnXwSktK5s9 5qcCHrOsmnYmQSfzmQeavCEbKKcV1fE4h+jYozOYrmI/oeufa8ZnhtbtzXFO08a6NWmGJnTsKLghj MD7T2tdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tnjhM-00000008U9c-1fxV; Thu, 27 Feb 2025 19:37:32 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tnfS5-00000007rFy-1BHG for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2025 15:05:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PeDwYN+9O7ofBfdGjMQgostKcsW9CtPj8yKA2FA+gnQ=; b=fKjB7U/sPzjpaWnvnHuoQuyRgG wZBrdPenKuIJhclehBhbAjcb8axTDwJBoR3vcO1Vv6zab6McpqgkftdKTc3wkWJthAUhYvFXjnsqI 1OgCtI2u+VPKBkOfdHZ5zS+s/FjdBrP7hil83VTxYmZ/TXp20xozg9RZzvj8sFCs/e5cfVTr1rbeN /zdwOCzDevN8DcM+kiAG1rk2wu/t09S9/D1hMraC8rD4Ygw7KpyXDqb6T/I/B0unT4UBxNCw4Kheq J5ANY94GeC7ePeXP8j9PAlJZHMhHtPSC3qUjRw5JSixDtpjt9jDgTdPkbjYDgCEIeT7HS72DqRZqe Ax4JYkTw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:46938 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tnfRy-0007WX-0X; Thu, 27 Feb 2025 15:05:22 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tnfRe-0057S9-6W; Thu, 27 Feb 2025 15:05:02 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jon Hunter , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Thierry Reding Subject: [PATCH RFC net-next 1/5] net: stmmac: call phylink_start() and phylink_stop() in XDP functions MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 27 Feb 2025 15:05:02 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250227_070529_324171_8B75D5EA X-CRM114-Status: GOOD ( 12.99 ) 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 Phylink does not permit drivers to mess with the netif carrier, as this will de-synchronise phylink with the MAC driver. Moreover, setting and clearing the TE and RE bits via stmmac_mac_set() in this path is also wrong as the link may not be up. Replace the netif_carrier_on(), netif_carrier_off() and stmmac_mac_set() calls with the appropriate phylink_start() and phylink_stop() calls, thereby allowing phylink to manage the netif carrier and TE/RE bits through the .mac_link_up() and .mac_link_down() methods. Note that RE should only be set after the DMA is ready to avoid the receive FIFO between the MAC and DMA blocks overflowing, so phylink_start() needs to be placed after DMA has been started. Signed-off-by: Russell King (Oracle) Tested-by: Furong Xu <0x1207@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 13796b1c8d7c..84d8b1c9f6d4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6887,6 +6887,8 @@ void stmmac_xdp_release(struct net_device *dev) /* Ensure tx function is not running */ netif_tx_disable(dev); + phylink_stop(priv->phylink); + /* Disable NAPI process */ stmmac_disable_all_queues(priv); @@ -6902,14 +6904,10 @@ void stmmac_xdp_release(struct net_device *dev) /* Release and free the Rx/Tx resources */ free_dma_desc_resources(priv, &priv->dma_conf); - /* Disable the MAC Rx/Tx */ - stmmac_mac_set(priv, priv->ioaddr, false); - /* set trans_start so we don't get spurious * watchdogs during reset */ netif_trans_update(dev); - netif_carrier_off(dev); } int stmmac_xdp_open(struct net_device *dev) @@ -6992,25 +6990,25 @@ int stmmac_xdp_open(struct net_device *dev) tx_q->txtimer.function = stmmac_tx_timer; } - /* Enable the MAC Rx/Tx */ - stmmac_mac_set(priv, priv->ioaddr, true); - /* Start Rx & Tx DMA Channels */ stmmac_start_all_dma(priv); + phylink_start(priv->phylink); + ret = stmmac_request_irq(dev); if (ret) goto irq_error; /* Enable NAPI process*/ stmmac_enable_all_queues(priv); - netif_carrier_on(dev); netif_tx_start_all_queues(dev); stmmac_enable_all_dma_irq(priv); return 0; irq_error: + phylink_stop(priv->phylink); + for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++) hrtimer_cancel(&priv->dma_conf.tx_queue[chan].txtimer); From patchwork Thu Feb 27 15:05:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13995083 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 727A9C282C5 for ; Thu, 27 Feb 2025 19:37:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=oqa9NrYSVqKjM2Z1WEm2zE1O8fLef4BbBY8UX3zYRHE=; b=AoFxQe0wFCiIhMos8JqQX9c9zo T8VwDnzQVE+mKEJ4L6UOms/zPkTm0Nejsmo+OTkb+wc148hhHJGthQEXAyKFVL1fQkr9hyb2CXPPw K31e/Ao0ynoUyFwHR0/PaJ+cGk4zXKBrUMlD8DHL7Eq378hLVUXXgWbe7G98FMAZU4W2luY0f5BiU AbgTqgEgWfTWstprcNCivKODdREcUxuKr+SyBnA1K/xAL5pefrsGMAuu5IjbiiR8gSND/G+2RrIoi 2YaHnkNcJYDZ6KfSXdd+sFC6fDXNLp0v9ets8W+F3gim40wVuzAzED4JuWk1fA7d8kAhVxTQJj/AJ ENEJFA8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tnjhN-00000008UBh-1pvb; Thu, 27 Feb 2025 19:37:33 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tnfS7-00000007rGV-4AHh for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2025 15:05:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oqa9NrYSVqKjM2Z1WEm2zE1O8fLef4BbBY8UX3zYRHE=; b=bUfHcvNHZZ5SJoDEH9o6VZS8yT 9IhsP0ZHaMibY/KgJKZ/xFPBCKcsRvGvmV41u79gEkJby5BCMlqOHKSlGZjt8DCB0T0oFj0w1pwXS Tx449dfOTHKhr4/yO40JpDbuoH8iQHwjXUHLwrTz/EU5a5yDLOy/y9qNtZITTiQpVkavr2HD8ydcr vdCAqAFOUXRiAdmESNWzdcMPmCeaAVfVlv4gLSK1cIAqwn/D9xgRSTkvWQYD/ILLwjRZsi2IvfCAZ 9wupUKteH4/ShpR5j66Dqxwp833xNJAhroeMdbN08QmxBWyQODFNkGN5s60n8YR7YrXkZTZy1U94r OD4FqwGA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:46940 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tnfS3-0007Wq-16; Thu, 27 Feb 2025 15:05:27 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tnfRj-0057SF-9t; Thu, 27 Feb 2025 15:05:07 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jon Hunter , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Thierry Reding Subject: [PATCH RFC net-next 2/5] net: stmmac: remove redundant racy tear-down in stmmac_dvr_remove() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 27 Feb 2025 15:05:07 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250227_070532_029181_9AD12739 X-CRM114-Status: UNSURE ( 9.11 ) X-CRM114-Notice: Please train this message. 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 While the network device is registered, it is published to userspace, and thus userspace can change its state. This means calling functions such as stmmac_stop_all_dma() and stmmac_mac_set() are racy. Moreover, unregister_netdev() will unpublish the network device, and then if appropriate call the .ndo_stop() method, which is stmmac_release(). This will first call phylink_stop() which will synchronously take the link down, resulting in stmmac_mac_link_down() and stmmac_mac_set(, false) being called. stmmac_release() will also call stmmac_stop_all_dma(). Consequently, neither of these two functions need to called prior to unregister_netdev() as that will safely call paths that will result in this work being done if necessary. Remove these redundant racy calls. Signed-off-by: Russell King (Oracle) Reviewed-by: Andrew Lunn Reviewed-by: Furong Xu <0x1207@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 84d8b1c9f6d4..9462d05c40c8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7757,8 +7757,6 @@ void stmmac_dvr_remove(struct device *dev) pm_runtime_get_sync(dev); - stmmac_stop_all_dma(priv); - stmmac_mac_set(priv, priv->ioaddr, false); unregister_netdev(ndev); #ifdef CONFIG_DEBUG_FS From patchwork Thu Feb 27 15:05:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13995084 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 5BD04C19F32 for ; Thu, 27 Feb 2025 19:37:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bwqVamQlIMiTRup9spj3AiZP8ueBDS1xeBFA9CjA03A=; b=4vb5m7oq+EsfwvYpjEHIlP3+9c C5KW8UDm47oou/i5C5COyWuJInPrFOktWjEFVHHsFL+0FXk00/S19K69gxd9fEys3dREydkQEo1CT QlOyihuiKSsKQSI2CI01YUYGT4BkqRv1p5X5Ni62wFGaae4AYRWcDdatLf1TW9WKU0/qbSjGfGoiD LRHi9Cqe03+2vuRDH8OyLZZZHN8l+MeTqhX7YCj4iGMm/sbeNWwngUaarRFcyyeL37GXY2bARTrVu xqdCWJi6gT8spCdSoofNlHceOFDRKkvWNcG7Ke+xzpnJy4Xw+obRszrJQOjdavX81cz/Mmuw3gqXV XsYADw+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tnjhO-00000008UDK-1nfz; Thu, 27 Feb 2025 19:37:34 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tnfSE-00000007rHz-0NO1 for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2025 15:05:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bwqVamQlIMiTRup9spj3AiZP8ueBDS1xeBFA9CjA03A=; b=jHmJGwUiTU2byERl8udaqgXIw/ LycRO5CT/8fkTYHA6seibmf/jbl2UJC4EZpvlX1/2uPVrh88Ey7FlTEtA9gPpd+ljjqtqUPHmhuYn SyJNbO8h720+HFSBrkZ5+pxLUZpt/skR6WYEOkCn+7oswQmiHiPlX8Yj4nZ6GuKCSJ5CtHlU8zvMp vLSmxbhWV54sSdrS5CI68Sg7uI/gsF7wQlCS4KSclymE4ieBWxp8lONc48qlpJIEwQL+5rCFhPSLk Y1I2D2D0Z52mT/Sv9m9A3fMrZfYM1ZvDjNq5yZu+QOu+F0WDyelpWI516wB03y2myPCdMNIaGf/g9 rrcTXojQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:35196 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tnfS8-0007X9-1m; Thu, 27 Feb 2025 15:05:32 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tnfRo-0057SL-Dz; Thu, 27 Feb 2025 15:05:12 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jon Hunter , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Thierry Reding Subject: [PATCH RFC net-next 3/5] net: stmmac: remove unnecessary stmmac_mac_set() in stmmac_release() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 27 Feb 2025 15:05:12 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250227_070538_125415_FD67B8AF X-CRM114-Status: UNSURE ( 8.09 ) X-CRM114-Notice: Please train this message. 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 stmmac_release() calls phylink_stop() and then goes on to call stmmac_mac_set(, false). However, phylink_stop() will call stmmac_mac_link_down() before returning, which will do this work. Remove this unnecessary call. Signed-off-by: Russell King (Oracle) Reviewed-by: Andrew Lunn Tested-by: Furong Xu <0x1207@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 9462d05c40c8..e47b702fb9f9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -4120,9 +4120,6 @@ static int stmmac_release(struct net_device *dev) /* Release and free the Rx/Tx resources */ free_dma_desc_resources(priv, &priv->dma_conf); - /* Disable the MAC Rx/Tx */ - stmmac_mac_set(priv, priv->ioaddr, false); - /* Powerdown Serdes if there is */ if (priv->plat->serdes_powerdown) priv->plat->serdes_powerdown(dev, priv->plat->bsp_priv); From patchwork Thu Feb 27 15:05:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13995086 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 4C02BC1B087 for ; Thu, 27 Feb 2025 19:37:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=B5lx7JkhQqTUFvx02MAjNql+WyKMowqOBnsMeSQXWtU=; b=PIcnEp+rtmFpfjmGojtoSsri5W hPzzA/w1JD3dBJmXRl16YnnNR450m7CMAYT7OlSDryhZAGWhxnOtVUwIeMCQ57gXGuCg7O6il7idK PkZ8AWTmosVOVirwr41aEKNysDYcGnox6QZuYlFAqVPfoqMYlqfFuaxXWYRU0nkjPCE66f85G+es+ zCaCxaObu2OhEhurByZLwgSXXelp2itMkbbDWeY3xP48Q23IwNsI0bqzOJr1On1ZkX6j0cNOG/4v+ lV4/KBLEBr13KekaXDOKoktqn7Ra8cJMJvUBrU4NaBvayzdeOA1dNd7GFRggR0LV0F02y5TsV2YG/ 0V6JC7ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tnjhP-00000008UEi-1Ugz; Thu, 27 Feb 2025 19:37:35 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tnfSI-00000007rIv-2fjP for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2025 15:05:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=B5lx7JkhQqTUFvx02MAjNql+WyKMowqOBnsMeSQXWtU=; b=UVnNqd+JJmc7ij8XJGyjqZKhLL KzdoMbqkVDVCNCVy3NWFI7wi3q9wZ3nu2ab6cP4rXrqi0fLFLpazdyklj3UMRK9ps6OJ2lAE8GX0K eH3dInY3JMd/EJ/tL5+42MqSFsd3YdYFSrIlP+hdVHW5Rt1KH1lZxyk/8bnl+ap+A1wxuhxD2f6uZ eJB5pzHGQSX9SCcRoA0RiRpha4zueuiay3zX4ykHOPmhsC0eep7Cz3Y0nL+IZVS9Nno+VE7V5aK+H R6jeMasobQwjntYl7KiNlTcrJRsrzjGr3AM0bRtA2ejPopFwW1mX0k7w+ULQlupo9/wbKqc45w4vU hq+HvPyA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:35204 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tnfSD-0007XS-2B; Thu, 27 Feb 2025 15:05:37 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tnfRt-0057SR-Hx; Thu, 27 Feb 2025 15:05:17 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jon Hunter , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Thierry Reding Subject: [PATCH RFC net-next 4/5] net: stmmac: remove _RE and _TE in (start|stop)_(tx|rx)() methods MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 27 Feb 2025 15:05:17 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250227_070542_677104_854D5FC3 X-CRM114-Status: UNSURE ( 8.71 ) X-CRM114-Notice: Please train this message. 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 fiddling with _TE and _RE in the GMAC control register in the start_tx/stop_tx/start_rx/stop_rx() methods as this should be handled by phylink and not during initialisation. Signed-off-by: Russell King (Oracle) Reviewed-by: Andrew Lunn Tested-by: Furong Xu <0x1207@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 8 -------- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 12 ------------ 2 files changed, 20 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c index 57c03d491774..61584b569be7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c @@ -50,10 +50,6 @@ void dwmac4_dma_start_tx(struct stmmac_priv *priv, void __iomem *ioaddr, value |= DMA_CONTROL_ST; writel(value, ioaddr + DMA_CHAN_TX_CONTROL(dwmac4_addrs, chan)); - - value = readl(ioaddr + GMAC_CONFIG); - value |= GMAC_CONFIG_TE; - writel(value, ioaddr + GMAC_CONFIG); } void dwmac4_dma_stop_tx(struct stmmac_priv *priv, void __iomem *ioaddr, @@ -77,10 +73,6 @@ void dwmac4_dma_start_rx(struct stmmac_priv *priv, void __iomem *ioaddr, value |= DMA_CONTROL_SR; writel(value, ioaddr + DMA_CHAN_RX_CONTROL(dwmac4_addrs, chan)); - - value = readl(ioaddr + GMAC_CONFIG); - value |= GMAC_CONFIG_RE; - writel(value, ioaddr + GMAC_CONFIG); } void dwmac4_dma_stop_rx(struct stmmac_priv *priv, void __iomem *ioaddr, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c index 7840bc403788..cba12edc1477 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c @@ -288,10 +288,6 @@ static void dwxgmac2_dma_start_tx(struct stmmac_priv *priv, value = readl(ioaddr + XGMAC_DMA_CH_TX_CONTROL(chan)); value |= XGMAC_TXST; writel(value, ioaddr + XGMAC_DMA_CH_TX_CONTROL(chan)); - - value = readl(ioaddr + XGMAC_TX_CONFIG); - value |= XGMAC_CONFIG_TE; - writel(value, ioaddr + XGMAC_TX_CONFIG); } static void dwxgmac2_dma_stop_tx(struct stmmac_priv *priv, void __iomem *ioaddr, @@ -302,10 +298,6 @@ static void dwxgmac2_dma_stop_tx(struct stmmac_priv *priv, void __iomem *ioaddr, value = readl(ioaddr + XGMAC_DMA_CH_TX_CONTROL(chan)); value &= ~XGMAC_TXST; writel(value, ioaddr + XGMAC_DMA_CH_TX_CONTROL(chan)); - - value = readl(ioaddr + XGMAC_TX_CONFIG); - value &= ~XGMAC_CONFIG_TE; - writel(value, ioaddr + XGMAC_TX_CONFIG); } static void dwxgmac2_dma_start_rx(struct stmmac_priv *priv, @@ -316,10 +308,6 @@ static void dwxgmac2_dma_start_rx(struct stmmac_priv *priv, value = readl(ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan)); value |= XGMAC_RXST; writel(value, ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan)); - - value = readl(ioaddr + XGMAC_RX_CONFIG); - value |= XGMAC_CONFIG_RE; - writel(value, ioaddr + XGMAC_RX_CONFIG); } static void dwxgmac2_dma_stop_rx(struct stmmac_priv *priv, void __iomem *ioaddr, From patchwork Thu Feb 27 15:05:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13995085 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 50E57C282C7 for ; Thu, 27 Feb 2025 19:37:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YCufWFd6G+xrz+BePjT03qTPZYQ4Xqveeaiwin3kBZY=; b=C1njU4ISTxAskZho+CpSAxT8pc v4BaPOnq96orkR0M0FlVZQ2GNLxMA+Cax94AZ3l6E45+epVScQV2eqsdzig8YLEtMWXtEFHM0YQ8/ BSeMFSf9V5CsfFQoxa8Owi5F5VV3d+Xb1n+ng8XyuV6Sjk85Gphe4cH+3++a24F4BG+7IPRnBtnJK uaJraWtZ3SBkt0xcAm2PURjFlSCkhe183mHA7AqEkLRSfpVbhA/H0IWi0hT5HK44xcMyAk0xQ5XqL dj8wsQCj0afmf0zAVzq9edCl1DR8tilcb4CNWPFidcCPiYGp/3Sue/SOnM2oCNmipwcWXOzV8I0lF NzAlzLjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tnjhQ-00000008UGw-2A40; Thu, 27 Feb 2025 19:37:36 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tnfSN-00000007rJi-1oBx for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2025 15:05:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=YCufWFd6G+xrz+BePjT03qTPZYQ4Xqveeaiwin3kBZY=; b=tlRKRqmfRq7SMY6gL21jv5t0mU qWtAohbIyGTYR85mQjfixnVJFbC2juOSSXj0NjQgKtr7wJkuXqcYJTRQ1FFywnnuqaWJ3H1UuzZ2F D8auRIOmrUdfIqgQZxBufhtUV4nt0czgVFfC9L1R+rdsm37G+bpDz1NRSebDiii7ecEH1MhGfP+81 ws8HsIdNNco/AZXDIOJY8xzOBS0tpu4tjcq0WeTG6dj7OB/EHW8XMxXwGIhw1MHmLyS1c2I6XUdcj /XcsoNotQahe9y5T+CYCs9X5LFLBzc49z1A3mdtER8BZZu1hoBIBlVTH4mXandvaEEM9vwyb0I+M0 SC1znplw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:41118 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tnfSI-0007Xj-2Q; Thu, 27 Feb 2025 15:05:42 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tnfRy-0057SX-Lj; Thu, 27 Feb 2025 15:05:22 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jon Hunter , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Thierry Reding Subject: [PATCH RFC net-next 5/5] net: stmmac: leave enabling RE and TE to stmmac_mac_link_up() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 27 Feb 2025 15:05:22 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250227_070547_467414_D2FBF35A X-CRM114-Status: GOOD ( 10.35 ) 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 We only need to enable the MAC receiver and transmiter only when the link has come up. With commit "net: stmmac: move phylink_resume() after resume setup is complete" we move the race between stmmac_mac_link_up() and stmmac_hw_setup(), ensuring that stmmac_mac_link_up() happens afterwards. This patch is a pre-requisit of this change. Remove the unnecessary call to stmmac_mac_set(, true) in stmmac_hw_setup(). Signed-off-by: Russell King (Oracle) Tested-by: Furong Xu <0x1207@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e47b702fb9f9..c80952349eb7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3506,9 +3506,6 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) priv->hw->rx_csum = 0; } - /* Enable the MAC Rx/Tx */ - stmmac_mac_set(priv, priv->ioaddr, true); - /* Set the HW DMA mode and the COE */ stmmac_dma_operation_mode(priv);