[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8344bcc0-6526-43be-b460-b5356f2251cd@lunn.ch>
Date: Tue, 27 Aug 2024 15:07:05 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Paolo Abeni <pabeni@...hat.com>
Cc: Mark Brown <broonie@...nel.org>,
Woojung Huh <woojung.huh@...rochip.com>,
UNGLinuxDriver@...rochip.com,
Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Marek Vasut <marex@...x.de>
Subject: Re: [PATCH] net: dsa: microchip: Use standard regmap locking
On Tue, Aug 27, 2024 at 02:54:52PM +0200, Paolo Abeni wrote:
> On 8/22/24 21:53, Mark Brown wrote:
> > For unclear reasons the ksz drivers use custom regmap locking which is
> > simply a wrapper around a standard mutex.
>
> According to the commit introducing such lock,
> 013572a236ef53cbd1e315e0acf2ee632cc816d4
> the ksz driver family one regmap per register width (8/16/32), accessing the
> same set of registers.
>
> The locking implemented with the code removed here allows serializing
> operations using different register widths.
Just expanding on that, here is the full commit message:
commit 013572a236ef53cbd1e315e0acf2ee632cc816d4
Author: Marek Vasut <marex@...x.de>
Date: Wed Oct 16 15:33:24 2019 +0200
net: dsa: microchip: Add shared regmap mutex
The KSZ driver uses one regmap per register width (8/16/32), each with
it's own lock, but accessing the same set of registers. In theory, it
is possible to create a race condition between these regmaps, although
the underlying bus (SPI or I2C) locking should assure nothing bad will
really happen and the accesses would be correct.
To make the driver do the right thing, add one single shared mutex for
all the regmaps used by the driver instead. This assures that even if
some future hardware is on a bus which does not serialize the accesses
the same way SPI or I2C does, nothing bad will happen.
Also, adding Marek to Cc:
Andrew
Powered by blists - more mailing lists