All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] net: macb: Fix regression breaking non-MDIO fixed-link PHYs
@ 2018-08-20 12:12 Ahmad Fatoum
  2018-08-20 12:12 ` [PATCH 2/4] of: phy: Warn about unexpected fixed-links in of_mdiobus_register Ahmad Fatoum
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Ahmad Fatoum @ 2018-08-20 12:12 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Nicolas Ferre
  Cc: kernel, netdev, mdf, Brad Mouring, Florian Fainelli, stable

The referenced commit broke initializing macb on the EVB-KSZ9477 eval board.
There, of_mdiobus_register was called even for the fixed-link representing
the SPI-connected switch PHY, with the result that the driver attempts to
enumerate PHYs on a non-existent MDIO bus:

	libphy: MACB_mii_bus: probed
	mdio_bus f0028000.ethernet-ffffffff: fixed-link has invalid PHY address
	mdio_bus f0028000.ethernet-ffffffff: scan phy fixed-link at address 0
        [snip]
	mdio_bus f0028000.ethernet-ffffffff: scan phy fixed-link at address 31
	macb f0028000.ethernet: broken fixed-link specification

Cc: <stable@vger.kernel.org>
Fixes: 739de9a1563a ("net: macb: Reorganize macb_mii bringup")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/net/ethernet/cadence/macb_main.c | 27 +++++++++++++++---------
 1 file changed, 17 insertions(+), 10 deletions(-)

Fixes since v1:
	Added one more error path for failing to register fixed-link
	Fixed a whitespace issue


diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index dc09f9a8a49b..ef6ce8691443 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -482,11 +482,6 @@ static int macb_mii_probe(struct net_device *dev)
 
 	if (np) {
 		if (of_phy_is_fixed_link(np)) {
-			if (of_phy_register_fixed_link(np) < 0) {
-				dev_err(&bp->pdev->dev,
-					"broken fixed-link specification\n");
-				return -ENODEV;
-			}
 			bp->phy_node = of_node_get(np);
 		} else {
 			bp->phy_node = of_parse_phandle(np, "phy-handle", 0);
@@ -569,7 +564,7 @@ static int macb_mii_init(struct macb *bp)
 {
 	struct macb_platform_data *pdata;
 	struct device_node *np;
-	int err;
+	int err = -ENXIO;
 
 	/* Enable management port */
 	macb_writel(bp, NCR, MACB_BIT(MPE));
@@ -592,12 +587,23 @@ static int macb_mii_init(struct macb *bp)
 	dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
 
 	np = bp->pdev->dev.of_node;
-	if (pdata)
-		bp->mii_bus->phy_mask = pdata->phy_mask;
+	if (np && of_phy_is_fixed_link(np)) {
+		if (of_phy_register_fixed_link(np) < 0) {
+			dev_err(&bp->pdev->dev,
+				"broken fixed-link specification\n");
+			goto err_out_free_mdiobus;
+		}
+
+		err = mdiobus_register(bp->mii_bus);
+	} else {
+		if (pdata)
+			bp->mii_bus->phy_mask = pdata->phy_mask;
+
+		err = of_mdiobus_register(bp->mii_bus, np);
+	}
 
-	err = of_mdiobus_register(bp->mii_bus, np);
 	if (err)
-		goto err_out_free_mdiobus;
+		goto err_out_free_fixed_link;
 
 	err = macb_mii_probe(bp->dev);
 	if (err)
@@ -607,6 +613,7 @@ static int macb_mii_init(struct macb *bp)
 
 err_out_unregister_bus:
 	mdiobus_unregister(bp->mii_bus);
+err_out_free_fixed_link:
 	if (np && of_phy_is_fixed_link(np))
 		of_phy_deregister_fixed_link(np);
 err_out_free_mdiobus:
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-08-21 18:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-20 12:12 [PATCH 1/4] net: macb: Fix regression breaking non-MDIO fixed-link PHYs Ahmad Fatoum
2018-08-20 12:12 ` [PATCH 2/4] of: phy: Warn about unexpected fixed-links in of_mdiobus_register Ahmad Fatoum
2018-08-20 12:31   ` Ahmad Fatoum
2018-08-20 13:37   ` Andrew Lunn
2018-08-20 13:51     ` Ahmad Fatoum
2018-08-20 12:12 ` [PATCH 3/4] net: macb: Support specifying PHYs in a mdio container dts node Ahmad Fatoum
2018-08-20 13:42   ` Andrew Lunn
2018-08-20 13:45     ` Ahmad Fatoum
2018-08-20 13:56       ` Andrew Lunn
2018-08-20 12:12 ` [PATCH 4/4] ARM: dts: macb: wrap macb PHYs in a mdio container Ahmad Fatoum
2018-08-20 13:55 ` [PATCH 1/4] net: macb: Fix regression breaking non-MDIO fixed-link PHYs Andrew Lunn
2018-08-20 15:56   ` Ahmad Fatoum
2018-08-20 19:06     ` Andrew Lunn
2018-08-21  8:26       ` Ahmad Fatoum
2018-08-21 13:34         ` Andrew Lunn
2018-08-21 14:59           ` Ahmad Fatoum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.