Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3729723ybv; Mon, 10 Feb 2020 05:26:54 -0800 (PST) X-Google-Smtp-Source: APXvYqzWiHtSyFj2hF/Myez8bGu0qKZvcry6rTFRsdO7bbUDCbyyYh5T8bsmkiRU1AjLEONTtAFt X-Received: by 2002:a9d:6212:: with SMTP id g18mr1102275otj.187.1581341214149; Mon, 10 Feb 2020 05:26:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581341214; cv=none; d=google.com; s=arc-20160816; b=RTGZpCe9cwk5TQLt/rbBfd7dGIRX1+49IsHIo6EiqbA6PEzbHU3qWBlrYzSmiYQ4v/ MC/cLWfu/w11hRMyd2Oq42A4ScBL3mEb3Dcda1synm44UR+vABGb1rBKFFOnAEZNaXBX h0BqHGxKrKZjFJYYC/+yalJ8tBDhXNYyMm4qRmD5ylers2LeHKIqF/Is827lUycat3Ai P7UuDxPTHYODQDxpS/831m0zXSWRiCczDitIPbBDTdOeY+9fPdyLjEORyg0H76CNoLpw PMwlUr/ykpiGOGzn8v21ztCZ440sxo2HAFKndeaN2bsC2kWpXDeB4o7FQwMpMxNfcZTU 1aIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0992mTT9oTVtCvnhZkNEF8DLpBMtmdc6JbkFtmpeyv0=; b=MnHWtQKV7ALH4RSdiZB601NePk44HMaQln0XBfjJJ3DsCOGy9y5J26lbaH+bS5tw/E 3PqYXqkFv1qYcAmx9+TLGOssNO+aTnful33QglMK46GbJTDsAkmKlOgjaesJdFqlh01s xEu74NZoqmuNPM+lTsEaOzovlu2Uv6fmOUuqlDAEviYx8pWKEoYr2OMjWf+vLG8Xt/YN 26Y6Gmdowko6tKgFh7YRjipnu5IkEcrbeOJRlFplisWvqs6iwzu6GTR8bNQEhK1NFibr Mvcji9HexbjMRmE6lKcARgtAtqTqE+IWuoIE9ucpcg9xIY+aCDxKl41H8uM7jEj4dPvr Iitg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DM86AXdB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k128si140527oih.274.2020.02.10.05.26.41; Mon, 10 Feb 2020 05:26:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DM86AXdB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731228AbgBJNZf (ORCPT + 99 others); Mon, 10 Feb 2020 08:25:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:57242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728550AbgBJMgx (ORCPT ); Mon, 10 Feb 2020 07:36:53 -0500 Received: from localhost (unknown [209.37.97.194]) (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 4F48E20838; Mon, 10 Feb 2020 12:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338212; bh=w16WrdxQwte7W7Dx1UrCfaCKoSIdMxp1Z6eyuv/J3IQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DM86AXdBPXXEH/Ui04atfibY403UT2jWk7Df9Hed6QWem/Px8kqz340KB32PUmg9E 6QlEd3odmRNoTDgGuQe7iNE0/sgk6AGyP7btOFyu4WwarxQMOgdCC+T0CrzwQiT8t4 vUSvq0BV2FmyuLl+NCucuytFpHY5M8/6T6WE7C1Y= 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.4 037/309] usb: dwc3: gadget: Check END_TRANSFER completion Date: Mon, 10 Feb 2020 04:29:53 -0800 Message-Id: <20200210122409.659401423@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122406.106356946@linuxfoundation.org> References: <20200210122406.106356946@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thinh Nguyen commit c58d8bfc77a2c7f6ff6339b58c9fca7ae6f57e70 upstream. While the END_TRANSFER command is sent but not completed, any request dequeue during this time will cause the driver to issue the END_TRANSFER command. The driver needs to submit the command only once to stop the controller from processing further. The controller may take more time to process the same command multiple times unnecessarily. Let's add a flag DWC3_EP_END_TRANSFER_PENDING to check for this condition. Fixes: 3aec99154db3 ("usb: dwc3: gadget: remove DWC3_EP_END_TRANSFER_PENDING") Signed-off-by: Thinh Nguyen Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/core.h | 1 + drivers/usb/dwc3/ep0.c | 4 +++- drivers/usb/dwc3/gadget.c | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -688,6 +688,7 @@ struct dwc3_ep { #define DWC3_EP_STALL BIT(1) #define DWC3_EP_WEDGE BIT(2) #define DWC3_EP_TRANSFER_STARTED BIT(3) +#define DWC3_EP_END_TRANSFER_PENDING BIT(4) #define DWC3_EP_PENDING_REQUEST BIT(5) /* This last one is specific to EP0 */ --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -1136,8 +1136,10 @@ void dwc3_ep0_interrupt(struct dwc3 *dwc case DWC3_DEPEVT_EPCMDCMPLT: cmd = DEPEVT_PARAMETER_CMD(event->parameters); - if (cmd == DWC3_DEPCMD_ENDTRANSFER) + if (cmd == DWC3_DEPCMD_ENDTRANSFER) { + dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING; dep->flags &= ~DWC3_EP_TRANSFER_STARTED; + } break; } } --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2625,6 +2625,7 @@ static void dwc3_endpoint_interrupt(stru cmd = DEPEVT_PARAMETER_CMD(event->parameters); if (cmd == DWC3_DEPCMD_ENDTRANSFER) { + dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING; dep->flags &= ~DWC3_EP_TRANSFER_STARTED; dwc3_gadget_ep_cleanup_cancelled_requests(dep); } @@ -2683,7 +2684,8 @@ static void dwc3_stop_active_transfer(st u32 cmd; int ret; - if (!(dep->flags & DWC3_EP_TRANSFER_STARTED)) + if (!(dep->flags & DWC3_EP_TRANSFER_STARTED) || + (dep->flags & DWC3_EP_END_TRANSFER_PENDING)) return; /* @@ -2728,6 +2730,8 @@ static void dwc3_stop_active_transfer(st if (!interrupt) dep->flags &= ~DWC3_EP_TRANSFER_STARTED; + else + dep->flags |= DWC3_EP_END_TRANSFER_PENDING; if (dwc3_is_usb31(dwc) || dwc->revision < DWC3_REVISION_310A) udelay(100);