Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.84.56 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796283114; b=szhydAN2r4pRI/rBWYylkqqEEumlpnSUPSmn4UO4EO7AvcJc0tzFZZX/eEy2GICSlhgY ouVos/3A6+JwYUf0F2i08J5d/zsTTbEX4gRG+h/40K3SgNe7qSL6bRES0qAVYbxcEZx0v qjWus0C2hO/zVHxAFZxSriM00a9SkM6mQqwcwjUlSIKBzq0Cj4t78CkGf0tIZUHiLo3Zv EjR6cn8PVh0myHz6PizolqVMcFQVE8/p4sOySAIrBiwJ/BsTdAywdtTjnrwv0qsgCILQr Fbn5Sa+P+HTzzS5tUzJE7Xx834l3M9Ju0/C0gopKqwuYR9lOzvO4OJyE5ARc6rvUVKQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796283114; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:To:Cc: Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding:X-Last-TLS-Session-Version; bh=tEJtP532qeV2mmVCvsYlL2ngdZbPY+OnJxVRdH4++mI=; b=p3dg+avTeN+JXxVzgOwpTT02GDBVuBAzhugu0+HDLT3i0I2pUOqOXMIgGvfAJYxEfOa8 h5VC3t1NpGRm8L5kodxjGTFNmxQbFf1t9UEIivSCuHsBpuMCC3GXnI0gjrBdXL3LEZJKo ly7fO4smt4/pvugqaDrw5eI+yGoRolE/gYbyD9iBWLDcyjOTDAhluun2F34h59ZXZBhrn T2NPzPViPcsGGc0lUaJq0+quAUZgjCHuA6tpGX+LsU4idmvs6qLuSQGLHOwrRGrjFvBHG pYOmaGmZNj63jnbTk6nzg71tERhsvH3RAEpp1+uY4xrNwRUvg5OV9nR7f6fCYAAHWFQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b="o/vbWjTs"; arc=none smtp.remote-ip=185.246.84.56 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 30AF1606A322 for ; Thu, 3 Dec 2026 07:31:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 30AF1606A322 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=o/vbWjTs 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-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 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