From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: "Nicolai Buchwitz" <nb@tipi-net.de>
Cc: "Conor Dooley" <conor.dooley@microchip.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Sean Anderson" <sean.anderson@linux.dev>,
"Antoine Tenart" <atenart@kernel.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
"Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
<stable@vger.kernel.org>
Subject: Re: [PATCH net] net: macb: take bp->lock around NCR read-modify-writes
Date: Mon, 21 Sep 2026 16:36:34 +0200 [thread overview]
Message-ID: <DLL2JCMFXCO0.313SCDHNUJ46Q@bootlin.com> (raw)
In-Reply-To: <f695ad9aa88acb08727f442307dafe9c@tipi-net.de>
Hello Nicolai,
On Fri Sep 18, 2026 at 10:31 PM CEST, Nicolai Buchwitz wrote:
> On 18.9.2026 21:59, Théo Lebrun wrote:
>> NCR is read-modify-written from many contexts:
>>
>> - macb_mac_link_down() clears RE|TE,
>> - macb_mac_link_up() sets RE|TE|PTPUNI,
>> - macb_hresp_error_task() clears then re-sets RE|TE,
>> - macb_start_xmit() / macb_tx_restart() / macb_tx_error_task() set
>> TSTART (already under bp->lock),
>> - macb_interrupt() might toggle RE (also under bp->lock).
>>
>> The first three risk concurrent RMW with anyone from the list as they
>> don't grab bp->lock.
>
> There is a fourth, in at91ether_interrupt():
>
> if (intstatus & MACB_BIT(RXUBR)) {
> ctl = macb_readl(bp, NCR);
> macb_writel(bp, NCR, ctl & ~MACB_BIT(RE));
> wmb();
> macb_writel(bp, NCR, ctl | MACB_BIT(RE));
> }
>
> I guess you have skipped this as the emac variants using this are not
> SMP?
Actually I skipped over this at91ether one because at91ether functions
use zero locking. But as you point out, yes, RMWs are safe from
interrupt context on a non-SMP platform.
> Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Thanks!
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2026-09-21 14:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 19:59 Théo Lebrun
2026-09-18 20:31 ` Nicolai Buchwitz
2026-09-21 14:36 ` Théo Lebrun [this message]
2026-09-22 8:00 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DLL2JCMFXCO0.313SCDHNUJ46Q@bootlin.com \
--to=theo.lebrun@bootlin.com \
--cc=andrew+netdev@lunn.ch \
--cc=atenart@kernel.org \
--cc=conor.dooley@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregory.clement@bootlin.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nb@tipi-net.de \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=sean.anderson@linux.dev \
--cc=stable@vger.kernel.org \
--cc=tawfik.bayouk@mobileye.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=vladimir.kondratiev@mobileye.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®