From patchwork Fri Jun 28 18:24:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 168127 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4020751ilk; Fri, 28 Jun 2019 11:24:29 -0700 (PDT) X-Received: by 2002:a17:902:a409:: with SMTP id p9mr13373241plq.218.1561746269764; Fri, 28 Jun 2019 11:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561746269; cv=none; d=google.com; s=arc-20160816; b=bwoViG8Z4kkna4YYqEbrIgt2t8cCAU0BuIghiZ7iCH42Z9/TvyVJubTa/aNwHwKvDk HoJ0U0bKI/EWvaflDapST4XKXHqFme8k15KEqxAR0Og1HNNFglGelqS4/oPYMuwNernM hUYKmNkl3LUIsjX1eHgCShbCHV9MzGGZwwHuFbTQEU7V93ID25sjY5HqQiu+NNujFRoY jU2JxzDHp1b0zS0XSzIuN0l2aIaLRlYprdRoZ/Va1UQIoWW+Nq1a3T40TgOoHt6iKIxs B48ngVOcwG2NSqbxkNZI4AB+r5FW7SmoX2+qdHZtFvWe49s5wFYUbLmC3WpsvdbHeet1 cZoA== 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=dZYduMfUWZ9SXxQiDlz5Ott25WscyPClGVJovh/j864=; b=Tnymy1AzDQGwur9fufRhUXhXiABpez0dXj9q2WjE7djdjO9OEo70X6DIAJn7FC7yff PTbwKxTAqo59qjWAXON+IS3Ju3CXK9wflCPFzdf7Dv2MLr/2LYmN4WzRnbLqjsYMBZj4 XVG0Cb6eyfPNmeL68jvxGMREcsqf1EJpGA/0QcXG9+1avABfRy/+6Ptwvqqv0xxTetfb 5XmXOuDfiAd7nxjDhZoqmM+SiHA0+6azJLwvjUr7DvRXKkNRiWN3H7E794GpSOzBxTzJ h65vKCqZ9aDlddQj7GMNACZAiqWGHtpoYRCiMTsxGomQQJDGcwoh8R6MMDMfiUaYFnxV eOcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dcz6yeTS; 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 e1sor1514108pff.23.2019.06.28.11.24.29 for (Google Transport Security); Fri, 28 Jun 2019 11:24:29 -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=dcz6yeTS; 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=dZYduMfUWZ9SXxQiDlz5Ott25WscyPClGVJovh/j864=; b=dcz6yeTS+k9GW7rabIn/2jY7ktaZSb0v0RMSqU/Vl5fRVl6SddKmc9Gs/PSNl3Ag3P GsdxcSY97gFY4U8+ipD0Hrdy9dIx3IZw5IeVPPujWUdv+A8BAKm+QGpxPJ4e4fGx/dSE R07ouFUy2VcVkbM7pkQ3U3zjXglParYEw9SXblesMALpid29Wq+XlhgJqkJ4gxvziwuO BkZs33KdHh8dj00S4qmdFqSpxX/cYWvdL5nHutJwLSBNr73FCjPZDXyLlFcNweKy9Ko1 f+1WQIIVCJuDZrQ6SzkKhvWqOPt//OvyHOH4zzF6QU+yh0rJVQvLznywfHoDy+emC4Vo RsJQ== 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=dZYduMfUWZ9SXxQiDlz5Ott25WscyPClGVJovh/j864=; b=aZXjYs9vzFMyjPLFec6QGjPtQMr3uFk5azJGsX0Uh53rE3sCCjrKVg6LSWOc0bQYdB PWECvwRPXbjXjV8JG2pQJQX2OgHcrUmKTXzVjNCz0bETsmIzWHnnVG3NfQRp3xd2rroP COSCrVVJ527RsPxe41JN2pMID7I+y7StDmUZKmPA9ep3RLL4RQA/ud7qP8HPRSnbhXtk xQq+eo2Ikxm7PZUDC05Nk4oofPjaa+EVQpCPZnfMNdeQY1X4iaOcuxRAMEcVaOavAC8J Cj8GJD8cXJrGCOY3M4fknzLDe74dEOAPj1nwgiKBqTFy60sRAx+Ii6u7YiDuB3bXB7UT Eicg== X-Gm-Message-State: APjAAAWXFpEG+MRexEeA+CWyOUmWOYAm4womc1WWBH8dJ+tCJh+KiSzC 2fiXHqk2ngQjCx7Em8femsS/3dH7 X-Google-Smtp-Source: APXvYqxwHT+rEAoznXp4RnOp+y/5ybIX1wyiM6yFmGmuvOOiuwojDxDrPEZMBAe5MJovxEHAv771qQ== X-Received: by 2002:a63:d4c:: with SMTP id 12mr10869247pgn.30.1561746269237; Fri, 28 Jun 2019 11:24:29 -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.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 11:24:28 -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 7/9] usb: dwc3: gadget: move requests to cancelled_list Date: Fri, 28 Jun 2019 18:24:11 +0000 Message-Id: <20190628182413.33225-8-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 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 c2169bc626c8..8291fa1624e1 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1364,6 +1364,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) { @@ -1400,8 +1411,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); @@ -1409,7 +1421,6 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, goto out0; } -out1: dwc3_gadget_giveback(dep, req, -ECONNRESET); out0: