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]
Date: Wed, 15 Nov 2023 17:12:03 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Romain Gantois <romain.gantois@...tlin.com>
Cc: davem@...emloft.net, Rob Herring <robh+dt@...nel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
	Jakub Kicinski <kuba@...nel.org>,
	Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
	devicetree@...r.kernel.org, thomas.petazzoni@...tlin.com,
	Florian Fainelli <f.fainelli@...il.com>,
	Heiner Kallweit <hkallweit1@...il.com>,
	Russell King <linux@...linux.org.uk>,
	linux-arm-kernel@...ts.infradead.org,
	Vladimir Oltean <vladimir.oltean@....com>,
	Luka Perkov <luka.perkov@...tura.hr>,
	Robert Marko <robert.marko@...tura.hr>,
	Andy Gross <agross@...nel.org>,
	Bjorn Andersson <andersson@...nel.org>,
	Konrad Dybcio <konrad.dybcio@...ainline.org>
Subject: Re: [PATCH net-next v3 6/8] net: phy: add calibration callbacks to
 phy_driver

On Wed, Nov 15, 2023 at 04:31:07PM +0100, Romain Gantois wrote:
> On Tue, 14 Nov 2023, Andrew Lunn wrote:
> 
> > > +static inline
> > > +int phy_start_calibration(struct phy_device *phydev)
> > > +{
> > > +	if (!(phydev->drv &&
> > > +	      phydev->drv->calibration_start &&
> > > +	      phydev->drv->calibration_stop))
> > > +		return -EOPNOTSUPP;
> > > +
> > > +	return phydev->drv->calibration_start(phydev);
> > > +}
> > > +
> > > +static inline
> > > +int phy_stop_calibration(struct phy_device *phydev)
> > > +{
> > > +	if (!(phydev->drv &&
> > > +	      phydev->drv->calibration_stop))
> > > +		return -EOPNOTSUPP;
> > > +
> > > +	return phydev->drv->calibration_stop(phydev);
> > > +}
> > > +
> > 
> > What is the locking model?
> > 
> >      Andrew
> > 
> This driver currently uses an atomic flag to make sure that the calibration 
> doesn't run twice. It doesn't acquire any locks before calling 
> phy_start_calibration(), which is a mistake.
> 
> I think a good locking model for this would be similar to the one used for 
> phy_cable_test. The phy_start_calibration() and phy_stop_calibration() wrappers 
> would acquire a lock on the PHY device and then test phydev->state, to check for 
> an ongoing calibration. A new enum member such as PHY_CALIB could be defined for 
> this purpose. The lock would be released by the phylib wrapper once the 
> phy_driver callback returns.
> 
> The problem with this is that one calibration run can access multiple 
> phy_device instances at the same time, e.g. if a switch is linked to a multiport 
> PHY via a PSGMII link.
> 
> So acquiring a lock on a single phy device isn't enough. Ideally, these 
> calls could somehow acquire one lock on all the hardware resources of a 
> multiport PHY simultaneously. From what I've seen, there is no standard kernel 
> interface that allows MAC drivers to know about link-sharing between phy 
> devices. I'll have to do more research on this but if you know of an existing 
> interface that I can use for this, please tell me.

Lets get the switch parts merged first, then we can think about this
calibration problem. I need a better understanding of the requirements
before i can suggest something.

       Andrew


Powered by blists - more mailing lists