[PATCH 15/18] [RFC] net: eth: Always use DEVICE_ID_DYNAMIC

Andrey Smirnov andrew.smirnov at gmail.com
Tue Feb 16 17:29:16 PST 2016


Assigning device IDs based on device tree aliases doesn't work very well
on platforms that have both NICs that are a part of a platform with
assigned aliases and NICs with DEVICE_ID_DYNAMIC policy of ID
assignement due to the nature of the interfaces they are connected
via (PCIe, USB, etc.). Consider the following scenario:

A device with built-in Ethernet adapter aliased to "ethernet0" and a
Ethernet chip connected via PCIe. This gives us two possible probing
orders:
  1.
    - built-in adapter comes up first gets assigned id of 0 and device
      "dev0"
    - PCIe adapter comes up second gets assigned id of 1 and device
      "dev1"
    - everything is hunky-dory

  2.
    - built-in adapter comes up first but its probing gets deffered
    - PCIe adapter comes up second gets assigned id of 0 and device
      "dev0"
    - built-in adapter gets probed the second time, sucessfuly
      initializes itself but fails to register Ethernet device because
      "dev0" is already taken

This patch solves the problem by forcing all Ethernet adapters to
use dynamic ID allocation.

Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
---
 net/eth.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index fb3f22f..d028f71 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -366,13 +366,7 @@ int eth_register(struct eth_device *edev)
 	if (edev->parent)
 		edev->dev.parent = edev->parent;
 
-	if (edev->dev.parent && edev->dev.parent->device_node) {
-		edev->dev.id = of_alias_get_id(edev->dev.parent->device_node, "ethernet");
-		if (edev->dev.id < 0)
-			edev->dev.id = DEVICE_ID_DYNAMIC;
-	} else {
-		edev->dev.id = DEVICE_ID_DYNAMIC;
-	}
+	edev->dev.id = DEVICE_ID_DYNAMIC;
 
 	ret = register_device(&edev->dev);
 	if (ret)
-- 
2.5.0




More information about the barebox mailing list