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: <ZdJbciylnw8+ve8V@shell.armlinux.org.uk>
Date: Sun, 18 Feb 2024 19:33:06 +0000
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Christian Marangi <ansuelsmth@...il.com>
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>,
	Florian Fainelli <florian.fainelli@...adcom.com>,
	Broadcom internal kernel review list <bcm-kernel-feedback-list@...adcom.com>,
	Robert Marko <robimarko@...il.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@....com>,
	Nipun Gupta <nipun.gupta@....com>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	Puneet Gupta <puneet.gupta@....com>,
	Abhijit Gangurde <abhijit.gangurde@....com>,
	Umang Jain <umang.jain@...asonboard.com>, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [net-next RFC PATCH 1/6] net: phy: add support for defining
 multiple PHY IDs in PHY driver

On Sun, Feb 18, 2024 at 08:00:27PM +0100, Christian Marangi wrote:
> Some PHY driver might implement the same OPs for different PHY ID and
> using a mask is not enough to match similar PHYs.
> 
> To reduce code duplication, add support for defining multiple PHY IDs in
> PHY driver struct.
> 
> Introduce a new variable in phy_driver struct, .ids, where a table array of
> mdio_device_id can be defined to reference multiple PHY IDs (with their
> own masks) supporting the same group of OPs and flags.
> 
> Introduce a new variable in phy_device, .dev_id, where the matching
> mdio_device_id is stored. PHYs supporting multiple PHYs for one PHY
> driver struct, should use this instead of matching for phy_id.
> 
> Single PHY ID implementation is still supported and dev_id is filled
> with the data from phy_driver in this case.

This looks like it's been reworked somewhat with my suggestion, or maybe
we just came across a similar structure for comparing the IDs?

> +	phy_dev_id = (struct mdio_device_id *)&phydev->dev_id;

Why this cast? Try to write code that doesn't need casts.

> +	/* Fill the mdio_device_id for the PHY istance.
> +	 * If PHY driver provide an array of PHYs, search the right one,
> +	 * in the other case fill it with the phy_driver data.
> +	 */
> +	if (phy_driver_match(phydrv, phydev, &dev_id) && dev_id) {
> +		memcpy(phy_dev_id, dev_id, sizeof(*dev_id));
> +	} else {
> +		phy_dev_id->phy_id = phydrv->phy_id;
> +		phy_dev_id->phy_id_mask = phydrv->phy_id_mask;

So this is the _driver_ phy_id.

>  static inline bool phydev_id_compare(struct phy_device *phydev, u32 id)
>  {
> -	return phy_id_compare(id, phydev->phy_id, phydev->drv->phy_id_mask);
> +	return phy_id_compare(id, phydev->dev_id.phy_id,
> +			      phydev->dev_id.phy_id_mask);

And thus this code is now different (since it _was_ comparing the
phydev phy_id, and you've changed it to effectively the driver's
phy_id. While that should be the same for a matched driver, that
is still a change that probably is't intentional.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ