[PATCH] usb: Add delay for control messages to reach usb stick
Simon Glass
sjg at chromium.org
Sat Aug 27 02:20:57 CEST 2022
Hi,
On Fri, 26 Aug 2022 at 13:37, Janne Grunau <j at jannau.net> wrote:
>
> Hej,
>
> On 2022-08-25 23:35:33 -0600, Ashok Reddy Soma wrote:
> > We are seeing timing issues with transcend usb sticks. These devices
> > seems to require more time than regular devices for the control messages
> > to reach device. Add 1ms delay before sending control message to fix
> > trancend device detection issue.
>
> I suspect I see something similar with the DWC3 controller on Apple
> M1/M2 devices. It seems to be related to USB full speed devices with
> bMaxPacketSize0 of 8. Failing devices are so only keyboards since that
> is a device everyone will connect when using a Mac Mini as desktop.
> I can reproduce the issue with older Logitech Unifying Receiver wireless
> keyboard/mouse dongles (bcdDevice 12.03 or 12.10). I could also resolve
> the issue with random 'mdelay(1);'. I chased the cause of the issue down
> to the initial USB descriptor read to parse 'bMaxPacketSize0' in
> usb_setup_descriptor(). Please test if adding the delay after the
> get_descriptor_len() call in usb_setup_descriptor() is enough.
> On the Apple silicon devices reducing the read size from 64 byte to 8
> resolves the issue as well. Please try attached work-in-progress patch
> (comment and commit message are not finalized).
>
> HTH Janne
>
> > Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma at amd.com>
> > ---
> >
> > common/usb.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/common/usb.c b/common/usb.c
> > index 6fcf1e8428..3fae32b048 100644
> > --- a/common/usb.c
> > +++ b/common/usb.c
> > @@ -241,6 +241,12 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
> > request, requesttype, value, index, size);
> > dev->status = USB_ST_NOT_PROC; /*not yet processed */
> >
> > + /* Timing issues are observed with transcend usb sticks such as
> > + * “Transcend Jetflash 350 USB2.0". Add 1ms delay for the usb
> > + * device to get detected.
> > + */
> > + mdelay(1);
>
> Please let's try to avoid this. I noticed a slowdown of USB probing with
> an hub with 4 devices connected. Since Apple silicon devices are desktop
> style machines I expect it's not uncommon to see systems with many USB
> devices.
Can we add a CONFIG for this, or put a setting in the device tree? Or
is there a way to detect the problem and retry?
>
> > +
> > err = submit_control_msg(dev, pipe, data, size, setup_packet);
> > if (err < 0)
> > return err;
> > --
> > 2.17.1
> >
Regards,
Simon
More information about the U-Boot
mailing list