Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp588186pxb; Tue, 15 Feb 2022 23:01:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVnrwo2nIYe8rJ3s23DABb+cg5Z0yzNfcqj0kghy7lr4pLlZhDGLviPbmKEM/GhW4ZCLXB X-Received: by 2002:a17:90b:4b92:b0:1b7:aca7:b2f3 with SMTP id lr18-20020a17090b4b9200b001b7aca7b2f3mr186236pjb.169.1644994882343; Tue, 15 Feb 2022 23:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644994882; cv=none; d=google.com; s=arc-20160816; b=f7ML7iJkwxZaK7IhvTbb6sxDIp+ht3VIkvQ++dg3NAtPnUmubX9JCOBbqZxeZ04Q6Z eGchSMJTaZu+4mSM1fNIxvyqWtOHhtJdio+W6Z7crxaldxt5120Z/CK1C85VmZqM2bw/ dBM3hPPIKUGx6ChkmYVhr0U5akPOla2Wn9Jqb7XPabwQK5Gj0MozGDP0kk7zz/XDJSa9 e4nZbuZ2kHFIscXy15R+WGFNn2W254Ssjhw599yO9VfJboTuA3REWXgNfdxPCr7XMFvZ +DcS9gcKUTBagLjeDm5+xSpRjLD4cgn/UBuOko17vp5pSf/aQPPIJjnoCtYVi68KNyTL pa0Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/GZeEkmYkAZZYNLAL6kCJUA/CjX7VtGAQb1BEzvn2S0=; b=wckRbyz7uS2D6WKsYyGQXzGIHV68hS5mr8VP9dddOT/DUmRjYvgAt7jJ/Yat1ZvFWt 10hNfe0mzbwCtDqEKkT49WpEYtLdOG2lJWlIs5LYxtZKh5avjoRmPSWnQMS4XYUpPAK7 5VhWfvop4Th+x0FCLOj1Ezft2Yceae6bodQEUSJ3VS8bFWQrEUVFtK//g4hLhUuZJbXb /O1bRAWzI/VH9lxX/Jp0x32Xig4eCHfqF4wunIA6HdotjgnBEZNgsyghx8PctplWvLJg s+FHR2UmsJu33U4Tco7Qg3uqIKcrvVJk08nmvmLctt7FWq+bcSXbgWQvT1YJMSwx07SK 0tEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=pB7rBdMJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t4si15363058pld.341.2022.02.15.23.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 23:01:22 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=pB7rBdMJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D0C99D74; Tue, 15 Feb 2022 22:41:23 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244961AbiBPAJH (ORCPT + 99 others); Tue, 15 Feb 2022 19:09:07 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240028AbiBPAJB (ORCPT ); Tue, 15 Feb 2022 19:09:01 -0500 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55840B16C2; Tue, 15 Feb 2022 16:08:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1644970130; x=1676506130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/GZeEkmYkAZZYNLAL6kCJUA/CjX7VtGAQb1BEzvn2S0=; b=pB7rBdMJt0tkuWFXdpvQAKrfc4jUNxsXlfTNtVNQGm4hMt82lqeWukX2 v5kCdJYUVBZ4q/DEiF/h1lYWmzeqqKq4sWGpIIEq7GUffQSAmP0cwSWef fPxB7dfF7SCox891YkNNxULxT7M/5yL1zNdYCdvSeV1TDCAEW35TO6gzl w=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 15 Feb 2022 16:08:50 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2022 16:08:50 -0800 Received: from nalasex01b.na.qualcomm.com (10.47.209.197) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Tue, 15 Feb 2022 16:08:49 -0800 Received: from wcheng-linux.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 15 Feb 2022 16:08:49 -0800 From: Wesley Cheng To: , CC: , , , , Wesley Cheng Subject: [RFC PATCH v2 3/3] usb: dwc3: Issue core soft reset before enabling run/stop Date: Tue, 15 Feb 2022 16:08:35 -0800 Message-ID: <20220216000835.25400-4-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220216000835.25400-1-quic_wcheng@quicinc.com> References: <20220216000835.25400-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is recommended by the Synopsis databook to issue a DCTL.CSftReset when reconnecting from a device-initiated disconnect routine. This resolves issues with enumeration during fast composition switching cases, which result in an unknown device on the host. Signed-off-by: Wesley Cheng --- drivers/usb/dwc3/core.c | 4 +--- drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/gadget.c | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 18adddfba3da..02d10e1cb774 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -115,8 +115,6 @@ void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) dwc->current_dr_role = mode; } -static int dwc3_core_soft_reset(struct dwc3 *dwc); - static void __dwc3_set_mode(struct work_struct *work) { struct dwc3 *dwc = work_to_dwc(work); @@ -261,7 +259,7 @@ u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type) * dwc3_core_soft_reset - Issues core soft reset and PHY reset * @dwc: pointer to our context structure */ -static int dwc3_core_soft_reset(struct dwc3 *dwc) +int dwc3_core_soft_reset(struct dwc3 *dwc) { u32 reg; int retries = 1000; diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 00348d6d479b..b27ad8dad317 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1532,6 +1532,8 @@ bool dwc3_has_imod(struct dwc3 *dwc); int dwc3_event_buffers_setup(struct dwc3 *dwc); void dwc3_event_buffers_cleanup(struct dwc3 *dwc); +int dwc3_core_soft_reset(struct dwc3 *dwc); + #if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE) int dwc3_host_init(struct dwc3 *dwc); void dwc3_host_exit(struct dwc3 *dwc); diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 0c89baedf220..788889f924f9 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2585,6 +2585,17 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) dwc->ev_buf->length; } } else { + /* + * In the Synopsis DesignWare Cores USB3 Databook Rev. 1.90a + * Section 4.1.9, it specifies that for a reconnect after a + * device-initiated disconnect requires a core soft reset + * (DCTL.CSftRst) before enabling the run/stop bit. + */ + spin_unlock_irqrestore(&dwc->lock, flags); + dwc3_core_soft_reset(dwc); + spin_lock_irqsave(&dwc->lock, flags); + + dwc3_event_buffers_setup(dwc); __dwc3_gadget_start(dwc); }