[PATCH v4] dm: uclass: don't assign aliased seq numbers

If there are aliases for an uclass, set the base for the "dynamically" allocated numbers next to the highest alias.
Please note, that this might lead to holes in the sequences, depending on the device tree. For example if there is only an alias "ethernet1", the next device seq number would be 2.
In particular this fixes a problem with boards which are using ethernet aliases but also might have network add-in cards like the E1000. If the board is started with the add-in card and depending on the order of the drivers, the E1000 might occupy the first ethernet device and mess up all the hardware addresses, because the devices are now shifted by one.
Also adapt the test cases to the new handling and add test cases checking the holes in the seq numbers.
Signed-off-by: Michael Walle michael@walle.cc Reviewed-by: Alex Marginean alexandru.marginean@nxp.com Tested-by: Alex Marginean alexandru.marginean@nxp.com Acked-by: Vladimir Oltean olteanv@gmail.com Reviewed-by: Simon Glass sjg@chromium.org --- changes since v3: - dev_read_alias_highest_id() is only available if CONFIG_OF_CONTROL is set. Thus added an additional condition "CONFIG_IS_ENABLED(OF_CONTROL)", thanks Simon.
changes since v2: - adapt/new test cases, thanks Simon
changes since v1: - move notice about superfluous commits from commit message to this section. - fix the comment style
arch/sandbox/dts/test.dts | 4 ++-- drivers/core/uclass.c | 21 +++++++++++++++------ include/configs/sandbox.h | 6 +++--- test/dm/eth.c | 14 +++++++------- test/dm/test-fdt.c | 22 +++++++++++++++++----- 5 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 4a277934a7..915f337ae8 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -19,8 +19,8 @@ pci0 = &pci0; pci1 = &pci1; pci2 = &pci2; - remoteproc1 = &rproc_1; - remoteproc2 = &rproc_2; + remoteproc0 = &rproc_1; + remoteproc1 = &rproc_2; rtc0 = &rtc_0; rtc1 = &rtc_1; spi0 = "/spi@0"; diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 58b19a4210..dab49fe627 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -688,13 +688,14 @@ int uclass_unbind_device(struct udevice *dev)
int uclass_resolve_seq(struct udevice *dev) { + struct uclass *uc = dev->uclass; + struct uclass_driver *uc_drv = uc->uc_drv; struct udevice *dup; - int seq; + int seq = 0; int ret;
assert(dev->seq == -1); - ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, dev->req_seq, - false, &dup); + ret = uclass_find_device_by_seq(uc_drv->id, dev->req_seq, false, &dup); if (!ret) { dm_warn("Device '%s': seq %d is in use by '%s'\n", dev->name, dev->req_seq, dup->name); @@ -706,9 +707,17 @@ int uclass_resolve_seq(struct udevice *dev) return ret; }
- for (seq = 0; seq < DM_MAX_SEQ; seq++) { - ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, seq, - false, &dup); + if (CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(DM_SEQ_ALIAS) && + (uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) { + /* + * dev_read_alias_highest_id() will return -1 if there no + * alias. Thus we can always add one. + */ + seq = dev_read_alias_highest_id(uc_drv->name) + 1; + } + + for (; seq < DM_MAX_SEQ; seq++) { + ret = uclass_find_device_by_seq(uc_drv->id, seq, false, &dup); if (ret == -ENODEV) break; if (ret) diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 1c13055cdc..b02c362fed 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -97,9 +97,9 @@ #endif
#define SANDBOX_ETH_SETTINGS "ethaddr=00:00:11:22:33:44\0" \ - "eth1addr=00:00:11:22:33:45\0" \ - "eth3addr=00:00:11:22:33:46\0" \ - "eth5addr=00:00:11:22:33:47\0" \ + "eth3addr=00:00:11:22:33:45\0" \ + "eth5addr=00:00:11:22:33:46\0" \ + "eth6addr=00:00:11:22:33:47\0" \ "ipaddr=1.2.3.4\0"
#define MEM_LAYOUT_ENV_SETTINGS \ diff --git a/test/dm/eth.c b/test/dm/eth.c index ad5354b4bf..75315a0c6d 100644 --- a/test/dm/eth.c +++ b/test/dm/eth.c @@ -47,7 +47,7 @@ static int dm_test_eth_alias(struct unit_test_state *uts) ut_assertok(net_loop(PING)); ut_asserteq_str("eth@10002000", env_get("ethact"));
- env_set("ethact", "eth1"); + env_set("ethact", "eth6"); ut_assertok(net_loop(PING)); ut_asserteq_str("eth@10004000", env_get("ethact"));
@@ -104,7 +104,7 @@ static int dm_test_eth_act(struct unit_test_state *uts) const char *ethname[DM_TEST_ETH_NUM] = {"eth@10002000", "eth@10003000", "sbe5", "eth@10004000"}; const char *addrname[DM_TEST_ETH_NUM] = {"ethaddr", "eth5addr", - "eth3addr", "eth1addr"}; + "eth3addr", "eth6addr"}; char ethaddr[DM_TEST_ETH_NUM][18]; int i;
@@ -187,15 +187,15 @@ static int dm_test_eth_rotate(struct unit_test_state *uts)
/* Invalidate eth1's MAC address */ memset(ethaddr, '\0', sizeof(ethaddr)); - strncpy(ethaddr, env_get("eth1addr"), 17); - /* Must disable access protection for eth1addr before clearing */ - env_set(".flags", "eth1addr"); - env_set("eth1addr", NULL); + strncpy(ethaddr, env_get("eth6addr"), 17); + /* Must disable access protection for eth6addr before clearing */ + env_set(".flags", "eth6addr"); + env_set("eth6addr", NULL);
retval = _dm_test_eth_rotate1(uts);
/* Restore the env */ - env_set("eth1addr", ethaddr); + env_set("eth6addr", ethaddr); env_set("ethrotate", NULL);
if (!retval) { diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 75ae08081c..23ce4339fa 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -360,20 +360,32 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts) ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 2, &dev)); ut_asserteq_str("d-test", dev->name);
- /* d-test actually gets 0 */ - ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 0, &dev)); + /* + * d-test actually gets 9, because thats the next free one after the + * aliases. + */ + ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 9, &dev)); ut_asserteq_str("d-test", dev->name);
- /* initially no one wants seq 1 */ - ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 1, + /* initially no one wants seq 10 */ + ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 10, &dev)); ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev)); ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 4, &dev));
/* But now that it is probed, we can find it */ - ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 1, &dev)); + ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 10, &dev)); ut_asserteq_str("f-test", dev->name);
+ /* + * And we should still have holes in our sequence numbers, that is 2 + * and 4 should not be used. + */ + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 2, + true, &dev)); + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 4, + true, &dev)); + return 0; } DM_TEST(dm_test_fdt_uclass_seq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);

On 03. 03. 20 8:47, Michael Walle wrote:
If there are aliases for an uclass, set the base for the "dynamically" allocated numbers next to the highest alias.
Please note, that this might lead to holes in the sequences, depending on the device tree. For example if there is only an alias "ethernet1", the next device seq number would be 2.
In particular this fixes a problem with boards which are using ethernet aliases but also might have network add-in cards like the E1000. If the board is started with the add-in card and depending on the order of the drivers, the E1000 might occupy the first ethernet device and mess up all the hardware addresses, because the devices are now shifted by one.
Also adapt the test cases to the new handling and add test cases checking the holes in the seq numbers.
Signed-off-by: Michael Walle michael@walle.cc Reviewed-by: Alex Marginean alexandru.marginean@nxp.com Tested-by: Alex Marginean alexandru.marginean@nxp.com Acked-by: Vladimir Oltean olteanv@gmail.com Reviewed-by: Simon Glass sjg@chromium.org
changes since v3:
- dev_read_alias_highest_id() is only available if CONFIG_OF_CONTROL is set. Thus added an additional condition "CONFIG_IS_ENABLED(OF_CONTROL)", thanks Simon.
changes since v2:
- adapt/new test cases, thanks Simon
changes since v1:
- move notice about superfluous commits from commit message to this section.
- fix the comment style
arch/sandbox/dts/test.dts | 4 ++-- drivers/core/uclass.c | 21 +++++++++++++++------ include/configs/sandbox.h | 6 +++--- test/dm/eth.c | 14 +++++++------- test/dm/test-fdt.c | 22 +++++++++++++++++----- 5 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 4a277934a7..915f337ae8 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -19,8 +19,8 @@ pci0 = &pci0; pci1 = &pci1; pci2 = &pci2;
remoteproc1 = &rproc_1;
remoteproc2 = &rproc_2;
remoteproc0 = &rproc_1;
rtc0 = &rtc_0; rtc1 = &rtc_1; spi0 = "/spi@0";remoteproc1 = &rproc_2;
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 58b19a4210..dab49fe627 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -688,13 +688,14 @@ int uclass_unbind_device(struct udevice *dev)
int uclass_resolve_seq(struct udevice *dev) {
- struct uclass *uc = dev->uclass;
- struct uclass_driver *uc_drv = uc->uc_drv; struct udevice *dup;
- int seq;
int seq = 0; int ret;
assert(dev->seq == -1);
- ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, dev->req_seq,
false, &dup);
- ret = uclass_find_device_by_seq(uc_drv->id, dev->req_seq, false, &dup); if (!ret) { dm_warn("Device '%s': seq %d is in use by '%s'\n", dev->name, dev->req_seq, dup->name);
@@ -706,9 +707,17 @@ int uclass_resolve_seq(struct udevice *dev) return ret; }
- for (seq = 0; seq < DM_MAX_SEQ; seq++) {
ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, seq,
false, &dup);
- if (CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
(uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) {
/*
* dev_read_alias_highest_id() will return -1 if there no
* alias. Thus we can always add one.
*/
seq = dev_read_alias_highest_id(uc_drv->name) + 1;
- }
- for (; seq < DM_MAX_SEQ; seq++) {
if (ret == -ENODEV) break; if (ret)ret = uclass_find_device_by_seq(uc_drv->id, seq, false, &dup);
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 1c13055cdc..b02c362fed 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -97,9 +97,9 @@ #endif
#define SANDBOX_ETH_SETTINGS "ethaddr=00:00:11:22:33:44\0" \
"eth1addr=00:00:11:22:33:45\0" \
"eth3addr=00:00:11:22:33:46\0" \
"eth5addr=00:00:11:22:33:47\0" \
"eth3addr=00:00:11:22:33:45\0" \
"eth5addr=00:00:11:22:33:46\0" \
"eth6addr=00:00:11:22:33:47\0" \ "ipaddr=1.2.3.4\0"
#define MEM_LAYOUT_ENV_SETTINGS \ diff --git a/test/dm/eth.c b/test/dm/eth.c index ad5354b4bf..75315a0c6d 100644 --- a/test/dm/eth.c +++ b/test/dm/eth.c @@ -47,7 +47,7 @@ static int dm_test_eth_alias(struct unit_test_state *uts) ut_assertok(net_loop(PING)); ut_asserteq_str("eth@10002000", env_get("ethact"));
- env_set("ethact", "eth1");
- env_set("ethact", "eth6"); ut_assertok(net_loop(PING)); ut_asserteq_str("eth@10004000", env_get("ethact"));
@@ -104,7 +104,7 @@ static int dm_test_eth_act(struct unit_test_state *uts) const char *ethname[DM_TEST_ETH_NUM] = {"eth@10002000", "eth@10003000", "sbe5", "eth@10004000"}; const char *addrname[DM_TEST_ETH_NUM] = {"ethaddr", "eth5addr",
"eth3addr", "eth1addr"};
char ethaddr[DM_TEST_ETH_NUM][18]; int i;"eth3addr", "eth6addr"};
@@ -187,15 +187,15 @@ static int dm_test_eth_rotate(struct unit_test_state *uts)
/* Invalidate eth1's MAC address */ memset(ethaddr, '\0', sizeof(ethaddr));
- strncpy(ethaddr, env_get("eth1addr"), 17);
- /* Must disable access protection for eth1addr before clearing */
- env_set(".flags", "eth1addr");
- env_set("eth1addr", NULL);
strncpy(ethaddr, env_get("eth6addr"), 17);
/* Must disable access protection for eth6addr before clearing */
env_set(".flags", "eth6addr");
env_set("eth6addr", NULL);
retval = _dm_test_eth_rotate1(uts);
/* Restore the env */
- env_set("eth1addr", ethaddr);
env_set("eth6addr", ethaddr); env_set("ethrotate", NULL);
if (!retval) {
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 75ae08081c..23ce4339fa 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -360,20 +360,32 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts) ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 2, &dev)); ut_asserteq_str("d-test", dev->name);
- /* d-test actually gets 0 */
- ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 0, &dev));
- /*
* d-test actually gets 9, because thats the next free one after the
* aliases.
*/
- ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 9, &dev)); ut_asserteq_str("d-test", dev->name);
- /* initially no one wants seq 1 */
- ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 1,
/* initially no one wants seq 10 */
ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 10, &dev)); ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev)); ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 4, &dev));
/* But now that it is probed, we can find it */
- ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 1, &dev));
ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 10, &dev)); ut_asserteq_str("f-test", dev->name);
/*
* And we should still have holes in our sequence numbers, that is 2
* and 4 should not be used.
*/
ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 2,
true, &dev));
ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 4,
true, &dev));
return 0;
} DM_TEST(dm_test_fdt_uclass_seq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
Tested-by: Michal Simek michal.simek@xilinx.com (zcu102-revA)
Thanks, Michal

On 03. 03. 20 8:47, Michael Walle wrote:
If there are aliases for an uclass, set the base for the "dynamically" allocated numbers next to the highest alias.
Please note, that this might lead to holes in the sequences, depending on the device tree. For example if there is only an alias "ethernet1", the next device seq number would be 2.
In particular this fixes a problem with boards which are using ethernet aliases but also might have network add-in cards like the E1000. If the board is started with the add-in card and depending on the order of the drivers, the E1000 might occupy the first ethernet device and mess up all the hardware addresses, because the devices are now shifted by one.
Also adapt the test cases to the new handling and add test cases checking the holes in the seq numbers.
Signed-off-by: Michael Walle michael@walle.cc Reviewed-by: Alex Marginean alexandru.marginean@nxp.com Tested-by: Alex Marginean alexandru.marginean@nxp.com Acked-by: Vladimir Oltean olteanv@gmail.com Reviewed-by: Simon Glass sjg@chromium.org
changes since v3:
- dev_read_alias_highest_id() is only available if CONFIG_OF_CONTROL is set. Thus added an additional condition "CONFIG_IS_ENABLED(OF_CONTROL)", thanks Simon.
changes since v2:
- adapt/new test cases, thanks Simon
changes since v1:
- move notice about superfluous commits from commit message to this section.
- fix the comment style
arch/sandbox/dts/test.dts | 4 ++-- drivers/core/uclass.c | 21 +++++++++++++++------ include/configs/sandbox.h | 6 +++--- test/dm/eth.c | 14 +++++++------- test/dm/test-fdt.c | 22 +++++++++++++++++----- 5 files changed, 44 insertions(+), 23 deletions(-)
Applied to u-boot-dm/next, thanks!

+Tom
Hi,
On Sat, 14 Mar 2020 at 14:33, sjg@google.com wrote:
On 03. 03. 20 8:47, Michael Walle wrote:
If there are aliases for an uclass, set the base for the "dynamically" allocated numbers next to the highest alias.
Please note, that this might lead to holes in the sequences, depending on the device tree. For example if there is only an alias "ethernet1", the next device seq number would be 2.
In particular this fixes a problem with boards which are using ethernet aliases but also might have network add-in cards like the E1000. If the board is started with the add-in card and depending on the order of the drivers, the E1000 might occupy the first ethernet device and mess up all the hardware addresses, because the devices are now shifted by one.
Also adapt the test cases to the new handling and add test cases checking the holes in the seq numbers.
Signed-off-by: Michael Walle michael@walle.cc Reviewed-by: Alex Marginean alexandru.marginean@nxp.com Tested-by: Alex Marginean alexandru.marginean@nxp.com Acked-by: Vladimir Oltean olteanv@gmail.com Reviewed-by: Simon Glass sjg@chromium.org
changes since v3:
- dev_read_alias_highest_id() is only available if CONFIG_OF_CONTROL is set. Thus added an additional condition "CONFIG_IS_ENABLED(OF_CONTROL)", thanks Simon.
changes since v2:
- adapt/new test cases, thanks Simon
changes since v1:
- move notice about superfluous commits from commit message to this section.
- fix the comment style
arch/sandbox/dts/test.dts | 4 ++-- drivers/core/uclass.c | 21 +++++++++++++++------ include/configs/sandbox.h | 6 +++--- test/dm/eth.c | 14 +++++++------- test/dm/test-fdt.c | 22 +++++++++++++++++----- 5 files changed, 44 insertions(+), 23 deletions(-)
Applied to u-boot-dm/next, thanks!
Sadly, after applying this was found to break rpi_3. Due to some still-pending patches mine doesn't boot anyway so I didn't notice.
The tbot trace is below. The first is the new u-boot-dm/master with two rpi patches, the second is the same with just your patch added. Ethernet seems to go away.
$ do-try-int.sh rpi3 HEAD
Checking revision eff8ae8810da44bbbad71e617ea80abc7d7cde45 tbot starting ... ├─Parameters: │ rev = 'eff8ae8810da44bbbad71e617ea80abc7d7cde45' │ clean = True ├─Calling uboot_checkout ... │ ├─Builder: rpi_3 │ └─Done. (1.100s) ├───────────────────────────────────────── └─SUCCESS (1.277s) tbot starting ... ├─Parameters: │ clean = False ├─Calling uboot_build_and_flash ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Calling uboot_build ... │ │ ├─Calling uboot_checkout ... │ │ │ ├─Builder: rpi_3 │ │ │ └─Done. (0.135s) │ │ ├─Configuring build ... │ │ ├─Calling uboot_make ... │ │ │ └─Done. (12.614s) │ │ └─Done. (15.038s) │ ├─Calling uboot_flash ... │ │ ├─Calling copy ... │ │ │ └─Done. (0.003s) │ │ └─Done. (3.628s) │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (19.594s) ├───────────────────────────────────────── └─SUCCESS (19.771s) tbot starting ... ├─Calling interactive_board ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Entering interactive shell (CTRL+D to exit) ... picocom v2.2
port is : /dev/ttyusb_port1 flowcontrol : none baudrate is : 115200 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs,
Type [C-a] [C-h] to see available commands
Terminal ready
U-Boot 2020.04-00305-geff8ae8810 (Apr 15 2020 - 07:40:23 -0600)
DRAM: 992 MiB RPI 3 Model B (0xa22082) MMC: mmc@7e202000: 0, sdhci@7e300000: 1 Loading Environment from FAT... *** Warning - bad CRC, using default environment
In: serial Out: vidconsole Err: vidconsole Net: No ethernet found. starting USB... Bus usb@7e980000: scanning bus usb@7e980000 for devices... Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000 4 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0 U-Boot> bootp Waiting for Ethernet connection... done. BOOTP broadcast 1 DHCP client bound to address 192.168.4.50 (4 ms) *** Warning: no boot file name; using 'C0A80432.img' Using smsc95xx_eth device TFTP from server 192.168.4.1; our IP address is 192.168.4.50 Filename 'C0A80432.img'. Load address: 0x200000 Loading: * Abort U-Boot> │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (26.173s) ├───────────────────────────────────────── └─SUCCESS (26.333s) ellesmere:~/u$ gp 8c324ac6faa [dm-push dd18fbdf7ff] dm: uclass: don't assign aliased seq numbers Author: Michael Walle michael@walle.cc Date: Tue Mar 3 08:47:38 2020 +0100 5 files changed, 45 insertions(+), 23 deletions(-) ellesmere:~/u$ do-try-int.sh rpi3 HEAD
Checking revision dd18fbdf7ff915672fb4933a1f82a78f7b484d24 tbot starting ... ├─Parameters: │ rev = 'dd18fbdf7ff915672fb4933a1f82a78f7b484d24' │ clean = True ├─Calling uboot_checkout ... │ ├─Builder: rpi_3 │ └─Done. (1.045s) ├───────────────────────────────────────── └─SUCCESS (1.259s) tbot starting ... ├─Parameters: │ clean = False ├─Calling uboot_build_and_flash ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Calling uboot_build ... │ │ ├─Calling uboot_checkout ... │ │ │ ├─Builder: rpi_3 │ │ │ └─Done. (0.123s) │ │ ├─Configuring build ... │ │ ├─Calling uboot_make ... │ │ │ └─Done. (12.167s) │ │ └─Done. (14.622s) │ ├─Calling uboot_flash ... │ │ ├─Calling copy ... │ │ │ └─Done. (0.003s) │ │ └─Done. (4.191s) │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (19.758s) ├───────────────────────────────────────── └─SUCCESS (19.946s) tbot starting ... ├─Calling interactive_board ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Entering interactive shell (CTRL+D to exit) ... picocom v2.2
port is : /dev/ttyusb_port1 flowcontrol : none baudrate is : 115200 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs,
Type [C-a] [C-h] to see available commands
Terminal ready
U-Boot 2020.04-00306-gdd18fbdf7f (Apr 15 2020 - 07:41:47 -0600)
DRAM: 992 MiB RPI 3 Model B (0xa22082) MMC: mmc@7e202000: 0, sdhci@7e300000: 1 Loading Environment from FAT... *** Warning - bad CRC, using default environment
In: serial Out: vidconsole Err: vidconsole Net: No ethernet found. starting USB... Bus usb@7e980000: scanning bus usb@7e980000 for devices... Error: smsc95xx_eth address not set. Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000 3 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0 U-Boot> bootp No ethernet found. U-Boot> │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (17.196s) ├───────────────────────────────────────── └─SUCCESS (17.337s)
Regards, Simon

Hi Simon,
Am 2020-04-15 15:56, schrieb Simon Glass:
+Tom
Hi,
On Sat, 14 Mar 2020 at 14:33, sjg@google.com wrote:
On 03. 03. 20 8:47, Michael Walle wrote:
If there are aliases for an uclass, set the base for the "dynamically" allocated numbers next to the highest alias.
Please note, that this might lead to holes in the sequences, depending on the device tree. For example if there is only an alias "ethernet1", the next device seq number would be 2.
In particular this fixes a problem with boards which are using ethernet aliases but also might have network add-in cards like the E1000. If the board is started with the add-in card and depending on the order of the drivers, the E1000 might occupy the first ethernet device and mess up all the hardware addresses, because the devices are now shifted by one.
Also adapt the test cases to the new handling and add test cases checking the holes in the seq numbers.
Signed-off-by: Michael Walle michael@walle.cc Reviewed-by: Alex Marginean alexandru.marginean@nxp.com Tested-by: Alex Marginean alexandru.marginean@nxp.com Acked-by: Vladimir Oltean olteanv@gmail.com Reviewed-by: Simon Glass sjg@chromium.org
changes since v3:
- dev_read_alias_highest_id() is only available if CONFIG_OF_CONTROL is set. Thus added an additional condition "CONFIG_IS_ENABLED(OF_CONTROL)", thanks Simon.
changes since v2:
- adapt/new test cases, thanks Simon
changes since v1:
- move notice about superfluous commits from commit message to this section.
- fix the comment style
arch/sandbox/dts/test.dts | 4 ++-- drivers/core/uclass.c | 21 +++++++++++++++------ include/configs/sandbox.h | 6 +++--- test/dm/eth.c | 14 +++++++------- test/dm/test-fdt.c | 22 +++++++++++++++++----- 5 files changed, 44 insertions(+), 23 deletions(-)
Applied to u-boot-dm/next, thanks!
Sadly, after applying this was found to break rpi_3. Due to some still-pending patches mine doesn't boot anyway so I didn't notice.
The tbot trace is below. The first is the new u-boot-dm/master with two rpi patches, the second is the same with just your patch added. Ethernet seems to go away.
could you dump "dm tree" and "dm uclass" in both cases?
I've had a look at the device tree and there seems to be one ethernet alias to the corresponding USB LAN device. I can only imagine that this alias doesn't match (for whatever reason) and as a second problem, the networking doesn't find a device if there is only a ethernet1.
-michael
$ do-try-int.sh rpi3 HEAD
Checking revision eff8ae8810da44bbbad71e617ea80abc7d7cde45 tbot starting ... ├─Parameters: │ rev = 'eff8ae8810da44bbbad71e617ea80abc7d7cde45' │ clean = True ├─Calling uboot_checkout ... │ ├─Builder: rpi_3 │ └─Done. (1.100s) ├───────────────────────────────────────── └─SUCCESS (1.277s) tbot starting ... ├─Parameters: │ clean = False ├─Calling uboot_build_and_flash ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Calling uboot_build ... │ │ ├─Calling uboot_checkout ... │ │ │ ├─Builder: rpi_3 │ │ │ └─Done. (0.135s) │ │ ├─Configuring build ... │ │ ├─Calling uboot_make ... │ │ │ └─Done. (12.614s) │ │ └─Done. (15.038s) │ ├─Calling uboot_flash ... │ │ ├─Calling copy ... │ │ │ └─Done. (0.003s) │ │ └─Done. (3.628s) │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (19.594s) ├───────────────────────────────────────── └─SUCCESS (19.771s) tbot starting ... ├─Calling interactive_board ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Entering interactive shell (CTRL+D to exit) ... picocom v2.2
port is : /dev/ttyusb_port1 flowcontrol : none baudrate is : 115200 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs,
Type [C-a] [C-h] to see available commands
Terminal ready
U-Boot 2020.04-00305-geff8ae8810 (Apr 15 2020 - 07:40:23 -0600)
DRAM: 992 MiB RPI 3 Model B (0xa22082) MMC: mmc@7e202000: 0, sdhci@7e300000: 1 Loading Environment from FAT... *** Warning - bad CRC, using default environment
In: serial Out: vidconsole Err: vidconsole Net: No ethernet found. starting USB... Bus usb@7e980000: scanning bus usb@7e980000 for devices... Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000 4 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0 U-Boot> bootp Waiting for Ethernet connection... done. BOOTP broadcast 1 DHCP client bound to address 192.168.4.50 (4 ms) *** Warning: no boot file name; using 'C0A80432.img' Using smsc95xx_eth device TFTP from server 192.168.4.1; our IP address is 192.168.4.50 Filename 'C0A80432.img'. Load address: 0x200000 Loading: * Abort U-Boot> │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (26.173s) ├───────────────────────────────────────── └─SUCCESS (26.333s) ellesmere:~/u$ gp 8c324ac6faa [dm-push dd18fbdf7ff] dm: uclass: don't assign aliased seq numbers Author: Michael Walle michael@walle.cc Date: Tue Mar 3 08:47:38 2020 +0100 5 files changed, 45 insertions(+), 23 deletions(-) ellesmere:~/u$ do-try-int.sh rpi3 HEAD
Checking revision dd18fbdf7ff915672fb4933a1f82a78f7b484d24 tbot starting ... ├─Parameters: │ rev = 'dd18fbdf7ff915672fb4933a1f82a78f7b484d24' │ clean = True ├─Calling uboot_checkout ... │ ├─Builder: rpi_3 │ └─Done. (1.045s) ├───────────────────────────────────────── └─SUCCESS (1.259s) tbot starting ... ├─Parameters: │ clean = False ├─Calling uboot_build_and_flash ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Calling uboot_build ... │ │ ├─Calling uboot_checkout ... │ │ │ ├─Builder: rpi_3 │ │ │ └─Done. (0.123s) │ │ ├─Configuring build ... │ │ ├─Calling uboot_make ... │ │ │ └─Done. (12.167s) │ │ └─Done. (14.622s) │ ├─Calling uboot_flash ... │ │ ├─Calling copy ... │ │ │ └─Done. (0.003s) │ │ └─Done. (4.191s) │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (19.758s) ├───────────────────────────────────────── └─SUCCESS (19.946s) tbot starting ... ├─Calling interactive_board ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Entering interactive shell (CTRL+D to exit) ... picocom v2.2
port is : /dev/ttyusb_port1 flowcontrol : none baudrate is : 115200 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs,
Type [C-a] [C-h] to see available commands
Terminal ready
U-Boot 2020.04-00306-gdd18fbdf7f (Apr 15 2020 - 07:41:47 -0600)
DRAM: 992 MiB RPI 3 Model B (0xa22082) MMC: mmc@7e202000: 0, sdhci@7e300000: 1 Loading Environment from FAT... *** Warning - bad CRC, using default environment
In: serial Out: vidconsole Err: vidconsole Net: No ethernet found. starting USB... Bus usb@7e980000: scanning bus usb@7e980000 for devices... Error: smsc95xx_eth address not set. Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000 3 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0 U-Boot> bootp No ethernet found. U-Boot> │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (17.196s) ├───────────────────────────────────────── └─SUCCESS (17.337s)
Regards, Simon

Hi Michael,
On Wed, 15 Apr 2020 at 09:22, Michael Walle michael@walle.cc wrote:
Hi Simon,
Am 2020-04-15 15:56, schrieb Simon Glass:
+Tom
Hi,
On Sat, 14 Mar 2020 at 14:33, sjg@google.com wrote:
On 03. 03. 20 8:47, Michael Walle wrote:
If there are aliases for an uclass, set the base for the "dynamically" allocated numbers next to the highest alias.
Please note, that this might lead to holes in the sequences, depending on the device tree. For example if there is only an alias "ethernet1", the next device seq number would be 2.
In particular this fixes a problem with boards which are using ethernet aliases but also might have network add-in cards like the E1000. If the board is started with the add-in card and depending on the order of the drivers, the E1000 might occupy the first ethernet device and mess up all the hardware addresses, because the devices are now shifted by one.
Also adapt the test cases to the new handling and add test cases checking the holes in the seq numbers.
Signed-off-by: Michael Walle michael@walle.cc Reviewed-by: Alex Marginean alexandru.marginean@nxp.com Tested-by: Alex Marginean alexandru.marginean@nxp.com Acked-by: Vladimir Oltean olteanv@gmail.com Reviewed-by: Simon Glass sjg@chromium.org
changes since v3:
- dev_read_alias_highest_id() is only available if CONFIG_OF_CONTROL is set. Thus added an additional condition "CONFIG_IS_ENABLED(OF_CONTROL)", thanks Simon.
changes since v2:
- adapt/new test cases, thanks Simon
changes since v1:
- move notice about superfluous commits from commit message to this section.
- fix the comment style
arch/sandbox/dts/test.dts | 4 ++-- drivers/core/uclass.c | 21 +++++++++++++++------ include/configs/sandbox.h | 6 +++--- test/dm/eth.c | 14 +++++++------- test/dm/test-fdt.c | 22 +++++++++++++++++----- 5 files changed, 44 insertions(+), 23 deletions(-)
Applied to u-boot-dm/next, thanks!
Sadly, after applying this was found to break rpi_3. Due to some still-pending patches mine doesn't boot anyway so I didn't notice.
The tbot trace is below. The first is the new u-boot-dm/master with two rpi patches, the second is the same with just your patch added. Ethernet seems to go away.
could you dump "dm tree" and "dm uclass" in both cases?
I've had a look at the device tree and there seems to be one ethernet alias to the corresponding USB LAN device. I can only imagine that this alias doesn't match (for whatever reason) and as a second problem, the networking doesn't find a device if there is only a ethernet1.
Yes please see below (first one is without your patch).
do-try-int.sh rpi3 HEAD
Checking revision eff8ae8810da44bbbad71e617ea80abc7d7cde45 tbot starting ... ├─Parameters: │ rev = 'eff8ae8810da44bbbad71e617ea80abc7d7cde45' │ clean = True ├─Calling uboot_checkout ... │ ├─Builder: rpi_3 │ └─Done. (1.002s) ├───────────────────────────────────────── └─SUCCESS (1.284s) tbot starting ... ├─Parameters: │ clean = False ├─Calling uboot_build_and_flash ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Calling uboot_build ... │ │ ├─Calling uboot_checkout ... │ │ │ ├─Builder: rpi_3 │ │ │ └─Done. (0.127s) │ │ ├─Configuring build ... │ │ ├─Calling uboot_make ... │ │ │ └─Done. (13.117s) │ │ └─Done. (15.603s) │ ├─Calling uboot_flash ... │ │ ├─Calling copy ... │ │ │ └─Done. (0.004s) │ │ └─Done. (4.412s) │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (20.975s) ├───────────────────────────────────────── └─SUCCESS (21.152s) tbot starting ... ├─Calling interactive_board ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Entering interactive shell (CTRL+D to exit) ...
U-Boot 2020.04-00305-geff8ae8810 (Apr 15 2020 - 13:15:29 -0600)
DRAM: 992 MiB RPI 3 Model B (0xa22082) MMC: mmc@7e202000: 0, sdhci@7e300000: 1 Loading Environment from FAT... *** Warning - bad CRC, using default environment
In: serial Out: vidconsole Err: vidconsole Net: No ethernet found. starting USB... Bus usb@7e980000: scanning bus usb@7e980000 for devices... Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000 4 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0 U-Boot> dm tree Class Index Probed Driver Name ----------------------------------------------------------- root 0 [ + ] root_driver root_driver simple_bus 0 [ + ] generic_simple_bus |-- soc pinctrl 0 [ + ] bcm283x_pinctrl | |-- gpio@7e200000 pinconfig 0 [ ] pinconfig | | |-- dpi_gpio0 pinconfig 1 [ ] pinconfig | | |-- emmc_gpio22 pinconfig 2 [ + ] pinconfig | | |-- emmc_gpio34 pinconfig 3 [ ] pinconfig | | |-- emmc_gpio48 pinconfig 4 [ ] pinconfig | | |-- gpclk0_gpio4 pinconfig 5 [ ] pinconfig | | |-- gpclk1_gpio5 pinconfig 6 [ ] pinconfig | | |-- gpclk1_gpio42 pinconfig 7 [ ] pinconfig | | |-- gpclk1_gpio44 pinconfig 8 [ ] pinconfig | | |-- gpclk2_gpio6 pinconfig 9 [ ] pinconfig | | |-- gpclk2_gpio43 pinconfig 10 [ ] pinconfig | | |-- i2c0_gpio0 pinconfig 11 [ ] pinconfig | | |-- i2c0_gpio28 pinconfig 12 [ ] pinconfig | | |-- i2c0_gpio44 pinconfig 13 [ ] pinconfig | | |-- i2c1_gpio2 pinconfig 14 [ ] pinconfig | | |-- i2c1_gpio44 pinconfig 15 [ ] pinconfig | | |-- i2c_slave_gpio18 pinconfig 16 [ ] pinconfig | | |-- jtag_gpio4 pinconfig 17 [ ] pinconfig | | |-- jtag_gpio22 pinconfig 18 [ ] pinconfig | | |-- pcm_gpio18 pinconfig 19 [ ] pinconfig | | |-- pcm_gpio28 pinconfig 20 [ ] pinconfig | | |-- pwm0_gpio12 pinconfig 21 [ ] pinconfig | | |-- pwm0_gpio18 pinconfig 22 [ ] pinconfig | | |-- pwm0_gpio40 pinconfig 23 [ ] pinconfig | | |-- pwm1_gpio13 pinconfig 24 [ ] pinconfig | | |-- pwm1_gpio19 pinconfig 25 [ ] pinconfig | | |-- pwm1_gpio41 pinconfig 26 [ ] pinconfig | | |-- pwm1_gpio45 pinconfig 27 [ + ] pinconfig | | |-- sdhost_gpio48 pinconfig 28 [ ] pinconfig | | |-- spi0_gpio7 pinconfig 29 [ ] pinconfig | | |-- spi0_gpio35 pinconfig 30 [ ] pinconfig | | |-- spi1_gpio16 pinconfig 31 [ ] pinconfig | | |-- spi2_gpio40 pinconfig 32 [ ] pinconfig | | |-- uart0_gpio14 pinconfig 33 [ ] pinconfig | | |-- uart0_ctsrts_gpio16 pinconfig 34 [ ] pinconfig | | |-- uart0_ctsrts_gpio30 pinconfig 35 [ ] pinconfig | | |-- uart0_gpio32 pinconfig 36 [ ] pinconfig | | |-- uart0_gpio36 pinconfig 37 [ ] pinconfig | | |-- uart0_ctsrts_gpio38 pinconfig 38 [ + ] pinconfig | | |-- uart1_gpio14 pinconfig 39 [ ] pinconfig | | |-- uart1_ctsrts_gpio16 pinconfig 40 [ ] pinconfig | | |-- uart1_gpio32 pinconfig 41 [ ] pinconfig | | |-- uart1_ctsrts_gpio30 pinconfig 42 [ ] pinconfig | | |-- uart1_gpio40 pinconfig 43 [ ] pinconfig | | |-- uart1_ctsrts_gpio42 pinconfig 44 [ ] pinconfig | | |-- gpioout pinconfig 45 [ ] pinconfig | | |-- alt0 gpio 0 [ ] gpio_bcm2835 | | `-- gpio_bcm2835 serial 0 [ ] bcm283x_pl011 | |-- serial@7e201000 mmc 0 [ + ] bcm2835-sdhost | |-- mmc@7e202000 blk 0 [ + ] mmc_blk | | `-- mmc@7e202000.blk serial 1 [ + ] serial_bcm283x_mu | |-- serial@7e215040 mmc 1 [ + ] sdhci-bcm2835 | |-- sdhci@7e300000 blk 1 [ ] mmc_blk | | `-- sdhci@7e300000.blk video 0 [ + ] bcm2835_video | |-- hdmi@7e902000 vidconsole 0 [ + ] vidconsole0 | | `-- hdmi@7e902000.vidconsole0 usb 0 [ + ] dwc2_usb | |-- usb@7e980000 usb_hub 0 [ + ] usb_hub | | `-- usb_hub usb_hub 1 [ + ] usb_hub | | `-- usb_hub eth 0 [ + ] smsc95xx_eth | | |-- smsc95xx_eth usb_dev_ge 0 [ + ] usb_dev_generic_drv | | `-- generic_bus_0_dev_4 simple_bus 1 [ ] generic_simple_bus | `-- firmware simple_bus 2 [ ] generic_simple_bus `-- clocks U-Boot> dm uclass uclass 0: root 0 * root_driver @ 3db67028, seq 0, (req -1)
uclass 20: blk 0 * mmc@7e202000.blk @ 3db683e0, seq 0, (req -1) 1 sdhci@7e300000.blk @ 3db686c8
EFI: Initializing UCLASS_EFI uclass 30: efi uclass 31: eth 0 * smsc95xx_eth @ 3db69ac0, seq 0, (req -1)
uclass 34: gpio 0 gpio_bcm2835 @ 3db68ac0
uclass 43: keyboard uclass 47: usb_mass_storage uclass 51: mmc 0 * mmc@7e202000 @ 3db68220, seq 0, (req -1) 1 * sdhci@7e300000 @ 3db68528, seq 1, (req -1)
uclass 54: nop uclass 58: panel uclass 59: backlight uclass 65: pinconfig 0 dpi_gpio0 @ 3db671a0 1 emmc_gpio22 @ 3db671f8 2 * emmc_gpio34 @ 3db67250, seq 2, (req -1) 3 emmc_gpio48 @ 3db672a8 4 gpclk0_gpio4 @ 3db67300 5 gpclk1_gpio5 @ 3db67358 6 gpclk1_gpio42 @ 3db673b0 7 gpclk1_gpio44 @ 3db67408 8 gpclk2_gpio6 @ 3db67460 9 gpclk2_gpio43 @ 3db674b8 10 i2c0_gpio0 @ 3db67510 11 i2c0_gpio28 @ 3db67568 12 i2c0_gpio44 @ 3db675c0 13 i2c1_gpio2 @ 3db67618 14 i2c1_gpio44 @ 3db67670 15 i2c_slave_gpio18 @ 3db676c8 16 jtag_gpio4 @ 3db67720 17 jtag_gpio22 @ 3db67778 18 pcm_gpio18 @ 3db677d0 19 pcm_gpio28 @ 3db67828 20 pwm0_gpio12 @ 3db67880 21 pwm0_gpio18 @ 3db678d8 22 pwm0_gpio40 @ 3db67930 23 pwm1_gpio13 @ 3db67988 24 pwm1_gpio19 @ 3db679e0 25 pwm1_gpio41 @ 3db67a38 26 pwm1_gpio45 @ 3db67a90 27 * sdhost_gpio48 @ 3db67ae8, seq 1, (req -1) 28 spi0_gpio7 @ 3db67b40 29 spi0_gpio35 @ 3db67b98 30 spi1_gpio16 @ 3db67bf0 31 spi2_gpio40 @ 3db67c48 32 uart0_gpio14 @ 3db67ca0 33 uart0_ctsrts_gpio16 @ 3db67cf8 34 uart0_ctsrts_gpio30 @ 3db67d50 35 uart0_gpio32 @ 3db67da8 36 uart0_gpio36 @ 3db67e00 37 uart0_ctsrts_gpio38 @ 3db67e58 38 * uart1_gpio14 @ 3db67eb0, seq 0, (req -1) 39 uart1_ctsrts_gpio16 @ 3db67f08 40 uart1_gpio32 @ 3db67f60 41 uart1_ctsrts_gpio30 @ 3db67fb8 42 uart1_gpio40 @ 3db68010 43 uart1_ctsrts_gpio42 @ 3db68068 44 gpioout @ 3db680c0 45 alt0 @ 3db68118
uclass 66: pinctrl 0 * gpio@7e200000 @ 3db67128, seq 0, (req -1)
uclass 78: serial 0 serial@7e201000 @ 3db68190, seq -1, (req 0) 1 * serial@7e215040 @ 3db684c0, seq 1, (req 1)
uclass 79: simple_bus 0 * soc @ 3db670a0, seq 0, (req -1) 1 firmware @ 3db688b8 2 clocks @ 3db68920
uclass 93: usb 0 * usb@7e980000 @ 3db68860, seq 0, (req -1)
uclass 94: usb_dev_generic 0 * generic_bus_0_dev_4 @ 3db6f728, seq 0, (req -1)
uclass 95: usb_hub 0 * usb_hub @ 3db79290, seq 0, (req -1) 1 * usb_hub @ 3db79cc8, seq 1, (req -1)
uclass 97: video 0 * hdmi@7e902000 @ 3db687c8, seq 0, (req -1)
uclass 99: vidconsole0 0 * hdmi@7e902000.vidconsole0 @ 3db6df38, seq 0, (req -1)
U-Boot> │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (18.473s) ├───────────────────────────────────────── └─SUCCESS (18.626s) ellesmere:~/u$ rc Successfully rebased and updated refs/heads/dm-push. ellesmere:~/u$ do-try-int.sh rpi3 HEAD
Checking revision dd18fbdf7ff915672fb4933a1f82a78f7b484d24 tbot starting ... ├─Parameters: │ rev = 'dd18fbdf7ff915672fb4933a1f82a78f7b484d24' │ clean = True ├─Calling uboot_checkout ... │ ├─Builder: rpi_3 │ └─Done. (1.053s) ├───────────────────────────────────────── └─SUCCESS (1.240s) tbot starting ... ├─Parameters: │ clean = False ├─Calling uboot_build_and_flash ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Calling uboot_build ... │ │ ├─Calling uboot_checkout ... │ │ │ ├─Builder: rpi_3 │ │ │ └─Done. (0.118s) │ │ ├─Configuring build ... │ │ ├─Calling uboot_make ... │ │ │ └─Done. (12.080s) │ │ └─Done. (14.524s) │ ├─Calling uboot_flash ... │ │ ├─Calling copy ... │ │ │ └─Done. (0.017s) │ │ └─Done. (4.399s) │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (19.826s) ├───────────────────────────────────────── └─SUCCESS (20.009s) tbot starting ... ├─Calling interactive_board ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Entering interactive shell (CTRL+D to exit) ...
U-Boot 2020.04-00306-gdd18fbdf7f (Apr 15 2020 - 13:16:20 -0600)
DRAM: 992 MiB RPI 3 Model B (0xa22082) MMC: mmc@7e202000: 0, sdhci@7e300000: 1 Loading Environment from FAT... *** Warning - bad CRC, using default environment
In: serial Out: vidconsole Err: vidconsole Net: No ethernet found. starting USB... Bus usb@7e980000: scanning bus usb@7e980000 for devices... Error: smsc95xx_eth address not set. Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000 3 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0 U-Boot> dm tree Class Index Probed Driver Name ----------------------------------------------------------- root 0 [ + ] root_driver root_driver simple_bus 0 [ + ] generic_simple_bus |-- soc pinctrl 0 [ + ] bcm283x_pinctrl | |-- gpio@7e200000 pinconfig 0 [ ] pinconfig | | |-- dpi_gpio0 pinconfig 1 [ ] pinconfig | | |-- emmc_gpio22 pinconfig 2 [ + ] pinconfig | | |-- emmc_gpio34 pinconfig 3 [ ] pinconfig | | |-- emmc_gpio48 pinconfig 4 [ ] pinconfig | | |-- gpclk0_gpio4 pinconfig 5 [ ] pinconfig | | |-- gpclk1_gpio5 pinconfig 6 [ ] pinconfig | | |-- gpclk1_gpio42 pinconfig 7 [ ] pinconfig | | |-- gpclk1_gpio44 pinconfig 8 [ ] pinconfig | | |-- gpclk2_gpio6 pinconfig 9 [ ] pinconfig | | |-- gpclk2_gpio43 pinconfig 10 [ ] pinconfig | | |-- i2c0_gpio0 pinconfig 11 [ ] pinconfig | | |-- i2c0_gpio28 pinconfig 12 [ ] pinconfig | | |-- i2c0_gpio44 pinconfig 13 [ ] pinconfig | | |-- i2c1_gpio2 pinconfig 14 [ ] pinconfig | | |-- i2c1_gpio44 pinconfig 15 [ ] pinconfig | | |-- i2c_slave_gpio18 pinconfig 16 [ ] pinconfig | | |-- jtag_gpio4 pinconfig 17 [ ] pinconfig | | |-- jtag_gpio22 pinconfig 18 [ ] pinconfig | | |-- pcm_gpio18 pinconfig 19 [ ] pinconfig | | |-- pcm_gpio28 pinconfig 20 [ ] pinconfig | | |-- pwm0_gpio12 pinconfig 21 [ ] pinconfig | | |-- pwm0_gpio18 pinconfig 22 [ ] pinconfig | | |-- pwm0_gpio40 pinconfig 23 [ ] pinconfig | | |-- pwm1_gpio13 pinconfig 24 [ ] pinconfig | | |-- pwm1_gpio19 pinconfig 25 [ ] pinconfig | | |-- pwm1_gpio41 pinconfig 26 [ ] pinconfig | | |-- pwm1_gpio45 pinconfig 27 [ + ] pinconfig | | |-- sdhost_gpio48 pinconfig 28 [ ] pinconfig | | |-- spi0_gpio7 pinconfig 29 [ ] pinconfig | | |-- spi0_gpio35 pinconfig 30 [ ] pinconfig | | |-- spi1_gpio16 pinconfig 31 [ ] pinconfig | | |-- spi2_gpio40 pinconfig 32 [ ] pinconfig | | |-- uart0_gpio14 pinconfig 33 [ ] pinconfig | | |-- uart0_ctsrts_gpio16 pinconfig 34 [ ] pinconfig | | |-- uart0_ctsrts_gpio30 pinconfig 35 [ ] pinconfig | | |-- uart0_gpio32 pinconfig 36 [ ] pinconfig | | |-- uart0_gpio36 pinconfig 37 [ ] pinconfig | | |-- uart0_ctsrts_gpio38 pinconfig 38 [ + ] pinconfig | | |-- uart1_gpio14 pinconfig 39 [ ] pinconfig | | |-- uart1_ctsrts_gpio16 pinconfig 40 [ ] pinconfig | | |-- uart1_gpio32 pinconfig 41 [ ] pinconfig | | |-- uart1_ctsrts_gpio30 pinconfig 42 [ ] pinconfig | | |-- uart1_gpio40 pinconfig 43 [ ] pinconfig | | |-- uart1_ctsrts_gpio42 pinconfig 44 [ ] pinconfig | | |-- gpioout pinconfig 45 [ ] pinconfig | | |-- alt0 gpio 0 [ ] gpio_bcm2835 | | `-- gpio_bcm2835 serial 0 [ ] bcm283x_pl011 | |-- serial@7e201000 mmc 0 [ + ] bcm2835-sdhost | |-- mmc@7e202000 blk 0 [ + ] mmc_blk | | `-- mmc@7e202000.blk serial 1 [ + ] serial_bcm283x_mu | |-- serial@7e215040 mmc 1 [ + ] sdhci-bcm2835 | |-- sdhci@7e300000 blk 1 [ ] mmc_blk | | `-- sdhci@7e300000.blk video 0 [ + ] bcm2835_video | |-- hdmi@7e902000 vidconsole 0 [ + ] vidconsole0 | | `-- hdmi@7e902000.vidconsole0 usb 0 [ + ] dwc2_usb | |-- usb@7e980000 usb_hub 0 [ + ] usb_hub | | `-- usb_hub usb_hub 1 [ + ] usb_hub | | `-- usb_hub usb_dev_ge 0 [ + ] usb_dev_generic_drv | | `-- generic_bus_0_dev_3 simple_bus 1 [ ] generic_simple_bus | `-- firmware simple_bus 2 [ ] generic_simple_bus `-- clocks U-Boot> dm ucl uclass 0: root 0 * root_driver @ 3db67028, seq 0, (req -1)
uclass 20: blk 0 * mmc@7e202000.blk @ 3db683e0, seq 0, (req -1) 1 sdhci@7e300000.blk @ 3db686c8
EFI: Initializing UCLASS_EFI uclass 30: efi uclass 31: eth uclass 34: gpio 0 gpio_bcm2835 @ 3db68ac0
uclass 43: keyboard uclass 47: usb_mass_storage uclass 51: mmc 0 * mmc@7e202000 @ 3db68220, seq 0, (req -1) 1 * sdhci@7e300000 @ 3db68528, seq 1, (req -1)
uclass 54: nop uclass 58: panel uclass 59: backlight uclass 65: pinconfig 0 dpi_gpio0 @ 3db671a0 1 emmc_gpio22 @ 3db671f8 2 * emmc_gpio34 @ 3db67250, seq 2, (req -1) 3 emmc_gpio48 @ 3db672a8 4 gpclk0_gpio4 @ 3db67300 5 gpclk1_gpio5 @ 3db67358 6 gpclk1_gpio42 @ 3db673b0 7 gpclk1_gpio44 @ 3db67408 8 gpclk2_gpio6 @ 3db67460 9 gpclk2_gpio43 @ 3db674b8 10 i2c0_gpio0 @ 3db67510 11 i2c0_gpio28 @ 3db67568 12 i2c0_gpio44 @ 3db675c0 13 i2c1_gpio2 @ 3db67618 14 i2c1_gpio44 @ 3db67670 15 i2c_slave_gpio18 @ 3db676c8 16 jtag_gpio4 @ 3db67720 17 jtag_gpio22 @ 3db67778 18 pcm_gpio18 @ 3db677d0 19 pcm_gpio28 @ 3db67828 20 pwm0_gpio12 @ 3db67880 21 pwm0_gpio18 @ 3db678d8 22 pwm0_gpio40 @ 3db67930 23 pwm1_gpio13 @ 3db67988 24 pwm1_gpio19 @ 3db679e0 25 pwm1_gpio41 @ 3db67a38 26 pwm1_gpio45 @ 3db67a90 27 * sdhost_gpio48 @ 3db67ae8, seq 1, (req -1) 28 spi0_gpio7 @ 3db67b40 29 spi0_gpio35 @ 3db67b98 30 spi1_gpio16 @ 3db67bf0 31 spi2_gpio40 @ 3db67c48 32 uart0_gpio14 @ 3db67ca0 33 uart0_ctsrts_gpio16 @ 3db67cf8 34 uart0_ctsrts_gpio30 @ 3db67d50 35 uart0_gpio32 @ 3db67da8 36 uart0_gpio36 @ 3db67e00 37 uart0_ctsrts_gpio38 @ 3db67e58 38 * uart1_gpio14 @ 3db67eb0, seq 0, (req -1) 39 uart1_ctsrts_gpio16 @ 3db67f08 40 uart1_gpio32 @ 3db67f60 41 uart1_ctsrts_gpio30 @ 3db67fb8 42 uart1_gpio40 @ 3db68010 43 uart1_ctsrts_gpio42 @ 3db68068 44 gpioout @ 3db680c0 45 alt0 @ 3db68118
uclass 66: pinctrl 0 * gpio@7e200000 @ 3db67128, seq 0, (req -1)
uclass 78: serial 0 serial@7e201000 @ 3db68190, seq -1, (req 0) 1 * serial@7e215040 @ 3db684c0, seq 1, (req 1)
uclass 79: simple_bus 0 * soc @ 3db670a0, seq 0, (req -1) 1 firmware @ 3db688b8 2 clocks @ 3db68920
uclass 93: usb 0 * usb@7e980000 @ 3db68860, seq 0, (req -1)
uclass 94: usb_dev_generic 0 * generic_bus_0_dev_3 @ 3db6f728, seq 0, (req -1)
uclass 95: usb_hub 0 * usb_hub @ 3db79290, seq 0, (req -1) 1 * usb_hub @ 3db79cc8, seq 1, (req -1)
uclass 97: video 0 * hdmi@7e902000 @ 3db687c8, seq 0, (req -1)
uclass 99: vidconsole0 0 * hdmi@7e902000.vidconsole0 @ 3db6df38, seq 0, (req -1)
U-Boot> │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (16.027s) ├───────────────────────────────────────── └─SUCCESS (16.192s)
Regards, Simon

Hi Simon,
Am 2020-04-15 21:22, schrieb Simon Glass:
Hi Michael,
On Wed, 15 Apr 2020 at 09:22, Michael Walle michael@walle.cc wrote:
Hi Simon,
Am 2020-04-15 15:56, schrieb Simon Glass:
+Tom
Hi,
On Sat, 14 Mar 2020 at 14:33, sjg@google.com wrote:
On 03. 03. 20 8:47, Michael Walle wrote:
If there are aliases for an uclass, set the base for the "dynamically" allocated numbers next to the highest alias.
Please note, that this might lead to holes in the sequences, depending on the device tree. For example if there is only an alias "ethernet1", the next device seq number would be 2.
In particular this fixes a problem with boards which are using ethernet aliases but also might have network add-in cards like the E1000. If the board is started with the add-in card and depending on the order of the drivers, the E1000 might occupy the first ethernet device and mess up all the hardware addresses, because the devices are now shifted by one.
Also adapt the test cases to the new handling and add test cases checking the holes in the seq numbers.
Signed-off-by: Michael Walle michael@walle.cc Reviewed-by: Alex Marginean alexandru.marginean@nxp.com Tested-by: Alex Marginean alexandru.marginean@nxp.com Acked-by: Vladimir Oltean olteanv@gmail.com Reviewed-by: Simon Glass sjg@chromium.org
changes since v3:
- dev_read_alias_highest_id() is only available if CONFIG_OF_CONTROL is set. Thus added an additional condition "CONFIG_IS_ENABLED(OF_CONTROL)", thanks Simon.
changes since v2:
- adapt/new test cases, thanks Simon
changes since v1:
- move notice about superfluous commits from commit message to this section.
- fix the comment style
arch/sandbox/dts/test.dts | 4 ++-- drivers/core/uclass.c | 21 +++++++++++++++------ include/configs/sandbox.h | 6 +++--- test/dm/eth.c | 14 +++++++------- test/dm/test-fdt.c | 22 +++++++++++++++++----- 5 files changed, 44 insertions(+), 23 deletions(-)
Applied to u-boot-dm/next, thanks!
Sadly, after applying this was found to break rpi_3. Due to some still-pending patches mine doesn't boot anyway so I didn't notice.
The tbot trace is below. The first is the new u-boot-dm/master with two rpi patches, the second is the same with just your patch added. Ethernet seems to go away.
could you dump "dm tree" and "dm uclass" in both cases?
I've had a look at the device tree and there seems to be one ethernet alias to the corresponding USB LAN device. I can only imagine that this alias doesn't match (for whatever reason) and as a second problem, the networking doesn't find a device if there is only a ethernet1.
Yes please see below (first one is without your patch).
Thanks
do-try-int.sh rpi3 HEAD
Checking revision eff8ae8810da44bbbad71e617ea80abc7d7cde45 tbot starting ... ├─Parameters: │ rev = 'eff8ae8810da44bbbad71e617ea80abc7d7cde45' │ clean = True ├─Calling uboot_checkout ... │ ├─Builder: rpi_3 │ └─Done. (1.002s) ├───────────────────────────────────────── └─SUCCESS (1.284s) tbot starting ... ├─Parameters: │ clean = False ├─Calling uboot_build_and_flash ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Calling uboot_build ... │ │ ├─Calling uboot_checkout ... │ │ │ ├─Builder: rpi_3 │ │ │ └─Done. (0.127s) │ │ ├─Configuring build ... │ │ ├─Calling uboot_make ... │ │ │ └─Done. (13.117s) │ │ └─Done. (15.603s) │ ├─Calling uboot_flash ... │ │ ├─Calling copy ... │ │ │ └─Done. (0.004s) │ │ └─Done. (4.412s) │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (20.975s) ├───────────────────────────────────────── └─SUCCESS (21.152s) tbot starting ... ├─Calling interactive_board ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Entering interactive shell (CTRL+D to exit) ...
U-Boot 2020.04-00305-geff8ae8810 (Apr 15 2020 - 13:15:29 -0600)
DRAM: 992 MiB RPI 3 Model B (0xa22082) MMC: mmc@7e202000: 0, sdhci@7e300000: 1 Loading Environment from FAT... *** Warning - bad CRC, using default environment
In: serial Out: vidconsole Err: vidconsole Net: No ethernet found. starting USB... Bus usb@7e980000: scanning bus usb@7e980000 for devices... Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000 4 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0 U-Boot> dm tree Class Index Probed Driver Name
root 0 [ + ] root_driver root_driver simple_bus 0 [ + ] generic_simple_bus |-- soc pinctrl 0 [ + ] bcm283x_pinctrl | |-- gpio@7e200000 pinconfig 0 [ ] pinconfig | | |-- dpi_gpio0 pinconfig 1 [ ] pinconfig | | |-- emmc_gpio22 pinconfig 2 [ + ] pinconfig | | |-- emmc_gpio34 pinconfig 3 [ ] pinconfig | | |-- emmc_gpio48 pinconfig 4 [ ] pinconfig | | |-- gpclk0_gpio4 pinconfig 5 [ ] pinconfig | | |-- gpclk1_gpio5 pinconfig 6 [ ] pinconfig | | |-- gpclk1_gpio42 pinconfig 7 [ ] pinconfig | | |-- gpclk1_gpio44 pinconfig 8 [ ] pinconfig | | |-- gpclk2_gpio6 pinconfig 9 [ ] pinconfig | | |-- gpclk2_gpio43 pinconfig 10 [ ] pinconfig | | |-- i2c0_gpio0 pinconfig 11 [ ] pinconfig | | |-- i2c0_gpio28 pinconfig 12 [ ] pinconfig | | |-- i2c0_gpio44 pinconfig 13 [ ] pinconfig | | |-- i2c1_gpio2 pinconfig 14 [ ] pinconfig | | |-- i2c1_gpio44 pinconfig 15 [ ] pinconfig | | |-- i2c_slave_gpio18 pinconfig 16 [ ] pinconfig | | |-- jtag_gpio4 pinconfig 17 [ ] pinconfig | | |-- jtag_gpio22 pinconfig 18 [ ] pinconfig | | |-- pcm_gpio18 pinconfig 19 [ ] pinconfig | | |-- pcm_gpio28 pinconfig 20 [ ] pinconfig | | |-- pwm0_gpio12 pinconfig 21 [ ] pinconfig | | |-- pwm0_gpio18 pinconfig 22 [ ] pinconfig | | |-- pwm0_gpio40 pinconfig 23 [ ] pinconfig | | |-- pwm1_gpio13 pinconfig 24 [ ] pinconfig | | |-- pwm1_gpio19 pinconfig 25 [ ] pinconfig | | |-- pwm1_gpio41 pinconfig 26 [ ] pinconfig | | |-- pwm1_gpio45 pinconfig 27 [ + ] pinconfig | | |-- sdhost_gpio48 pinconfig 28 [ ] pinconfig | | |-- spi0_gpio7 pinconfig 29 [ ] pinconfig | | |-- spi0_gpio35 pinconfig 30 [ ] pinconfig | | |-- spi1_gpio16 pinconfig 31 [ ] pinconfig | | |-- spi2_gpio40 pinconfig 32 [ ] pinconfig | | |-- uart0_gpio14 pinconfig 33 [ ] pinconfig | | |-- uart0_ctsrts_gpio16 pinconfig 34 [ ] pinconfig | | |-- uart0_ctsrts_gpio30 pinconfig 35 [ ] pinconfig | | |-- uart0_gpio32 pinconfig 36 [ ] pinconfig | | |-- uart0_gpio36 pinconfig 37 [ ] pinconfig | | |-- uart0_ctsrts_gpio38 pinconfig 38 [ + ] pinconfig | | |-- uart1_gpio14 pinconfig 39 [ ] pinconfig | | |-- uart1_ctsrts_gpio16 pinconfig 40 [ ] pinconfig | | |-- uart1_gpio32 pinconfig 41 [ ] pinconfig | | |-- uart1_ctsrts_gpio30 pinconfig 42 [ ] pinconfig | | |-- uart1_gpio40 pinconfig 43 [ ] pinconfig | | |-- uart1_ctsrts_gpio42 pinconfig 44 [ ] pinconfig | | |-- gpioout pinconfig 45 [ ] pinconfig | | |-- alt0 gpio 0 [ ] gpio_bcm2835 | | `-- gpio_bcm2835 serial 0 [ ] bcm283x_pl011 | |-- serial@7e201000 mmc 0 [ + ] bcm2835-sdhost | |-- mmc@7e202000 blk 0 [ + ] mmc_blk | | `-- mmc@7e202000.blk serial 1 [ + ] serial_bcm283x_mu | |-- serial@7e215040 mmc 1 [ + ] sdhci-bcm2835 | |-- sdhci@7e300000 blk 1 [ ] mmc_blk | | `-- sdhci@7e300000.blk video 0 [ + ] bcm2835_video | |-- hdmi@7e902000 vidconsole 0 [ + ] vidconsole0 | | `-- hdmi@7e902000.vidconsole0 usb 0 [ + ] dwc2_usb | |-- usb@7e980000 usb_hub 0 [ + ] usb_hub | | `-- usb_hub usb_hub 1 [ + ] usb_hub | | `-- usb_hub eth 0 [ + ] smsc95xx_eth | | |-- smsc95xx_eth usb_dev_ge 0 [ + ] usb_dev_generic_drv | | `-- generic_bus_0_dev_4 simple_bus 1 [ ] generic_simple_bus | `-- firmware simple_bus 2 [ ] generic_simple_bus `-- clocks U-Boot> dm uclass uclass 0: root 0 * root_driver @ 3db67028, seq 0, (req -1)
uclass 20: blk 0 * mmc@7e202000.blk @ 3db683e0, seq 0, (req -1) 1 sdhci@7e300000.blk @ 3db686c8
EFI: Initializing UCLASS_EFI uclass 30: efi uclass 31: eth 0 * smsc95xx_eth @ 3db69ac0, seq 0, (req -1)
Shouldn't this be "req 0" if the ethernet alias is actually matched. Does u-boot actually supports matching usb nodes to devices? If not, shouldn't the alias be removed then?
That being said, it is still strange why the bootloader doesn't find ethernet-1 then. I've tried with my board, no native ethernet support and an usb network dongle which works as expected (well the dongle seems to have some issues to actually transfer frames).
U-Boot 2020.04-00278-gab5be282e8-dirty (Apr 16 2020 - 12:40:55 +0200)
SoC: LS1028A Rev1.0 (0x870b0110) Clock Configuration: CPU0(A72):1300 MHz CPU1(A72):1300 MHz Bus: 400 MHz DDR: 1600 MT/s Reset Configuration Word (RCW): 00000000: 34004010 00000030 00000000 00000000 00000010: 00000000 008f0000 0030c000 00000000 00000020: 06200000 00002580 00000000 00019016 00000030: 00000000 00000048 00000000 00000000 00000040: 00000000 00000000 00000000 00000000 00000050: 00000000 00000000 00000000 00000000 00000060: 00000103 00000000 100e7026 00000000 00000070: bb580000 00020000 Model: Kontron SMARC-sAL28 Board DRAM: 3.9 GiB DDR 3.9 GiB (DDR3, 32-bit, CL=11, ECC on) Using SERDES1 Protocol: 47960 (0xbb58) PCIe0: pcie@3400000 Root Complex: no link PCIe1: pcie@3500000 Root Complex: no link WDT: Started with servicing (60s timeout) Waking secondary cores to start from fbd47000 All (2) cores are up. MMC: FSL_SDHC: 0, FSL_SDHC: 1 Loading Environment from SPI Flash... spi_nor_init SF: Detected w25q32dw with page size 256 Bytes, erase size 64 KiB, total 4 MiB OK In: serial Out: serial Err: serial Net: No ethernet found. Hit any key to stop autoboot: 0 => usb start starting USB... Bus usb3@3100000: Register 200017f NbrPorts 2 Starting the controller USB XHCI 1.00 Bus usb3@3110000: Register 200017f NbrPorts 2 Starting the controller USB XHCI 1.00 scanning bus usb3@3100000 for devices... 1 USB Device(s) found scanning bus usb3@3110000 for devices... Warning: ax88179_eth MAC addresses don't match: Address in ROM is 00:0a:cd:27:0e:8c Address in environment is 00:de:ad:be:ef:01 4 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found # dm uclass [..] uclass 32: eth 0 * ax88179_eth @ fbb494a0, seq 1, (req -1) [..]
-michael

Hi Michael,
On Thu, 16 Apr 2020 at 04:50, Michael Walle michael@walle.cc wrote:
Hi Simon,
Am 2020-04-15 21:22, schrieb Simon Glass:
Hi Michael,
On Wed, 15 Apr 2020 at 09:22, Michael Walle michael@walle.cc wrote:
Hi Simon,
Am 2020-04-15 15:56, schrieb Simon Glass:
+Tom
Hi,
On Sat, 14 Mar 2020 at 14:33, sjg@google.com wrote:
On 03. 03. 20 8:47, Michael Walle wrote:
If there are aliases for an uclass, set the base for the "dynamically" allocated numbers next to the highest alias.
Please note, that this might lead to holes in the sequences, depending on the device tree. For example if there is only an alias "ethernet1", the next device seq number would be 2.
In particular this fixes a problem with boards which are using ethernet aliases but also might have network add-in cards like the E1000. If the board is started with the add-in card and depending on the order of the drivers, the E1000 might occupy the first ethernet device and mess up all the hardware addresses, because the devices are now shifted by one.
Also adapt the test cases to the new handling and add test cases checking the holes in the seq numbers.
Signed-off-by: Michael Walle michael@walle.cc Reviewed-by: Alex Marginean alexandru.marginean@nxp.com Tested-by: Alex Marginean alexandru.marginean@nxp.com Acked-by: Vladimir Oltean olteanv@gmail.com Reviewed-by: Simon Glass sjg@chromium.org
changes since v3:
- dev_read_alias_highest_id() is only available if CONFIG_OF_CONTROL is set. Thus added an additional condition "CONFIG_IS_ENABLED(OF_CONTROL)", thanks Simon.
changes since v2:
- adapt/new test cases, thanks Simon
changes since v1:
- move notice about superfluous commits from commit message to this section.
- fix the comment style
arch/sandbox/dts/test.dts | 4 ++-- drivers/core/uclass.c | 21 +++++++++++++++------ include/configs/sandbox.h | 6 +++--- test/dm/eth.c | 14 +++++++------- test/dm/test-fdt.c | 22 +++++++++++++++++----- 5 files changed, 44 insertions(+), 23 deletions(-)
Applied to u-boot-dm/next, thanks!
Sadly, after applying this was found to break rpi_3. Due to some still-pending patches mine doesn't boot anyway so I didn't notice.
The tbot trace is below. The first is the new u-boot-dm/master with two rpi patches, the second is the same with just your patch added. Ethernet seems to go away.
could you dump "dm tree" and "dm uclass" in both cases?
I've had a look at the device tree and there seems to be one ethernet alias to the corresponding USB LAN device. I can only imagine that this alias doesn't match (for whatever reason) and as a second problem, the networking doesn't find a device if there is only a ethernet1.
Yes please see below (first one is without your patch).
Thanks
do-try-int.sh rpi3 HEAD
Checking revision eff8ae8810da44bbbad71e617ea80abc7d7cde45 tbot starting ... ├─Parameters: │ rev = 'eff8ae8810da44bbbad71e617ea80abc7d7cde45' │ clean = True ├─Calling uboot_checkout ... │ ├─Builder: rpi_3 │ └─Done. (1.002s) ├───────────────────────────────────────── └─SUCCESS (1.284s) tbot starting ... ├─Parameters: │ clean = False ├─Calling uboot_build_and_flash ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Calling uboot_build ... │ │ ├─Calling uboot_checkout ... │ │ │ ├─Builder: rpi_3 │ │ │ └─Done. (0.127s) │ │ ├─Configuring build ... │ │ ├─Calling uboot_make ... │ │ │ └─Done. (13.117s) │ │ └─Done. (15.603s) │ ├─Calling uboot_flash ... │ │ ├─Calling copy ... │ │ │ └─Done. (0.004s) │ │ └─Done. (4.412s) │ ├─POWEROFF (Raspberry Pi 3b) │ └─Done. (20.975s) ├───────────────────────────────────────── └─SUCCESS (21.152s) tbot starting ... ├─Calling interactive_board ... │ ├─POWERON (Raspberry Pi 3b) │ ├─Entering interactive shell (CTRL+D to exit) ...
U-Boot 2020.04-00305-geff8ae8810 (Apr 15 2020 - 13:15:29 -0600)
DRAM: 992 MiB RPI 3 Model B (0xa22082) MMC: mmc@7e202000: 0, sdhci@7e300000: 1 Loading Environment from FAT... *** Warning - bad CRC, using default environment
In: serial Out: vidconsole Err: vidconsole Net: No ethernet found. starting USB... Bus usb@7e980000: scanning bus usb@7e980000 for devices... Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000 4 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0 U-Boot> dm tree Class Index Probed Driver Name
root 0 [ + ] root_driver root_driver simple_bus 0 [ + ] generic_simple_bus |-- soc pinctrl 0 [ + ] bcm283x_pinctrl | |-- gpio@7e200000 pinconfig 0 [ ] pinconfig | | |-- dpi_gpio0 pinconfig 1 [ ] pinconfig | | |-- emmc_gpio22 pinconfig 2 [ + ] pinconfig | | |-- emmc_gpio34 pinconfig 3 [ ] pinconfig | | |-- emmc_gpio48 pinconfig 4 [ ] pinconfig | | |-- gpclk0_gpio4 pinconfig 5 [ ] pinconfig | | |-- gpclk1_gpio5 pinconfig 6 [ ] pinconfig | | |-- gpclk1_gpio42 pinconfig 7 [ ] pinconfig | | |-- gpclk1_gpio44 pinconfig 8 [ ] pinconfig | | |-- gpclk2_gpio6 pinconfig 9 [ ] pinconfig | | |-- gpclk2_gpio43 pinconfig 10 [ ] pinconfig | | |-- i2c0_gpio0 pinconfig 11 [ ] pinconfig | | |-- i2c0_gpio28 pinconfig 12 [ ] pinconfig | | |-- i2c0_gpio44 pinconfig 13 [ ] pinconfig | | |-- i2c1_gpio2 pinconfig 14 [ ] pinconfig | | |-- i2c1_gpio44 pinconfig 15 [ ] pinconfig | | |-- i2c_slave_gpio18 pinconfig 16 [ ] pinconfig | | |-- jtag_gpio4 pinconfig 17 [ ] pinconfig | | |-- jtag_gpio22 pinconfig 18 [ ] pinconfig | | |-- pcm_gpio18 pinconfig 19 [ ] pinconfig | | |-- pcm_gpio28 pinconfig 20 [ ] pinconfig | | |-- pwm0_gpio12 pinconfig 21 [ ] pinconfig | | |-- pwm0_gpio18 pinconfig 22 [ ] pinconfig | | |-- pwm0_gpio40 pinconfig 23 [ ] pinconfig | | |-- pwm1_gpio13 pinconfig 24 [ ] pinconfig | | |-- pwm1_gpio19 pinconfig 25 [ ] pinconfig | | |-- pwm1_gpio41 pinconfig 26 [ ] pinconfig | | |-- pwm1_gpio45 pinconfig 27 [ + ] pinconfig | | |-- sdhost_gpio48 pinconfig 28 [ ] pinconfig | | |-- spi0_gpio7 pinconfig 29 [ ] pinconfig | | |-- spi0_gpio35 pinconfig 30 [ ] pinconfig | | |-- spi1_gpio16 pinconfig 31 [ ] pinconfig | | |-- spi2_gpio40 pinconfig 32 [ ] pinconfig | | |-- uart0_gpio14 pinconfig 33 [ ] pinconfig | | |-- uart0_ctsrts_gpio16 pinconfig 34 [ ] pinconfig | | |-- uart0_ctsrts_gpio30 pinconfig 35 [ ] pinconfig | | |-- uart0_gpio32 pinconfig 36 [ ] pinconfig | | |-- uart0_gpio36 pinconfig 37 [ ] pinconfig | | |-- uart0_ctsrts_gpio38 pinconfig 38 [ + ] pinconfig | | |-- uart1_gpio14 pinconfig 39 [ ] pinconfig | | |-- uart1_ctsrts_gpio16 pinconfig 40 [ ] pinconfig | | |-- uart1_gpio32 pinconfig 41 [ ] pinconfig | | |-- uart1_ctsrts_gpio30 pinconfig 42 [ ] pinconfig | | |-- uart1_gpio40 pinconfig 43 [ ] pinconfig | | |-- uart1_ctsrts_gpio42 pinconfig 44 [ ] pinconfig | | |-- gpioout pinconfig 45 [ ] pinconfig | | |-- alt0 gpio 0 [ ] gpio_bcm2835 | | `-- gpio_bcm2835 serial 0 [ ] bcm283x_pl011 | |-- serial@7e201000 mmc 0 [ + ] bcm2835-sdhost | |-- mmc@7e202000 blk 0 [ + ] mmc_blk | | `-- mmc@7e202000.blk serial 1 [ + ] serial_bcm283x_mu | |-- serial@7e215040 mmc 1 [ + ] sdhci-bcm2835 | |-- sdhci@7e300000 blk 1 [ ] mmc_blk | | `-- sdhci@7e300000.blk video 0 [ + ] bcm2835_video | |-- hdmi@7e902000 vidconsole 0 [ + ] vidconsole0 | | `-- hdmi@7e902000.vidconsole0 usb 0 [ + ] dwc2_usb | |-- usb@7e980000 usb_hub 0 [ + ] usb_hub | | `-- usb_hub usb_hub 1 [ + ] usb_hub | | `-- usb_hub eth 0 [ + ] smsc95xx_eth | | |-- smsc95xx_eth usb_dev_ge 0 [ + ] usb_dev_generic_drv | | `-- generic_bus_0_dev_4 simple_bus 1 [ ] generic_simple_bus | `-- firmware simple_bus 2 [ ] generic_simple_bus `-- clocks U-Boot> dm uclass uclass 0: root 0 * root_driver @ 3db67028, seq 0, (req -1)
uclass 20: blk 0 * mmc@7e202000.blk @ 3db683e0, seq 0, (req -1) 1 sdhci@7e300000.blk @ 3db686c8
EFI: Initializing UCLASS_EFI uclass 30: efi uclass 31: eth 0 * smsc95xx_eth @ 3db69ac0, seq 0, (req -1)
Shouldn't this be "req 0" if the ethernet alias is actually matched. Does u-boot actually supports matching usb nodes to devices? If not, shouldn't the alias be removed then?
That being said, it is still strange why the bootloader doesn't find ethernet-1 then. I've tried with my board, no native ethernet support and an usb network dongle which works as expected (well the dongle seems to have some issues to actually transfer frames).
It is a bit strange. Removing the alias does not fix it though.
So far as I know U-Boot doesn't work with the alias, since there is no driver for the "usb424,2514" compatible string.
U-Boot 2020.04-00278-gab5be282e8-dirty (Apr 16 2020 - 12:40:55 +0200)
SoC: LS1028A Rev1.0 (0x870b0110) Clock Configuration: CPU0(A72):1300 MHz CPU1(A72):1300 MHz Bus: 400 MHz DDR: 1600 MT/s Reset Configuration Word (RCW): 00000000: 34004010 00000030 00000000 00000000 00000010: 00000000 008f0000 0030c000 00000000 00000020: 06200000 00002580 00000000 00019016 00000030: 00000000 00000048 00000000 00000000 00000040: 00000000 00000000 00000000 00000000 00000050: 00000000 00000000 00000000 00000000 00000060: 00000103 00000000 100e7026 00000000 00000070: bb580000 00020000 Model: Kontron SMARC-sAL28 Board DRAM: 3.9 GiB DDR 3.9 GiB (DDR3, 32-bit, CL=11, ECC on) Using SERDES1 Protocol: 47960 (0xbb58) PCIe0: pcie@3400000 Root Complex: no link PCIe1: pcie@3500000 Root Complex: no link WDT: Started with servicing (60s timeout) Waking secondary cores to start from fbd47000 All (2) cores are up. MMC: FSL_SDHC: 0, FSL_SDHC: 1 Loading Environment from SPI Flash... spi_nor_init SF: Detected w25q32dw with page size 256 Bytes, erase size 64 KiB, total 4 MiB OK In: serial Out: serial Err: serial Net: No ethernet found. Hit any key to stop autoboot: 0 => usb start starting USB... Bus usb3@3100000: Register 200017f NbrPorts 2 Starting the controller USB XHCI 1.00 Bus usb3@3110000: Register 200017f NbrPorts 2 Starting the controller USB XHCI 1.00 scanning bus usb3@3100000 for devices... 1 USB Device(s) found scanning bus usb3@3110000 for devices... Warning: ax88179_eth MAC addresses don't match: Address in ROM is 00:0a:cd:27:0e:8c Address in environment is 00:de:ad:be:ef:01 4 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found # dm uclass [..] uclass 32: eth 0 * ax88179_eth @ fbb494a0, seq 1, (req -1) [..]
-michael
Regards, Simon

Hi Simon,
Am 2020-04-20 01:38, schrieb Simon Glass:
[..snip..]
uclass 31: eth 0 * smsc95xx_eth @ 3db69ac0, seq 0, (req -1)
Shouldn't this be "req 0" if the ethernet alias is actually matched. Does u-boot actually supports matching usb nodes to devices? If not, shouldn't the alias be removed then?
That being said, it is still strange why the bootloader doesn't find ethernet-1 then. I've tried with my board, no native ethernet support and an usb network dongle which works as expected (well the dongle seems to have some issues to actually transfer frames).
It is a bit strange. Removing the alias does not fix it though.
Are you sure you removed the alias in the correct file? There are two, could you please double check if is not contained in the resulting device tree?
dtc -I dtb -O dts dts/dt.dtb
I just tested it on a rpi3b. and it works if i remove the alias.
So far as I know U-Boot doesn't work with the alias, since there is no driver for the "usb424,2514" compatible string.
So it is actually correct behaviour of my patch. ethernet1 doesn't work because there is no eth1addr. So I see three solutions:
(1) make the matching work (2) remove the alias (3) set eth1addr instead of ethaddr
have a nice weekend, -michael

Hi Simon,
Am 2020-04-24 16:17, schrieb Michael Walle:
Hi Simon,
Am 2020-04-20 01:38, schrieb Simon Glass:
[..snip..]
uclass 31: eth 0 * smsc95xx_eth @ 3db69ac0, seq 0, (req -1)
Shouldn't this be "req 0" if the ethernet alias is actually matched. Does u-boot actually supports matching usb nodes to devices? If not, shouldn't the alias be removed then?
That being said, it is still strange why the bootloader doesn't find ethernet-1 then. I've tried with my board, no native ethernet support and an usb network dongle which works as expected (well the dongle seems to have some issues to actually transfer frames).
It is a bit strange. Removing the alias does not fix it though.
Are you sure you removed the alias in the correct file? There are two, could you please double check if is not contained in the resulting device tree?
dtc -I dtb -O dts dts/dt.dtb
I just tested it on a rpi3b. and it works if i remove the alias.
So far as I know U-Boot doesn't work with the alias, since there is no driver for the "usb424,2514" compatible string.
So it is actually correct behaviour of my patch. ethernet1 doesn't work because there is no eth1addr. So I see three solutions:
(1) make the matching work (2) remove the alias (3) set eth1addr instead of ethaddr
Any news on this? Can I help somewhere? I'd go with (2).
-michael

Hi Michael,
On Tue, 19 May 2020 at 06:17, Michael Walle michael@walle.cc wrote:
Hi Simon,
Am 2020-04-24 16:17, schrieb Michael Walle:
Hi Simon,
Am 2020-04-20 01:38, schrieb Simon Glass:
[..snip..]
uclass 31: eth 0 * smsc95xx_eth @ 3db69ac0, seq 0, (req -1)
Shouldn't this be "req 0" if the ethernet alias is actually matched. Does u-boot actually supports matching usb nodes to devices? If not, shouldn't the alias be removed then?
That being said, it is still strange why the bootloader doesn't find ethernet-1 then. I've tried with my board, no native ethernet support and an usb network dongle which works as expected (well the dongle seems to have some issues to actually transfer frames).
It is a bit strange. Removing the alias does not fix it though.
Are you sure you removed the alias in the correct file? There are two, could you please double check if is not contained in the resulting device tree?
dtc -I dtb -O dts dts/dt.dtb
I just tested it on a rpi3b. and it works if i remove the alias.
So far as I know U-Boot doesn't work with the alias, since there is no driver for the "usb424,2514" compatible string.
So it is actually correct behaviour of my patch. ethernet1 doesn't work because there is no eth1addr. So I see three solutions:
(1) make the matching work (2) remove the alias (3) set eth1addr instead of ethaddr
Any news on this? Can I help somewhere? I'd go with (2).
What is involved in (1)?
Regards, Simon

Hi Simon,
Am 2020-05-19 18:47, schrieb Simon Glass:
Hi Michael,
On Tue, 19 May 2020 at 06:17, Michael Walle michael@walle.cc wrote:
Hi Simon,
Am 2020-04-24 16:17, schrieb Michael Walle:
Hi Simon,
Am 2020-04-20 01:38, schrieb Simon Glass:
[..snip..]
uclass 31: eth 0 * smsc95xx_eth @ 3db69ac0, seq 0, (req -1)
Shouldn't this be "req 0" if the ethernet alias is actually matched. Does u-boot actually supports matching usb nodes to devices? If not, shouldn't the alias be removed then?
That being said, it is still strange why the bootloader doesn't find ethernet-1 then. I've tried with my board, no native ethernet support and an usb network dongle which works as expected (well the dongle seems to have some issues to actually transfer frames).
It is a bit strange. Removing the alias does not fix it though.
Are you sure you removed the alias in the correct file? There are two, could you please double check if is not contained in the resulting device tree?
dtc -I dtb -O dts dts/dt.dtb
I just tested it on a rpi3b. and it works if i remove the alias.
So far as I know U-Boot doesn't work with the alias, since there is no driver for the "usb424,2514" compatible string.
So it is actually correct behaviour of my patch. ethernet1 doesn't work because there is no eth1addr. So I see three solutions:
(1) make the matching work (2) remove the alias (3) set eth1addr instead of ethaddr
Any news on this? Can I help somewhere? I'd go with (2).
What is involved in (1)?
I've given it a try in the new v5 version.
-michael
participants (4)
-
Michael Walle
-
Michal Simek
-
Simon Glass
-
sjg@google.com