FAILED: patch "[PATCH] xhci: tegra: Fix ghost USB device on dual-role port unplug" failed to apply to 6.1-stable tree
Subsystems (4)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 5a4c828b8b29b47534814ade26d9aee09d5101fc
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026060434-finlike-uncombed-dc4e@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 5a4c828b8b29b47534814ade26d9aee09d5101fc Mon Sep 17 00:00:00 2001
From: Wei-Cheng Chen <[email protected]>
Date: Tue, 5 May 2026 19:26:30 +0800
Subject: [PATCH] xhci: tegra: Fix ghost USB device on dual-role port unplug
When a USB device is unplugged from the dual-role port, the device-mode path in tegra_xhci_id_work() explicitly clears both SS and HS port power via direct hub_control ClearPortFeature(POWER) calls. This preempts the xHCI controller's normal disconnect processing -- PORT_CSC is never generated, the USB core never sees the disconnect, and the device remains in its internal tree as a ghost visible in lsusb.
Add an otg_set_port_power flag to control whether the dual-role switch path performs explicit port power management. SoCs that need it (Tegra124 / Tegra210 / Tegra186) set the flag; later SoCs (Tegra194 and beyond) rely on the PHY mode change to handle disconnect naturally and skip all port power calls.
Within the port power path, otg_reset_sspi additionally gates the SSPI reset sequence on host-mode entry for SoCs that require it.
Flags set per SoC:
Tegra124, Tegra186 -> otg_set_port_power Tegra210 -> otg_set_port_power, otg_reset_sspi Tegra194 and later -> (none)
drivers/usb/host/xhci-tegra.c +40 -31
@@ -247,6 +247,7 @@ struct tegra_xusb_soc {bool has_ipfs;bool lpm_support;bool otg_reset_sspi; +bool otg_set_port_power;bool has_bar2; };
@@ -1352,12 +1353,13 @@ static void tegra_xhci_id_work(struct work_struct *work)struct tegra_xusb_mbox_msg msg;struct phy *phy =tegra_xusb_get_phy (tegra,"usb2" , tegra->otg_usb2_port); +bool host_mode = tegra->host_mode;u32 status;int ret; -dev_dbg (tegra->dev,"host mode %s\n" ,str_on_off (tegra->host_mode)); +dev_dbg (tegra->dev,"host mode %s\n" ,str_on_off (host_mode)); -if (tegra->host_mode) +if (host_mode)phy_set_mode_ext (phy,PHY_MODE_USB_OTG ,USB_ROLE_HOST );else phy_set_mode_ext (phy,PHY_MODE_USB_OTG ,USB_ROLE_NONE );
@@ -1366,41 +1368,43 @@ static void tegra_xhci_id_work(struct work_struct *work) tegra->otg_usb2_port);pm_runtime_get_sync (tegra->dev); -if (tegra->host_mode) { -/* switch to host mode */ -if (tegra->otg_usb3_port >=0 ) { -if (tegra->soc->otg_reset_sspi) { -/* set PP=0 */ - tegra_xhci_hc_driver.hub_control ( - xhci->shared_hcd, GetPortStatus, -0 , tegra->otg_usb3_port+1 , - (char *) &status,sizeof (status)); -if (status &USB_SS_PORT_STAT_POWER ) -tegra_xhci_set_port_power (tegra, false, - false); +if (tegra->soc->otg_set_port_power) { +if (host_mode) { +/* switch to host mode */ +if (tegra->otg_usb3_port >=0 ) { +if (tegra->soc->otg_reset_sspi) { +/* set PP=0 */ + tegra_xhci_hc_driver.hub_control ( + xhci->shared_hcd, GetPortStatus, +0 , tegra->otg_usb3_port+1 , + (char *) &status,sizeof (status)); +if (status &USB_SS_PORT_STAT_POWER ) +tegra_xhci_set_port_power (tegra, false, + false); -/* reset OTG port SSPI */ - msg.cmd =MBOX_CMD_RESET_SSPI ; - msg.data = tegra->otg_usb3_port+1 ; +/* reset OTG port SSPI */ + msg.cmd =MBOX_CMD_RESET_SSPI ; + msg.data = tegra->otg_usb3_port+1 ; - ret =tegra_xusb_mbox_send (tegra, &msg); -if (ret <0 ) { -dev_info (tegra->dev, -"failed to RESET_SSPI %d\n" , - ret); + ret =tegra_xusb_mbox_send (tegra, &msg); +if (ret <0 ) { +dev_info (tegra->dev, +"failed to RESET_SSPI %d\n" , + ret); + } } + +tegra_xhci_set_port_power (tegra, false, true); } -tegra_xhci_set_port_power (tegra, false, true); +tegra_xhci_set_port_power (tegra, true, true); + + }else { +if (tegra->otg_usb3_port >=0 ) +tegra_xhci_set_port_power (tegra, false, false); + +tegra_xhci_set_port_power (tegra, true, false); } - -tegra_xhci_set_port_power (tegra, true, true); - - }else { -if (tegra->otg_usb3_port >=0 ) -tegra_xhci_set_port_power (tegra, false, false); - -tegra_xhci_set_port_power (tegra, true, false); }pm_runtime_put_autosuspend (tegra->dev); }
@@ -2553,6 +2557,7 @@ static const struct tegra_xusb_soc tegra124_soc = { .scale_ss_clock = true, .has_ipfs = true, .otg_reset_sspi = false, + .otg_set_port_power = true, .ops = &tegra124_ops, .mbox = { .cmd = 0xe4,
@@ -2593,6 +2598,7 @@ static const struct tegra_xusb_soc tegra210_soc = { .scale_ss_clock = false, .has_ipfs = true, .otg_reset_sspi = true, + .otg_set_port_power = true, .ops = &tegra124_ops, .mbox = { .cmd = 0xe4,
@@ -2640,6 +2646,7 @@ static const struct tegra_xusb_soc tegra186_soc = { .scale_ss_clock = false, .has_ipfs = false, .otg_reset_sspi = false, + .otg_set_port_power = true, .ops = &tegra124_ops, .mbox = { .cmd = 0xe4,
@@ -2673,6 +2680,7 @@ static const struct tegra_xusb_soc tegra194_soc = { .scale_ss_clock = false, .has_ipfs = false, .otg_reset_sspi = false, + .otg_set_port_power = false, .ops = &tegra124_ops, .mbox = { .cmd = 0x68,
@@ -2708,6 +2716,7 @@ static const struct tegra_xusb_soc tegra234_soc = { .scale_ss_clock = false, .has_ipfs = false, .otg_reset_sspi = false, + .otg_set_port_power = false, .ops = &tegra234_ops, .mbox = { .cmd = XUSB_BAR2_ARU_MBOX_CMD,
PATCH 1/1 xhci: tegra: Fix ghost USB device on dual-role port unplug
[ Upstream commit 5a4c828b8b29b47534814ade26d9aee09d5101fc ]
When a USB device is unplugged from the dual-role port, the device-mode path in tegra_xhci_id_work() explicitly clears both SS and HS port power via direct hub_control ClearPortFeature(POWER) calls. This preempts the xHCI controller's normal disconnect processing -- PORT_CSC is never generated, the USB core never sees the disconnect, and the device remains in its internal tree as a ghost visible in lsusb.
Add an otg_set_port_power flag to control whether the dual-role switch path performs explicit port power management. SoCs that need it (Tegra124 / Tegra210 / Tegra186) set the flag; later SoCs (Tegra194 and beyond) rely on the PHY mode change to handle disconnect naturally and skip all port power calls.
Within the port power path, otg_reset_sspi additionally gates the SSPI reset sequence on host-mode entry for SoCs that require it.
Flags set per SoC:
Tegra124, Tegra186 -> otg_set_port_power Tegra210 -> otg_set_port_power, otg_reset_sspi Tegra194 and later -> (none)
[ Backport to 6.1.y: keep the host-mode snapshot in the existing
tegra->lock section, retain pm_runtime_mark_last_busy() in the host port-power path, and omit the newer Tegra234 entry. ]
--- drivers/usb/host/xhci-tegra.c | 78 ++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 34 deletions(-)
drivers/usb/host/xhci-tegra.c +44 -34
@@ -210,6 +210,7 @@ struct tegra_xusb_soc {bool has_ipfs;bool lpm_support;bool otg_reset_sspi; +bool otg_set_port_power; };struct tegra_xusb_context {
@@ -1211,14 +1212,17 @@ static void tegra_xhci_id_work(struct work_struct *work)struct tegra_xusb_mbox_msg msg;struct phy *phy =tegra_xusb_get_phy (tegra,"usb2" , tegra->otg_usb2_port); +bool host_mode;u32 status;int ret; -dev_dbg (tegra->dev,"host mode %s\n" , tegra->host_mode ?"on" :"off" ); -mutex_lock (&tegra->lock); -if (tegra->host_mode) + host_mode = tegra->host_mode; + +dev_dbg (tegra->dev,"host mode %s\n" , host_mode ?"on" :"off" ); + +if (host_mode)phy_set_mode_ext (phy,PHY_MODE_USB_OTG ,USB_ROLE_HOST );else phy_set_mode_ext (phy,PHY_MODE_USB_OTG ,USB_ROLE_NONE );
@@ -1229,42 +1233,44 @@ static void tegra_xhci_id_work(struct work_struct *work) tegra->otg_usb2_port);pm_runtime_get_sync (tegra->dev); -if (tegra->host_mode) { -/* switch to host mode */ -if (tegra->otg_usb3_port >=0 ) { -if (tegra->soc->otg_reset_sspi) { -/* set PP=0 */ - tegra_xhci_hc_driver.hub_control ( - xhci->shared_hcd, GetPortStatus, -0 , tegra->otg_usb3_port+1 , - (char *) &status,sizeof (status)); -if (status &USB_SS_PORT_STAT_POWER ) -tegra_xhci_set_port_power (tegra, false, - false); - -/* reset OTG port SSPI */ - msg.cmd =MBOX_CMD_RESET_SSPI ; - msg.data = tegra->otg_usb3_port+1 ; - - ret =tegra_xusb_mbox_send (tegra, &msg); -if (ret <0 ) { -dev_info (tegra->dev, -"failed to RESET_SSPI %d\n" , - ret); +if (tegra->soc->otg_set_port_power) { +if (host_mode) { +/* switch to host mode */ +if (tegra->otg_usb3_port >=0 ) { +if (tegra->soc->otg_reset_sspi) { +/* set PP=0 */ + tegra_xhci_hc_driver.hub_control ( + xhci->shared_hcd, GetPortStatus, +0 , tegra->otg_usb3_port+1 , + (char *) &status,sizeof (status)); +if (status &USB_SS_PORT_STAT_POWER ) +tegra_xhci_set_port_power (tegra, false, + false); + +/* reset OTG port SSPI */ + msg.cmd =MBOX_CMD_RESET_SSPI ; + msg.data = tegra->otg_usb3_port+1 ; + + ret =tegra_xusb_mbox_send (tegra, &msg); +if (ret <0 ) { +dev_info (tegra->dev, +"failed to RESET_SSPI %d\n" , + ret); + } } - } -tegra_xhci_set_port_power (tegra, false, true); - } +tegra_xhci_set_port_power (tegra, false, true); + } -tegra_xhci_set_port_power (tegra, true, true); -pm_runtime_mark_last_busy (tegra->dev); +tegra_xhci_set_port_power (tegra, true, true); +pm_runtime_mark_last_busy (tegra->dev); - }else { -if (tegra->otg_usb3_port >=0 ) -tegra_xhci_set_port_power (tegra, false, false); + }else { +if (tegra->otg_usb3_port >=0 ) +tegra_xhci_set_port_power (tegra, false, false); -tegra_xhci_set_port_power (tegra, true, false); +tegra_xhci_set_port_power (tegra, true, false); + } }pm_runtime_put_autosuspend (tegra->dev); }
@@ -2289,6 +2295,7 @@ static const struct tegra_xusb_soc tegra124_soc = { .scale_ss_clock = true, .has_ipfs = true, .otg_reset_sspi = false, + .otg_set_port_power = true, .mbox = { .cmd = 0xe4, .data_in = 0xe8,
@@ -2325,6 +2332,7 @@ static const struct tegra_xusb_soc tegra210_soc = { .scale_ss_clock = false, .has_ipfs = true, .otg_reset_sspi = true, + .otg_set_port_power = true, .mbox = { .cmd = 0xe4, .data_in = 0xe8,
@@ -2366,6 +2374,7 @@ static const struct tegra_xusb_soc tegra186_soc = { .scale_ss_clock = false, .has_ipfs = false, .otg_reset_sspi = false, + .otg_set_port_power = true, .mbox = { .cmd = 0xe4, .data_in = 0xe8,
@@ -2397,6 +2406,7 @@ static const struct tegra_xusb_soc tegra194_soc = { .scale_ss_clock = false, .has_ipfs = false, .otg_reset_sspi = false, + .otg_set_port_power = false, .mbox = { .cmd = 0x68, .data_in = 0x6c,
Signature · 1 line
2.43.0
Re: [PATCH 6.1.y] xhci: tegra: Fix ghost USB device on dual-role port unplug
Quoted 1 line
[PATCH 6.1.y] xhci: tegra: Fix ghost USB device on dual-role port unplug
Queued for 6.1.y, thanks.
Signature · 2 lines
Thanks, Sasha