The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: netdev-bot+sashiko@kernel.org
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
Subject: Re: [PATCH net-next] net: stmmac: dwmac-sun8i: set the RX FIFO flow control in the RX mode setup
Date: Fri, 4 Dec 2026 09:14:44 +0100	[thread overview]
Message-ID: <2cd00a15-ab7e-43bc-8b87-7ebd6428e586@bootlin.com> (raw)
In-Reply-To: <179637103775.3146.6270261810238093842@kernel.org>



On 12/4/26 08:57, netdev-bot+sashiko@kernel.org wrote:
> 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?

There's no change in behaviour.

 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.

see my reply to Nicolai, "gating TX pause" with EMAC_TX_FLOW_CTL is
enough.

> 
> 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")

it's net-next, I can add it but not super necessary, no need to
backport or anything.

Maxime


  reply	other threads:[~2026-12-04  8:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  7:31 [PATCH net-next] net: stmmac: dwmac-sun8i: set the RX FIFO flow control in the RX mode setup Maxime Chevallier
2026-12-03  7:59 ` Nicolai Buchwitz
2026-12-03  9:05   ` Maxime Chevallier
2026-12-03  9:26     ` Nicolai Buchwitz
2026-12-04  7:57 ` netdev-bot+sashiko
2026-12-04  8:14   ` Maxime Chevallier [this message]
2026-12-04  8:59 ` Lorenzo Bianconi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2cd00a15-ab7e-43bc-8b87-7ebd6428e586@bootlin.com \
    --to=maxime.chevallier@bootlin.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=alexis.lothore@bootlin.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux@armlinux.org.uk \
    --cc=lorenzo.bianconi@oss.qualcomm.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=nb@tipi-net.de \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=samuel@sholland.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wens@kernel.org \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox