[PATCH] usb: storage: increase retries to 20

Stefan Agner stefan at agner.ch
Sun Sep 20 21:55:15 CEST 2020


On 2020-09-20 21:01, Stefan Agner wrote:
> A JMicron JMS583 based NVMe to USB 3.1 enclosure connected to a Raspberry
> Pi 4 fails to enumerate as a USB Mass Storage device on first try:
> 
>   ...
>   startig USB...
>   Bus xhci_pci: Register 5000420 NbrPorts 5
>   Starting the controller
>   USB XHCI 1.00
>   scanning bus xhci_pci for devces... Device NOT ready
>      Request Sense returned 02 04 01
>   4 USB Device(s) found
>          scanning usb for storage devices... 0 Sorage Device(s) found

It turned out, the device was not sufficiently powered. Even after I was
able to use U-Boot to boot from it, Linux reported USB resets every ~30s
or so.

Supplying the device with enough power (e.g. by connecting via powered
USB 3.0 Hub) things started to work better: The device was always ready
below 1s (8 tries). So it seems that the default of 10 is actually good
enough also for this device.

--
Stefan

> 
> However, it consistently works on the second try. It seems that the
> device takes longer than 1s to detect the media. With debug enabled
> it shows that the 11th retry count typically works.
> 
> Increase retries to 20 for a startup time of up to 2s.
> 
> Signed-off-by: Stefan Agner <stefan at agner.ch>
> ---
>  common/usb_storage.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/usb_storage.c b/common/usb_storage.c
> index ff25441995..04910de21f 100644
> --- a/common/usb_storage.c
> +++ b/common/usb_storage.c
> @@ -1019,7 +1019,7 @@ static int usb_request_sense(struct scsi_cmd
> *srb, struct us_data *ss)
>  
>  static int usb_test_unit_ready(struct scsi_cmd *srb, struct us_data *ss)
>  {
> -	int retries = 10;
> +	int retries = 20;
>  
>  	do {
>  		memset(&srb->cmd[0], 0, 12);


More information about the U-Boot mailing list