[PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool rx-all
James Hilliard
james.hilliard1 at gmail.com
Sun Nov 22 12:05:48 PST 2026
On Sun, Nov 22, 2026 at 11:39 AM Andrew Lunn <andrew at lunn.ch> wrote:
>
> > +static void sun8i_dwmac_update_rx_ctl1(struct stmmac_priv *priv, u32 clear, u32 set)
> > {
> > + struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
> > u32 v;
> >
> > - v = readl(ioaddr + EMAC_RX_CTL1);
> > - v |= EMAC_RX_DMA_START;
> > - v |= EMAC_RX_DMA_EN;
> > - writel(v, ioaddr + EMAC_RX_CTL1);
> > + guard(spinlock_irqsave)(&gmac->rx_ctl1_lock);
> > + v = readl(priv->ioaddr + EMAC_RX_CTL1);
> > + writel((v & ~clear) | set, priv->ioaddr + EMAC_RX_CTL1);
>
> Netdev does not like these magical guard constructs. scoped_guard is
> acceptable, but good old fashioned lock/unlock is preferred.
>
> It is also unclear why this now needs locks, when before it did not.
I added the lock because changing rx-all adds a new writer to RX_CTL1
while the interface is up. The runt-forwarding bit shares that register
with the RX DMA enable bit. If ethtool read the register just before
another CPU stopped RX DMA, writing it back with runt forwarding
enabled could also turn DMA back on.
I went back through the callers to see whether that can actually
happen. RTNL serializes the ethtool change with opening and closing the
interface, resetting it, and reconfiguring RX queues. Neither the sun8i
IRQ handler nor its TX completion path requests a DMA threshold change.
System suspend does stop RX DMA outside RTNL, but userspace is frozen
before the driver reaches that point on the normal sun8i suspend path.
So although the register is shared, I couldn't find a path where the
new writer races an existing one. I think we can drop the lock and
leave the existing DMA callbacks alone.
> This patch is too big, does too many things. Please break it up into
> smaller changes, with good commit messages, which are obviously
> correct.
>
> Andrew
>
More information about the linux-arm-kernel
mailing list