From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FCB6212F03; Tue, 12 Nov 2024 10:31:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731407468; cv=none; b=uLeXx1gTBRSVTwmlAU/6fDCwPkxgqJrE4JqvSmLivrhN9BPv8cZYmYZ36UsZBZI70BSldF3UPxcOhcyV+RaxFzyuKQhutwqAdNbQQM8KNQX1q+4I3yzY4Hb6kKbyU+rfn5rneBf0eVa1mPuNoeNDtmq7Tv9pYf9LcAKOzYJndlg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731407468; c=relaxed/simple; bh=5SOgaQgdSX5k6M6VzCKe9hyjAkho9CIY3zYGqVuVLb0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vf5iFqeW1EaN9md8GcpH2jTDmEK1qKA4MoNlwJ1Ow/PylwRB4z9mztoN16eIByWxP4sX48A6uzq/SOFg6h2gm3qX9riyP8xSZQnscXDwu75jUnS9OrWqL5ER7mQ6Qyn496jGLeQSPFJ/p6TRTgLJ0KnofT74s3SiE51SDUeOJ1w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=k2cOvmE7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="k2cOvmE7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1D00C4CECD; Tue, 12 Nov 2024 10:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1731407468; bh=5SOgaQgdSX5k6M6VzCKe9hyjAkho9CIY3zYGqVuVLb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2cOvmE7b6lJjV0tz93YK0hg8VRhTqXL5+7cJPWG8QsEX/4bN1AE1mej8nnQT6c2T CLPfs9UZkIojcaryBqdozYZvHhOn5u/4XofyRIJZgeydxP6uN2+d3POKjVd/yWVgyM e4PWgnWOfrPH0j98eNspGiA4Ia2OT487A1rxLN8A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, William McVicker , Roger Quadros , Thinh Nguyen Subject: [PATCH 6.1 85/98] usb: dwc3: fix fault at system suspend if device was already runtime suspended Date: Tue, 12 Nov 2024 11:21:40 +0100 Message-ID: <20241112101847.486580805@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112101844.263449965@linuxfoundation.org> References: <20241112101844.263449965@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Roger Quadros commit 9cfb31e4c89d200d8ab7cb1e0bb9e6e8d621ca0b upstream. If the device was already runtime suspended then during system suspend we cannot access the device registers else it will crash. Also we cannot access any registers after dwc3_core_exit() on some platforms so move the dwc3_enable_susphy() call to the top. Cc: stable@vger.kernel.org # v5.15+ Reported-by: William McVicker Closes: https://lore.kernel.org/all/ZyVfcUuPq56R2m1Y@google.com Fixes: 705e3ce37bcc ("usb: dwc3: core: Fix system suspend on TI AM62 platforms") Signed-off-by: Roger Quadros Acked-by: Thinh Nguyen Tested-by: Will McVicker Link: https://lore.kernel.org/r/20241104-am62-lpm-usb-fix-v1-1-e93df73a4f0d@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/core.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -2131,10 +2131,18 @@ static int dwc3_suspend_common(struct dw { u32 reg; - dwc->susphy_state = (dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)) & - DWC3_GUSB2PHYCFG_SUSPHY) || - (dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)) & - DWC3_GUSB3PIPECTL_SUSPHY); + if (!pm_runtime_suspended(dwc->dev) && !PMSG_IS_AUTO(msg)) { + dwc->susphy_state = (dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)) & + DWC3_GUSB2PHYCFG_SUSPHY) || + (dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)) & + DWC3_GUSB3PIPECTL_SUSPHY); + /* + * TI AM62 platform requires SUSPHY to be + * enabled for system suspend to work. + */ + if (!dwc->susphy_state) + dwc3_enable_susphy(dwc, true); + } switch (dwc->current_dr_role) { case DWC3_GCTL_PRTCAP_DEVICE: @@ -2183,15 +2191,6 @@ static int dwc3_suspend_common(struct dw break; } - if (!PMSG_IS_AUTO(msg)) { - /* - * TI AM62 platform requires SUSPHY to be - * enabled for system suspend to work. - */ - if (!dwc->susphy_state) - dwc3_enable_susphy(dwc, true); - } - return 0; }