From patchwork Sat Jul 28 01:52:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 10547855 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 D4577112B for ; Sat, 28 Jul 2018 01:52:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C43EC20415 for ; Sat, 28 Jul 2018 01:52:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8A452C56F; Sat, 28 Jul 2018 01:52:50 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 660D72C574 for ; Sat, 28 Jul 2018 01:52:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389109AbeG1DRW (ORCPT ); Fri, 27 Jul 2018 23:17:22 -0400 Received: from smtprelay.synopsys.com ([198.182.60.111]:36393 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388894AbeG1DRW (ORCPT ); Fri, 27 Jul 2018 23:17:22 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 864DE10C0D61; Fri, 27 Jul 2018 18:52:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1532742769; bh=HKyv/k5nVd2r4p5lEUtoxk8IHF76NIujA1qRBfr5m0g=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=Z7Ge1I9VYmEm42+8Mr0u9+1LFu0kUg27I8kKiRLUQg4sE52X/qN7VILDn14Hvdip7 bG+oovhJawxbVSj1FMAoukmkG/afPb7jwsLHNJJhmkxrNLzJR3kIDFDoctkz1VHO3o qWojEQIgrfrTdFm7m7jE/038M5uQVIkDeAsaHNCfPosKQUU3rjEiMb8PliQANiTEnn v8kJaA2ScrhABNXdDiO/rwrhI87rdjpw3ALV70xDPrH7vk1tfqZNSma1XmdcjQu2p1 rIpTb0B1Th47uUpuyLmAF6JmmfcVOFL/Mb3cybqzucuUFIFGkLKfYupo9n7PsrTBgg Iy8bQlPb6nSWA== Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) by mailhost.synopsys.com (Postfix) with ESMTP id 76619581F; Fri, 27 Jul 2018 18:52:49 -0700 (PDT) Received: from US01WEHTC3.internal.synopsys.com (10.15.84.232) by us01wehtc1.internal.synopsys.com (10.12.239.235) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 27 Jul 2018 18:52:49 -0700 Received: from te-lab16 (10.13.184.20) by US01WEHTC3.internal.synopsys.com (10.15.84.231) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 27 Jul 2018 18:52:48 -0700 Received: by te-lab16 (sSMTP sendmail emulation); Fri, 27 Jul 2018 18:52:47 -0700 Date: Fri, 27 Jul 2018 18:52:47 -0700 Message-ID: <19a1dd73d68507543e955f508fe47eb7ffef9e73.1532742607.git.thinhn@synopsys.com> In-Reply-To: <437a32ebba5bedbae4f6be1a43c1174f4e596f76.1532742607.git.thinhn@synopsys.com> References: <437a32ebba5bedbae4f6be1a43c1174f4e596f76.1532742607.git.thinhn@synopsys.com> From: Thinh Nguyen Subject: [PATCH 2/3] usb: dwc3: gadget: Don't skip updating remaining data To: Felipe Balbi , CC: John Youn MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] 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 DWC3 must check for the BUFSIZ and update the req->remaining regardless of transfer alignment. Returning early from transfer OUT unalignment will skip updating the req->remaining. Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize") Signed-off-by: Thinh Nguyen --- drivers/usb/dwc3/gadget.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 032ea7d709ba..a5b8387a37ba 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2246,6 +2246,9 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep, if (chain && (trb->ctrl & DWC3_TRB_CTRL_HWO)) trb->ctrl &= ~DWC3_TRB_CTRL_HWO; + count = trb->size & DWC3_TRB_SIZE_MASK; + req->remaining += count; + /* * If we're dealing with unaligned size OUT transfer, we will be left * with one TRB pending in the ring. We need to manually clear HWO bit @@ -2256,9 +2259,6 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep, return 1; } - count = trb->size & DWC3_TRB_SIZE_MASK; - req->remaining += count; - if ((trb->ctrl & DWC3_TRB_CTRL_HWO) && status != -ESHUTDOWN) return 1;