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

Michael Walle michael at walle.cc
Thu Apr 16 12:50:05 CEST 2020


Hi Simon,

Am 2020-04-15 21:22, schrieb Simon Glass:
> Hi Michael,
> 
> On Wed, 15 Apr 2020 at 09:22, Michael Walle <michael at 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 at 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 at walle.cc>
>> >> > Reviewed-by: Alex Marginean <alexandru.marginean at nxp.com>
>> >> > Tested-by: Alex Marginean <alexandru.marginean at nxp.com>
>> >> > Acked-by: Vladimir Oltean <olteanv at gmail.com>
>> >> > Reviewed-by: Simon Glass <sjg at 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 at 7e202000: 0, sdhci at 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 at 7e980000: scanning bus usb at 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 at 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 at 7e201000
>  mmc           0  [ + ]   bcm2835-sdhost        |   |-- mmc at 7e202000
>  blk           0  [ + ]   mmc_blk               |   |   `-- 
> mmc at 7e202000.blk
>  serial        1  [ + ]   serial_bcm283x_mu     |   |-- serial at 7e215040
>  mmc           1  [ + ]   sdhci-bcm2835         |   |-- sdhci at 7e300000
>  blk           1  [   ]   mmc_blk               |   |   `-- 
> sdhci at 7e300000.blk
>  video         0  [ + ]   bcm2835_video         |   |-- hdmi at 7e902000
>  vidconsole    0  [ + ]   vidconsole0           |   |   `--
> hdmi at 7e902000.vidconsole0
>  usb           0  [ + ]   dwc2_usb              |   |-- usb at 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 at 7e202000.blk @ 3db683e0, seq 0, (req -1)
> 1     sdhci at 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 at 3400000 Root Complex: no link
PCIe1: pcie at 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 at 3100000: Register 200017f NbrPorts 2
Starting the controller
USB XHCI 1.00
Bus usb3 at 3110000: Register 200017f NbrPorts 2
Starting the controller
USB XHCI 1.00
scanning bus usb3 at 3100000 for devices... 1 USB Device(s) found
scanning bus usb3 at 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


More information about the U-Boot mailing list