* [PATCH] usb: host: xhci-tegra: Handle PHY failures while exiting ELPG
@ 2026-09-06 3:41 Pengpeng Hou
0 siblings, 0 replies; only message in thread
From: Pengpeng Hou @ 2026-09-06 3:41 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman
Cc: Pengpeng Hou, Thierry Reding, Jonathan Hunter, JC Kuo, linux-usb,
linux-tegra, linux-kernel
tegra_xusb_exit_elpg() ignores phy_init() and phy_power_on() failures
and continues to restore firmware and xHCI state.
Stop at the first failed PHY, undo a successful init for that PHY when
power-on fails, and unwind only the previously enabled PHYs in reverse
order before using the existing partition and clock cleanup.
The issue was found by our static-analysis tool and manually reviewed.
Fixes: 971ee247060d ("usb: xhci: tegra: Enable ELPG for runtime/system PM")
Assisted-by: gpt 5
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
---
drivers/usb/host/xhci-tegra.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index 6f235d1e117e..7b7cf22a577d 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -2328,10 +2328,18 @@ static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool is_auto_resume)
if (!tegra->phys[i])
continue;
- if (!wakeup)
- phy_init(tegra->phys[i]);
+ if (!wakeup) {
+ err = phy_init(tegra->phys[i]);
+ if (err)
+ goto disable_enabled_phys;
+ }
- phy_power_on(tegra->phys[i]);
+ err = phy_power_on(tegra->phys[i]);
+ if (err) {
+ if (!wakeup)
+ phy_exit(tegra->phys[i]);
+ goto disable_enabled_phys;
+ }
}
if (tegra->suspended)
tegra_xhci_program_utmi_power_lp0_exit(tegra);
@@ -2367,7 +2375,9 @@ static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool is_auto_resume)
goto out;
disable_phy:
- for (i = 0; i < tegra->num_phys; i++) {
+ i = tegra->num_phys;
+disable_enabled_phys:
+ while (i--) {
if (!tegra->phys[i])
continue;
--
2.50.1 (Apple Git-155)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-06 3:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-06 3:41 [PATCH] usb: host: xhci-tegra: Handle PHY failures while exiting ELPG Pengpeng Hou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®