usb: host: xhci-tegra: Handle PHY failures while exiting ELPG
Subsystems (3)
PATCH 1/1 usb: host: xhci-tegra: Handle PHY failures while exiting ELPG
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 <[email protected]>
--- drivers/usb/host/xhci-tegra.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-tegra.c +14 -4
@@ -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 ;
Signature · 1 line
2.50.1 (Apple Git-155)