From patchwork Tue Apr 5 18:31:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 606673 X-Patchwork-Delegate: trini@ti.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 3qfctJ4bprz9t3Z for ; Wed, 6 Apr 2016 04:33:12 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 321CBB37F7; Tue, 5 Apr 2016 20:33:05 +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 K9Oh5MjgWAOf; Tue, 5 Apr 2016 20:33:03 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6744AA752D; Tue, 5 Apr 2016 20:32:56 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 22615A76F5 for ; Tue, 5 Apr 2016 20:32:20 +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 N6qhS8WGH4oM for ; Tue, 5 Apr 2016 20:32:19 +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-gw2-out.broadcom.com (mail-gw2-out.broadcom.com [216.31.210.63]) by theia.denx.de (Postfix) with ESMTP id 4A476A752D for ; Tue, 5 Apr 2016 20:32:07 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.24,445,1455004800"; d="scan'208";a="92419043" Received: from mail-irv-18.broadcom.com ([10.15.198.37]) by mail-gw2-out.broadcom.com with ESMTP; 05 Apr 2016 11:41:34 -0700 Received: from mail-irva-13.broadcom.com (mail-irva-13.broadcom.com [10.11.16.103]) by mail-irv-18.broadcom.com (Postfix) with ESMTP id 241DC8202D; Tue, 5 Apr 2016 11:32:06 -0700 (PDT) Received: from VM-host64-64-A1.ric.broadcom.com (unknown [10.136.4.105]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 8C2B941007; Tue, 5 Apr 2016 11:31:30 -0700 (PDT) From: Steve Rae To: u-boot@lists.denx.de, Sam Protsenko Date: Tue, 5 Apr 2016 11:31:49 -0700 Message-Id: <1459881109-25259-1-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 Cc: Steve Rae , Tom Rini , Marek Vasut Subject: [U-Boot] [PATCH v2] 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: 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" commit 9e4b510 fastboot: OUT transaction length must be aligned to wMaxPacketSize breaks some boards... Therefore add a conditional Kconfig to optionally enable this feature. Signed-off-by: Steve Rae --- Changes in v2: - ammendment to the original patch drivers/usb/gadget/Kconfig | 7 +++++++ drivers/usb/gadget/f_fastboot.c | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index f4698f4..ab1c605 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -33,3 +33,10 @@ menuconfig USB_GADGET a USB peripheral device. Configure one hardware driver for your peripheral/device side bus controller, and a "gadget driver" for your peripheral protocol. + +config USB_GADGET_FASTBOOT_DOWNLOAD_ALIGNMENT_REQUIRED + bool "fastboot download requires alignment with wMaxPacketSize" + help + By default, the fastboot download OUT transactions are aligned + to "ep->maxpacket". This option causes the fastboot download OUT + transactions to be aligned with "wMaxPacketSize". diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 2e87fee..130b5d0 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -430,17 +430,19 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) static unsigned int rx_bytes_expected(unsigned int maxpacket) { int rx_remain = download_size - download_bytes; - int rem = 0; + int __maybe_unused rem = 0; if (rx_remain < 0) return 0; if (rx_remain > EP_BUFFER_SIZE) return EP_BUFFER_SIZE; +#ifdef CONFIG_USB_GADGET_FASTBOOT_DOWNLOAD_ALIGNMENT_REQUIRED if (rx_remain < maxpacket) { rx_remain = maxpacket; } else if (rx_remain % maxpacket != 0) { rem = rx_remain % maxpacket; rx_remain = rx_remain + (maxpacket - rem); } +#endif return rx_remain; }