2018-01-05 09:36:31

by Madalin-cristian Bucur

[permalink] [raw]
Subject: [PATCH net] of_mdio: avoid MDIO bus removal when a PHY is missing

If one of the child devices is missing the of_mdiobus_register_phy()
call will return -ENODEV. When a missing device is encountered the
registration of the remaining PHYs is stopped and the MDIO bus will
fail to register. Propagate all errors except ENODEV to avoid it.

Signed-off-by: Madalin Bucur <[email protected]>
---
drivers/of/of_mdio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 3481e69..93d41275 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -231,7 +231,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
rc = of_mdiobus_register_phy(mdio, child, addr);
else
rc = of_mdiobus_register_device(mdio, child, addr);
- if (rc)
+ if (rc && rc != -ENODEV)
goto unregister;
}

@@ -255,7 +255,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)

if (of_mdiobus_child_is_phy(child)) {
rc = of_mdiobus_register_phy(mdio, child, addr);
- if (rc)
+ if (rc && rc != -ENODEV)
goto unregister;
}
}
--
2.1.0


2018-01-05 15:12:46

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH net] of_mdio: avoid MDIO bus removal when a PHY is missing

On Fri, Jan 05, 2018 at 11:36:14AM +0200, Madalin Bucur wrote:
> If one of the child devices is missing the of_mdiobus_register_phy()
> call will return -ENODEV. When a missing device is encountered the
> registration of the remaining PHYs is stopped and the MDIO bus will
> fail to register. Propagate all errors except ENODEV to avoid it.

Hi Madalin

This is is not clear cut. If the PHY is in device tree, the PHY should
exist. So returning ENODEV is justified. The device tree blob is
broken. But i can also see the value for continuing. There is a chance
some of your other interfaces come up, allowing you to get the correct
device tree blob for the hardware.

Please add

dev_err(&mdio->dev, "MDIO device at address %d is missing.\n");

Andrew

>
> Signed-off-by: Madalin Bucur <[email protected]>
> ---
> drivers/of/of_mdio.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
> index 3481e69..93d41275 100644
> --- a/drivers/of/of_mdio.c
> +++ b/drivers/of/of_mdio.c
> @@ -231,7 +231,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
> rc = of_mdiobus_register_phy(mdio, child, addr);
> else
> rc = of_mdiobus_register_device(mdio, child, addr);
> - if (rc)
> + if (rc && rc != -ENODEV)
> goto unregister;
> }
>
> @@ -255,7 +255,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
>
> if (of_mdiobus_child_is_phy(child)) {
> rc = of_mdiobus_register_phy(mdio, child, addr);
> - if (rc)
> + if (rc && rc != -ENODEV)
> goto unregister;
> }
> }
> --
> 2.1.0
>

2018-01-08 08:49:09

by Madalin-cristian Bucur

[permalink] [raw]
Subject: RE: [PATCH net] of_mdio: avoid MDIO bus removal when a PHY is missing

> -----Original Message-----
> From: Andrew Lunn [mailto:[email protected]]
> Sent: Friday, January 05, 2018 5:13 PM
> To: Madalin-cristian Bucur <[email protected]>
> Subject: Re: [PATCH net] of_mdio: avoid MDIO bus removal when a PHY is
> missing
>
> On Fri, Jan 05, 2018 at 11:36:14AM +0200, Madalin Bucur wrote:
> > If one of the child devices is missing the of_mdiobus_register_phy()
> > call will return -ENODEV. When a missing device is encountered the
> > registration of the remaining PHYs is stopped and the MDIO bus will
> > fail to register. Propagate all errors except ENODEV to avoid it.
>
> Hi Madalin
>
> This is is not clear cut. If the PHY is in device tree, the PHY should
> exist. So returning ENODEV is justified. The device tree blob is
> broken. But i can also see the value for continuing. There is a chance
> some of your other interfaces come up, allowing you to get the correct
> device tree blob for the hardware.
>
> Please add
>
> dev_err(&mdio->dev, "MDIO device at address %d is missing.\n");
>
> Andrew

This appears on boards that include in the device tree the description
for the PHYs found on an optional riser card. When the riser card is
removed, this issue is triggered. I'll send a v2 with the dev_err()
included.

Thanks,
Madalin