[PATCH] cmd: usb: Prevent reset in usb tree/info command
Xavier Drudis Ferran
xdrudis at tinet.cat
Thu Jun 8 09:39:28 CEST 2023
El Thu, Jun 08, 2023 at 12:05:18AM +0200, Marek Vasut deia:
> On 6/5/23 17:20, Xavier Drudis Ferran wrote:
> > Add a check to avoid dommed (by null pointer dereference) recursive
> > call, not only for UCLASS_BLK.
> >
> > When booting my Rock Pi 4B+ with a USB mass storage stick plugged
> > into one of the USB 2 ports (EHCI), when it is plugged before power
> > on, when issuing a
> >
> > usb tree
> >
> > or
> >
> > usb info
>
> I cannot reproduce the problem. Do you perform any other interaction with
> the USB stack, like e.g. 'usb start' or 'usb reset' before issuing the
> aforementioned commands ?
>
No. Well, in some tests yes and some no, but I got the error in all cases.
Btw, I was testing on the next branch. I had those two commits on top
https://patchwork.ozlabs.org/project/uboot/patch/202013db5a47ecbac4a53c360ed1ca91ca663996.1685974993.git.xdrudis@tinet.cat/
https://patchwork.ozlabs.org/project/uboot/patch/464111fca83008503022e8ada5305e69ffd1afbd.1685974993.git.xdrudis@tinet.cat/
And minor configuration changes (but I had bootstage active, might or might not be related)
U-Boot was in a microSD card.
> What kind of USB stick is used here, please share model, VID, PID.
>
It may only happen with ext4 partitions or something...
Or it might have to do with other media not being bootable (they used
to be for some old and customized version of U-boot, but not the
current one)
This is the lsusb -v output of the same USB stick in another computer
Bus 007 Device 008: ID 0718:070a Imation Corp. TF10
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0718 Imation Corp.
idProduct 0x070a
bcdDevice 1.00
iManufacturer 1 TDK LoR
iProduct 2 TF10
iSerial 3 07032B6B1D0ACB96
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0020
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 200mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0000
(Bus Powered)
Partitions:
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: TDK LoR TF10 (scsi)
Disk /dev/sda: 32,0GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0,00B 32,0GB 32,0GB ext4
The content in the ext4 partition is just data, 3 files,
lost+found and another directory
Let me get to my logs... (I added a printf here uclass_id=22 is UCLASS_BLK
uclass_id=25 is UCLASS_BOOTDEV )
U-Boot TPL 2023.07-rc2-00089-gab17b3d648-dirty (Jun 05 2023 - 10:42:52)
lpddr4_set_rate: change freq to 400MHz 0, 1
Channel 0: LPDDR4, 400MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
Channel 1: LPDDR4, 400MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
256B stride
lpddr4_set_rate: change freq to 800MHz 1, 0
Trying to boot from BOOTROM
Returning to boot ROM...
U-Boot SPL 2023.07-rc2-00089-gab17b3d648-dirty (Jun 05 2023 - 10:42:52 +0200)
Trying to boot from MMC1
NOTICE: BL31: v2.1(release):v2.1-728-ged01e0c4-dirty
NOTICE: BL31: Built : 18:29:11, Mar 22 2022
U-Boot 2023.07-rc2-00089-gab17b3d648-dirty (Jun 05 2023 - 10:42:52 +0200)
SoC: Rockchip rk3399
Reset cause: POR
Model: Radxa ROCK Pi 4B
DRAM: 4 GiB (effective 3.9 GiB)
PMIC: RK808
Core: 284 devices, 29 uclasses, devicetree: separate
MMC: mmc at fe310000: 2, mmc at fe320000: 1, mmc at fe330000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Model: Radxa ROCK Pi 4B
Net: eth0: ethernet at fe300000
Hit any key to stop autoboot: 2 1 0
rockchip_pcie pcie at f8000000: PCIe link training gen1 timeout!
Bus usb at fe380000: USB EHCI 1.00
Bus usb at fe3c0000: USB EHCI 1.00
Bus usb at fe800000: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
Bus usb at fe900000: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb at fe380000 for devices... 1 USB Device(s) found
scanning bus usb at fe3c0000 for devices... 2 USB Device(s) found
scanning bus usb at fe800000 for devices... 1 USB Device(s) found
scanning bus usb at fe900000 for devices... 1 USB Device(s) found
rockchip_pcie pcie at f8000000: failed to find ep-gpios property
ethernet at fe300000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Could not initialize PHY ethernet at fe300000
rockchip_pcie pcie at f8000000: failed to find ep-gpios property
ethernet at fe300000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Could not initialize PHY ethernet at fe300000
=> usb tree
USB device tree:
1 Hub (480 Mb/s, 0mA)
u-boot EHCI Host Controller
1 Hub (480 Mb/s, 0mA)
| u-boot EHCI Host Controller
|
uclass_id=64
|+-2 Mass Storage (480 Mb/s, 200mA)
TDK LoR TF10 07032B6B1D0ACB96
uclass_id=22
uclass_id=25
"Synchronous Abort" handler, esr 0x96000010, far 0x948
elr: 00000000002157d4 lr : 00000000002157d4 (reloc)
elr: 00000000f3f4f7d4 lr : 00000000f3f4f7d4
x0 : 0000000000000005 x1 : 0000000000000000
x2 : 0000000000000020 x3 : 00000000ff1a0000
x4 : 00000000ff1a0000 x5 : 0000000000000000
x6 : 00000000f1f1c000 x7 : 0000000000000001
x8 : 0000000000000001 x9 : 00000000ffffffd0
x10: 0000000000000006 x11: 000000000001869f
x12: 0000000000000200 x13: 0000000000000000
x14: 00000000ffffffff x15: 00000000f1f1bbc9
x16: 000000007e4f2113 x17: 000000009a11f13e
x18: 00000000f1f31d80 x19: 0000000000000000
x20: 00000000f1f1c110 x21: 0000000000000004
x22: 00000000f1f1c114 x23: 00000000f1f65398
x24: 00000000f1f653b8 x25: 0000000000000000
x26: 0000000000000000 x27: 0000000000000000
x28: 0000000000000000 x29: 00000000f1f1c000
Code: aa0003f5 900003c0 9123b800 940191f5 (f944a660)
Resetting CPU ...
resetting ...
> > command I get a "Synchronous Error" and a reset just after printing the
> > mass storage device in the usb tree or usb info. It might depend on the
> > contents of the USB stick too, I'm not sure.
> >
> > It seems like I have two devices as children of the mass storage
> > device. When there's only a UCLASS_BLK it works fine, but when there's
> > a UCLASS_BLK and a UCLASS_BOOTDEV, it recurses with a null udev as
> > first parameter and fails.
> >
> > Likewise for usb_show_info().
> >
> > Not sure if this should be a patch, an RFC or a bug report. There may
> > be a better way to solve this, I haven't researched commit
> > 201417d700a2ab09 ("bootstd: Add the bootdev uclass") and bootdev flow
> > properly, or thought about cases where udev is not null but the
> > recursive call might need preventing too. Feel free to think it over
> > before merging (or after).
>
> It is unclear what the real issue is, so until that is sorted out, no
> merging will occur, sorry.
>
That's ok.
I'm guessing the issue may be some mismatched assumption on what is
under USB devices between the bootdev code and the cmd/usb.c code.
> > But this at least fixes a reset at an
> > innocent looking usb tree or usb info command. Maybe we can improve it
> > later?
>
> NAK, please let's not add ad-hoc poorly understood changes into core code.
Ok, sorry.
I'll reply back if/when I get a clearer theory.
Thanks.
More information about the U-Boot
mailing list