Skip to content

Commit ebcf778

Browse files
Jim Linjfvogel
authored andcommitted
usb: host: tegra: Prevent host controller crash when OTG port is used
commit 732f35c upstream. When a USB device is connected to the OTG port, the tegra_xhci_id_work() routine transitions the PHY to host mode and calls xhci_hub_control() with the SetPortFeature command to enable port power. In certain cases, the XHCI controller may be in a low-power state when this operation occurs. If xhci_hub_control() is invoked while the controller is suspended, the PORTSC register may return 0xFFFFFFFF, indicating a read failure. This causes xhci_hc_died() to be triggered, leading to host controller shutdown. Example backtrace: [ 105.445736] Workqueue: events tegra_xhci_id_work [ 105.445747] dump_backtrace+0x0/0x1e8 [ 105.445759] xhci_hc_died.part.48+0x40/0x270 [ 105.445769] tegra_xhci_set_port_power+0xc0/0x240 [ 105.445774] tegra_xhci_id_work+0x130/0x240 To prevent this, ensure the controller is fully resumed before interacting with hardware registers by calling pm_runtime_get_sync() prior to the host mode transition and xhci_hub_control(). Fixes: f836e78 ("usb: xhci-tegra: Add OTG support") Cc: stable <[email protected]> Signed-off-by: Jim Lin <[email protected]> Signed-off-by: Wayne Chang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 08eca452a6489e9a414abbaa14c7b14a784cac05) Signed-off-by: Jack Vogel <[email protected]>
1 parent c2e7c1f commit ebcf778

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/usb/host/xhci-tegra.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,7 @@ static void tegra_xhci_id_work(struct work_struct *work)
13631363
tegra->otg_usb3_port = tegra_xusb_padctl_get_usb3_companion(tegra->padctl,
13641364
tegra->otg_usb2_port);
13651365

1366+
pm_runtime_get_sync(tegra->dev);
13661367
if (tegra->host_mode) {
13671368
/* switch to host mode */
13681369
if (tegra->otg_usb3_port >= 0) {
@@ -1392,13 +1393,15 @@ static void tegra_xhci_id_work(struct work_struct *work)
13921393
}
13931394

13941395
tegra_xhci_set_port_power(tegra, true, true);
1396+
pm_runtime_mark_last_busy(tegra->dev);
13951397

13961398
} else {
13971399
if (tegra->otg_usb3_port >= 0)
13981400
tegra_xhci_set_port_power(tegra, false, false);
13991401

14001402
tegra_xhci_set_port_power(tegra, true, false);
14011403
}
1404+
pm_runtime_put_autosuspend(tegra->dev);
14021405
}
14031406

14041407
#if IS_ENABLED(CONFIG_PM) || IS_ENABLED(CONFIG_PM_SLEEP)

0 commit comments

Comments
 (0)