Re: [PATCH net-next] net: stmmac: dwmac-sun8i: set the RX FIFO flow control in the RX mode setup
From: Maxime Chevallier
Date: Fri Dec 04 2026 - 03:15:30 EST
On 12/4/26 08:57, netdev-bot+sashiko@xxxxxxxxxx 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