From patchwork Tue Jun 27 16:20:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13294804 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 701CAEB64D9 for ; Tue, 27 Jun 2023 16:32:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232206AbjF0Qce (ORCPT ); Tue, 27 Jun 2023 12:32:34 -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 Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 Acked-by: Thinh Nguyen --- 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);