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/2026…%40bootlin.com