From patchwork Thu Jun 27 20:52:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 167984 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2821914ilk; Thu, 27 Jun 2019 13:52:49 -0700 (PDT) X-Received: by 2002:a17:902:d695:: with SMTP id v21mr6528464ply.342.1561668769597; Thu, 27 Jun 2019 13:52:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561668769; cv=none; d=google.com; s=arc-20160816; b=clSAONd87Y6lo0OLjyHopFGGVSkxmoOR0LEm5khkgqGNijWEszAZrokZh/QeZihPG6 /7uGDYJYiBMSgJoL4cPSVCI0eKbPlTbADI9Zg1IOYu1sp6D1oQ0jQ2zMo0T9ukO/XleA v13+YCdNmI/VjWQa0wtpipme49hUvk7tCKBcEZRxyaBK2dyVzx+yw6Qx/OwHQgWtasQ2 X+Jjmn8crG4qg7Cj7ma8FlzuRrwiBL8VROteCoMDBwtzIFBU5mgpujMyX2osi/gbS8L/ kY07WH2KW8QYn5OBXKvdpt2T1iF27uq/HIaILngVAtu5HfZTq78MJVw+K6KniM9mWpTn nmAQ== 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=9FOb1l6NNujBgS6Pd8VeV0djJsyicx4ys2rNzFqoG7Q=; b=FKOIs3ORcxvbltCIrORM8By2El9uJpcXeQRP/po8DBBxKHBG32EXKhir7WGagHAvzT NX2HmPH9w2ooaXWSXt/1kY/MZrGEOXinEtqE20txh2cvQ8HXDawBBxdQRGjRXIJ/nF3f DvOkTQUyZDriAPn16Dx7QYd59IszHD5K9s3bBVcHyjUd5CiwzTZb5s9SMgYB5fl4K4Lm ef0JBQtC8aImAlZezleu7U9tV9jT+7dS1s14qgwbrkVzdDJHD3ZE8Z57VQUL0RKWD+Ym Ru5tZTM0CGPg6/BuI1lZ8TX2b5LTthuzHWACc9EoEziM8hBocRxK32QRsfotkHXENQDf 0bRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jZTy9GN9; 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 o2sor7797091pjp.26.2019.06.27.13.52.49 for (Google Transport Security); Thu, 27 Jun 2019 13:52:49 -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=jZTy9GN9; 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=9FOb1l6NNujBgS6Pd8VeV0djJsyicx4ys2rNzFqoG7Q=; b=jZTy9GN90LSuaoebKhySaUJBbIs/l70thCKH0ogjOOYnf/FImagU1mFVs7SVkvyqv1 Oj6TfG4WHhDxW0FALTRuCvImxwAMbuCetVw2/Uz+Cmm57Se0OLRiYUOoUo5o3yCfIRZq WzyzhtDTiNoptljlGDvrfADw560u434AQtlScKg+2m86W7cuCH1GUaywOowQsJDvvgih O1aVgm4kH1rwEmBrhHAAhjowCSNKJeFnVlPD+SuBnzN8DrAY1WWjCHGOCZt8OwhUQIPX CV1L8NyANpsdnx+5aKvDhAW3Z7LaFgiAGKVJKBwOhTQjTqLmMmTzFXQ+vfydsbQhNKB+ YkFA== 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=9FOb1l6NNujBgS6Pd8VeV0djJsyicx4ys2rNzFqoG7Q=; b=al1YhjCE/ZR441yiQn1h2GeVl5ZrIMGoN0gSjT3RiuyLYBXFvB7NaqnOhVGHtrmWqW zOSzGULeF2kmLUOMmAWWeBDJGuDHo0HlgJG0dX7W26wY+vDHF9nawUaqtUlBPjgRXAy4 bWGOLSSwQzrT1vlJlKnSXOT3hYTQLxZ++IKlx9q2WyZV/AjW8j65R7HDZ0mMjVHGspH9 1/yDzkJcn0ecNSN2u4Ohr5eTqkB+5ufzQXRY2ryYnsQs+6+iixC7hb4bLN81sl5gfW2D jBcIBPxe3JRv9CQ0k01UwE/KQLPJIanmNsJQvnkYlWZx0JfAS96z9kl0D8HvDscTLBDr juuw== X-Gm-Message-State: APjAAAW/CsSYYSw2Un9ojBxqEzyS9QDWssNKisLfnZ0K/JksuefqTQWp AxPkpIJXbs+DuANXVjb2m2580Dvc X-Google-Smtp-Source: APXvYqxRCzT9WvpX0UY5boOll5wk4dWaNsxfMfmoyhUn7t+zOVaBDkQ7G/8C8FNy0PH5a0V2038Erw== X-Received: by 2002:a17:90a:634a:: with SMTP id v10mr8609992pjs.16.1561668769151; Thu, 27 Jun 2019 13:52:49 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id 2sm3674083pff.174.2019.06.27.13.52.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 13:52:48 -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 3/9] usb: dwc3: gadget: use num_trbs when skipping TRBs on ->dequeue() Date: Thu, 27 Jun 2019 20:52:34 +0000 Message-Id: <20190627205240.38366-4-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190627205240.38366-1-john.stultz@linaro.org> References: <20190627205240.38366-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 019643a6ce9d..cb6dfea5d5e7 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1370,6 +1370,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); @@ -1407,32 +1409,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; } @@ -1443,8 +1425,6 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, } out1: - /* giveback the request */ - dwc3_gadget_giveback(dep, req, -ECONNRESET); out0: