From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC5BF606A322 for ; Thu, 3 Dec 2026 07:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=NjRUllPt; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=o/vbWjTs 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:Message-ID:Date:Subject:Cc:To:From: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-Unsubscribe-Post:List-Owner; bh=tEJtP532qeV2mmVCvsYlL2ngdZbPY+OnJxVRdH4++mI=; b=NjRUllPtmb0RXsW5C2wuy+HW57 rJxSNmBtaxaVz3D9B7Qy3cYUz6ImfuDP6ADQxSV2p/ntrdjVrV8DEAFlkB/R32HusCFRPH0EjWjLD gI6W99lOTGeL16q9N6eqZGe8zqOGjyAJWbyusiHwVclkNSlhEei7oJJaTPMa+Y7nxKeFW/owoI7E7 TJWtgKSddwhYRxjmQE8+/7nKjXJqCbTnjidD6YLIOA2wpj3I6iclb0IaDPQJLELn6s9JFmgxsqF2/ vhDn6S6iBHyL6qI6LU+QcG+h58k09jy5Z1fudWnfPajTl0/sJsX/MaU60wgcfYa4jjrXVgnGbKPx5 DsH3dGqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ1IO-0000000Dl3Y-0ldM; Thu, 03 Dec 2026 07:32:02 +0000 Received: from smtpout-02.galae.net ([185.246.84.56]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ1IG-0000000Dl2x-3ebe for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 07:31:56 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 2EBFE1A1909; Thu, 3 Dec 2026 07:31:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id EB4F3604ED; Thu, 3 Dec 2026 07:31:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5F19011EA18A0; Thu, 03 Dec 2026 08:31:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796283108; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=tEJtP532qeV2mmVCvsYlL2ngdZbPY+OnJxVRdH4++mI=; b=o/vbWjTs0yzZ8ZNY/APbEp1LRsIMeLPji+V4Tj7F/m3ndsFJEMS0QJOYifjyOBr9FqSBpv No4rCg1xUyIAlLuyRMZE8KMN9OOstQmc5uy6lNWaWo88A2SpYzAShYbNkxzN2AHWyW6M9q M6r6zVNN0uDJ4/HBZ931sEG6y8mFuHBCVPpP7FLiDe7WQ1fih0qYQMvp/e4iRyF0iVSKDR dsOvg4RoO2nlp/5uNloJrGwKNBXQmRxacnhX4y8CRooEWeokk/bKYc0rWnYRx7ras948cV etWLqct+oI4EGXqBtGKkp7Abw8PIjhzMf7ouC5KU9pXKhSY8rNzCScRAbui3Iw== From: Maxime Chevallier To: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Willem de Bruijn , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maxime Coquelin , Alexandre Torgue , Russell King , Lorenzo Bianconi , Nicolai Buchwitz Cc: Maxime Chevallier , thomas.petazzoni@bootlin.com, =?UTF-8?q?Alexis=20Lothor=C3=A9?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH net-next] net: stmmac: dwmac-sun8i: set the RX FIFO flow control in the RX mode setup Date: Thu, 3 Dec 2026 08:31:36 +0100 Message-ID: <20261203073137.958539-1-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.56.1 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261202_233153_075863_8B3861A6 X-CRM114-Status: GOOD ( 17.73 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On dwmac sun8i, the TX pause behaviour is controlled via 2 registers: - TX_FLOW_CTL_EN, to enable/disable TX pause and set a few extra pause params, - EMAC_RX_CTL1, that configures the fifo thresholds to start/stop sending pause frames EMAC_RX_CTL1 also configures the DMA engine, to enable/disable it as well as start/stop it. There's a chance for a race if we trigger an action that starts the DMA engine at the same time as we configure pause. Let's move the threshold setup in the DMA configuration path, making it the only piece of code that touches this register. This is OK, as we just set the thresholds, we don't change the FC status. That's also what's done in other glues. The thresholds are now configured unconditionnally, that's also OK as it doesn't affect anything else that TX FC, and only if it's enabled in HW. This didn't happen before, as we didn't configure the thresholds up until: commit 22fc89783468 ("net: stmmac: dwmac-sun8i: emit pause frames when the RX FIFO fills") This was reported by Sashiko when submitting the above patch. I've tested this on Allwinner H2+, but only to make sure FC still works, I haven't tried to reproduce the race. Signed-off-by: Maxime Chevallier --- .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c index 613199da57c1..5a660d22b219 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c @@ -562,6 +562,12 @@ static void sun8i_dwmac_dma_operation_mode_rx(struct stmmac_priv *priv, else if (mode < 128) v |= EMAC_RX_TH_128; } + + v &= ~(EMAC_RX_FLOW_CTL_TH_ACT | EMAC_RX_FLOW_CTL_TH_DEACT); + v |= EMAC_RX_FIFO_FLOW_CTL | + FIELD_PREP(EMAC_RX_FLOW_CTL_TH_ACT, EMAC_RX_FLOW_CTL_TH_2K) | + FIELD_PREP(EMAC_RX_FLOW_CTL_TH_DEACT, EMAC_RX_FLOW_CTL_TH_4K); + writel(v, ioaddr + EMAC_RX_CTL1); } @@ -774,17 +780,6 @@ static void sun8i_dwmac_flow_ctrl(struct mac_device_info *hw, v &= ~EMAC_RX_FLOW_CTL_EN; writel(v, ioaddr + EMAC_RX_CTL0); - v = readl(ioaddr + EMAC_RX_CTL1); - v &= ~(EMAC_RX_FIFO_FLOW_CTL | EMAC_RX_FLOW_CTL_TH_ACT | - EMAC_RX_FLOW_CTL_TH_DEACT); - if (fc & FLOW_TX) - v |= EMAC_RX_FIFO_FLOW_CTL | - FIELD_PREP(EMAC_RX_FLOW_CTL_TH_ACT, - EMAC_RX_FLOW_CTL_TH_2K) | - FIELD_PREP(EMAC_RX_FLOW_CTL_TH_DEACT, - EMAC_RX_FLOW_CTL_TH_4K); - writel(v, ioaddr + EMAC_RX_CTL1); - v = readl(ioaddr + EMAC_TX_FLOW_CTL); v &= ~(EMAC_TX_FLOW_CTL_EN | EMAC_TX_FLOW_CTL_ZQP_FRM_EN | EMAC_TX_FLOW_CTL_PAUSE_TIME); -- 2.56.1