Linux USB
 help / color / mirror / Atom feed
* [PATCH] xhci: Reset controller on xhci shutdown
@ 2026-10-01 22:25 wenxiong
  2026-10-01 22:40 ` Mathias Nyman
  2026-10-02  8:29 ` Michal Pecio
  0 siblings, 2 replies; 9+ messages in thread
From: wenxiong @ 2026-10-01 22:25 UTC (permalink / raw)
  To: mathias.nyman, gregkh
  Cc: linux-usb, linux-kernel, stable, wenxiong, Wen Xiong, Brian King,
	Samuel Mendoza-Jonas, Joel Stanley

From: Wen Xiong <wenxiong@linux.ibm.com>

Fixes kexec boot. Without a hard reset, some USB chips will fail to
initialize in a kexec booted kernel.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Wen Xiong <wenxiong@linux.ibm.com>
---
 drivers/usb/host/xhci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index a9e47e178c28..364bd61a4bd7 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -781,6 +781,9 @@ void xhci_shutdown(struct usb_hcd *hcd)
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
 			"xhci_shutdown completed - status = %x",
 			readl(&xhci->op_regs->status));
+
+	/* TI XHCI controllers do not come back after kexec without this hack */
+	pci_reset_function_locked(to_pci_dev(hcd->self.sysdev));
 }
 EXPORT_SYMBOL_GPL(xhci_shutdown);
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] xhci: Reset controller on xhci shutdown
  2026-10-01 22:25 [PATCH] xhci: Reset controller on xhci shutdown wenxiong
@ 2026-10-01 22:40 ` Mathias Nyman
  2026-10-02 14:08   ` Wen Xiong
  2026-10-02  8:29 ` Michal Pecio
  1 sibling, 1 reply; 9+ messages in thread
From: Mathias Nyman @ 2026-10-01 22:40 UTC (permalink / raw)
  To: wenxiong, mathias.nyman, gregkh
  Cc: linux-usb, linux-kernel, stable, wenxiong, Brian King,
	Samuel Mendoza-Jonas, Joel Stanley

Hi

On 10/2/26 01:25, wenxiong@linux.ibm.com wrote:
> From: Wen Xiong <wenxiong@linux.ibm.com>
> 
> Fixes kexec boot. Without a hard reset, some USB chips will fail to
> initialize in a kexec booted kernel.
> 
> Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> Signed-off-by: Wen Xiong <wenxiong@linux.ibm.com>
> ---
>   drivers/usb/host/xhci.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index a9e47e178c28..364bd61a4bd7 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -781,6 +781,9 @@ void xhci_shutdown(struct usb_hcd *hcd)
>   	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
>   			"xhci_shutdown completed - status = %x",
>   			readl(&xhci->op_regs->status));
> +
> +	/* TI XHCI controllers do not come back after kexec without this hack */
> +	pci_reset_function_locked(to_pci_dev(hcd->self.sysdev));
>   }
>   EXPORT_SYMBOL_GPL(xhci_shutdown);
>   

Should be added to xhci-pci.c: xhci_pci_shutdown() instead.

Probably also limited to that specific TI xHC controller

Thanks
Mathias


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xhci: Reset controller on xhci shutdown
  2026-10-01 22:25 [PATCH] xhci: Reset controller on xhci shutdown wenxiong
  2026-10-01 22:40 ` Mathias Nyman
@ 2026-10-02  8:29 ` Michal Pecio
  2026-10-02 14:05   ` Wen Xiong
  1 sibling, 1 reply; 9+ messages in thread
From: Michal Pecio @ 2026-10-02  8:29 UTC (permalink / raw)
  To: wenxiong
  Cc: mathias.nyman, gregkh, linux-usb, linux-kernel, stable, wenxiong,
	Brian King, Samuel Mendoza-Jonas, Joel Stanley

On Thu,  1 Oct 2026 18:25:27 -0400, wenxiong@linux.ibm.com wrote:
> From: Wen Xiong <wenxiong@linux.ibm.com>
> 
> Fixes kexec boot. Without a hard reset, some USB chips will fail to
> initialize in a kexec booted kernel.

What exactly happens after kexec?
Why a PCI reset in particular?
Are we sure it's not a bug elsewhere?

Regards,
Michal

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xhci: Reset controller on xhci shutdown
  2026-10-02  8:29 ` Michal Pecio
@ 2026-10-02 14:05   ` Wen Xiong
  2026-10-02 14:18     ` Michal Pecio
  0 siblings, 1 reply; 9+ messages in thread
From: Wen Xiong @ 2026-10-02 14:05 UTC (permalink / raw)
  To: Michal Pecio
  Cc: mathias.nyman, gregkh, linux-usb, linux-kernel, stable, wenxiong,
	Brian King, Samuel Mendoza-Jonas, Joel Stanley

On 2026-10-02 03:29, Michal Pecio wrote:
> What exactly happens after kexec?
> Why a PCI reset in particular?
> Are we sure it's not a bug elsewhere?
> 
After executing a kexec boots on a bare metal machine, the USB 
controller disappeared.
With a PCI reset, the USB controller is showed up after a kexec kernel.

Thanks,
Wendy

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xhci: Reset controller on xhci shutdown
  2026-10-01 22:40 ` Mathias Nyman
@ 2026-10-02 14:08   ` Wen Xiong
  0 siblings, 0 replies; 9+ messages in thread
From: Wen Xiong @ 2026-10-02 14:08 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: mathias.nyman, gregkh, linux-usb, linux-kernel, stable, wenxiong,
	Brian King, Samuel Mendoza-Jonas, Joel Stanley


> Should be added to xhci-pci.c: xhci_pci_shutdown() instead.
> 
> Probably also limited to that specific TI xHC controller
> 
Hi Mathias,

I will try that.

Thanks,
Wendy

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xhci: Reset controller on xhci shutdown
  2026-10-02 14:05   ` Wen Xiong
@ 2026-10-02 14:18     ` Michal Pecio
  2026-10-05 13:01       ` Wen Xiong
  0 siblings, 1 reply; 9+ messages in thread
From: Michal Pecio @ 2026-10-02 14:18 UTC (permalink / raw)
  To: Wen Xiong
  Cc: mathias.nyman, gregkh, linux-usb, linux-kernel, stable, wenxiong,
	Brian King, Samuel Mendoza-Jonas, Joel Stanley

On Fri, 02 Oct 2026 09:05:36 -0500, Wen Xiong wrote:
> On 2026-10-02 03:29, Michal Pecio wrote:
> > What exactly happens after kexec?
> > Why a PCI reset in particular?
> > Are we sure it's not a bug elsewhere?
> >   
> After executing a kexec boots on a bare metal machine, the USB 
> controller disappeared.

Sure, but what does it mean exactly?
Not even showing up in lspci output?

Is this our problem and not PCI subsystem's?
Are we sure it's not a bug elsewhere?

(Last time somebody reported issues with kexec,
it turned out to be an obscure Intel IOMMU bug).

Regards,
Michal

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xhci: Reset controller on xhci shutdown
  2026-10-02 14:18     ` Michal Pecio
@ 2026-10-05 13:01       ` Wen Xiong
  2026-10-06 10:55         ` Michal Pecio
  0 siblings, 1 reply; 9+ messages in thread
From: Wen Xiong @ 2026-10-05 13:01 UTC (permalink / raw)
  To: Michal Pecio
  Cc: mathias.nyman, gregkh, linux-usb, linux-kernel, stable, wenxiong,
	Brian King, Samuel Mendoza-Jonas, Joel Stanley


> Sure, but what does it mean exactly?
> Not even showing up in lspci output?

When executing "kexec -e", saw the error:
xhci_hcd 0005:01:00.0: Host halt failed. -110

USB device is still showed up in lspci but lsusb didn't show any
USB devices.
  #lspci|grep USB
0005:01:00.0 USB controller: Texas Instruments TUSB73x0 SuperSpeed USB 
3.0 xHCI Host Controller (rev 02)
[root@localhost ~]# lsusb

looks we saw a frozen USB subsystem during suspend/shutdown.

> Is this our problem and not PCI subsystem's?
> Are we sure it's not a bug elsewhere?
> 
> (Last time somebody reported issues with kexec,
> it turned out to be an obscure Intel IOMMU bug).

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xhci: Reset controller on xhci shutdown
  2026-10-05 13:01       ` Wen Xiong
@ 2026-10-06 10:55         ` Michal Pecio
  2026-10-14 20:32           ` Wen Xiong
  0 siblings, 1 reply; 9+ messages in thread
From: Michal Pecio @ 2026-10-06 10:55 UTC (permalink / raw)
  To: Wen Xiong
  Cc: mathias.nyman, gregkh, linux-usb, linux-kernel, stable, wenxiong,
	Brian King, Samuel Mendoza-Jonas, Joel Stanley

On Mon, 05 Oct 2026 08:01:46 -0500, Wen Xiong wrote:
> When executing "kexec -e", saw the error:
> xhci_hcd 0005:01:00.0: Host halt failed. -110

That's interesting, because we call xhci_halt() in xhci_shutdown().
So the xHC should already be halted before the new kernel boots and
then xhci_halt() should succeed immediately.

It seems unlikely that anything restarts the xHC (or is there a FW
involved?), so either this TI chip reacts badly to trying to halt
it again or the first halt (befor kexec) already fails, or perhaps
something is broken outside xhci_hcd.

Are you able to capture the original kernel's dmesg (through serial,
netconsole, etc) and see if the same "Host halt failed" is there?

And if you enable dynamic debug before kexec,

  echo 'module xhci_hcd +p' >/proc/dynamic_debug/control

what's printed by the debug message at the end of xhci_shutdown()?

Do you also get errors from quirk_usb_handoff_xhci() by any chance?

Regards,
Michal

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xhci: Reset controller on xhci shutdown
  2026-10-06 10:55         ` Michal Pecio
@ 2026-10-14 20:32           ` Wen Xiong
  0 siblings, 0 replies; 9+ messages in thread
From: Wen Xiong @ 2026-10-14 20:32 UTC (permalink / raw)
  To: Michal Pecio
  Cc: mathias.nyman, gregkh, linux-usb, linux-kernel, stable, wenxiong,
	Brian King, Samuel Mendoza-Jonas, Joel Stanley

On 2026-10-06 05:55, Michal Pecio wrote:
> Are you able to capture the original kernel's dmesg (through serial,
> netconsole, etc) and see if the same "Host halt failed" is there?
> 
Below is xhci messages after executing a kexec kernel. This is dmesg for 
kexec kernel.
[root@ltc-boston11 ~]# dmesg|grep xhci
[    1.085853] xhci_hcd 0005:01:00.0: xHCI Host Controller
[    1.085992] xhci_hcd 0005:01:00.0: new USB bus registered, assigned 
bus number 1
[    1.144472] xhci_hcd 0005:01:00.0: Host halt failed, -110
[    1.144518] xhci_hcd 0005:01:00.0: can't setup: -110
[    1.144571] xhci_hcd 0005:01:00.0: USB bus 1 deregistered
[    1.144778] xhci_hcd 0005:01:00.0: init 0005:01:00.0 fail, -110
[    1.144842] xhci_hcd 0005:01:00.0: probe with driver xhci_hcd failed 
with error -110

This is the reason why we can't see usb devices after a kexec kernel.

With the patch,
  #dmesg|grep xhci
[    0.859562] xhci_hcd 0005:01:00.0: xHCI Host Controller
[    0.859670] xhci_hcd 0005:01:00.0: new USB bus registered, assigned 
bus number 1
[    0.859797] xhci_hcd 0005:01:00.0: iommu: 64-bit OK but direct DMA is 
limited by 0
[    0.859858] xhci_hcd 0005:01:00.0: iommu: 64-bit OK but direct DMA is 
limited by 0
[    0.859982] xhci_hcd 0005:01:00.0: hcc params 0x0270f06d hci version 
0x96 quirks 0x0000000004000000
[    0.860614] xhci_hcd 0005:01:00.0: xHCI Host Controller
[    0.860719] xhci_hcd 0005:01:00.0: new USB bus registered, assigned 
bus number 2
[    0.860770] xhci_hcd 0005:01:00.0: Host supports USB 3.0 SuperSpeed
[    0.861091] usb usb1: Manufacturer: Linux 7.3.0-rc6-usb-gbatra+ 
xhci-hcd
[    0.862130] usb usb2: Manufacturer: Linux 7.3.0-rc6-usb-gbatra+ 
xhci-hcd
[    1.127210] usb 1-3: new high-speed USB device number 2 using 
xhci_hcd
[    1.407320] usb 2-2: new SuperSpeed USB device number 2 using 
xhci_hcd
[    1.556759] usb 1-4: new high-speed USB device number 3 using 
xhci_hcd
[    1.806902] usb 1-3.1: new low-speed USB device number 4 using 
xhci_hcd

#[root@ltc-boston11 ~]# lsusb
Bus 002 Device 002: ID 18a5:0252 Verbatim, Ltd
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 0451:80ff Texas Instruments, Inc.
Bus 001 Device 004: ID 0557:2419 ATEN International Co., Ltd Virtual 
mouse/keyboard device
Bus 001 Device 002: ID 0557:7000 ATEN International Co., Ltd Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub



> And if you enable dynamic debug before kexec,
> 
>   echo 'module xhci_hcd +p' >/proc/dynamic_debug/control
> 
> what's printed by the debug message at the end of xhci_shutdown()?
> 
> Do you also get errors from quirk_usb_handoff_xhci() by any chance?
> 
After executing a kexec kernel, is the control setting lost?
I didn't see much useful information in control after a kexec kernel.

Probably we can resubmit the patch with mathias's suggestion.

Thanks,
Wendy

T

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-10-14 20:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-01 22:25 [PATCH] xhci: Reset controller on xhci shutdown wenxiong
2026-10-01 22:40 ` Mathias Nyman
2026-10-02 14:08   ` Wen Xiong
2026-10-02  8:29 ` Michal Pecio
2026-10-02 14:05   ` Wen Xiong
2026-10-02 14:18     ` Michal Pecio
2026-10-05 13:01       ` Wen Xiong
2026-10-06 10:55         ` Michal Pecio
2026-10-14 20:32           ` Wen Xiong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox