🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26824

Re: [PATCH net-next] net: stmmac: dwmac-sun8i: set the RX FIFO flow control in the RX mode setup

#26824
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 07:57
127 lines
13222 bytes
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
Technical Details
Message-ID: <179637103775.3146.6270261810238093842@kernel.org>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377175-linux-kernel-netdev=dewy.ru
References: <20261203073137.958539-1-maxime.chevallier@bootlin.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377175-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next] net: stmmac: dwmac-sun8i: set the RX FIFO flow
 control in the RX mode setup
Date: Fri, 04 Dec 2026 07:57:17 +0000
Organization: Usenet Network
Message-ID: <179637103775.3146.6270261810238093842@kernel.org>
References: <20261203073137.958539-1-maxime.chevallier@bootlin.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2709722"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VyusQzFk/Tckh7RPLedGRiPPlto= sha256:LTXsGD6IQ3Q47gSsXwvZiIYrUaI+nHLHM0hebyKNUgg=
	sha1:X0yXDNEkfSwLSiVuOxBmF6zAJIU= sha256:mw0/r83bdP94e/+01b5iPof4LZ2KmKAwMGHREpUqbXM=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id C3F2B117B5F; Fri,  4 Dec 2026 10:57:38 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id ZCR19tmtdc1M;
	Fri,  4 Dec 2026 10:57:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-377175-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 4A6D9117B46; Fri,  4 Dec 2026 10:57:26 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 4866921BD8; Fri,  4 Dec 2026 07:57:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796371040;
	b=Ja3X8hlWsz4akZrZQYi5W54f6HdnnJpjObZDYQ67luQp4WAPXuWjbGF6PBbWGv/eKxu6
	 A3jYVP61qKsCXXvvff5NXDcEUipIDHw5od1+ELte27C81fpByy/K1hXST27o1BpqvcAbq
	 FHcw27AjBH5MPjWxqYpjj4zQrfxLw4U19KVDXeIeHBfcZiNTy/CNDhqKRz+CedOsAKIc1
	 F1n3eZjCeAwwJVlgpJ/3d99nW1MGxtTGunQcs0jCTtZabH9q6jkNTCTIQdcGrFJ0aMqIU
	 TZIppS/94RcdKrhMMHyTdytwBXSqjbB+Zfp0uGed1fuvjKXjUwnJxL7eoPp2+jJqlQg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796371040;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=YYXXNeQ6E8JL0umgTRGa/Jqxij1nTWEA7JJg8YIch7Y=;
	b=SWoKlFpDHdknHkeH1XQzM2NfJ+e/rUUEzyRNlb8J7hv2WaMk0W/7efUhkRcdSAH3i1wT
	 Gr9CrjGz9UYp+qxhYrMmGpo8OTvPZHj8NNDItvbvrvuX8tJe+cA7Rs2NKUyfVFp9aCh7g
	 etv1tS9d/NrJp2wLl/Ah0ghx15URfnii8/7VIz+SeeYZnmk5RHO5KjkjZ3jDs8eXlgA6/
	 HtBmziifAlLk3kkGALE/pYeA7UTvrD+GRAtTyMp6WF0JQCq2yM4FVbwrxHngs945yGcUl
	 1figqfAHXyTHcV8qa7/CNZn2rLKAFon7hMyVELx3cWpSnC90itcAQgxOeq53+BGRzaA==
X-ARC-Authentication-Results: i=2; 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=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id A00E7606A33B;
	Fri,  4 Dec 2026 07:57:20 +0000 (UTC)
X-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
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-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==
X-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==
X-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
X-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)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3949C1F000C2;
	Fri,  4 Dec 2026 07:57:18 +0000 (UTC)
X-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==
X-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
X-In-Reply-To: <20261203073137.958539-1-maxime.chevallier@bootlin.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list