Skip to contentSkip to conversation

Fix for mv643xx_eth built as module

PATCH In review Simon Baatz 3 participants 5 messages Mar 24, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Fix for mv643xx_eth built as module

Recently [1], mv643xx_eth was changed to make use of mvmdio. However, this change introduces two problems when mvmdio and mv643xx_eth are built as modules:

- mvmdio is not loaded automatically by udev
- mv643xx_eth oopses when it can't find its PHY, i.e. when mvmdio is not yet loaded

The first problem can be fixed easily by adding a module alias for the respective platform device. The proposed fix for the second problem uses EPROBE_DEFER as suggested by Thomas Petazzoni when the driver can't find its PHY.

These patches apply on top of Florian Fainelli's patchset. They have been tested on Marvel Kirkwood non-DT.

- Simon

[1] https://lkml.org/lkml/2013/3/22/247

Simon Baatz (2):
net: mvmdio: define module alias for platform device
mv643xx_eth: defer probing if Marvell Orion MDIO driver not loaded

 drivers/net/ethernet/marvell/mv643xx_eth.c |   12 +++++++++---
 drivers/net/ethernet/marvell/mvmdio.c      |    1 +
 2 files changed, 10 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/2 net: mvmdio: define module alias for platform device

The mvmdio driver can be instantiated using device tree or as a classic platform device. In order to load the driver automatically by udev in the latter case, the driver needs to define a module alias for the platform device.

---
 drivers/net/ethernet/marvell/mvmdio.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/marvell/mvmdio.c +1 -0
index 3472574..7b5158f 100644
@@ -295,3 +295,4 @@ module_platform_driver(orion_mdio_driver);
 MODULE_DESCRIPTION("Marvell MDIO interface driver");
 MODULE_AUTHOR("Thomas Petazzoni <[email protected]>");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:orion-mdio");
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/2 mv643xx_eth: defer probing if Marvell Orion MDIO driver not loaded

In reply to Simon Baatz

When both the Marvell MV643XX ethernet driver and the Orion MDIO driver are compiled as modules, the ethernet driver may be probed before the MDIO driver. Let mv643xx_eth_probe() return EPROBE_DEFER in this case, i.e. when it cannot find the PHY.

---
 drivers/net/ethernet/marvell/mv643xx_eth.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +9 -3
index a65a92e..aedbd82 100644
@@ -2681,7 +2681,7 @@ static struct phy_device *phy_scan(struct mv643xx_eth_private *mp,
 	}
 
 	/* Attempt to connect to the PHY using orion-mdio */
-	phydev = NULL;
+	phydev = ERR_PTR(-ENODEV);
 	for (i = 0; i < num; i++) {
 		int addr = (start + i) & 0x1f;
 
@@ -2812,11 +2812,17 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
 	netif_set_real_num_tx_queues(dev, mp->txq_count);
 	netif_set_real_num_rx_queues(dev, mp->rxq_count);
 
-	if (pd->phy_addr != MV643XX_ETH_PHY_NONE)
+	if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
 		mp->phy = phy_scan(mp, pd->phy_addr);
 
-	if (mp->phy != NULL)
+		if (IS_ERR(mp->phy)) {
+			err = PTR_ERR(mp->phy);
+			if (err == -ENODEV)
+				err = -EPROBE_DEFER;
+			goto out;
+		}
 		phy_init(mp, pd->speed, pd->duplex);
+	}
 
 	SET_ETHTOOL_OPS(dev, &mv643xx_eth_ethtool_ops);
 
Signature · 1 line
1.7.9.5
Acked-by on the v1 series
#3 lore raw
In reply to Simon Baatz

Hello Simon,

Le dimanche 24 mars 2013 21:33:58, Simon Baatz a ?crit :

Quoted 8 lines

Recently [1], mv643xx_eth was changed to make use of mvmdio. However, this change introduces two problems when mvmdio and mv643xx_eth are built as modules:

- mvmdio is not loaded automatically by udev
- mv643xx_eth oopses when it can't find its PHY, i.e. when mvmdio is not yet loaded

Quoted 7 lines

The first problem can be fixed easily by adding a module alias for the respective platform device. The proposed fix for the second problem uses EPROBE_DEFER as suggested by Thomas Petazzoni when the driver can't find its PHY.

These patches apply on top of Florian Fainelli's patchset. They have been tested on Marvel Kirkwood non-DT.

Both fixes look good to me, thanks for fixing this!

Signature · 1 line
Florian
maintainer
#4 lore raw

From: Florian Fainelli <[email protected]>
Date: Sun, 24 Mar 2013 21:48:33 +0100

Quoted 16 lines

Hello Simon,

Le dimanche 24 mars 2013 21:33:58, Simon Baatz a ?crit :

Quoted 13 lines

Recently [1], mv643xx_eth was changed to make use of mvmdio. However, this change introduces two problems when mvmdio and mv643xx_eth are built as modules:

- mvmdio is not loaded automatically by udev
- mv643xx_eth oopses when it can't find its PHY, i.e. when mvmdio is not yet loaded

The first problem can be fixed easily by adding a module alias for the respective platform device. The proposed fix for the second problem uses EPROBE_DEFER as suggested by Thomas Petazzoni when the driver can't find its PHY.

Quoted 6 lines
Quoted 2 lines

These patches apply on top of Florian Fainelli's patchset. They have been tested on Marvel Kirkwood non-DT.

Both fixes look good to me, thanks for fixing this!

All applied, thanks.