From patchwork Tue May 3 20:51:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 618147 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3qztdY3Y7Zz9ssM for ; Wed, 4 May 2016 06:52:01 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 91B8CA77B3; Tue, 3 May 2016 22:51:51 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kD0fne8d0a0G; Tue, 3 May 2016 22:51:51 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0009FA77A7; Tue, 3 May 2016 22:51:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3D153A75C8 for ; Tue, 3 May 2016 22:51:32 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5o0G6Pb4_hmF for ; Tue, 3 May 2016 22:51:32 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by theia.denx.de (Postfix) with ESMTPS id 0CB4FA750E for ; Tue, 3 May 2016 22:51:27 +0200 (CEST) Received: from mail.nefkom.net (unknown [192.168.8.184]) by mail-out.m-online.net (Postfix) with ESMTP id 3qztcv2Rs0z3hjJs; Tue, 3 May 2016 22:51:27 +0200 (CEST) X-Auth-Info: 5ShBmuGhYm5Vou4DSbcah3ZsZJY5fzHoStD4bCFTY+k= Received: from chi.lan (unknown [195.140.253.167]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 3qztct4sZPzvdWV; Tue, 3 May 2016 22:51:26 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Tue, 3 May 2016 22:51:15 +0200 Message-Id: <1462308680-9366-2-git-send-email-marex@denx.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1462308680-9366-1-git-send-email-marex@denx.de> References: <1462308680-9366-1-git-send-email-marex@denx.de> Cc: Marek Vasut , Stephen Warren , Chin Liang See , Stefan Roese Subject: [U-Boot] [PATCH 2/7] usb: dwc2: Resend setup packet in all fail cases X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The USB function can respond to a Setup packet with ACK or, in case it's busy, it can ignore the Setup packet. The USB function usually gets busy if we hammer it with Control EP transfers too much (ie. sending multiple Get Descriptor requests in a single microframe tends to trigger it on certain USB sticks). The DWC2 controller will interpret not receiving an ACK after Setup packet as XACTERR. Check for this condition and if it happens, retry sending the Setup packet. Signed-off-by: Marek Vasut Cc: Chin Liang See Cc: Dinh Nguyen Cc: Hans de Goede Cc: Stefan Roese Cc: Stephen Warren Reviewed-by: Chin Liang See Tested-by: Chin Liang See --- drivers/usb/host/dwc2.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index 30b51b3..8d3949e 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -737,6 +737,7 @@ int wait_for_chhltd(struct dwc2_hc_regs *hc_regs, uint32_t *sub, u8 *toggle) { int ret; uint32_t hcint, hctsiz; + u8 pid = *toggle; ret = wait_for_bit(__func__, &hc_regs->hcint, DWC2_HCINT_CHHLTD, true, 1000, false); @@ -758,6 +759,19 @@ int wait_for_chhltd(struct dwc2_hc_regs *hc_regs, uint32_t *sub, u8 *toggle) if (hcint & (DWC2_HCINT_NAK | DWC2_HCINT_FRMOVRUN)) return -EAGAIN; + /* + * The USB function can respond to a Setup packet with ACK or, in + * case it's busy, it can ignore the Setup packet. The USB function + * usually gets busy if we hammer it with Control EP transfers too + * much (ie. sending multiple Get Descriptor requests in a single + * microframe tends to trigger it on certain USB sticks). The DWC2 + * controller will interpret not receiving an ACK after Setup packet + * as XACTERR. Check for this condition and if it happens, retry + * sending the Setup packet. + */ + if (hcint & DWC2_HCINT_XACTERR && (pid == DWC2_HC_PID_SETUP)) + return -EAGAIN; + debug("%s: Error (HCINT=%08x)\n", __func__, hcint); return -EINVAL; }