lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250917100243.s55irruj4bzg343v@skbuf>
Date: Wed, 17 Sep 2025 13:02:43 +0300
From: Vladimir Oltean <olteanv@...il.com>
To: Andrew Lunn <andrew@...n.ch>
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

On Wed, Sep 17, 2025 at 02:08:31AM +0200, Andrew Lunn wrote:
> > > +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

Ok, I misunderstood the reason for your comment to leave the MDIO lock
alone. Acquiring &bus->mdio_lock I can agree with, regardless of whether
the "driver lock" exists. I'm currently reviewing drivers/mfd/airoha-an8855.c
and it handles this the same way.

I'm not sure that a "driver lock" is something that drivers need.
In this case it creates a lot of red tape. Function yt921x_dsa_X() takes
the driver lock and calls function yt921x_X() which does the work.
IMO that's part of what gives "vendor crap" drivers their name, when
there's no reason behind it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ