From patchwork Thu Jun 27 20:52:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 167987 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2821988ilk; Thu, 27 Jun 2019 13:52:54 -0700 (PDT) X-Received: by 2002:a17:902:778d:: with SMTP id o13mr7076197pll.82.1561668774203; Thu, 27 Jun 2019 13:52:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561668774; cv=none; d=google.com; s=arc-20160816; b=wFQk4w2JAkarJjOCpD3omGTzy2InSM6Srz3YMFCxJfGQmj77wCHMgZe96D59edIOjE FtWEIvbrDPMZElA4oieBuvfP3eY5Cykb345LOJABldAMluXwN30gOe0NoVc8Kn6fbRYW Y37vfd32inKns/0seSaZ3fmDv85I+IrSzGmWPCHHvYvym9Es5xTPlVsgjWIU3YxTHluw lHX1vd6NbZhcC3o5W1pXBmvIGG2BBoLc+vatPLfSVblcWE5FzKVF4JlK5z3B/II8jR0o 0EKE8CgEj3YpeleiuOAfPujLACIuNxuBJwHgHLpNujQqE//yZ5X3dj99SITyXQYg6u/V S/ew== 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=ZrL274DhNKyTQBw9OhusDzJRVLn3r/FwIe97KUSVcog=; b=LO0n1AjSmWCT1U7v1lNpYIFp2cqRCDmrraqDNGIBTjMHQ7mTMBlrXucrXQFa1O+8KA ZnMbOVvhEh5vq7KhGQA4jVfOZoe1GDTcGhSiaxeV0WPswpxnoiFgbbTc7bScqdYNd70o +OpLtkoUZQP/0waFrC/1b09zNwm8FcNUCv/FWkGjWlYU+vEMFZqLI5r+D3iJi1GRFOyn bQz9Cz0sGpLRumCSdsq4zZ8DyPS3rwwrtphDiL7yL371IlB5tOZxXeOblgK7oq/T66XO 4GTb7EgL7YveqN5P85xQ5Gp5s8+rn6yOAPYYHz7WSZ7Em1JMaZf6rM+dbAf6+lVbL2Y9 Ifyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LijsNOiR; 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 n13sor8043142pjf.14.2019.06.27.13.52.54 for (Google Transport Security); Thu, 27 Jun 2019 13:52:54 -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=LijsNOiR; 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=ZrL274DhNKyTQBw9OhusDzJRVLn3r/FwIe97KUSVcog=; b=LijsNOiRu7AOnbIFYl8i2/9YtZD/HBFXNXyokFi7ArT8pjo4rUhbK7ZABtYNbou5t7 vZwPWaBA/26JvKn/KJqALkNkLyNPIURIWlmMOajizfJxyMyqtZpBg3Cs3SP/a4s4W471 NH/JKDXu9Xjg/AYuN4bjY+33UeTX4fwXjAYuUYb+0ArMMJzWdgcrbVids31C6xdG3cRW GjsQzPsW5g2ZWRDPTaCLM/U2OiBC4uJ17u9EV3uGyVURg1OOumzJy0Y4/9APc5AUQoYk 3a6tr+pEeHEoYwQEe8zvX4DiIEZm6lpJey83CFiQxv7JdnN2qUotZjw9Xd1vUfIKXgcj A3SA== 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=ZrL274DhNKyTQBw9OhusDzJRVLn3r/FwIe97KUSVcog=; b=r7IX/Wm/z3AXww5H47Qi2NglPlAzfn0jgl2zf8s1LEov9p2TSAVhpNddWdnKU6fiZh 2iTPvVHoeTCTlkyper3kp/JwBNTiAQ9cn3O3c4AKuwQmrdRJZZdKFHEKNaZfFXLBGt2/ eU2pUUKhww4T1+xueLuUIC/3xpjWM54BSw9xdMs7CwQ9Qgkqe1IaLeizgmzpydRnOVNo KfzqYCKWosBplh9Vh5tqa937n4cKhbuAs+13Kvc1aQWjAAFi/kMMXNhHDyeDzBkt1Aoj /JhQDn7Q7NwgyuZ8OD/KKKJKWEPOYzILRv8oGKPWx3a3jfkjLqmQcUFDct8QtmVlpYzs 72Ag== X-Gm-Message-State: APjAAAXRaAo24el6ZeZYK9duSnHXVMq875TG2dn4Q9lxb2trnoIB8NTs zbwAumm2U8U37q1r+mhvETEhvHqS X-Google-Smtp-Source: APXvYqwo0ph4DAMPKAKH/MsnyPj2uoZWLuEKCKC099RmQ8ouNVtkjqZJdDaOlT9eegAIdii+wQO9Tg== X-Received: by 2002:a17:90a:8d86:: with SMTP id d6mr8058912pjo.127.1561668773759; Thu, 27 Jun 2019 13:52:53 -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.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 13:52:52 -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 6/9] usb: dwc3: gadget: move requests to cancelled_list Date: Thu, 27 Jun 2019 20:52:37 +0000 Message-Id: <20190627205240.38366-7-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 d4f1afe5e896c18ae01099a85dab5e1a198bd2a8 upstream Whenever we have a request in flight, we can move it to the cancelled list and later simply iterate over that list and skip over any TRBs we find. 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 d4f1afe5e896c18ae01099a85dab5e1a198bd2a8) Signed-off-by: John Stultz --- drivers/usb/dwc3/gadget.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 34331a9fb584..25cdce359736 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1366,6 +1366,17 @@ static void dwc3_gadget_ep_skip_trbs(struct dwc3_ep *dep, struct dwc3_request *r } } +static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep) +{ + struct dwc3_request *req; + struct dwc3_request *tmp; + + list_for_each_entry_safe(req, tmp, &dep->cancelled_list, list) { + dwc3_gadget_ep_skip_trbs(dep, req); + dwc3_gadget_giveback(dep, req, -ECONNRESET); + } +} + static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, struct usb_request *request) { @@ -1402,8 +1413,9 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, if (!r->trb) goto out0; - dwc3_gadget_ep_skip_trbs(dep, r); - goto out1; + dwc3_gadget_move_cancelled_request(req); + dwc3_gadget_ep_cleanup_cancelled_requests(dep); + goto out0; } dev_err(dwc->dev, "request %pK was not queued to %s\n", request, ep->name); @@ -1411,7 +1423,6 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, goto out0; } -out1: dwc3_gadget_giveback(dep, req, -ECONNRESET); out0: