Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp876202pxb; Wed, 1 Sep 2021 11:53:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/+zUkhosRXS2GESd4TyXYBz+uloJKnmagNc/+vRaqSTYb6EEgR2MBvD4aUkaiGuA1cEC2 X-Received: by 2002:aa7:c60e:: with SMTP id h14mr1055394edq.43.1630522389362; Wed, 01 Sep 2021 11:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630522389; cv=none; d=google.com; s=arc-20160816; b=ILSAVtcd30s2ALJzbfAx4497S4oSFyk6MHXNGW9e6wqxJ4jh8pX2E3ClvUuBy0gHLW APtsLNvQrQRbcgrZYU3D/zOpfCoHfgc6jYTaKir90LOtgdkiIXiNVcgHL4Qgw0+2mSzJ 2Fyp1VQACXyyy6ipx6fV7269Q3TZRDHepgYUNDm0pR1DGQmJM7hpeGa4JokGEeKP8KV0 IIKKDsU1vNeKRf0j0mtgs8ihCVg8AX6uxvN5EEFsyoKAhM5f7VHaJvSAaot1XTQKE3/c 21FXgx4F2cAL1lsvKhlITdnW7qA6Irr/RCgcXwHbvv8owG7Kg7WlydEPbw69NMuryQSQ 9h2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aCezorWlVhNFYau62Ml5hLHIGw7S8zpWUV/UfdTcxiM=; b=A6tQDDdaS8tfeDoNVuJO/tYbOl4Hkle2n496kZKTg+veVA+mXK0VUliU8qtBKveZGv ZfyE59BP7mNksoKt8bbv+sAOca9XBBaDSKv5fAV+dIUMX9YKcCwrCjECZ6iuYZgVJap4 x6r8slIQbVx1h7RpE5mKcigUlnT6UHNv1/JspXQC00zdFKyoE+Oips+2WD/jQINIs8pH 0mxAgBj5SnFW6EVe4NZ996N+UduFkJC+omx2U3Yhl2HwEL9xnTVwLtwJsN1wm/5Uxs4b dSaHG/BWNOekqnx4B8B+U61qI80ggqkQyfMElClp6zaIARRMU7EJQy/Pds7EMYU68VHa Y79w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z8CndE3E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si546830ejx.341.2021.09.01.11.52.45; Wed, 01 Sep 2021 11:53:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z8CndE3E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244583AbhIAMao (ORCPT + 99 others); Wed, 1 Sep 2021 08:30:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:59206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244103AbhIAM34 (ORCPT ); Wed, 1 Sep 2021 08:29:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 365E1610CB; Wed, 1 Sep 2021 12:28:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1630499335; bh=A32YqnXIiWfn79MYz9xPt+aCXx+c/OIIJI16s8KGgyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z8CndE3EJ+X5TglPD3z4qeGWrwsz1B4pIWpwkW+kQhZyYZLrH6NDfX4g7UjO0Yofd Y94iUiemDejBNXWPl6khJgM43jO2gzkqBCE8ihjI3LF4/CVwGQeuizmxkdIJ0Wvh3x wjjdahBpEy9idJyQ6VYsMF0QP+prOFtX3eZ0An5I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen , Felipe Balbi , Wesley Cheng Subject: [PATCH 4.14 06/23] usb: dwc3: gadget: Stop EP0 transfers during pullup disable Date: Wed, 1 Sep 2021 14:26:51 +0200 Message-Id: <20210901122249.986313322@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210901122249.786673285@linuxfoundation.org> References: <20210901122249.786673285@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wesley Cheng commit 4a1e25c0a029b97ea4a3d423a6392bfacc3b2e39 upstream. During a USB cable disconnect, or soft disconnect scenario, a pending SETUP transaction may not be completed, leading to the following error: dwc3 a600000.dwc3: timed out waiting for SETUP phase If this occurs, then the entire pullup disable routine is skipped and proper cleanup and halting of the controller does not complete. Instead of returning an error (which is ignored from the UDC perspective), allow the pullup disable routine to continue, which will also handle disabling of EP0/1. This will end any active transfers as well. Ensure to clear any delayed_status also, as the timeout could happen within the STATUS stage. Fixes: bb0147364850 ("usb: dwc3: gadget: don't clear RUN/STOP when it's invalid to do so") Cc: Reviewed-by: Thinh Nguyen Acked-by: Felipe Balbi Signed-off-by: Wesley Cheng Link: https://lore.kernel.org/r/20210825042855.7977-1-wcheng@codeaurora.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1799,10 +1799,8 @@ static int dwc3_gadget_pullup(struct usb ret = wait_for_completion_timeout(&dwc->ep0_in_setup, msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT)); - if (ret == 0) { - dev_err(dwc->dev, "timed out waiting for SETUP phase\n"); - return -ETIMEDOUT; - } + if (ret == 0) + dev_warn(dwc->dev, "timed out waiting for SETUP phase\n"); } spin_lock_irqsave(&dwc->lock, flags); @@ -1936,6 +1934,7 @@ static int __dwc3_gadget_start(struct dw /* begin to receive SETUP packets */ dwc->ep0state = EP0_SETUP_PHASE; dwc->link_state = DWC3_LINK_STATE_SS_DIS; + dwc->delayed_status = false; dwc3_ep0_out_start(dwc); dwc3_gadget_enable_irq(dwc);