From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796371039; b=dQFK8HJck3HhlJP3jLLUh1DP9a63w98T2cwLW2qtKFpAUCvRD2iLKGKJZc96suXBUCnv PUL63X67rJCvWhCvNofkcpT6neFizaT4PJVEiCXhrGgPJahUCEw8JgXvddiwk+hUHfvgO 53HHihCHbL4JK5qlWeniETzNrX2W4MVdoqZZsdaQeI97JRT4/4IKA5LnlmedP15L5OUBQ doxh0uToyZmyr+o6oqgoF22wDVaITUk0y15Eg/+kvhoLZUrR9UbEeiWQDkuU2jh4NeGvm Dyhxl6vEV+LlG4/13fnNWIIh4V1UgC+8NUsSceAEh3T62xKB9QHuF3hupnE2invNg9A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796371039; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=YYXXNeQ6E8JL0umgTRGa/Jqxij1nTWEA7JJg8YIch7Y=; b=AqGCop72ZInXDPddiWOecW4D1jJ8i8uR9CmJFFMvyl4mmcV5XtH87JrliXEm4iu3YTq4 YlYsgCxZZW5OiGWEqjmna3nWfhytrH46Rx02YViHJ0LuW07KbJqEdt4AUXvZc54xYzumW eqYuDmwAu3+CkZwefFeUqPj4S8Sh0TVS5ww3eL944Lyw3gA6taT0Y0k5OvAFuNrkT0WSn EEjGcwWZcHQC+2xuF+caMKU4ZR9dy6YMDm9ZAzw+kwDcnxxhcfa9i9aqawqQyjSqAqt57 +jkTZtY906rhKFpZEdifOn8EqtXXPmb9If6qKzjLtaGaEu3HIfzmkMJkWEuts+aVAEQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cNddoJL9; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCC32606A32D; Fri, 4 Dec 2026 07:57:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cNddoJL9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3949C1F000C2; Fri, 4 Dec 2026 07:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796371039; bh=YYXXNeQ6E8JL0umgTRGa/Jqxij1nTWEA7JJg8YIch7Y=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=cNddoJL9ttAnSReNF40vc8NKb0+pbA9NYj8HaWvHS/EFR3pAVUIJcJD2RCge1Wetu EpgLn1YaXV6OaHpfUl/WrMrtQdWcGjBIW7kwzNvbBeb0VBJk08mWQvwdrKyMOVHBAW ATyvy4TJTCyt090ceCs9vu1Ssm8CSjKEU+l8fUkH1WpHs1N8l82R/vDwZsgFPl5z/x ExTVzez4SeNG9QKddympqR7s6+HAcrUm46sASsnX0bzEtR5xn1gYvjY7QZ94je1epp E4EewDl1LNAu1pfO47SIx2zQo2Mi02pQ15ebuF5RnPas6SZFfWTlw7qKn+5yiJtnR8 3mRJCYFD4O0MA== Subject: Re: [PATCH net-next] net: stmmac: dwmac-sun8i: set the RX FIFO flow control in the RX mode setup From: netdev-bot+sashiko@kernel.org To: maxime.chevallier@bootlin.com Cc: andrew+netdev@lunn.ch, kuba@kernel.org, davem@davemloft.net, edumazet@kernel.org, pabeni@redhat.com, horms@kernel.org, willemb@google.com, wens@kernel.org, jernej.skrabec@gmail.com, samuel@sholland.org, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux@armlinux.org.uk, lorenzo.bianconi@oss.qualcomm.com, nb@tipi-net.de, thomas.petazzoni@bootlin.com, alexis.lothore@bootlin.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Date: Fri, 04 Dec 2026 07:57:17 +0000 Message-ID: <179637103775.3146.6270261810238093842@kernel.org> In-Reply-To: <20261203073137.958539-1-maxime.chevallier@bootlin.com> References: <20261203073137.958539-1-maxime.chevallier@bootlin.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 1 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The patch changes behaviour without saying so, and the commit message is inaccurate. - [Low] The commit fixes a race that commit 22fc89783468 ("net: stmmac: dwmac-sun8i: emit pause frames when the RX FIFO fills") introduced,… -- net: stmmac: dwmac-sun8i: set the RX FIFO flow control in the RX mode setup This patch moves the EMAC_RX_CTL1 RX FIFO flow control threshold setup out of sun8i_dwmac_flow_ctrl() and into sun8i_dwmac_dma_operation_mode_rx(). The flow control path then no longer does a read-modify-write of the register that also holds the RX DMA start/enable bits. The thresholds and EMAC_RX_FIFO_FLOW_CTL are now set unconditionally. > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c > index 613199da57c1b..5a660d22b219f 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); [Severity: Medium] Is this change in behaviour intended? Before this patch, sun8i_dwmac_flow_ctrl() cleared EMAC_RX_FIFO_FLOW_CTL unless fc & FLOW_TX was set: 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 | ... Now this code always sets the bit, and the clear mask here does not include it. sun8i_dwmac_flow_ctrl() also no longer touches EMAC_RX_CTL1. The only thing that clears the bit is the writel(0, ioaddr + EMAC_RX_CTL1) in sun8i_dwmac_dma_reset(), and stmmac_hw_setup() sets it again right after. When TX pause is disabled (ethtool -A tx off, or a link partner without pause support), only EMAC_TX_FLOW_CTL_EN in EMAC_TX_FLOW_CTL now gates TX pause. If the sun8i EMAC does not gate RX FIFO threshold flow control on EMAC_TX_FLOW_CTL_EN, could the MAC now send pause frames in full duplex, or apply back-pressure in half duplex, while TX pause is off? The other Synopsys cores do set the equivalent bit unconditionally in the rx mode path (DMA_CONTROL_EFC in dwmac1000, MTL_OP_MODE_EHFC in dwmac4, XGMAC_EHFC in dwxgmac2). I couldn't find anything showing that the Allwinner EMAC behaves the same way. The commit message also says: 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. EMAC_RX_FIFO_FLOW_CTL looks like an enable bit rather than a threshold. sun8i_dwmac_dma_reset(), sun8i_dwmac_dma_start_rx() and sun8i_dwmac_dma_stop_rx() also still write EMAC_RX_CTL1, for example: sun8i_dwmac_dma_start_rx() { v = readl(ioaddr + EMAC_RX_CTL1); v |= EMAC_RX_DMA_START; v |= EMAC_RX_DMA_EN; writel(v, ioaddr + EMAC_RX_CTL1); } Could the commit message say that the flow control path no longer writes EMAC_RX_CTL1, and mention the EMAC_RX_FIFO_FLOW_CTL change? [ ... ] > @@ -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); > - [Severity: Low] This isn't a bug, but this removes the EMAC_RX_CTL1 read-modify-write that commit 22fc89783468 added. The commit message already names that commit as the source of the race. Should this carry a Fixes: tag? Fixes: 22fc89783468 ("net: stmmac: dwmac-sun8i: emit pause frames when the RX FIFO fills") The race comes from the phylink resolve worker calling stmmac_mac_link_up()->stmmac_mac_flow_ctrl()->sun8i_dwmac_flow_ctrl() without rtnl. That path can run at the same time as sun8i_dwmac_dma_start_rx() or sun8i_dwmac_dma_stop_rx(), which modify the same register. [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203073137.958539-1-maxime.chevallier%40bootlin.com