From patchwork Fri Feb 13 17:59:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dileep Katta X-Patchwork-Id: 44674 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0C1B921527 for ; Fri, 13 Feb 2015 18:00:01 +0000 (UTC) Received: by labge10 with SMTP id ge10sf11563235lab.3 for ; Fri, 13 Feb 2015 09:59:59 -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:in-reply-to :references: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=cg4I5zYNUURNazgs2qa776QTYsdNHojxEI4NkhnUCgo=; b=IuR6xEZ/4Kd2clkCdlPi5sqz0WwOWmziZ9Plbdpk1OqsZZQnlgmkRxZcFTUPulrHc3 uf32zfx6vQATRVKokzVbey+l3IYap0byzz7NlQDWUyc1Fzunhp3w2hbbvbyyqIeydb7G BrHL7m2AJhIIgOwf/JYARCtg4XVuqlWotQJBjC7bCD0+fsHVDU7AAYNRdUyxc7yyQo46 Av/cQrpq7hZGlnXNkcUM3cvyJIjbox2dvwn4ysHdGAkel+VD15VMXpARLgvbvJQCykRq jMJcW+bqyRRi4o6ka9CzLyGgO3XGXLewkVqlQXX1VgZMzC9OM4/V12Lkkfm7EMnZeM1X mMHA== X-Gm-Message-State: ALoCoQlzO1gC5QXaBK2DvIzrlQI39lCO1AMORBuhGSGxf86Iv/mWrLo0at93+gqv+21dmtAoaau6 X-Received: by 10.194.11.70 with SMTP id o6mr1547940wjb.6.1423850399854; Fri, 13 Feb 2015 09:59:59 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.163 with SMTP id x3ls321278lal.96.gmail; Fri, 13 Feb 2015 09:59:59 -0800 (PST) X-Received: by 10.152.116.18 with SMTP id js18mr8705020lab.106.1423850399690; Fri, 13 Feb 2015 09:59:59 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id f5si81325lbk.83.2015.02.13.09.59.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Feb 2015 09:59:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id b6so16967269lbj.12 for ; Fri, 13 Feb 2015 09:59:59 -0800 (PST) X-Received: by 10.112.171.168 with SMTP id av8mr9517413lbc.88.1423850399203; Fri, 13 Feb 2015 09:59:59 -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 h5csp11578lbj; Fri, 13 Feb 2015 09:59:58 -0800 (PST) X-Received: by 10.194.48.74 with SMTP id j10mr21398969wjn.38.1423850398469; Fri, 13 Feb 2015 09:59:58 -0800 (PST) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id lo2si5056873wic.50.2015.02.13.09.59.57; Fri, 13 Feb 2015 09:59:58 -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 B13794B8F7; Fri, 13 Feb 2015 18:59:56 +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 wQ79nXia1w3e; Fri, 13 Feb 2015 18:59:56 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E31794B8F2; Fri, 13 Feb 2015 18:59:55 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F01FD4B8F2 for ; Fri, 13 Feb 2015 18:59:52 +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 XKGlW3o31QCe for ; Fri, 13 Feb 2015 18:59:52 +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-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by theia.denx.de (Postfix) with ESMTPS id 747444B8F1 for ; Fri, 13 Feb 2015 18:59:49 +0100 (CET) Received: by mail-pa0-f47.google.com with SMTP id lf10so20358932pab.6 for ; Fri, 13 Feb 2015 09:59:47 -0800 (PST) X-Received: by 10.68.69.102 with SMTP id d6mr17200601pbu.110.1423850387552; Fri, 13 Feb 2015 09:59:47 -0800 (PST) Received: from T440p.solutionip.com ([210.177.145.245]) by mx.google.com with ESMTPSA id zs8sm7412080pac.9.2015.02.13.09.59.44 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Feb 2015 09:59:46 -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: Sat, 14 Feb 2015 01:59:11 +0800 Message-Id: <1423850351-14660-1-git-send-email-dileep.katta@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1423809223-24219-1-git-send-email-dileep.katta@linaro.org> References: <1423809223-24219-1-git-send-email-dileep.katta@linaro.org> Cc: Dileep Katta Subject: [U-Boot] [PATCH v2 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.217.181 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 wMaxPacketSize and ep->maxpacket may not be the same value, and it is the value of wMaxPacketSize that should be used for alignment. Signed-off-by: Dileep Katta --- Changes from v1: - Corrected source of wMaxPacketSize 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..b18452e 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(fs_ep_out.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(fs_ep_out.wMaxPacketSize); if (req->length < ep->maxpacket) req->length = ep->maxpacket; }