linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix for mv643xx_eth built as module
@ 2013-03-24 20:33 Simon Baatz
  2013-03-24 20:33 ` [PATCH 1/2] net: mvmdio: define module alias for platform device Simon Baatz
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Simon Baatz @ 2013-03-24 20:33 UTC (permalink / raw)
  To: linux-arm-kernel

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(-)

-- 
1.7.9.5

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

* [PATCH 1/2] net: mvmdio: define module alias for platform device
  2013-03-24 20:33 [PATCH 0/2] Fix for mv643xx_eth built as module Simon Baatz
@ 2013-03-24 20:33 ` Simon Baatz
  2013-03-24 20:34 ` [PATCH 2/2] mv643xx_eth: defer probing if Marvell Orion MDIO driver not loaded Simon Baatz
  2013-03-24 20:48 ` [PATCH 0/2] Fix for mv643xx_eth built as module Florian Fainelli
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Baatz @ 2013-03-24 20:33 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Simon Baatz <gmbnomis@gmail.com>
---
 drivers/net/ethernet/marvell/mvmdio.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 3472574..7b5158f 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -295,3 +295,4 @@ module_platform_driver(orion_mdio_driver);
 MODULE_DESCRIPTION("Marvell MDIO interface driver");
 MODULE_AUTHOR("Thomas Petazzoni <thomas.petazzoni@free-electrons.com>");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:orion-mdio");
-- 
1.7.9.5

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

* [PATCH 2/2] mv643xx_eth: defer probing if Marvell Orion MDIO driver not loaded
  2013-03-24 20:33 [PATCH 0/2] Fix for mv643xx_eth built as module Simon Baatz
  2013-03-24 20:33 ` [PATCH 1/2] net: mvmdio: define module alias for platform device Simon Baatz
@ 2013-03-24 20:34 ` Simon Baatz
  2013-03-24 20:48 ` [PATCH 0/2] Fix for mv643xx_eth built as module Florian Fainelli
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Baatz @ 2013-03-24 20:34 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Simon Baatz <gmbnomis@gmail.com>
---
 drivers/net/ethernet/marvell/mv643xx_eth.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index a65a92e..aedbd82 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -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);
 
-- 
1.7.9.5

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

* [PATCH 0/2] Fix for mv643xx_eth built as module
  2013-03-24 20:33 [PATCH 0/2] Fix for mv643xx_eth built as module Simon Baatz
  2013-03-24 20:33 ` [PATCH 1/2] net: mvmdio: define module alias for platform device Simon Baatz
  2013-03-24 20:34 ` [PATCH 2/2] mv643xx_eth: defer probing if Marvell Orion MDIO driver not loaded Simon Baatz
@ 2013-03-24 20:48 ` Florian Fainelli
  2013-03-24 21:07   ` David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Florian Fainelli @ 2013-03-24 20:48 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Simon,

Le dimanche 24 mars 2013 21:33:58, Simon Baatz a ?crit :
> 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.

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

Acked-by: Florian Fainelli <florian@openwrt.org>
-- 
Florian

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

* [PATCH 0/2] Fix for mv643xx_eth built as module
  2013-03-24 20:48 ` [PATCH 0/2] Fix for mv643xx_eth built as module Florian Fainelli
@ 2013-03-24 21:07   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2013-03-24 21:07 UTC (permalink / raw)
  To: linux-arm-kernel

From: Florian Fainelli <florian@openwrt.org>
Date: Sun, 24 Mar 2013 21:48:33 +0100

> Hello Simon,
> 
> Le dimanche 24 mars 2013 21:33:58, Simon Baatz a ?crit :
>> 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.
> 
> Both fixes look good to me, thanks for fixing this!
> 
> Acked-by: Florian Fainelli <florian@openwrt.org>

All applied, thanks.

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

end of thread, other threads:[~2013-03-24 21:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-24 20:33 [PATCH 0/2] Fix for mv643xx_eth built as module Simon Baatz
2013-03-24 20:33 ` [PATCH 1/2] net: mvmdio: define module alias for platform device Simon Baatz
2013-03-24 20:34 ` [PATCH 2/2] mv643xx_eth: defer probing if Marvell Orion MDIO driver not loaded Simon Baatz
2013-03-24 20:48 ` [PATCH 0/2] Fix for mv643xx_eth built as module Florian Fainelli
2013-03-24 21:07   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).