Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3256418rwb; Mon, 15 Aug 2022 22:28:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR5JDajyFdL+JcIWyOzmsq12vdeqdXLlYaWoYXDhVPGQea1fafgFxnVIPN6L+vV6urWkk0jr X-Received: by 2002:a05:6a00:2906:b0:52a:bc7f:f801 with SMTP id cg6-20020a056a00290600b0052abc7ff801mr20194803pfb.49.1660627712238; Mon, 15 Aug 2022 22:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660627712; cv=none; d=google.com; s=arc-20160816; b=pO0zp2TfDXje2beoVuA+ScUEKN7KAjl3hUSp9wQAOn5MLfoi3v0mBoL7ouuKdRtCAw tTu+ishJJ0ewU3I4Uc2oUg0KQX7jLHPu1hGoVQoCWsq2FduGxREhXiHcb/vaAcxN0W5p c9ym66qTF1Tf1IY/PkbNgdX7l9JTnETpY0Ii+xpY6GQ/rs3hoXQDV+HOWj7AnvzAJTTt 4r7ykJGFVg3masEAKyX24+0zmxs+YWsXVU74ka+TmpIuniw53hz6649cbme84n6lRfSI yM2zD+oFRezutAcnQjGu9HHENaMR9A5UGigYVx1Sh8GJxyvgBdnH5WaT4v9jYuiPooBh Rk1w== 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=QeET80yT3akFD//fZMBWsykUSUucsNH2hLPYGgA2BlQ=; b=KL47RgvmhTJGYaR48KNGHekWbpChejgimfonZnfGrrgmTL5AA5bzUWbHrYcMMMlI/1 BLrhemYAExAFTZ0hwzsCGJCJA/Gu1ES/XnMVZzPRtH1QwpCRT9Vgg9Xbfb1XUGZ1Ymyt 1Ji1pUTAv/oP6olx8ESFExdIIfyDPugBG/VTc9jJDCNaZdSiNYDHn6NaXSKIs29pumCq l/PiBUMYFbl9XBG1qIeRYR5UJz/LhgFwJj23nCjagY5+ZZerpaYNxUNHIq4vYAPnBzZk lD1/fKtMKOrXf80K1og0A0VnZoDHW0ADTFOdjTpI9I0/LNEUzzS5N+brdrZrTK43uNUT cEkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gGIyiEWd; 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 nu10-20020a17090b1b0a00b001f7299d9c0fsi15167269pjb.59.2022.08.15.22.28.22; Mon, 15 Aug 2022 22:28:32 -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=gGIyiEWd; 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 S231905AbiHPEnQ (ORCPT + 99 others); Tue, 16 Aug 2022 00:43:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231879AbiHPEkc (ORCPT ); Tue, 16 Aug 2022 00:40:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB864D1E18; Mon, 15 Aug 2022 13:33:20 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7BA29B8113E; Mon, 15 Aug 2022 20:33:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C34DCC433D6; Mon, 15 Aug 2022 20:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595587; bh=lqFeD8MAkRoKJduKvTpl2VoSr2nYJ07xNk3pjF9zMZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gGIyiEWd0VBU9TE169xc02sDK6NjW6WJDg4SzbWB5vJfmQ/mTRVt54B6mJ0vlZDfw yAPfV/e5ajsHRnDVZ3VEQV7bdeAjO4Zu4B662AEeF/PqDrwEHy39TnJQ2Wvcw+W28J O31RbDsRy4/RbFoVgOQXAqx3pVl9YjEor7YS0ncM= 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.19 0811/1157] usb: dwc3: core: Do not perform GCTL_CORE_SOFTRESET during bootup Date: Mon, 15 Aug 2022 20:02:47 +0200 Message-Id: <20220815180511.945558529@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 4c753cc0fa61..ba2fa91be1d6 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