Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2882041rwb; Mon, 15 Aug 2022 13:13:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Luq576OjI9TsZmk7KHlG/IzILXSubbKcXkoIzi6DZ/TsM6EfeBANvv0qf5ML9KC94Lwuo X-Received: by 2002:a05:6402:34c3:b0:43d:d8d7:a328 with SMTP id w3-20020a05640234c300b0043dd8d7a328mr16089638edc.297.1660594437783; Mon, 15 Aug 2022 13:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594437; cv=none; d=google.com; s=arc-20160816; b=ENMZAcZb3d349yFraxmPgGO82TTCPNGZd2JNooMpTq762wpKhAuMfMCswW25wBBO3n hWpXcSiyawY1Uom7KeLGEub99XfDZ9RLtR9dVD8vbSMypSL3etwR8dB8V69vtmpHU8QI Emxj5Frx1ZBb4wB3lPjuszwhrOobHPb0iYckZgrSSQYuJBouNRrpg+gZNl1xREd1eNPV RVbNYGsRv5TO0WSBYQcO7b384qqF/VU4HX98h+FxvnTTw4oqJ3mdGgTtAYD8KNRvGdtm w9FVHxUue1tzjyONfD8y7FDh16wiUGfTYjvvCdA+Dv7WymJN3qh+OVxFNP592sd3WDDF BWNw== 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=cznGAuJNIIwha6T55repi1j2yJrkYndf414qU90Q6SQ=; b=m8zWla8lgRkoHeT4lKUrycFQDiMdeCEE9Qb3yCBkjbXr5M+hQDuZbJ+KyD2L7yJTMS ueABZl2moOWgDk7iy5nk/Ixrwqr7oDLLJNsrRPrOAfWxZNU/Log9HEs0dPNBvEBzD1op VEd6kpI2QH/wdDpcHrMCRtj1HvBuRCtL864rKiBiyXS7Dytplx0cBC5K8O4FJon5PWDq ga4XHGwbkKE+/iRjkWuStoI78WK/94pHj/hZFex6t+tWIafQBIeuiSXMut5gpXqfcczQ OQyWHIM3k8NqyN2t5JICbvNrum+9soYAuYXjJGyEWouMGfSnd0FP5aTQ/zOMr/LIviqC Bw7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G2Vd0YFG; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr2-20020a170907720200b007262b057924si7738433ejc.900.2022.08.15.13.13.32; Mon, 15 Aug 2022 13:13:57 -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=@linuxfoundation.org header.s=korg header.b=G2Vd0YFG; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244431AbiHOTYA (ORCPT + 99 others); Mon, 15 Aug 2022 15:24:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344631AbiHOTVZ (ORCPT ); Mon, 15 Aug 2022 15:21:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADBBE646F; Mon, 15 Aug 2022 11:40:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9B55861154; Mon, 15 Aug 2022 18:40:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95C5DC433D6; Mon, 15 Aug 2022 18:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588820; bh=sk4lIZvVGOueaKj0wAzDD6CxUXQdfitup2cyTbAEu54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G2Vd0YFGRN0SGKtGr8UCqXeFlFd05KzdVyLkYvJzMsDpbzSO9vVirmqiDeLL0Src9 zSIKF15PusoMgaN98/2tp+DiGYNcE4w1+XWRg1vUt1hbBvjPkHH2IRYyOu6jp7OY8l MzIRsKcTaH4NOV7jf+6j2rPdLRfSsl2TnI+ObH3w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rohith Kollalsi , Sasha Levin Subject: [PATCH 5.15 493/779] usb: dwc3: core: Do not perform GCTL_CORE_SOFTRESET during bootup Date: Mon, 15 Aug 2022 20:02:17 +0200 Message-Id: <20220815180358.345485471@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Rohith Kollalsi [ Upstream commit 07903626d98853e605fe63e5ce149f1b7314bbea ] 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 Link: https://lore.kernel.org/r/20220714045625.20377-1-quic_rkollals@quicinc.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 8adb26599797..cfac5503aa66 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 not set, there's no role switching. + * Only perform GCTL.CoreSoftReset when there's DRD role switching. + */ + 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.35.1