From patchwork Mon Jan 21 09:33:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Joglekar X-Patchwork-Id: 10773445 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 1B126746 for ; Mon, 21 Jan 2019 09:33:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BFFC29EB4 for ; Mon, 21 Jan 2019 09:33:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 005E329EB6; Mon, 21 Jan 2019 09:33:32 +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 9E6AB29EB4 for ; Mon, 21 Jan 2019 09:33:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727587AbfAUJdb (ORCPT ); Mon, 21 Jan 2019 04:33:31 -0500 Received: from smtprelay.synopsys.com ([198.182.47.9]:53472 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726284AbfAUJd3 (ORCPT ); Mon, 21 Jan 2019 04:33:29 -0500 Received: from mailhost.synopsys.com (unknown [10.13.135.209]) (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 27F1124E16A2; Mon, 21 Jan 2019 01:33:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1548063209; bh=MCGRGf/SEpXcmMSd4y37vQb4GQjNUgDtTVaPAVj9Qu0=; h=Date:From:Subject:To:CC:From; b=IUza7mSR793Nql0lGQmaRxEKTi0bcVPLIW0xe9DpsZuvEoqSbtu6Qv0CrHYd8Sypm XSF1IHmh5sSGDAz7vmaVXP7XrqwXo2reAWB4ivgg8xxjWj+UZXEO4/pMSoJASShspU z9BiYv5MASRfzYMtiMPAWUw0ozNoaWMEoDH/J1ap4r8YJ69KvjAhDBZtQLLLvMXkms fea7312gG5LpX1W7IZiKzzdfr9nnaKGOXbkR63xnEUQnXNlQ7PG4MKN6MkPE9yS82z 7wfKND9kPX2nr4vRBC7tQGIGPn8bVA9XBQtKOawMWnWAz22j+e3TtXEwNtePp9wQE2 36A+wZ9op9AAg== 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 1A44EA031C; Mon, 21 Jan 2019 09:33:29 +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 01:33:28 -0800 Received: from tejas-VirtualBox (10.145.65.85) by us01wehtc1.internal.synopsys.com (10.12.239.231) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 21 Jan 2019 01:33:27 -0800 Received: by tejas-VirtualBox (sSMTP sendmail emulation); Mon, 21 Jan 2019 15:03:22 +0530 Date: Mon, 21 Jan 2019 15:03:22 +0530 From: Tejas Joglekar Subject: [PATCH v2] usb: dwc3: gadget: Handle 0 xfer length for OUT EP To: Felipe Balbi , CC: John Youn , Tejas Joglekar , , MIME-Version: 1.0 Message-ID: <4423b9f3-d70b-4576-80cf-79c9c77f6aba@US01WEHTC1.internal.synopsys.com> X-Originating-IP: [10.145.65.85] 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 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;