From patchwork Mon Oct 21 01:03:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 2694439648@qq.com X-Patchwork-Id: 13843469 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 26568D3C934 for ; Mon, 21 Oct 2024 01:05:26 +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:Content-Transfer-Encoding: MIME-Version:Date:Subject:Cc:To:From:Message-ID:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=pXdO7FzWdme0VVOEOK6+AI3hpoZS5YDRXo5kibSnml0=; b=w2QMg/Lkp3+Sz1QcaYR9NptJ6y t1UMumwW5tGoCFT8XEvBD+2u0CJ5/EttNHc6emV2oVtB2ayNxOhEtgeHg+0xmAqxxlrZWLMcsHukh JEuhyFzcJxUV4o/GePJPYjF+oHUJkrx74UBiC+IScPXz+Uk6BBOPMdgg0VbB34aezRxGXOWDMXw87 t5r6LQe2YbO9GkD0+cgO+9Ec4Y4Ktr7lQdKKc6foN4FTFIv5w26mnXMTzGXxie8uYY2X/p6SAE1FJ kwaR04/4rSArWsR1Or38xMJ6A9fdU2wKNA7cZ3Lmewl1RKuyUc4UddVRNGmRt7oQSQ6sq8ipRZMiU meoGcR9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2grA-00000005mOc-2b9C; Mon, 21 Oct 2024 01:05:12 +0000 Received: from out162-62-58-216.mail.qq.com ([162.62.58.216]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2gpg-00000005mJH-0ZVK for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2024 01:03:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1729472610; bh=pXdO7FzWdme0VVOEOK6+AI3hpoZS5YDRXo5kibSnml0=; h=From:To:Cc:Subject:Date; b=FRDXRDcKYATg4Gx0CR2r6qElZPnFfsXny3958QtOA7a43b+kJsMCqWVLbqptE3IAm QPCYe/u25xehAizuGV3XG9gc+VWhjUrT0dUMhY18VtYQeWFfNDjilFaNhZv8+iCr0r o0tZK1Dx+nb5BLBFkyNcDvnteuZmg8twnVHziSbQ= Received: from localhost ([58.246.87.66]) by newxmesmtplogicsvrszgpuc1-0.qq.com (NewEsmtp) with SMTP id C7BECE2; Mon, 21 Oct 2024 09:03:07 +0800 X-QQ-mid: xmsmtpt1729472587tn8xvfi5d Message-ID: X-QQ-XMAILINFO: OUUXHEo9i1ukMlaV8FBgvyQA6Aslcp3UpBMlH8jpNXs53ckQAdSj0fGh3LvFlV cLkLIPdZtk4ovPL3ZtKOIE+dv62rqEI86yEdye7KUVFgmIGpkXJn1PXXiZNoZ6q9fWYqAJojmAk1 eLoYEDR4QVXfaLt98p12DGZfnKVqybMkF+PYTMmy4ipuX/A6PaQhHlT5BTZd/SXEKaaxYs3Tmtf0 teAs5xH4XR4Aow21Xi5IuWtCmHO10OKNiTL6gC4QeRimqs5gsCScKeuuXPpMLixI0Mk/Azgo06fz CahWY6GXbhhe881UmAF2sfcHbVzTtIJVaqTeS9nR+N8NGFldjkpzBHADpfZFtoVVinoLl6ojLSbR cred4hRv12+bnqQQL2JbZWiDyll/WrFOWxJodS1ALOwWfxxuL1gWsITD20dSO0cmbLoPokACzhQM E65R86YArLCNlp14RANPuy1Jlhj0kAPp+Wm33MC/ctz1obxW0Ky3zkdeiciFe4yK/389rUU33bgX T6C6GEBExXw2MMG9iigfeKlJ/Pxl3Jqp95gyCuUOpsxtf7YkyIfN1q69zB4sMh7SRt1cdDVsx5Ui c56muyusSIpLZodj9g64Akqfsr9qa+T86B8vspb0oJCC7zFj8UdwgkkWu0zU5OfvZ7qOyt79DqIh oUHBeSEYOGQUOaNxu5OKqKIxRvwaiB4YCae2BUt9I24wVsuSBrbwAL60yag2VRUsQdvLnYtHmuPK TnwvT6EmoqEpbDJUfX5EO4+c0KiSrCZZPaflnsoCF69K7jaQYNAvxTxBsjrWwmJTD1R8mjkkPwEL cAiWxEEiaPyEzAh9E+a0tdq2hOJZ5Hv37QBxDBYglpxdrroSCVyl0wzSYR5/qWJb0FrE3VARr/C1 kq/DJCk9ixTZhtfLAb3J6qKvUFgTQPJ6TwcSK83nQyJoN1Pq8OGgY54un5hrpwls1SdSw+wVg9VQ G3VdPLBLk= X-QQ-XMRINFO: OD9hHCdaPRBwq3WW+NvGbIU= From: 2694439648@qq.com To: alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, hailong.fan@siengine.com Subject: [PATCH v1] net: stmmac: enable MAC after MTL configuring Date: Mon, 21 Oct 2024 09:03:05 +0800 X-OQ-MSGID: <9e4821f4b153f01611066ccc2b7d33416426a6ea.1729472506.git.hailong.fan@siengine.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241020_180341_231989_08D52FCF X-CRM114-Status: GOOD ( 13.44 ) 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 From: "hailong.fan" DMA maybe block while ETH is opening, Adjust the enable sequence, put the MAC enable last For example, ETH is directly connected to the switch, which never power down and sends broadcast packets at regular intervals. During the process of opening ETH, data may flow into the MTL FIFO, once MAC RX is enabled. and then, MTL will be set, such as FIFO size. Once enable DMA, There is a certain probability that DMA will read incorrect data from MTL FIFO, causing DMA to hang up. By read DMA_Debug_Status, you can be observed that the RPS remains at a certain value forever. The correct process should be to configure MAC/MTL/DMA before enabling DMA/MAC Signed-off-by: hailong.fan --- V0-V1: 1. update commit messages --- drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 8 -------- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 12 ------------ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++--- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c index 0d185e54e..92448d858 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 7840bc403..cba12edc1 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, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e21404822..c19ca62a4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3437,9 +3437,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); @@ -3523,6 +3520,9 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) /* Start the ball rolling... */ stmmac_start_all_dma(priv); + /* Enable the MAC Rx/Tx */ + stmmac_mac_set(priv, priv->ioaddr, true); + stmmac_set_hw_vlan_mode(priv, priv->hw); return 0;