From patchwork Thu Jun 27 20:52:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 167990 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2822075ilk; Thu, 27 Jun 2019 13:52:59 -0700 (PDT) X-Received: by 2002:a17:902:8d97:: with SMTP id v23mr6801977plo.157.1561668779617; Thu, 27 Jun 2019 13:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561668779; cv=none; d=google.com; s=arc-20160816; b=MalhqOIVUkdyPESX2pUiffCA9reaIbbmH/MZuHYQDMDWfbkVnzxfaUGX5LtAmQhcJX /Pr44mOyvFgSuE/F1BPe8Jb4cMRSd0/tM42Y7/z9YqZU5atlgXbiWvGpaC6ljt/BkylQ 56PcgKG9yasvP+XOQvvdW9z/AoTfNOu17J3XtrKx34/gYKAD57I6+ZipZJCAigi/DQUI lrTB4eZ244lrrp/74vbKZLzxBsYcojArXUDpLUlfYcH7HC7NfobehCBHWviLRRsyGKSy P0GlKglvRj3zFTC+q2+ufx17HAzFDdebrqXqrfNYlSHFtd4Nq7JJmIHdxp4/eoJU24i6 Q+lQ== 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=DJRudAcAZNXH2ktZLcWW05FSEYSS+9+cw/N+J58T4tAwGImGG9dUjdhelVsAx80tO3 IV/h/WBKBzUp20E950S1+gpigPBWh+KYMbYVkFY2bBEweJe8v3YNUnMy4+VZB1E8rsKK 2VbgsVbA4NDCcSoGHRKD0pFZCXUAMu+nHBRyDdBL+iLfxKUtbcqtKD6tnieW3buTsjOe MPhHYGQfm9AQCs5UCZBOpyV0e778SQgWusiBT+/Y5E3RyNJtK9Mb47kfTDdGcEM79Eeu +2TCD2iZxnhSLWLeGzstG9GDUgmiGOIbQ4MC5WESR52UYg+TzkIGpyShAhyvidWVI1IO bY/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FT+BOXS8; 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 y16sor4390pfe.48.2019.06.27.13.52.59 for (Google Transport Security); Thu, 27 Jun 2019 13:52:59 -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=FT+BOXS8; 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=FT+BOXS8krhFYzP6qgkGdTRIuN8UEsdd7/J8Rk/TUCvNz5vD+gALlNCjhBRbIyg2+e MhGEv+r6MSWMg0hPYeg+IO7ul1XPK65iNNIVI6Z0n3TbWoWyTiOzVSbZ1TrHf3P5bsll wflv/q/ksLyXrQJQzt13c5gcCn8ChgNlwa8D+06Mp8/blyCxT/DNAUTeVhtYIwNTTRAH 4A1YRmiJzIY8sAIaajfuF2qEu/ZXMnUvTcYbEzmJ6DRI23NNxVHK3EGJZXFDvOONHjVy b/x/iCuPGw6JGjnvJCYoxYs7SzL/j19MXh3Z+y+kfPrn44MA+V+WR3aP1HHbvclQs3GO cEXw== 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=TrPMB6cwAEmth6ADqHC1UUyej6ql1MVJKpJ9k0ZP+Y+lVOIP2ZtR2ncqUe63RWIqZ8 Bv9srVSVDG5gTTf0LjSXLCqoyeV0AXxSzLwaykEAPHIk82bE8rtdggL+O62nlHMn9PiA m5FIxrKO2tXe0SckEpeAfkolmlRpFQqThcx06XDuyD/QOMYWxfGoBZYWMAkeoX9/6g8G i5+JZ5edIbNIz9HZNeUPgN0O4XT+tnz0ndIF5ia6ft6Q+wwMtTB9eBKx8ZWZ7cUhUN+H GT49OdyF0/R/Sv1XtAVBO2lHZKkmBpsqYofMXAiXz8EBB2Hevifunhv9DKETMxl48Uc/ c9Lw== X-Gm-Message-State: APjAAAXPE2DXGn83Q1MbTyiuqPSziVOzu2unKmOV3xXw4ve1JPOk9uP3 AMu8HU8x7+XSWeUOm4LnpcK9xO5w X-Google-Smtp-Source: APXvYqyBb+wX2HfJ0wt7W/TgcNxknQdoGdW16YqdoS56BW7Ng+PgtitplGMtO7YyOovSzLxYZ3UKug== X-Received: by 2002:a65:500d:: with SMTP id f13mr5539367pgo.151.1561668779150; Thu, 27 Jun 2019 13:52:59 -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.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 13:52:58 -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 9/9] usb: dwc3: gadget: Clear req->needs_extra_trb flag on cleanup Date: Thu, 27 Jun 2019 20:52:40 +0000 Message-Id: <20190627205240.38366-10-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: 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;