From patchwork Fri Jun 28 18:24:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 168128 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4020822ilk; Fri, 28 Jun 2019 11:24:33 -0700 (PDT) X-Received: by 2002:a63:89c2:: with SMTP id v185mr10424676pgd.241.1561746273165; Fri, 28 Jun 2019 11:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561746273; cv=none; d=google.com; s=arc-20160816; b=J6FcIthS4gsiRcvxo6m9UbCH+oJbI6XTYP7xcQqdy2FTM7DdIPZ8rLueSQTYDiSwBl 3/gnGlqAfk+jD2NZcW0wvCS3T5My8eQ0Y6XeIxE/5jpPRGhmQv25ISkTBhUlavX8QszI pnlOYC3oD0x26E48/P141EokBhTEtn/JULW8HLMcBN8A1sw2Eu+lnAIBVAFPHSHpX9GG bsvkXUSXIF5n7E12b3YTGGhWVLHOaske7jSuq6RliclXKcHvRMxppynVzDb+E9vxZWI2 R+fWdaVcqnLtMt5IAl9dSJfDK3d9G+yjyyfuUBnkb3z0bFwLDVJa21qqSfx/vMd/NdpK Xvvg== 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=PDI+SV9GVbs38aQev8L4wXqHdjl41NulymWKKVfYEMs=; b=HVpEKBMQPTkOyHmWsJDPX6c/10bJGO/Wapyd3Z9PNBEjHXob5xdTJOZLBdxq6AvpEm n4Gpk4QubN4TbI1Gj7mzPmqtcSe8G12XptB4nreuUe4WfUeNBJMlgqdAKzx2waLwJVVN 9jqpsnlDOZeRAztxusigO3Ipz9hn5OW/q6wtAAMitTHGKrttnNqHyirQN1hqgetdeoCP EKpxjSh8Tl1A6wYJfxWRX5ekQem4MMnnyD1XKZEVs33F/AMjMaGu37IQ3bneozaBrKes /HdIS8/vyis7fHX93FpWLOGTm3Nf17QOZvWY7f0gl7C7uuYF+prF/z13b4ndwDxyf7eY 5ysw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qYrnaW3l; 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 37sor3526759pld.19.2019.06.28.11.24.33 for (Google Transport Security); Fri, 28 Jun 2019 11:24:33 -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=qYrnaW3l; 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=PDI+SV9GVbs38aQev8L4wXqHdjl41NulymWKKVfYEMs=; b=qYrnaW3lA1R/6Lwx4ACSRpppLZSqj/nsm3HWJ/XyVJwBmDMDUednPJzQch3mC+6g81 cPJ9u2y2ef5RaRc4afkelF71jKIGTM6gU1NZtMwdTJngKcmKhXrSuxlNPocHnozZLmvs oR2JXHYWYgFKOZk1ELyxIUUZhBKMm4lp/A2PL4hNsaczXpzhQy3Z024AghkMA5TLL0VQ EdGdtVc+6BVpxJeup6O0MuUV17IsSM5fRlQvXnPxWQgr91vTI4uVmTQ8gakEk5WDCYwi vh0wbNusAu55fvfNftAaOQjKXrnSj1YPFpRzKidXW+9Sr9de4iFTLvHi9AYeaQTpguGC evfw== 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=PDI+SV9GVbs38aQev8L4wXqHdjl41NulymWKKVfYEMs=; b=PFAx9MfgDgwgBl10tMSNG+A6y2dOQIvayeYJfGs1bEnLjVoTXkrnrRfvqXa8apwMoV /oV3grgtyj1PYnn01oC4X/dZGmpn4om2vUfHZIOd0dWe/FO8Qgme1Yu3f937df4mRWHU cH52t8fFZDicg+zwbTO7f87h7ZaOxDwT1cImVbdQ1MSKS13fNOa3K6SB8HHYP2tAvs02 s2an5eC5Gc+Bwl/LKx7pX/i5TjYRa7LsBW/8NuI3shPBM+HkoFNezqkmrolf9xPEcy3Z MKhjeITsbEHiHH4F3PZ//Z6upowkHGY+lUk2xWoP9QpowTH5xPKNylqyWchYuYbTs5iP ZKkg== X-Gm-Message-State: APjAAAU5Grxy4IARdbFIKf7r+Ytmp7k8qEYwYbHXWQ4V0+agWNjUHFac NquKa5LhxJ45s9bXdvQYujS7fiyW X-Google-Smtp-Source: APXvYqy5EteuxJPd8uSp7RfKzmDXMzcgaoORnjNlj/kg/wwocf9+URJb3sIck64ZvXt+s++AWxRmvA== X-Received: by 2002:a17:90a:9f08:: with SMTP id n8mr14979208pjp.102.1561746272721; Fri, 28 Jun 2019 11:24:32 -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.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 11:24:31 -0700 (PDT) From: John Stultz To: stable@vger.kernel.org Cc: Jack Pham , Fei Yang , Sam Protsenko , Felipe Balbi , linux-usb@vger.kernel.org, Felipe Balbi , John Stultz Subject: [PATCH 4.19.y v2 9/9] usb: dwc3: gadget: Clear req->needs_extra_trb flag on cleanup Date: Fri, 28 Jun 2019 18:24:13 +0000 Message-Id: <20190628182413.33225-10-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: Jack Pham commit bd6742249b9ca918565e4e3abaa06665e587f4b5 upstream OUT endpoint requests may somtimes have this flag set when preparing to be submitted to HW indicating that there is an additional TRB chained to the request for alignment purposes. If that request is removed before the controller can execute the transfer (e.g. ep_dequeue/ep_disable), the request will not go through the dwc3_gadget_ep_cleanup_completed_request() handler and will not have its needs_extra_trb flag cleared when dwc3_gadget_giveback() is called. This same request could be later requeued for a new transfer that does not require an extra TRB and if it is successfully completed, the cleanup and TRB reclamation will incorrectly process the additional TRB which belongs to the next request, and incorrectly advances the TRB dequeue pointer, thereby messing up calculation of the next requeust's actual/remaining count when it completes. The right thing to do here is to ensure that the flag is cleared before it is given back to the function driver. A good place to do that is in dwc3_gadget_del_and_unmap_request(). Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize") 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: Jack Pham Signed-off-by: Felipe Balbi (cherry picked from commit bd6742249b9ca918565e4e3abaa06665e587f4b5) Signed-off-by: John Stultz --- drivers/usb/dwc3/gadget.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 843586f20572..e7122b5199d2 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -177,6 +177,7 @@ static void dwc3_gadget_del_and_unmap_request(struct dwc3_ep *dep, req->started = false; list_del(&req->list); req->remaining = 0; + req->needs_extra_trb = false; if (req->request.status == -EINPROGRESS) req->request.status = status;