🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20522

Re: [PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool rx-all

#20522
From: Andrew Lunn
Date: Sun, 22 Nov 2026 20:57
48 lines
11059 bytes
On Sun, Nov 22, 2026 at 01:05:48PM -0700, James Hilliard wrote:
> On Sun, Nov 22, 2026 at 11:39 AM Andrew Lunn <andrew@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.

And this is where, small changes, with good commit messages helps
you. In order to write the commit message for a small patch adding a
new lock, you would of done this investigation in order to write the
commit message, answering the question "Why?"

I don't say this just for reviewers benefit. It also helps you get
your code correct.

     Andrew
Technical Details
Message-ID: <97515dd2-72b1-4275-910f-94336f8f18a4@lunn.ch>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368820-linux-kernel-netdev=dewy.ru
References: <20261122-submit-sun8i-rxall-v1-v1-0-607789772c56@gmail.com> <20261122-submit-sun8i-rxall-v1-v1-2-607789772c56@gmail.com> <ba116748-1650-4816-97a6-69eeecd4b2cb@lunn.ch> <CADvTj4pDQhnABu0GnsXN-mNhvdiHkwrrk3yJs5gq9RaMPWZFSg@mail.gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368820-linux-kernel-netdev=dewy.ru
From: andrew@lunn.ch (Andrew Lunn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool
 rx-all
Date: Sun, 22 Nov 2026 21:57:36 +0100
Organization: Usenet Network
Message-ID: <97515dd2-72b1-4275-910f-94336f8f18a4@lunn.ch>
References: <20261122-submit-sun8i-rxall-v1-v1-0-607789772c56@gmail.com>
 <20261122-submit-sun8i-rxall-v1-v1-2-607789772c56@gmail.com>
 <ba116748-1650-4816-97a6-69eeecd4b2cb@lunn.ch>
 <CADvTj4pDQhnABu0GnsXN-mNhvdiHkwrrk3yJs5gq9RaMPWZFSg@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3721998"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:mDFc/Aq2cKGBzvfbaAQ1/j9YFw8= sha256:Dley07hPeFllpE0ZbAP1NVuo1XOrRBBN1L4Jp/vzdtE=
	sha1:7XwWY6cbiq643py9G7aexvLZN+o= sha256:A3+EmJghbAnu5r6awJCGV37teto03nn3wlM91mjf6bA=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CC38B125D83; Sun, 22 Nov 2026 23:58:02 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=lunn.ch
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id IpgcSDriuhPR;
	Sun, 22 Nov 2026 23:57:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368820-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=lunn.ch
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id D423C125D82; Sun, 22 Nov 2026 23:57:48 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 09F9A2B9F3; Sun, 22 Nov 2026 20:57:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795381065;
	b=SyBZ/AV+bNoAcEVyaXLYJRE+zuvjnBmlMBJ28aoAZ8f6IBDZjl02x5ftaFXTEY2JLqYA
	 UvUll2KPOTh+61P4kmDHgbpVivm1YQCxP5wvF6bxyDgYwL9ZngxTmKfiT5YaaIzfWkCBu
	 OPRcwfRzaSGWQnOIaO5GuTfyBCI4bhwOEgBVLFDDZx1qMIpspBjhqKKS09zecAZ9n82ew
	 wsQKg3g49ZQK07eIoBvAOfU9ibfZmu5ISgOVcgokpAOA9SqevtLjfE7CRrEB89i0JnieX
	 r/u3VEZnDLOkAXWe26XgbuS/urF/vR2athiwmR6XDal2DlGraJs1nOuayFxUldAgrMA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795381065;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date:
	 From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type:Content-Disposition:
	 Content-Transfer-Encoding:In-Reply-To;
	bh=iDERK68xOldbgeUiiGYyw/w8twcI1O8oq6PXPbGFfdU=;
	b=27o8fV0psX82C3YgangIBv3AzlJ8fENXU4GkEHi4FQkc28STIcdwz1f8JQ+85YUYxPHy
	 4lLgRKODimtZmYe+SR27Vte7licssWW3BFfIXCQx/KIrMcfSMrPnkG6RUInACYv60CtP/
	 cMpyc4ecMABgPVQmfq1TOGvXm78HfxFR+tTD8JBbiSN6UH/DCI9h9gQttSUQuEh47w6oF
	 GsYZkxfkebJxF0S/QVfNiTD0/xgWvI/zLlAObxIYNhVWUZ3GcEEbSToa47PEB2TW4teG5
	 YvTx+kIpT5ScmdpK5nSWCfwBcgiIF4xckLOGNFcTB6kLvsn2EJ6USlKI9Wfr4fsePXQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=bFKN3hQc;
	dmarc=pass header.from=lunn.ch;
	spf=pass smtp.mailfrom=lunn.ch;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D288A606A32D;
	Sun, 22 Nov 2026 20:57:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=bFKN3hQc
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=156.67.10.101
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795381065;
	b=ckLtjhfZWfy1PBBNm2BRjON8QZnRhH59JYdsHu2PGLqxH6exZv3FuHCu3615n9ix38hC
	 jHyRs7/It4pRYg4S7mh+Gm3QCt9bBHU/ELLVcd5IhqQY6gkYnKDDlCE7+VlKlkvblMY8g
	 dl3g87lwYPTKLYbvbPxXVjpuGVQJA5hZ6ds3mkTRXejbDD2YbBhrl63kTCdA8SL5Rqsmv
	 BaclvSi+BI8DVG6RwKS+QrRSKfdAhszAGIvlYjIP5/FdCGnELt+Qa6rN+xuID8cmXI68g
	 5fCPVcmM1eYtlmaYYVHHzVq9gAuAhi4tWQ6xB+d5J6YACQAa1spfwyqpEVxjkT1WuiQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795381065;
	h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject:
	 Message-ID:References:MIME-Version:Content-Type:Content-Disposition:
	 Content-Transfer-Encoding:In-Reply-To;
	bh=iDERK68xOldbgeUiiGYyw/w8twcI1O8oq6PXPbGFfdU=;
	b=y4WjCJotxiPzeOPDbZKO86B3SjnoeQMYFq6LuNgqwhIfDPXV76R4svc6TcbVktCr6MFe
	 Np4hRz7MLTMRr4OVHLFZAOpd5LTMB2qx4qXDvAGjV1mjoYpczRbvOIYtQskD56rR4vOlv
	 i7d48ramjQ39sH6sNy8k4LdrZxP2xTwx4P+c19VZ8ALU4DWMPRFO6UXgijQxmWhcfqis/
	 wENsXo68WNWk3zu/XB8JupVSZ+TLkRJHZtCdhMxVC88RyNa21UP6+33iQ3T3eNLvkJSkt
	 7Ohgcejt1Y6A2uwaTRX+O+26ZMcGtsFz5aS0ysEshWLQGLT/fsqHVWS5s17ZstyW88g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=lunn.ch;
	spf=pass smtp.mailfrom=lunn.ch;
	dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=bFKN3hQc;
	arc=none smtp.remote-ip=156.67.10.101
X-Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E2C9606A31A;
	Sun, 22 Nov 2026 20:57:44 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9E2C9606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch;
	s=20171124; h=In-Reply-To:Content-Transfer-Encoding:Content-Disposition:
	Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:From:
	Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:
	Content-Transfer-Encoding:Content-ID:Content-Description:Content-Disposition:
	In-Reply-To:References; bh=iDERK68xOldbgeUiiGYyw/w8twcI1O8oq6PXPbGFfdU=; b=bF
	KN3hQc8rftOmJOB85CjYZtIUwFRh3FHC98U/Jxsa5dG0F7/Q+MlsyaPWa6ziHHenmf2Xrj2E0WgEq
	96ZmT9hIRl02+gh9IlaBgc6fG3CbNLOmyIHE7AhAIxGXG5T7dryZsIVsCAnsCt2JyeJxKxTa7CMy1
	rHTAMPX0T/xRf2M=;
X-Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2)
	(envelope-from <andrew@lunn.ch>)
	id 1xVEcy-000cTP-42; Sun, 22 Nov 2026 21:57:36 +0100
X-Cc: netdev@vger.kernel.org,
	Maxime Chevallier <maxime.chevallier@bootlin.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Chen-Yu Tsai <wens@kernel.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <CADvTj4pDQhnABu0GnsXN-mNhvdiHkwrrk3yJs5gq9RaMPWZFSg@mail.gmail.com>