From patchwork Fri Jun 28 18:24:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 168124 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4020662ilk; Fri, 28 Jun 2019 11:24:24 -0700 (PDT) X-Received: by 2002:a65:55ca:: with SMTP id k10mr10735117pgs.14.1561746264744; Fri, 28 Jun 2019 11:24:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561746264; cv=none; d=google.com; s=arc-20160816; b=ng2sfo2jB/NoeXX6REXTTJdwUoWPCfsSAPG81N49lYUP50NtVksbQ8qnHzL6wKy+Ql UpmnTwC/aRYPT553DoPMTXGeEWXwUB7LxaHE9nLoq+I+4BEbxMAF2WuNZUwFThqCB0qN Vg1Y3Y5KTtCZiOBheEme7EgR0BWcOchkeb/miHN/oRJFwpwUiu2VdzgDQ1CyB8G/DqCM 3KegU0TA9HyACyGAV5Sul9mCsAlFG7/8Y5M0fuE/hWFirCD0KmbwXWnowMEU+aUxm4Kp 9bYZNQDsZHx6Rg/JxY0rzn5oITOBUBuOw88udDy5bfbUfuy3DmtiWjT3mzP5CIpyKUeh XbrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IT1pd6Y/Qs6l6wqmDTMXa67ucrhPLOrxpJINsob31Ek=; b=aR9UInjRlYUoq3ug2w9j3cFMCdIHRxenVM1tFGJJGGqTjjnO5r6f0r/qfs736Gycb5 toHTFvk9r7NU+/eX3ZgpPo91Xfo2Msa3D3mWw8nMjzhySfEELtgnqy7ZxZijNRX0QO3M YrKELOqXW7nbHA5Twov+tXwUgVEXV+QP3xFrSAP24fEWRDUkqPXr6UxcLCwRwtbqqG3J qmo+rTAT2LFjUnZz+IGmNOXkQW/a3REfOL0oa6NIMpmPsXUgpuG4z7pUsjaidjtCCaFN W1+YWDdoYxu1T2lwSNHtTh5KQty77YgyJvqGHtMxI/IKW7Bq61QZ7z62vhxG66yGMHGE /tlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JDN8QZz7; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id t69sor3416879pjb.5.2019.06.28.11.24.24 for (Google Transport Security); Fri, 28 Jun 2019 11:24:24 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JDN8QZz7; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IT1pd6Y/Qs6l6wqmDTMXa67ucrhPLOrxpJINsob31Ek=; b=JDN8QZz7n8TFHv42pQ/ba4vuwtpFNDbmqW5mj5+fH8kag6pOfRfLtILhFQm8UvflA+ ijuYHFrvdKOYi/J9cU+GDlPTfCweQOfAGu4SrdcBc5n+dZDf+46EfqBAcEcxrZYtebOr ZSULmjefsey6rzKLDhrEltCdQRXDvp0k+eBClIS2TmSwCqFfCZeaILMaW7+P0dQyaMHG Iaff/YJBxaVjGtacLoyimeulIWl074RkPcdAEUkowwN95AD1c3XTNo+X/R/L/n8FjabZ FKGqbyu3mgi2fwlKFHSl9VCRFwIWqDUTueSUaW4fDiGUlqk/Yywo78rkA10UJd2sVnIY 1qWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IT1pd6Y/Qs6l6wqmDTMXa67ucrhPLOrxpJINsob31Ek=; b=WChNqZ0Vvqq/owjm+TJ3grPrSGPbWRckjG4ykZ19HojTW4rJCslm8jqo0qwa8qOdQw a+g486ZVlIlKma3/X/RH6jXgcRe9WcXVK2uGLov37s6Qag6zQVjbf9PM4jFwbPSMtGiR jINhdu3WgxEKsVxk8FwN+p8HC5LdlX+X4ONrGt73pbXikbOUZRLz/fwTCxYhouC4Ox5Q 4RK7eeIuQbg4L2AYMu7Oveb7I4y8wv6lJ1CZYksuh00UptttTnq8s8fCQ4Gyi3ZeFD+4 hDK46jUWyWWKm1/MvC9SdZNHRgElMcAwhCdQqpPffhPTTOmZ4mDo7VGyZrv9/2L+Pyc6 fCaA== X-Gm-Message-State: APjAAAU8+qpuai/Y9iuyJzIG9uFVU48hXlFJwzGBIkx3r4clE7hUdmiH 4mfCcc1ALfqSW/bfX9i717crxZ/K X-Google-Smtp-Source: APXvYqzeLd2WfKVOEvFZElOrK1KYgAkV0GbyMlNufBzlTwl/hEkuywHYikMsTe1rxYvjEBuYisYOJA== X-Received: by 2002:a17:90a:9503:: with SMTP id t3mr5159952pjo.47.1561746264299; Fri, 28 Jun 2019 11:24:24 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id s15sm2916223pfd.183.2019.06.28.11.24.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 11:24:23 -0700 (PDT) From: John Stultz To: stable@vger.kernel.org Cc: Felipe Balbi , Fei Yang , Sam Protsenko , Felipe Balbi , linux-usb@vger.kernel.org, John Stultz Subject: [PATCH 4.19.y v2 4/9] usb: dwc3: gadget: use num_trbs when skipping TRBs on ->dequeue() Date: Fri, 28 Jun 2019 18:24:08 +0000 Message-Id: <20190628182413.33225-5-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190628182413.33225-1-john.stultz@linaro.org> References: <20190628182413.33225-1-john.stultz@linaro.org> From: Felipe Balbi 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 --- drivers/usb/dwc3/gadget.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) -- 2.17.1 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: