From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.85.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796283114; b=dDK/P+ZOdqkW5T9fsnw+I8OPvLdagwXM6jhNc+z8K1L9Lm44CbLzp7uqO0h2nS2+Y1oO Tjiezz2TjkQk6q9Z3wWMwV/LxBiH9RkTNREcQ9rzRmyP3Z60JuNM7VkkrG8XciTX+AHqr CVldfHc5hrZTzsnIwo59gb5CffKVn5vFj5P63yhdxmFgONLe7zO+6zhLoaskoy8/RMZCL yblTJi+zpyHn6+VvGyspj3IH0GQCjSA1LgaGDfLP13u9bE8dexcEg0zNLx8ZSXIU0viDS UEJCbTmQiJYzkfFU4hXUDxhWV21EdsG2buKG9KsKeusukUVLbErgLcBNkTcWPjTEsNw== 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=oGPclBQIThcVVXmtpQsbfCyfdsSeqN+E21DBSwhi5ZmKDklBTZBbP3FRdMtz0ZEkwopq iLjdJYyeJmh6+RHC3lCy6S7tRY7v+02427CCJBtZ/9z75Uqvka8y/0iCvliZ/hFyvCDGH WIqbuf/8T2syjc+l8hOHifnDS0oyxkU0xB3cbnzAhD0/se5LKKMeM4ylUq0O0QuJVBmN/ /kGquTO/uQB92Z0cQKssxian7ktvYCdwFGAK6EZ5kXIcEmb9ZUbmee5Fq3TbSdlE2JBpL B13XfQ2C3KN42OdvMDwqkQStTtnhyAjHT6nLrQsUDjxWRQ29+dloVE86YU3YcSo7/Ng== 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.85.4 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 24FCC606A32C; Thu, 3 Dec 2026 07:31:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 24FCC606A32C 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) 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-03.galae.net (Postfix) with ESMTPS id 36E2B4E41858; 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: netdev@vger.kernel.org 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