From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3EF0ECAAD2 for ; Sat, 27 Aug 2022 10:40:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE5E384062; Sat, 27 Aug 2022 12:40:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jannau.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 1735784047; Sat, 27 Aug 2022 12:40:32 +0200 (CEST) Received: from soltyk.jannau.net (soltyk.jannau.net [144.76.91.90]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9396D84062 for ; Sat, 27 Aug 2022 12:40:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jannau.net Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=janne@jannau.net Received: by soltyk.jannau.net (Postfix, from userid 1000) id 3229726EED2; Sat, 27 Aug 2022 12:40:29 +0200 (CEST) Date: Sat, 27 Aug 2022 12:40:29 +0200 From: Janne Grunau To: Simon Glass Cc: Ashok Reddy Soma , U-Boot Mailing List , Marek Vasut , Michal Simek , git , git@amd.com Subject: Re: [PATCH] usb: Add delay for control messages to reach usb stick Message-ID: <20220827104029.GB10102@jannau.net> References: <20220826053533.23805-1-ashok.reddy.soma@amd.com> <20220826193717.GA10102@jannau.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On 2022-08-26 18:20:57 -0600, Simon Glass wrote: > Hi, > > On Fri, 26 Aug 2022 at 13:37, Janne Grunau 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 > > > --- > > > > > > 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? A short search suggests that Transcend USB1.0 flash drives have a bMaxPacketSize0 of 64 so it's unlikely that my change to reduce the initial read of the usb descriptor will fix this but please try first. Have you verified that this delay is required for every USB control message and not just for a single one? Compare the mdelay for "Kingston DT Ultimate" in usb_select_config(). If this is an issue of this specific USB devices I don't see how a config option or device tree entry is going to help. Since it is an issue in the device detection it might not be even possible to add a device specific quirk for this. Have you tried if shorter delays than 1 ms fix the issue as well? I'll clean up the comment in my commit and send it later as patch. Best regards Janne