From patchwork Fri Feb 13 06:33:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dileep Katta X-Patchwork-Id: 44669 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 10A632153D for ; Fri, 13 Feb 2015 06:34:17 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id r20sf5380971wiv.3 for ; Thu, 12 Feb 2015 22:34:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=U0caZEtSBEtrbzbr1hoqG+6ZXTlpyT7fJfc7MbnmP58=; b=TmvYE9Ou6lDWroAlvjjbW4JJn3H1Ywy9QB5hIgO9vwG/Jmkz1zAFkTX3ltAsP/TUdO fTnEUsw9WRBopArXmvOsFpYMQxA4LQ5rDu7cf4VUH2DSBOlIm/z3U+17va/7p1/aqDNc y1eavjtc0wKxTRB/yr5TB6d4DYnqyInSiUPOc4o8JKdPHrmrQBEvirl3yYUY98viQmQT b/oq2F30RniHNVvudchA5XES0nA1fCCOTpYRSlZoGdrQiuTsxSFmaupw0kgLgVtufFy7 0TsZFulpkmkkioPUtbpUd9eZykkL+KDBtEcAf8WGMJrxzgMtzTMZkkhgZelkWo4ZuOy9 qljQ== X-Gm-Message-State: ALoCoQkqhXqb+NlIM0dkcAKL17sD80BHfN1L3BI0DYkYg5l0/oxrihSG3Dwa0h2cPCx/zV4T0x9a X-Received: by 10.194.178.234 with SMTP id db10mr1099302wjc.2.1423809256349; Thu, 12 Feb 2015 22:34:16 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.132 with SMTP id n4ls285719lae.6.gmail; Thu, 12 Feb 2015 22:34:16 -0800 (PST) X-Received: by 10.152.43.67 with SMTP id u3mr6428673lal.23.1423809256050; Thu, 12 Feb 2015 22:34:16 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id yj1si854956lab.138.2015.02.12.22.34.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Feb 2015 22:34:16 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by labgq15 with SMTP id gq15so14555536lab.6 for ; Thu, 12 Feb 2015 22:34:15 -0800 (PST) X-Received: by 10.112.14.196 with SMTP id r4mr3043178lbc.86.1423809255932; Thu, 12 Feb 2015 22:34:15 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp882001lbj; Thu, 12 Feb 2015 22:34:15 -0800 (PST) X-Received: by 10.180.77.232 with SMTP id v8mr12763042wiw.65.1423809255325; Thu, 12 Feb 2015 22:34:15 -0800 (PST) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id pk1si2145283wjc.46.2015.02.12.22.34.14; Thu, 12 Feb 2015 22:34:15 -0800 (PST) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 038E1A7464; Fri, 13 Feb 2015 07:34:13 +0100 (CET) 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 qfaJ44kwCRHp; Fri, 13 Feb 2015 07:34:13 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 30983A7442; Fri, 13 Feb 2015 07:34:13 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 08862A7442 for ; Fri, 13 Feb 2015 07:34:09 +0100 (CET) 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 1qEScpsq4oxP for ; Fri, 13 Feb 2015 07:34:08 +0100 (CET) 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-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by theia.denx.de (Postfix) with ESMTPS id 88385A7439 for ; Fri, 13 Feb 2015 07:34:06 +0100 (CET) Received: by pdbfp1 with SMTP id fp1so17339721pdb.9 for ; Thu, 12 Feb 2015 22:34:04 -0800 (PST) X-Received: by 10.68.195.65 with SMTP id ic1mr12436972pbc.109.1423809244816; Thu, 12 Feb 2015 22:34:04 -0800 (PST) Received: from localhost.localdomain ([210.177.145.249]) by mx.google.com with ESMTPSA id xx7sm5653479pab.21.2015.02.12.22.34.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Feb 2015 22:34:04 -0800 (PST) From: Dileep Katta To: u-boot@lists.denx.de, robherring2@gmail.com, trini@ti.com, rob.herring@linaro.org, srae@broadcom.com, l.majewski@samsung.com, angelabaker@ti.com Date: Fri, 13 Feb 2015 14:33:41 +0800 Message-Id: <1423809223-24219-1-git-send-email-dileep.katta@linaro.org> X-Mailer: git-send-email 1.8.3.2 Cc: Dileep Katta Subject: [U-Boot] [PATCH v1 1/3] fastboot: OUT transaction length must be aligned to wMaxPacketSize X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dileep.katta@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 OUT transactions must be aligned to wMaxPacketSize for each transfer, or else transfer will not complete successfully. This patch modifies rx_bytes_expected to return a transfer length that is aligned to wMaxPacketSize. Note that the value of ep->desc->wMaxPacketSize and ep->maxpacket may not be the same value, and it is the value of ep->desc->wMaxPacketSize that should be used for alignment. Signed-off-by: Dileep Katta --- drivers/usb/gadget/f_fastboot.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index a8d8205..0d53a61 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -370,13 +370,20 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) fastboot_tx_write_str(response); } -static unsigned int rx_bytes_expected(void) +static unsigned int rx_bytes_expected(unsigned maxpacket) { int rx_remain = download_size - download_bytes; + int rem = 0; if (rx_remain < 0) return 0; if (rx_remain > EP_BUFFER_SIZE) return EP_BUFFER_SIZE; + if (rx_remain < maxpacket) { + rx_remain = maxpacket; + } else if (rx_remain % maxpacket != 0) { + rem = rx_remain % maxpacket; + rx_remain = rx_remain + (maxpacket - rem); + } return rx_remain; } @@ -425,7 +432,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req) printf("\ndownloading of %d bytes finished\n", download_bytes); } else { - req->length = rx_bytes_expected(); + req->length = rx_bytes_expected(ep->desc->wMaxPacketSize); if (req->length < ep->maxpacket) req->length = ep->maxpacket; } @@ -453,7 +460,7 @@ static void cb_download(struct usb_ep *ep, struct usb_request *req) } else { sprintf(response, "DATA%08x", download_size); req->complete = rx_handler_dl_image; - req->length = rx_bytes_expected(); + req->length = rx_bytes_expected(ep->desc->wMaxPacketSize); if (req->length < ep->maxpacket) req->length = ep->maxpacket; }