Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3729847ybv; Mon, 10 Feb 2020 05:27:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyfhW4XITVIFxXQlMglA7+n08HYOTOj03dBEtDr0afnMmM17rYQMYqVwdkB5acRQkOTSQtX X-Received: by 2002:a05:6830:1050:: with SMTP id b16mr1082878otp.140.1581341223032; Mon, 10 Feb 2020 05:27:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581341223; cv=none; d=google.com; s=arc-20160816; b=VPY4UHsqQ/aUGk+8elVH3vfp62iXHFFjdCjHjrBPuWwbZFFHKpNoMTvqKh+/lJAL4S /Y72nLKfxBKvqOqVGYwbv+LWx3RCSYndyygDqWSB3jopt03NfhsKQOwTB/Il2VexTU5t zZeR97us8XyQe7E8D4YTeiMh1KIsoFmMPDRKXS/v31+2TMYpXrWtASWwV3IPUzww27bF +OQKHOlQpEWSOYvwjHPr4+pcxThKRJyOZFwJUo8Z+EGws8Sc6M71LfUBL3NM/VAQ/T3K Lb3LYlozRGQ91ULOZjNdKydARgMFXPyVqewaomWnd9EZi9+NrrQWeN7USDIt3qX5hYS2 Tv7g== 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=ZFxj+JKbAJRe/eXdFezxBB6+xz+pSndgFfumT6o63gc=; b=LtXbO5Fi7+SU0fasFp1RBZWt1YvVr12pZipco59Jiw7/TaPtmedLdCyxqxZ2U+i5PW 56sm2U3b+8dP0he5yL52ArnmO3qub9ERPXRwpvWsInCEi2CRIhbdcQf4F4RBe4bIIwfD 68zU19pUnz8Gu6uLX39WmcyG/iK+uHP5J0gj2pESX49HJE2RuajZIc+JtV9ybnchKrRE NAY5Yt/lNClGjTskgvsblh/5cK+PddPkG2Okbfg8hCEzPNs2HVPQGlXxOl4MyX95z4Xo giFPmgSKnZj5kv3Sk7dHKeraLk9U+KYDPEeG59bSiNlalsf7PqvO9YCR85W5vQUj4miZ S1lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T0X6YPyk; 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 b15si254509ots.99.2020.02.10.05.26.50; Mon, 10 Feb 2020 05:27:03 -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=T0X6YPyk; 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 S1728762AbgBJNZm (ORCPT + 99 others); Mon, 10 Feb 2020 08:25:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:57264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728554AbgBJMgx (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 CB2F320873; 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=96Km2JAKJQt5E4CSNG5FHIUcJJU0qlgelVWwZfkR42o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T0X6YPykTal4iXGd3K49D1KB3pLFMYdejbn+HbUdCl7N29QBnQfcBF0xvYDK/frZD EVEnx1Ae7EjF54saZgDC6/QGIY4INzp0cTOIhqENiNPj6f/OzS9jkYcQ6agYQILAg5 uXe3xsnvuVuFZGNAGiACXh9hM5d0W9Kjfc/KY9zc= 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 038/309] usb: dwc3: gadget: Delay starting transfer Date: Mon, 10 Feb 2020 04:29:54 -0800 Message-Id: <20200210122409.747341371@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 da10bcdd6f70dc9977f2cf18f4783cf78520623a upstream. If the END_TRANSFER command hasn't completed yet, then don't send the START_TRANSFER command. The controller may not be able to start if that's the case. Some controller revisions depend on this. See commit 76a638f8ac0d ("usb: dwc3: gadget: wait for End Transfer to complete"). Let's only send START_TRANSFER command after the END_TRANSFER command had completed. 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/gadget.c | 11 +++++++++++ 2 files changed, 12 insertions(+) --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -690,6 +690,7 @@ struct dwc3_ep { #define DWC3_EP_TRANSFER_STARTED BIT(3) #define DWC3_EP_END_TRANSFER_PENDING BIT(4) #define DWC3_EP_PENDING_REQUEST BIT(5) +#define DWC3_EP_DELAY_START BIT(6) /* This last one is specific to EP0 */ #define DWC3_EP0_DIR_IN BIT(31) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1447,6 +1447,12 @@ static int __dwc3_gadget_ep_queue(struct list_add_tail(&req->list, &dep->pending_list); req->status = DWC3_REQUEST_STATUS_QUEUED; + /* Start the transfer only after the END_TRANSFER is completed */ + if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) { + dep->flags |= DWC3_EP_DELAY_START; + return 0; + } + /* * NOTICE: Isochronous endpoints should NEVER be prestarted. We must * wait for a XferNotReady event so we will know what's the current @@ -2628,6 +2634,11 @@ static void dwc3_endpoint_interrupt(stru dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING; dep->flags &= ~DWC3_EP_TRANSFER_STARTED; dwc3_gadget_ep_cleanup_cancelled_requests(dep); + if ((dep->flags & DWC3_EP_DELAY_START) && + !usb_endpoint_xfer_isoc(dep->endpoint.desc)) + __dwc3_gadget_kick_transfer(dep); + + dep->flags &= ~DWC3_EP_DELAY_START; } break; case DWC3_DEPEVT_STREAMEVT: