Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17981348rwd; Tue, 27 Jun 2023 09:56:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6eAtr5xv+/JwZC/xYU5Q7lGmA+t7nugq2/XQGKELh6LNnK9BjwgFfqbeqkGIXg+uqsITfJ X-Received: by 2002:a17:902:ea10:b0:1ad:e633:ee96 with SMTP id s16-20020a170902ea1000b001ade633ee96mr7457374plg.55.1687885016959; Tue, 27 Jun 2023 09:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687885016; cv=none; d=google.com; s=arc-20160816; b=XHwNiYlXalThNltQoAt2ibjDSuVyvdA79GLclthY62DRw4ViSUMla80bCRp1qxSO1U zOjXAJTP9tYCHf2wQjhyEefuG7bA7ItS48ssc1nUo0lDDTB3c2tHluvy49LF+Bh70suR Yd5+XD+iMB7CLYbI+tjmg7LZWPo2/QPLOGRtGFUuMAp8pYXRnmitbyTQ65a93QG6gjnC pIIyTzrcJyZ5ikKgZTdWfWqpIl3IqtZFuIIZTlooILJ/h98zJ6af9pwS4nB+1HRKM88c 6P6qOUNIG7Zg9ju+nj7i9uYxv14xAzxSdIOdrpZkBJriAezPFqfL1kelw8bMw3RvFCI0 pmZQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=WzxB8hrRdvUGRsp8pqfy6LDhl5XYJx35/hpgCPKTOzg=; fh=vo14NhicYp2C5q8eZJ8osVrnfIJeD333NQJOdx5owTw=; b=zZiYsBuIQlqqc+zvA+onSKLlB0f61TJwS/8DjYQWbC2hzj175zVTTH7Tcq+zaGDvwv NCly16PDRe+WPpOXynaeqKC7RyUszJOxMaPiWatkTdcc3YhF1GyHATZS3GqHPt13DlAZ wQV4VlOxh82+PwBr+V1oPiXcMtRs8wAoDnfeNYV0XxXcs2f4UeCJtwgJ/dlIvutJ4VcD 1ijbrbQMy5iKDDS1d9x186OKz1u7jKxHQFEGj6p8Ca/YyqPCSD0YS5int1ksPNq1HH3V qCaK3MD4Rnmj2c53NOc2QOhrJew7KspOBfmFhw060fzNg3P1wusPnT2KuI72gr5x/w/a ae0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jX3dBg74; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l11-20020a170902f68b00b001b06fa86af9si7773448plg.462.2023.06.27.09.56.44; Tue, 27 Jun 2023 09:56:56 -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=@kernel.org header.s=k20201202 header.b=jX3dBg74; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232578AbjF0Qcf (ORCPT + 99 others); Tue, 27 Jun 2023 12:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232157AbjF0Qbz (ORCPT ); Tue, 27 Jun 2023 12:31:55 -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 5A8A3359E; Tue, 27 Jun 2023 09:31:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C940F611DD; Tue, 27 Jun 2023 16:31:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35835C433CB; Tue, 27 Jun 2023 16:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687883503; bh=GJTR0fuq9BYrm0IoPMBtlqWndUVb8e5wV/QtxPR9vds=; h=From:To:Cc:Subject:Date:From; b=jX3dBg74rhvE6obyMgTC2O5DQXzvT3zGCWLUbE9iEDYUD0uUQgbqU2Ing/+JiTHtg bFYV0rXN/qU3rjtMYpoDWzh4McJXPqeFqxxPUzE7EVP6uV/1xn5XoD+Bsau9baRoPa B0k6ERoKzti4dXyNzbj42FbOj/hSZ7FUIf3Zruuhv21JzlkbfszPK0qWMsfcR6j1kt r67gk6BQsr19XlxiMg/I+R6f7GokpUY8ryb1I5R2Q/Cbtyro+Qit8cwMaVPiiASp7j sv3gwd9KdglLia6V7RfpRcU/vilB7OSOyQMsdhzXIocIefhfCgAqAbPMGrkhC+TB+w UCyXsXULDS7CQ== From: Jisheng Zhang To: Thinh Nguyen , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: dwc3: don't reset device side if dwc3 was configured as host-only Date: Wed, 28 Jun 2023 00:20:18 +0800 Message-Id: <20230627162018.739-1-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 Commit c4a5153e87fd ("usb: dwc3: core: Power-off core/PHYs on system_suspend in host mode") replaces check for HOST only dr_mode with current_dr_role. But during booting, the current_dr_role isn't initialized, thus the device side reset is always issued even if dwc3 was configured as host-only. What's more, on some platforms with host only dwc3, aways issuing device side reset by accessing device register block can cause kernel panic. Fixes: c4a5153e87fd ("usb: dwc3: core: Power-off core/PHYs on system_suspend in host mode") Signed-off-by: Jisheng Zhang --- drivers/usb/dwc3/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 7b2ce013cc5b..16d7a1d1cbfa 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -277,9 +277,9 @@ int dwc3_core_soft_reset(struct dwc3 *dwc) /* * We're resetting only the device side because, if we're in host mode, * XHCI driver will reset the host block. If dwc3 was configured for - * host-only mode, then we can return early. + * host-only mode or current role is host, then we can return early. */ - if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST) + if (dwc->dr_mode == USB_DR_MODE_HOST || dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST) return 0; reg = dwc3_readl(dwc->regs, DWC3_DCTL); -- 2.40.1