From patchwork Thu Jul 26 20:20:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Shimer X-Patchwork-Id: 173534 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 A0E272C007B for ; Fri, 27 Jul 2012 08:21:13 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6FFCF2808B; Fri, 27 Jul 2012 00:21:09 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 dcCl82b80HyG; Fri, 27 Jul 2012 00:21:09 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 24DA228084; Fri, 27 Jul 2012 00:21:07 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5CD6A28085 for ; Fri, 27 Jul 2012 00:09:36 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 l6H42Vr7uy0N for ; Fri, 27 Jul 2012 00:09:34 +0200 (CEST) X-Greylist: delayed 6511 seconds by postgrey-1.27 at theia; Fri, 27 Jul 2012 00:09:31 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 exprod5og112.obsmtp.com (exprod5og112.obsmtp.com [64.18.0.24]) by theia.denx.de (Postfix) with ESMTPS id 1918E28084 for ; Fri, 27 Jul 2012 00:09:31 +0200 (CEST) Received: from DE01MGRG01.AM.MOT-MOBILITY.COM ([192.54.82.14]) (using TLSv1) by exprod5ob112.postini.com ([64.18.4.12]) with SMTP ID DSNKUBHAFlSjEd1bNFVSJjYk3yNXt/dz541p@postini.com; Thu, 26 Jul 2012 15:09:33 PDT Received: from DE01MGRG01.AM.MOT-MOBILITY.COM ([10.176.130.20]) by DE01MGRG01.AM.MOT-MOBILITY.COM (8.14.3/8.14.3) with ESMTP id q6QKMsZr001524 for ; Thu, 26 Jul 2012 16:22:54 -0400 (EDT) Received: from mail-we0-f174.google.com (mail-we0-f174.google.com [74.125.82.174]) by DE01MGRG01.AM.MOT-MOBILITY.COM (8.14.3/8.14.3) with ESMTP id q6QKMq9A001503 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 26 Jul 2012 16:22:53 -0400 (EDT) Received: by weyx8 with SMTP id x8so1611459wey.19 for ; Thu, 26 Jul 2012 13:20:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :x-gm-message-state; bh=4tg2uWVl8eeHZiBShW2IaH+Bwf4jkwZt6+e7E59u9Q8=; b=GFW3yBoxZ6SvX+D+CvlFNDf5ym73lXGSTs9Sxsr+hzZd+hSiVC99XLD4DVwYi1CHot WTtGbXIdHOw/YR+H9975zKEtpr3KW2wvj879bcqP+pJxSI+MMRQ1nsSl6rQHCXf3grNh ia/cjJx6lzRzMYuj7fabZFcOgi5wIwvuHUODSOpqkS+PZckeSArUN30XVCBsru4xXhs8 9AXyQC6jcf8/tUuOb7/XOSzB+3oOuRrDnMYDHBi2Kje7NZq0wYVwJRRKwu0tkgkLr9mY 6LaH0EMw2W9u3SO8fXH20J7sFuTxYz/mkkrhquBD4wBBSlcIHZcTdVKhO+EvO99JvnDw k1dw== MIME-Version: 1.0 Received: by 10.216.49.6 with SMTP id w6mr15225696web.207.1343334048786; Thu, 26 Jul 2012 13:20:48 -0700 (PDT) Received: by 10.180.96.41 with HTTP; Thu, 26 Jul 2012 13:20:48 -0700 (PDT) Date: Thu, 26 Jul 2012 16:20:48 -0400 Message-ID: From: Jim Shimer To: u-boot@lists.denx.de X-Gm-Message-State: ALoCoQliKI4hV33+R4YgsHNrCsPSChnysgAw5E5OwInrv9yLF74cD2q7lV7ZIrkK/TmBQ0Mjodmi X-CFilter-Loop: Reflected X-Mailman-Approved-At: Fri, 27 Jul 2012 00:21:05 +0200 X-Content-Filtered-By: Mailman/MimeDel 2.1.11 Subject: [U-Boot] usb_stor_BBB_transport 5 ms delay - performance X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de I'm seeing a 5ms delay in usb_stor_BBB_transport, which occurs every 10K of data for fatload usb or 500ms of delay per 1MB of image size. This adds up to quite a bit of delay if you're loading a large ramdisk. Does anyone know what the reason for the 5ms delay really is? I'm assuming that this delay is to debounce the 5V/100ma USB power up. I made some modification, where the delay is skipped if the device has already been queried as ready. This has save me 500ms/M on fatload times (eg, 140M=70seconds). Is there anything wrong with this tweak? Here's a diff of what I've done to get the performance I need: start, smallblks, buf_addr); @@ -1188,6 +1202,7 @@ retry_it: blks -= smallblks; buf_addr += srb->datalen; } while (blks != 0); + usb_set_unit_not_ready((struct us_data *)dev->privptr); USB_STOR_PRINTF("usb_write: end startblk %lx, blccnt %x buffer %lx\n", start, smallblks, buf_addr); @@ -1398,6 +1413,7 @@ int usb_stor_get_info(struct usb_device cap[0] = 2880; cap[1] = 0x200; } + usb_set_unit_not_ready((struct us_data *)dev->privptr); USB_STOR_PRINTF("Read Capacity returns: 0x%lx, 0x%lx\n", cap[0], cap[1]); #if 0 I'd appreciate any feedback. Regards --- usb_storage.c.orig 2012-07-26 16:06:40.775251000 -0400 +++ usb_storage.c 2012-07-26 13:49:36.000000000 -0400 @@ -132,6 +132,7 @@ static block_dev_desc_t usb_dev_desc[USB struct us_data; typedef int (*trans_cmnd)(ccb *cb, struct us_data *data); typedef int (*trans_reset)(struct us_data *data); +typedef enum us_status { USB_NOT_READY, USB_READY} us_status; struct us_data { struct usb_device *pusb_dev; /* this usb_device */ @@ -154,6 +155,7 @@ struct us_data { ccb *srb; /* current srb */ trans_reset transport_reset; /* reset routine */ trans_cmnd transport; /* transport routine */ + us_status status; }; static struct us_data usb_stor[USB_MAX_STOR_DEV]; @@ -691,7 +693,10 @@ int usb_stor_BBB_transport(ccb *srb, str usb_stor_BBB_reset(us); return USB_STOR_TRANSPORT_FAILED; } - wait_ms(5); + if(us->status != USB_READY) + { + wait_ms(5); + } pipein = usb_rcvbulkpipe(us->pusb_dev, us->ep_in); pipeout = usb_sndbulkpipe(us->pusb_dev, us->ep_out); /* DATA phase + error handling */ @@ -957,7 +962,10 @@ static int usb_test_unit_ready(ccb *srb, srb->datalen = 0; srb->cmdlen = 12; if (ss->transport(srb, ss) == USB_STOR_TRANSPORT_GOOD) + { + ss->status = USB_READY; return 0; + } usb_request_sense(srb, ss); wait_ms(100); } while (retries--); @@ -965,6 +973,11 @@ static int usb_test_unit_ready(ccb *srb, return -1; } +static void usb_set_unit_not_ready(struct us_data *ss) +{ + ss->status = USB_NOT_READY; +} + static int usb_read_capacity(ccb *srb, struct us_data *ss) { int retry; @@ -1108,6 +1121,7 @@ retry_it: blks -= smallblks; buf_addr += srb->datalen; } while (blks != 0); + usb_set_unit_not_ready((struct us_data *)dev->privptr); USB_STOR_PRINTF("usb_read: end startblk %lx, blccnt %x buffer %lx\n",