Skip to contentSkip to conversation

net: phy: probe PHY drivers synchronously

PATCH Superseded Heiner Kallweit 2 participants 5 messages Mar 26, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 net: phy: probe PHY drivers synchronously

If we have scenarios like

mdiobus_register()

	-> loads PHY driver module(s)
	-> registers PHY driver(s)
	-> may schedule async probe

phydev = mdiobus_get_phy()
<phydev action involving PHY driver>

or

phydev = phy_device_create()

	-> loads PHY driver module
	-> registers PHY driver
	-> may schedule async probe

<phydev action involving PHY driver>

then we expect the PHY driver to be bound to the phydev when triggering the action. This may not be the case in case of asynchronous probing. Therefore ensure that PHY drivers are probed synchronously.

---
 drivers/net/phy/phy_device.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/phy/phy_device.c +1 -0
index d6024b678..ac2784192 100644
@@ -2575,6 +2575,7 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner)
 	new_driver->mdiodrv.driver.probe = phy_probe;
 	new_driver->mdiodrv.driver.remove = phy_remove;
 	new_driver->mdiodrv.driver.owner = owner;
+	new_driver->mdiodrv.driver.probe_type = PROBE_FORCE_SYNCHRONOUS;
 
 	retval = driver_register(&new_driver->mdiodrv.driver);
 	if (retval) {
Signature · 1 line
2.26.0
maintainer
#1 lore raw
Quoted 12 lines · Heiner Kallweit

If we have scenarios like

mdiobus_register()

	-> loads PHY driver module(s)
	-> registers PHY driver(s)
	-> may schedule async probe

phydev = mdiobus_get_phy()
<phydev action involving PHY driver>

or

phydev = phy_device_create()

Quoted 8 lines
	-> loads PHY driver module
	-> registers PHY driver
	-> may schedule async probe

<phydev action involving PHY driver>

then we expect the PHY driver to be bound to the phydev when triggering the action. This may not be the case in case of asynchronous probing. Therefore ensure that PHY drivers are probed synchronously.

Hi Heiner

We have been doing asynchronous driver loads since forever, and not noticed any problem. Do you have a real example of it going wrong?

Andrew

author maintainer
#2 lore raw
Quoted 18 lines · Andrew Lunn
Quoted 17 lines · Heiner Kallweit

If we have scenarios like

mdiobus_register()

	-> loads PHY driver module(s)
	-> registers PHY driver(s)
	-> may schedule async probe

phydev = mdiobus_get_phy()
<phydev action involving PHY driver>

or

phydev = phy_device_create()

	-> loads PHY driver module
	-> registers PHY driver
	-> may schedule async probe

<phydev action involving PHY driver>

Quoted 6 lines
Quoted 3 lines

then we expect the PHY driver to be bound to the phydev when triggering the action. This may not be the case in case of asynchronous probing. Therefore ensure that PHY drivers are probed synchronously.

Hi Heiner

Hi Andrew,

Quoted 3 lines

We have been doing asynchronous driver loads since forever, and not noticed any problem. Do you have a real example of it going wrong?

it's not about async driver loading, but about async probing once the driver was loaded. See driver_allows_async_probing(). Default still is sync probing, except you explicitly request async probing. But I saw some comments that the intention is to promote async probing for more parallelism in boot process. I want to be prepared for the case that the default is changed to async probing. I'm not aware of any current issues, therefore I submitted it for net-next.

Quoted 2 lines

Andrew

Heiner

maintainer
#3 lore raw
Quoted 4 lines

Default still is sync probing, except you explicitly request async probing. But I saw some comments that the intention is to promote async probing for more parallelism in boot process. I want to be prepared for the case that the default is changed to async probing.

Right. So this should be in the commit message. This is the real reason you are proposing the change.

Andrew

author maintainer
#4 lore raw
Quoted 8 lines · Andrew Lunn
Quoted 4 lines

Default still is sync probing, except you explicitly request async probing. But I saw some comments that the intention is to promote async probing for more parallelism in boot process. I want to be prepared for the case that the default is changed to async probing.

Right. So this should be in the commit message. This is the real reason you are proposing the change.

OK, I'll add it to the commit message.

Quoted 2 lines

Andrew

Heiner