Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3051675ybi; Tue, 2 Jul 2019 01:10:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4PM/W/UF6zj13D0n73uRx2Si/UIqXWh+lpA126RLQfO+Ngklpe38fgpl7pgpN1lDdjqpx X-Received: by 2002:a17:902:8bc1:: with SMTP id r1mr20686506plo.42.1562055047315; Tue, 02 Jul 2019 01:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055047; cv=none; d=google.com; s=arc-20160816; b=H55xSJ5eecxLlpYSj8A1aCx1SGkDcloR5h8gi+tK1o+qpzLbGNLQhE8sHE0v9tRCKn f5qDUCsCYVDX5VOTqn021vETsMjQ9+OyqjwlSGKQd1/oaUk3GfCNRLpIsAohlti9+t4i bYqN8YW3Me8ljSw/tsLXTHfXCcsSsSfBqjCAmnBnlXwrb/+47jF/D8HeMnpp0WyRXHul vgzVzboMDotk/SxKovHUSGLfdl1Zi9CJrGWzA1GThRJV93nbZcgX7pdBtVBEu0I/86PE eyL3RNWFz03WVjgrIvFJvzeky+LrRGOLEcyJUsiBLPFtD9gv6oaJuRtW3veo381ArxUw Mdyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zBTQpCJjgTFbu3PSNMp3KhdkxZS2c9LKNH/tXwUPB0U=; b=FbRq9s2mRvb8orFCMAzTfkzQjjxnh83n7G4PdHYETchajuUINgzOL/IiMiL8M7t95F AuXOk5eibSspQgO53RPFKVGAwcSpuD8XZfsfR9VaCfZSLaFUYN5nqZf+wj1mdxSBS9Vw d2V/kY82dSgAz5ZFY00sTRHFfA1gVAFPY1P4ZAr0xRgP05fTePO9Y2xUZMQRi5b21mPI tnBTmQvAJoD5b4fivfra7lh+SfEG9m0lcn7aUgIu+32xMMvr7gXXmgC4qG1HnASHpaVc y8l+lwf4BOo50A24pm9Q19DqJPhfJ4i5DLRM05ENLu+7lHQbGHOB8dJebP0BnMMwyzcr oG7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kVgj0T0I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i15si13325075pfd.259.2019.07.02.01.10.32; Tue, 02 Jul 2019 01:10:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kVgj0T0I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727387AbfGBIIN (ORCPT + 99 others); Tue, 2 Jul 2019 04:08:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:55640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728373AbfGBIIJ (ORCPT ); Tue, 2 Jul 2019 04:08:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5E10B206A2; Tue, 2 Jul 2019 08:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054888; bh=dBd5Gi/aU9o+YoIteL3TsGFh0gBXpK4pcIblhu743gU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kVgj0T0IXwcdw7XUjrjiwwB20P33kuwPEnH0Ib0VRyROoMukTYYUKy41xtWFNtejA 7BUz/WbgkIkEi5ys2p8AVFcZfN2cwZ/G0dHQvkVcDI0nEp03r9Zbpt9PJ+/wKMnHUr eDhHkNp5aQ3hGTbgxHo0Wf1lJKiHoR9GOU/IjNeY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fei Yang , Sam Protsenko , Felipe Balbi , linux-usb@vger.kernel.org, Felipe Balbi , John Stultz , Sasha Levin Subject: [PATCH 4.19 26/72] usb: dwc3: gadget: use num_trbs when skipping TRBs on ->dequeue() Date: Tue, 2 Jul 2019 10:01:27 +0200 Message-Id: <20190702080126.031346654@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit c3acd59014148470dc58519870fbc779785b4bf7 upstream Now that we track how many TRBs a request uses, it's easier to skip over them in case of a call to usb_ep_dequeue(). Let's do so and simplify the code a bit. Cc: Fei Yang Cc: Sam Protsenko Cc: Felipe Balbi Cc: linux-usb@vger.kernel.org Cc: stable@vger.kernel.org # 4.19.y Signed-off-by: Felipe Balbi (cherry picked from commit c3acd59014148470dc58519870fbc779785b4bf7) Signed-off-by: John Stultz Signed-off-by: Sasha Levin --- drivers/usb/dwc3/gadget.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index fd91c494307c..4e08904890ed 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1368,6 +1368,8 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, break; } if (r == req) { + int i; + /* wait until it is processed */ dwc3_stop_active_transfer(dep, true); @@ -1405,32 +1407,12 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, if (!r->trb) goto out0; - if (r->num_pending_sgs) { + for (i = 0; i < r->num_trbs; i++) { struct dwc3_trb *trb; - int i = 0; - - for (i = 0; i < r->num_pending_sgs; i++) { - trb = r->trb + i; - trb->ctrl &= ~DWC3_TRB_CTRL_HWO; - dwc3_ep_inc_deq(dep); - } - - if (r->needs_extra_trb) { - trb = r->trb + r->num_pending_sgs + 1; - trb->ctrl &= ~DWC3_TRB_CTRL_HWO; - dwc3_ep_inc_deq(dep); - } - } else { - struct dwc3_trb *trb = r->trb; + trb = r->trb + i; trb->ctrl &= ~DWC3_TRB_CTRL_HWO; dwc3_ep_inc_deq(dep); - - if (r->needs_extra_trb) { - trb = r->trb + 1; - trb->ctrl &= ~DWC3_TRB_CTRL_HWO; - dwc3_ep_inc_deq(dep); - } } goto out1; } @@ -1441,8 +1423,6 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, } out1: - /* giveback the request */ - dwc3_gadget_giveback(dep, req, -ECONNRESET); out0: -- 2.20.1