[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b0fc2de5-bccc-4ef8-a04d-0c3b13cde914@lunn.ch>
Date: Wed, 17 Sep 2025 02:08:31 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Vladimir Oltean <olteanv@...il.com>
Cc: David Yang <mmyangfl@...il.com>, netdev@...r.kernel.org,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Simon Horman <horms@...nel.org>,
Russell King <linux@...linux.org.uk>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v9 3/3] net: dsa: yt921x: Add support for
Motorcomm YT921x
> > +static int yt921x_reg_mdio_read(void *context, u32 reg, u32 *valp)
> > +{
> > + struct yt921x_reg_mdio *mdio = context;
> > + struct mii_bus *bus = mdio->bus;
> > + int addr = mdio->addr;
> > + u32 reg_addr;
> > + u32 reg_data;
> > + u32 val;
> > + int res;
> > +
> > + /* Hold the mdio bus lock to avoid (un)locking for 4 times */
> > + mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
>
> Andrew, are you satisfied with this lock?
This is O.K. You snipped too much context. As the comment says, the
code is about to do 4 MDIO bus transactions. Each will take and
release the lock. By taking it now, and then using the unlocked
version for read/write, it will make it a tiny bit faster. The time to
do the bus transaction will however dominate.
> Perhaps I missed some part of
> the conversation, but didn't you say "leave the mdio lock alone"?
Yes, i did, but then the mdio lock was being abused as a DSA driver
lock. The DSA driver now has its own lock. So what we see above is
purely an optimisation, not a locking scheme.
Andrew
Powered by blists - more mailing lists