From patchwork Tue Jan 22 07:56:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Joglekar X-Patchwork-Id: 10775025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08CE76C2 for ; Tue, 22 Jan 2019 07:57:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF09D2A969 for ; Tue, 22 Jan 2019 07:57:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E72F82AA90; Tue, 22 Jan 2019 07:57:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F44A2A9B1 for ; Tue, 22 Jan 2019 07:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727396AbfAVH47 (ORCPT ); Tue, 22 Jan 2019 02:56:59 -0500 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:41628 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727165AbfAVH46 (ORCPT ); Tue, 22 Jan 2019 02:56:58 -0500 Received: from mailhost.synopsys.com (unknown [10.192.0.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtprelay.synopsys.com (Postfix) with ESMTPS id 4F77824E24D6; Mon, 21 Jan 2019 23:56:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1548143818; bh=qqkSV3Y8/TdnjBA3dDcdgQqcfBH79hC3kNPAhaHKKi8=; h=Date:From:Subject:To:CC:From; b=XhFw6cBcWumwYdGwDZZARmfLlsBI47nVehA4A3Stbm4mewlYqPmlqIfEJyia6DX1o KABnHatf/U+eBOME13n/NrpRHRUUW5/QXcf/C8EFrDbP4taNEPuCUoL0rUudMI93ZQ qDE8HcUY2JEgPlFm7T9rdbvfelBcJiyYn/tQiin7HIgSs6tOiN8OPaaInAHIyVjWxH j4ADMtTtTCjIippsaP7AsKTVSugprbpJroVFfy+MPiwHCtYOPvox9lYH5OBB4v+5rL VB54yx8kPtNz3gbi00JyzT8xrC2UlDt0zgqVcZnCbI2WDO1Hii0H9ymCQjCXjeTZCC ds0MrVfQfmCQA== Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id 305A1A0067; Tue, 22 Jan 2019 07:56:58 +0000 (UTC) Received: from US01WEHTC1.internal.synopsys.com (10.12.239.236) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 21 Jan 2019 23:56:57 -0800 Received: from tejas-VirtualBox (10.145.64.129) by us01wehtc1.internal.synopsys.com (10.12.239.231) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 21 Jan 2019 23:56:56 -0800 Received: by tejas-VirtualBox (sSMTP sendmail emulation); Tue, 22 Jan 2019 13:26:51 +0530 Date: Tue, 22 Jan 2019 13:26:51 +0530 From: Tejas Joglekar Subject: [PATCH v3] usb: dwc3: gadget: Handle 0 xfer length for OUT EP To: Felipe Balbi , CC: John Youn , Tejas Joglekar , , MIME-Version: 1.0 Message-ID: <7bbca67a-1508-4c35-b231-a3bcc8c2f714@US01WEHTC1.internal.synopsys.com> X-Originating-IP: [10.145.64.129] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For OUT endpoints, zero-length transfers require MaxPacketSize buffer as per the DWC_usb3 programming guide 3.30a section 4.2.3.3. This patch fixes this by explicitly checking zero length transfer to correctly pad up to MaxPacketSize. Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize") Cc: stable@vger.kernel.org Signed-off-by: Tejas Joglekar --- Changes in v3: - Enclose summary for fixes with " " and no wrap Changes in v2: - Remove sg patch hunk - Added fixes and stable tag drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index bed2ff4..6c9b76b 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1119,7 +1119,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); unsigned int rem = length % maxp; - if (rem && usb_endpoint_dir_out(dep->endpoint.desc)) { + if ((!length || rem) && usb_endpoint_dir_out(dep->endpoint.desc)) { struct dwc3 *dwc = dep->dwc; struct dwc3_trb *trb;