From patchwork Tue Nov 3 20:34:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 317186 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E59BC388F9 for ; Tue, 3 Nov 2020 20:47:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 196CC2242A for ; Tue, 3 Nov 2020 20:47:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436425; bh=adrOmpVNtXk0w1K1x91AoAl2Qjk42x/Id2yz/Dg7u+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=12kwUnMp/Hod/uqd1aJHSUhhzMfMhPp1ABUMVUOs/7SFqcJHOQECvUHymNFMs+IKv xbq12qnAwgIzqWw5VgiFjcce6NVd1e1j9jR+1ax06XnB9OJrsGKwJpRByyfMOo7bw3 KRpfPWDdEmPQC1s4Pdfu/o2upE7yq4vjmfr/uEoM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730500AbgKCUrE (ORCPT ); Tue, 3 Nov 2020 15:47:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:36940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730729AbgKCUrA (ORCPT ); Tue, 3 Nov 2020 15:47:00 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 20B9B20719; Tue, 3 Nov 2020 20:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436419; bh=adrOmpVNtXk0w1K1x91AoAl2Qjk42x/Id2yz/Dg7u+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=arSu2TakxiuewHGV8/IwDbOejLY6+DBKxJ/QwPe984/OkzTxpGLrIWlYGzjXQeonp awSaJuIUERmBJMkqU3plxOFA2C8MphgITFi5wZxkBDptgMW2O8e3Uy5mVZL19naMHF TJJXYgj3z763xSMX4kxyQzW+P2UGDh+aThnzEmW8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen , Felipe Balbi Subject: [PATCH 5.9 242/391] usb: dwc3: gadget: Reclaim extra TRBs after request completion Date: Tue, 3 Nov 2020 21:34:53 +0100 Message-Id: <20201103203403.337060578@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Thinh Nguyen commit 690e5c2dc29f8891fcfd30da67e0d5837c2c9df5 upstream. An SG request may be partially completed (due to no available TRBs). Don't reclaim extra TRBs and clear the needs_extra_trb flag until the request is fully completed. Otherwise, the driver will reclaim the wrong TRB. Cc: stable@vger.kernel.org Fixes: 1f512119a08c ("usb: dwc3: gadget: add remaining sg entries to ring") Signed-off-by: Thinh Nguyen Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2732,6 +2732,11 @@ static int dwc3_gadget_ep_cleanup_comple ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, status); + req->request.actual = req->request.length - req->remaining; + + if (!dwc3_gadget_ep_request_completed(req)) + goto out; + if (req->needs_extra_trb) { unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); @@ -2747,11 +2752,6 @@ static int dwc3_gadget_ep_cleanup_comple req->needs_extra_trb = false; } - req->request.actual = req->request.length - req->remaining; - - if (!dwc3_gadget_ep_request_completed(req)) - goto out; - dwc3_gadget_giveback(dep, req, status); out: