[PATCH 0/2] efi: remove error in efi_disk_probe/efi_disk_remove

Patrick Delaunay patrick.delaunay at foss.st.com
Wed Mar 8 14:26:46 CET 2023


Proposed serie after investigate crash:
- board stm32mp157c-dk2, including a USB HUB 4 ports
- 2 USB key on the USB HUB (same PID/VID)
- multiple command usb start/usb stop

Without these patches, U-Boot failed to probe / failed to unbind the 2nd
key and crash in USB stack, usb_find_usb2_hub_address_port()

When the probe for USB child failed, the unbind failed also.
For example when PSCI stack can't handle 2 devices with the same EFI
handle based on PIDVID for USB device.

On the "usb stop" command, the USB tree becomes invalid as the EFI
stack forbids to remove the USB devices, the USB are still present
(checked with "dm tree" command).

On the next USB start, on USB scan, when the USB devices children of
USB HUB are added dynamically, the USB stack crashes...

I propose to remove the return error in efi_disk_probe/efi_disk_remove
and to replace them by log_error
=> even if EFI can't export the devices, the device should be
   available for U-Boot proper and the probe should be complete properly
   (the 2nd USB keys are see in dm tree in the example)

Sequence to reproduce the issue with 2 identical USB key

STM32MP> usb start && usb tree && usb stop && usb start && usb tree
         && usb stop && usb start && usb tree && usb stop

starting USB...
Bus usb at 5800d000: USB EHCI 1.00
scanning bus usb at 5800d000 for devices...
Adding disk for usb_mass_storage.lun0 failed (err=-2147483628/0x80000014)
device 'usb_mass_storage.lun0' failed to unbind
3 USB Device(s) found
device 'usb_mass_storage.lun0' failed to unbind
       scanning usb for storage devices... 2 Storage Device(s) found
USB device tree:
  1  Hub (480 Mb/s, 0mA)
  |  u-boot EHCI Host Controller
  |
  +-2  Hub (480 Mb/s, 2mA)
    |
    +-3  Mass Storage (480 Mb/s, 200mA)
    |    Generic Mass Storage 81ED9AA7
    |
stopping USB..
device 'usb_mass_storage.lun0' failed to unbind
device 'usb_mass_storage' failed to unbind
device 'usb_hub' failed to unbind
starting USB...
Bus usb at 5800d000: USB EHCI 1.00
scanning bus usb at 5800d000 for devices...
Adding disk for usb_mass_storage.lun0 failed (err=-2147483628/0x80000014)
device 'usb_mass_storage.lun0' failed to unbind
3 USB Device(s) found
device 'usb_mass_storage.lun0' failed to unbind
       scanning usb for storage devices... 2 Storage Device(s) found
USB device tree:
  1  Hub (480 Mb/s, 0mA)
  |  u-boot EHCI Host Controller
  |
  +-2  Hub (480 Mb/s, 2mA)
    |
    +-3  Mass Storage (480 Mb/s, 200mA)
    |    Generic Mass Storage 81ED9AA7
    |
stopping USB..
starting USB...
Bus usb at 5800d000: scanning bus usb at 5800d000 for devices... data abort
pc : [<ddb3e7b6>]	   lr : [<ddb3e7b7>]
reloc pc : [<c01227b6>]	   lr : [<c01227b7>]
sp : dbafa708  ip : dbb54cc0	 fp : dbafa780
r10: dbafac40  r9 : dbb19e80	 r8 : 00000000
r7 : dbafa727  r6 : dbafa726	 r5 : dbb40fc0  r4 : dbafac40
r3 : 00000001  r2 : dbafa726	 r1 : dbafa727  r0 : 00000000
Flags: nZCv  IRQs off  FIQs off  Mode SVC_32 (T)
Code: 592c 4628 f008 ff1d (6843) 2b03
Resetting CPU ...

After the 2 patches, with the 2 SAME keys on the USB HUB
the EFI handle is not created, with error in trace,
BUT the USB key is available in U-Boot proper.

STM32MP> usb start && usb tree && usb stop
starting USB...
Bus usb at 5800d000: USB EHCI 1.00
scanning bus usb at 5800d000 for devices...
Adding disk for usb_mass_storage.lun0 failed (err=-2147483628/0x80000014)
efi_disk_create_raw usb_mass_storage.lun0 failed (-2)
4 USB Device(s) found
       scanning usb for storage devices... 2 Storage Device(s) found
USB device tree:
  1  Hub (480 Mb/s, 0mA)
  |  u-boot EHCI Host Controller
  |
  +-2  Hub (480 Mb/s, 2mA)
    |
    +-3  Mass Storage (480 Mb/s, 200mA)
    |    Generic Mass Storage 81ED9AA7
    |
    +-4  Mass Storage (480 Mb/s, 200mA)
         Generic Mass Storage C3EAEAD2

stopping USB..
efi_disk_remove failed for usb_mass_storage.lun0 uclass 22 (-1)
efi_disk_remove failed for usb_mass_storage.lun0:1 uclass 73 (-1)


Patrick Delaunay (2):
  efi: remove error in efi_disk_probe
  efi: remove error in efi_disk_remove

 lib/efi_loader/efi_disk.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

-- 
2.25.1



More information about the U-Boot mailing list