All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Pecio <michal.pecio@gmail.com>
To: Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Paul Menzel <pmenzel@molgen.mpg.de>,
	Wen Xiong <wenxiong@linux.ibm.com>
Cc: linux-usb@vger.kernel.org, linux-pci@vger.kernel.org
Subject: [RFC PATCH] usb: pci-quirks: Reset stubborn xHCI controllers
Date: Thu, 3 Dec 2026 19:45:30 +0100	[thread overview]
Message-ID: <20261203194530.5d382b9e.michal.pecio@gmail.com> (raw)

TUSB7340 has been reported to get stuck and refuse to halt after
kexec; at least in one case problems turned out to begin already
in xhci_shutdown() routine before kexec. Issuing a PCI function
reset to the chip was reported to restore operation.

I obtained a PCIe card with TUSB7340 and found that problems are
not limited to kexec - ordinary reboot also triggers halt error
(seen over netconsole) if a busy device like keyboard (opened by
the kernel's VT) or a network interface (brought up) is present.
Some chips don't seem to appreciate halting mid-operation.

The issue is also triggered by my BIOS if a keyboard is connected.
The BIOS doesn't halt xHCI chips used for legacy USB support at
all (USBSTS shows EINT | PCD), and when the booting kernel tries
to halt a TUSB7340, the chip locks up as usual.

All chips also get IOMMU faults on USB port connection if I patch
quirk_usb_handoff_xhci() not to halt them after the handoff and
blacklist xhci-hcd, but faulting addresses belong to a reserved
area so that's OK, at least in my BIOS. Good luck.

All things considered, it seems that when an xHCI chip is in the
"running" state (power-on default is "halted") and it refuses to
stop, it's better to take this seriously and give it a good kick.
This allows my TUSB7340 to work even after being used by BIOS:

pci 0000:08:00.0: xHCI HW did not halt within 32000 usec status = 0x18
pci 0000:08:00.0: Function reset, status 0
pci 0000:08:00.0: quirk_usb_early_handoff+0x0/0x680 took 138097 usecs
xhci_hcd 0000:08:00.0: xHCI Host Controller

Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
Link: https://lore.kernel.org/linux-usb/fb68e15d-b8f2-42ac-aa65-0d9fedcfcdbd@molgen.mpg.de/
Reported-by: Wen Xiong <wenxiong@linux.ibm.com>
Link: https://lore.kernel.org/linux-usb/20261001222527.11742-1-wenxiong@linux.ibm.com/
Suggested-by: Wen Xiong <wenxiong@linux.ibm.com>
Signed-off-by: Michal Pecio <michal.pecio@gmail.com>
---
 drivers/usb/host/pci-quirks.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 1dbfd697a582..ba30ac74ab30 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -1253,10 +1253,14 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
 	timeout = handshake(op_reg_base + XHCI_STS_OFFSET, XHCI_STS_HALT, 1,
 			XHCI_MAX_HALT_USEC, 125);
 	if (timeout) {
+		int ret;
+
 		val = readl(op_reg_base + XHCI_STS_OFFSET);
 		dev_warn(&pdev->dev,
 			 "xHCI HW did not halt within %d usec status = 0x%x\n",
 			 XHCI_MAX_HALT_USEC, val);
+		ret = pci_reset_function(pdev);
+		dev_warn(&pdev->dev, "Function reset, status %d\n", ret);
 	}
 
 iounmap:
-- 
2.48.1

                 reply	other threads:[~2026-12-03 18:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203194530.5d382b9e.michal.pecio@gmail.com \
    --to=michal.pecio@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=pmenzel@molgen.mpg.de \
    --cc=wenxiong@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.