Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4647116imw; Tue, 12 Jul 2022 11:37:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vzySg+iPtFtK+iWAEInD8AZIEYBz/ukKwSmJ7IaxS1wr4h8c7vLU/slWNQFI7a7fbRiuNJ X-Received: by 2002:a17:906:5a6f:b0:72b:10c8:8513 with SMTP id my47-20020a1709065a6f00b0072b10c88513mr25109670ejc.312.1657651071015; Tue, 12 Jul 2022 11:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657651071; cv=none; d=google.com; s=arc-20160816; b=BlTu06aubIjU4/0mvPrhHCQ5MS6W1h2gqSZ4z2LbpfMLWruSq5IklTvFoNSYxXExbw iqh95j+TgB5Z/AHW1LmlbZ/mMFoYh6zmSbaoR9DPoAVo7xr8wKOChX2qEumSC7Rnoa0S rZha62avGu8A9rHtuHUsf724qQxmyvJd/QhAO2koP2b/PtDh2LJ/RZyaTSSEjrx2W+HM DUqoysVSsOlPrS/3VBL+V+lv000p8bCzrbr0Z6c4TMoITacPEAbVS2BHIcOIXGA4c1C2 hz2GURsbDu8aR7h9quoGhr9yDXHNju22E6QOM1j/lMoxEnc9h5PX5+79B3oLjiVz36rQ Ec2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=n/EFQWi2zN3zPt+WoTW4/wSsWNc9KD0J7PX0+1/53+M=; b=IXjM/Q/2H0iYH2qFWj8xPJxpX5IwLQ18cNT4iBKveMRpjVcnXUcHXAa6bv1mGZZSt2 Zn9UNJsfPzX59tVEYN7jNozHY0CAZv1qWQlX/92UGytQbQJ/oE9564KvA8JCvZonrdTC rB2jAHwLv62s3cOwt2wL12guZcfi/VMldMw+ftCpw92Cy+m/KgZp+43va/NcNaMWfM9g e2yibkLwubZZ+Vkwj7jpLg1Rum8EYZJ0xTGl69ByZh3Ix9lv/6TBb7MmelYUxd0lBrDD bJUdHAZFOC46/BD6hTNz7MgZLr2fWWF50VlthgMQ2rLxdxyr4jelMcil9Gm1yYBxVFht Tehw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=Td6WIUZq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id um9-20020a170906cf8900b007269a9c3019si1225531ejb.818.2022.07.12.11.37.25; Tue, 12 Jul 2022 11:37:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=Td6WIUZq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233013AbiGLRok (ORCPT + 99 others); Tue, 12 Jul 2022 13:44:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbiGLRoj (ORCPT ); Tue, 12 Jul 2022 13:44:39 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F084CDA2A; Tue, 12 Jul 2022 10:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1657647878; x=1689183878; h=from:to:cc:subject:date:message-id:mime-version; bh=n/EFQWi2zN3zPt+WoTW4/wSsWNc9KD0J7PX0+1/53+M=; b=Td6WIUZqSNBRWbiC61TOpf0pKn4PIjVOJMm2M/HlSbUFEj0Seyk3Q5tF aRY49hGr3Kr2coQG50vS+LYLZzbY8MdIQWDSGc3IopIoXflHpaqYlsxXO omk52EKlmtjb0NL83uzx4oNl/sO94owZIzTy28aPD3B8d7znOusOqetbk w=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 12 Jul 2022 10:44:38 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2022 10:44:38 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) 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.22; Tue, 12 Jul 2022 10:44:37 -0700 Received: from hu-rkollals-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 12 Jul 2022 10:44:35 -0700 From: Rohith Kollalsi To: Felipe Balbi , Greg Kroah-Hartman , Philipp Zabel CC: , , "Rohith Kollalsi" Subject: [PATCH] usb: dwc3: core: Do not perform GCTL_CORE_SOFTRESET during bootup Date: Tue, 12 Jul 2022 23:14:23 +0530 Message-ID: <20220712174423.20484-1-quic_rkollals@quicinc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 According to the programming guide, it is recommended to perform a GCTL_CORE_SOFTRESET only when switching the mode from device to host or host to device. However, it is found that during bootup when __dwc3_set_mode() is called for the first time, GCTL_CORESOFTRESET is done with suspendable bit(BIT 17) of DWC3_GUSB3PIPECTL set. This some times leads to issues like controller going into bad state and controller registers reading value zero. Until GCTL_CORESOFTRESET is done and run/stop bit is set core initialization is not complete. Setting suspendable bit of DWC3_GUSB3PIPECTL and then performing GCTL_CORESOFTRESET is therefore not recommended. Avoid this by only performing the reset if current_dr_role is set, that is, when doing subsequent role switching. Fixes: f88359e1588b ("usb: dwc3: core: Do core softreset when switch mode") Signed-off-by: Rohith Kollalsi --- drivers/usb/dwc3/core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 050b2ba5986d..7ce0e033d755 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -158,9 +158,13 @@ static void __dwc3_set_mode(struct work_struct *work) break; } - /* For DRD host or device mode only */ - if ((DWC3_IP_IS(DWC3) || DWC3_VER_IS_PRIOR(DWC31, 190A)) && - dwc->desired_dr_role != DWC3_GCTL_PRTCAP_OTG) { + /* + * When current_dr_role is zero, do not perform GCTL_CORESOFTRESET. + * Perform it only for DRD host or device mode. + */ + if (dwc->current_dr_role && ((DWC3_IP_IS(DWC3) || + DWC3_VER_IS_PRIOR(DWC31, 190A)) && + dwc->desired_dr_role != DWC3_GCTL_PRTCAP_OTG)) { reg = dwc3_readl(dwc->regs, DWC3_GCTL); reg |= DWC3_GCTL_CORESOFTRESET; dwc3_writel(dwc->regs, DWC3_GCTL, reg); -- 2.17.1