
Changes:
v5: fixes a bug that Christoph Fritz discovered, consisting in the wrong eror code returned when enabling or disabling the clock because property_enable() returns an error code in linux but the modified register value in U-Boot. This caused the clk disable to abort before freeing the clock and it apparently left things bad enough to cause a hang or a reset.
With your patches ontop of v2023.04-rc2, xhci works now fine on a rk3399 board:
=> usb start starting USB... Bus usb@fe380000: USB EHCI 1.00 Bus usb@fe3c0000: USB EHCI 1.00 Bus usb@fe800000: Register 2000140 NbrPorts 2 Starting the controller USB XHCI 1.10 Bus usb@fe900000: Register 2000140 NbrPorts 2 Starting the controller USB XHCI 1.10 scanning bus usb@fe380000 for devices... 4 USB Device(s) found scanning bus usb@fe3c0000 for devices... 1 USB Device(s) found scanning bus usb@fe800000 for devices... 3 USB Device(s) found scanning bus usb@fe900000 for devices... 1 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found
Totally unrelated to your patches, stopping usb still crashes (with or without your patch) but only when a USB-Ethernet-Dongle (+HUB) is connected:
=> usb start starting USB... do_usb_start, 581 Bus usb@fe380000: USB EHCI 1.00 Bus usb@fe3c0000: USB EHCI 1.00 Bus usb@fe800000: Register 2000140 NbrPorts 2 Starting the controller USB XHCI 1.10 Bus usb@fe900000: Register 2000140 NbrPorts 2 Starting the controller USB XHCI 1.10 scanning bus usb@fe380000 for devices... 3 USB Device(s) found scanning bus usb@fe3c0000 for devices... 1 USB Device(s) found scanning bus usb@fe800000 for devices... 1 USB Device(s) found scanning bus usb@fe900000 for devices... 1 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found => usb tree USB device tree: 1 Hub (480 Mb/s, 0mA) | u-boot EHCI Host Controller | +-2 Hub (480 Mb/s, 100mA) | USB2.0 Hub | +-3 Human Interface (12 Mb/s, 400mA) ILITEK ILITEK-TP
1 Hub (480 Mb/s, 0mA) u-boot EHCI Host Controller
1 Hub (5 Gb/s, 0mA) U-Boot XHCI Host Controller
1 Hub (5 Gb/s, 0mA) U-Boot XHCI Host Controller
=> usb stop stopping USB.. => usb start starting USB... Bus usb@fe380000: USB EHCI 1.00 Bus usb@fe3c0000: USB EHCI 1.00 Bus usb@fe800000: Register 2000140 NbrPorts 2 Starting the controller USB XHCI 1.10 Bus usb@fe900000: Register 2000140 NbrPorts 2 Starting the controller USB XHCI 1.10 scanning bus usb@fe380000 for devices... 4 USB Device(s) found scanning bus usb@fe3c0000 for devices... 1 USB Device(s) found scanning bus usb@fe800000 for devices... 3 USB Device(s) found scanning bus usb@fe900000 for devices... 1 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found => usb tree USB device tree: 1 Hub (480 Mb/s, 0mA) | u-boot EHCI Host Controller | +-2 Hub (480 Mb/s, 100mA) | USB2.0 Hub | +-3 Hub (480 Mb/s, 0mA) | VIA Labs, Inc. USB2.0 Hub | +-4 Human Interface (12 Mb/s, 400mA) ILITEK ILITEK-TP
1 Hub (480 Mb/s, 0mA) u-boot EHCI Host Controller
1 Hub (5 Gb/s, 0mA) | U-Boot XHCI Host Controller | +-2 Hub (5 Gb/s, 0mA) | VIA Labs, Inc. USB3.0 Hub | +-3 Vendor specific (5 Gb/s, 36mA) Realtek USB 10/100/1000 LAN 00E04C68034E
1 Hub (5 Gb/s, 0mA) U-Boot XHCI Host Controller
=> usb stop stopping USB.. <hangs here forever>
I just quirked/masked the underlying issue by not doing usb_stop() at all in drivers/usb/host/usb-uclass.c.