From patchwork Tue Aug 31 18:45:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatolij Gustschin X-Patchwork-Id: 71835 X-Patchwork-Delegate: linux@bohmer.net Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 3DE57157D71 for ; Tue, 31 Aug 2010 20:47:46 +0200 (CEST) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id 1FBCD30E5B6F for ; Tue, 31 Aug 2010 20:47:46 +0200 (MEST) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.17) for (single-drop); Tue, 31 Aug 2010 20:47:46 +0200 (MEST) Received: from murder ([192.168.8.180]) by backend2 (Cyrus v2.2.12) with LMTPA; Tue, 31 Aug 2010 20:45:46 +0200 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend1.mail.m-online.net (Cyrus v2.2.12) with LMTPA; Tue, 31 Aug 2010 20:45:45 +0200 Received: from scanner-1.m-online.net (scanner-1.mail.m-online.net [192.168.8.165]) by mail.m-online.net (Postfix) with ESMTP id EACA51C001A6; Tue, 31 Aug 2010 20:45:45 +0200 (CEST) Received: from mxin-2.m-online.net ([192.168.1.21]) by scanner-1.m-online.net (scanner-1.m-online.net [192.168.8.165]) (amavisd-new, port 10026) with ESMTP id 18929-02; Tue, 31 Aug 2010 20:45:43 +0200 (CEST) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-2.m-online.net (Postfix) with ESMTP id 53406468D62; Tue, 31 Aug 2010 20:45:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 72E3F28084; Tue, 31 Aug 2010 20:45:34 +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 vAKLxBMRU2xM; Tue, 31 Aug 2010 20:45:34 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 18B5928085; Tue, 31 Aug 2010 20:45:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1D27D2807E for ; Tue, 31 Aug 2010 20:45:27 +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 wgyTnwe6Dp0b for ; Tue, 31 Aug 2010 20:45:25 +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.10]) by theia.denx.de (Postfix) with ESMTP id 06D5E2807B for ; Tue, 31 Aug 2010 20:45:23 +0200 (CEST) Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 822891C002A7; Tue, 31 Aug 2010 20:45:23 +0200 (CEST) X-Auth-Info: rllUl+68b7Oxcc7hxXu3UKQbs6ejYjGglMG71ZCIUGc= Received: from localhost (p4FE3D4E0.dip.t-dialin.net [79.227.212.224]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA id 421C01C000FC; Tue, 31 Aug 2010 20:45:23 +0200 (CEST) From: Anatolij Gustschin To: u-boot@lists.denx.de Date: Tue, 31 Aug 2010 20:45:14 +0200 Message-Id: <1283280314-10700-1-git-send-email-agust@denx.de> X-Mailer: git-send-email 1.7.0.4 Subject: [U-Boot] [PATCH] usb: fix usb start problem with SMSC USB hub and Toshiba USB stick X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Virus-Scanned: by amavisd-new at m-online.net Checking the status field of the qTD token in the current code do not take into acount cases where endpoint stall (halted) bit is set together with some other status bits. As a result clearing stall on an endpoint won't be done if other status bits were set. E.g. 'usb start' often fails with Toshiba USB stick 0x930/0x6545 connected to the SMSC USB 2.0 hub 0x424/0x2514. Debugging the issue showed that while bulk IN transfers with length of 13 or 18 the status field of the qTD token sometimes indicates trans- action error (XactErr) and sometimes additionally endpoint halted state. In the latter case resetting the USB device in error recovery code fails as no clear stall request on the endpoint will be done. The patch fixes status field checking code to properly handle endpoint halted state. However this fix is not enough to solve 'usb start' problem with hub/stick combination mentioned above. Running with lot of debug code in ehci_submit_async() I've never seen the problem with usb stick recognition. After removing this debug code the similar problem sometimes showed up again. Therefore the patch also adds delay in ehci_submit_async() for above-mentioned hub/stick combination. Even without this delay the fix is an improvement since it fixes the problem with board freezy after subsequent failed 'usb start/stop' cycles as it was observed on mpc5121ads board. Signed-off-by: Anatolij Gustschin --- common/usb_storage.c | 5 +++-- drivers/usb/host/ehci-hcd.c | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/common/usb_storage.c b/common/usb_storage.c index 76949b8..5ca92c3 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -680,7 +680,8 @@ int usb_stor_BBB_transport(ccb *srb, struct us_data *us) result = usb_bulk_msg(us->pusb_dev, pipe, srb->pdata, srb->datalen, &data_actlen, USB_CNTL_TIMEOUT * 5); /* special handling of STALL in DATA phase */ - if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) { + if ((result < 0) && + (us->pusb_dev->status & (USB_ST_STALLED | USB_ST_CRC_ERR))) { USB_STOR_PRINTF("DATA:stall\n"); /* clear the STALL on the endpoint */ result = usb_stor_BBB_clear_endpt_stall(us, @@ -710,7 +711,7 @@ again: /* special handling of STALL in STATUS phase */ if ((result < 0) && (retry < 1) && - (us->pusb_dev->status & USB_ST_STALLED)) { + (us->pusb_dev->status & (USB_ST_STALLED | USB_ST_CRC_ERR))) { USB_STOR_PRINTF("STATUS:stall\n"); /* clear the STALL on the endpoint */ result = usb_stor_BBB_clear_endpt_stall(us, us->ep_in); diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 37d056e..7463a75 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -430,6 +430,12 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, usbsts = ehci_readl(&hcor->or_usbsts); ehci_writel(&hcor->or_usbsts, (usbsts & 0x3f)); + if (dev->descriptor.idVendor == 0x930 && + dev->descriptor.idProduct == 0x6545 && + dev->parent->descriptor.idVendor == 0x424 && + dev->parent->descriptor.idProduct == 0x2514) + wait_ms(10); + /* Enable async. schedule. */ cmd = ehci_readl(&hcor->or_usbcmd); cmd |= CMD_ASE; @@ -490,6 +496,8 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, break; default: dev->status = USB_ST_CRC_ERR; + if ((token & 0x40) == 0x40) + dev->status |= USB_ST_STALLED; break; } dev->act_len = length - ((token >> 16) & 0x7fff);