Re: [PATCH net-next 2/3] net: stmmac: dwmac-sun8i: emit pause frames when the RX FIFO fills
From: Maxime Chevallier
Date: Mon Nov 23 2026 - 11:19:40 EST
On 11/23/26 15:51, netdev-bot+sashiko@xxxxxxxxxx wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> 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] Unserialized read-modify-write of EMAC_RX_CTL1 in
> sun8i_dwmac_flow_ctrl() (drivers/net/ethernet/stmicro/stmmac/dwmac-…
>
> --
>
> net: stmmac: dwmac-sun8i: emit pause frames when the RX FIFO fills
>
> This commit sets the RX FIFO flow control thresholds in EMAC_RX_CTL1 from
> sun8i_dwmac_flow_ctrl(). With these thresholds, the MAC sends pause
> frames when less than 2K is left in the RX FIFO and stops when more than
> 4K is free. The new bits are set only when TX flow control is requested.
>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>> index c63f4d87de509..75c743dfe3483 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>
> [ ... ]
>
>> @@ -766,6 +772,17 @@ 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: Medium]
> Can this read-modify-write of EMAC_RX_CTL1 race with the RX DMA start and
> stop helpers?
Hmmm yes indeed, I think we can work around that by writing these FIFO
values in sun8i_dwmac_dma_operation_mode_rx(), just like we do in dwmac1000
and dwmac4, that way no race :)
I'll iterate and fix my typos,
Maxime