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: <aVrjdEVYCag4yKxg@makrotopia.org>
Date: Sun, 4 Jan 2026 22:02:28 +0000
From: Daniel Golle <daniel@...rotopia.org>
To: "Russell King (Oracle)" <linux@...linux.org.uk>
Cc: Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Vladimir Oltean <vladimir.oltean@....com>,
	Michael Klein <michael@...sekall.de>,
	Aleksander Jan Bajkowski <olek2@...pl>,
	Bevan Weiss <bevan.weiss@...il.com>, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 3/4] net: phy: realtek: use paged access for
 MDIO_MMD_VEND2 in C22 mode

On Sun, Jan 04, 2026 at 09:23:00PM +0000, Russell King (Oracle) wrote:
> On Sun, Jan 04, 2026 at 01:12:13PM +0000, Daniel Golle wrote:
> > +static int rtl822xb_read_mmd(struct phy_device *phydev, int devnum, u16 reg)
> > +{
> > +	int oldpage, ret, read_ret;
> > +	u16 page;
> > +
> > +	/* Use Clause-45 bus access in case it is available */
> > +	if (phydev->is_c45)
> > +		return __mdiobus_c45_read(phydev->mdio.bus, phydev->mdio.addr,
> > +					  devnum, mmdreg);
> > +
> > +	/* Use indirect access via MII_MMD_CTRL and MII_MMD_DATA for all
> > +	 * MMDs except MDIO_MMD_VEND2
> > +	 */
> > +	if (devnum != MDIO_MMD_VEND2) {
> > +		__mdiobus_write(phydev->mdio.bus, phydev->mdio.addr,
> > +				MII_MMD_CTRL, devnum);
> > +		__mdiobus_write(phydev->mdio.bus, phydev->mdio.addr,
> > +				MII_MMD_DATA, mmdreg);
> > +		__mdiobus_write(phydev->mdio.bus, phydev->mdio.addr,
> > +				MII_MMD_CTRL, devnum | MII_MMD_CTRL_NOINCR);
> > +
> > +		return __mdiobus_read(phydev->mdio.bus, phydev->mdio.addr,
> > +				       MII_MMD_DATA);
> > +	}
> 
> I think I'd prefer this structure:
> 
> 	if (devnum != MDIO_MMD_VEND2)
> 		return mmd_phy_read(phydev->mdio.bus, phydev->mdio.addr,
> 				    phydev->is_c45, devnum, regad);
> 
> 	if (phydev->is_c45)
> 		return __mdiobus_c45_read(phydev->mdio.bus, phydev->mdio.addr,
> 					  devnum, mmdreg);

Even this would be possible then:
	if (devnum != MDIO_MMD_VEND2 || phydev->is_c45)
		return mmd_phy_read(phydev->mdio.bus, phydev->mdio.addr,
				    phydev->is_c45, devnum, regad);

> 
> rather than open-coding the indirect access, or the reverse order with
> mmd_phy_read() called with is_c45 set to false.
> 
> Same for the write function.

I also thought it'd be good to do that, but that would require moving
the function prototypes from drivers/net/phy/phylib-internal.h to a
public header which the PHY driver may include, eg. phylib.h. (I suppose
that 'phylib-internal.h' should not be included in PHY drivers).

Needless to say that I also don't fancy open-coding unlocked variants
of phy_{read,write}_paged, but that's on a other story...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ