* [PATCH v6] usb: pci-quirks: always assert xHCI OS ownership
@ 2026-10-30 19:36 Rishabh Jain
2026-10-30 19:44 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Rishabh Jain @ 2026-10-30 19:36 UTC (permalink / raw)
To: Mathias Nyman
Cc: Greg Kroah-Hartman, Mario Limonciello, Michal Pecio, McKenna Fan,
Quinn Schive, Bruno Filipe, Maciej Zonski, linux-usb,
linux-kernel, stable, Rishabh Jain
The xHCI ownership protocol requires the OS driver to assert the HC OS
Owned semaphore before using the host controller, then wait for HC BIOS
Owned to clear if firmware owns it.
quirk_usb_handoff_xhci() currently asserts OS Owned only when BIOS Owned
is already set. If firmware leaves BIOS Owned clear, Linux uses the xHC
while both ownership semaphores remain clear.
The timeout fallback also clears BIOS Owned using the original register
value, which can clear OS Owned at the same time.
On an AMD PROM21 xHCI controller (1022:43fc), this caused every S3
resume to terminate Controller Restore State with USBSTS 0x401. Linux
then reset the host controller, both root hubs and the USB Bluetooth
adapter.
The controller entered resume ready and halted with USBSTS 0x1.
Endpoint state, 100 ms save/restore delays, scratchpads, the DCBAA,
device contexts and command, event and transfer rings were verified not
to cause the restore error.
Across four S3 cycles, asserting only HC OS Owned changed USBLEGSUP from
0x00000801 to 0x01000801 and eliminated the restore failure. Testing
included the unmodified 7.1.8-ogc1.1.fc44.x86_64 distribution kernel
using a test module that set the HC OS Owned semaphore. The same test
was repeated after review with the same result. Clearing USBLEGCTLSTS
was independently verified to be unnecessary.
Always assert OS Owned for controllers using the standard xHCI handoff,
and leave the existing TI/Renesas forced handoff unchanged. Keep OS
Owned asserted after the standard handoff, including when forcing BIOS
Owned clear after a timeout, to prevent firmware from reclaiming the
controller during subsequent suspends.
Fixes: 66d4eadd8d06 ("USB: xhci: BIOS handoff and HW initialization.")
Cc: stable@vger.kernel.org
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Tested-by: McKenna Fan <blue_sun@tuta.io>
Tested-by: Quinn Schive <quinnschive@hotmail.com>
Tested-by: Bruno Filipe <bmilreu@gmail.com>
Tested-by: Maciej Zonski <me@zonni.pl>
Signed-off-by: Rishabh Jain <rishabh.jain1198@gmail.com>
---
Sorry for threading the earlier revisions together.
Changes in v6:
- Rebase onto current Linus mainline; no code changes from v5.
- Collect the Reviewed-by and Tested-by tags.
- Send as a new thread.
- Move AI disclosure here following removal of the Assisted-by tag.
An LLM assisted with the investigation, patch, and submission text.
v5:
https://lore.kernel.org/r/178832755831.50581.1058201741431375556@gmail.com/
drivers/usb/host/pci-quirks.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index f670e7aab984..1dbfd697a582 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -1195,10 +1195,11 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
&& pdev->device == 0x0014)) {
val = (val | XHCI_HC_OS_OWNED) & ~XHCI_HC_BIOS_OWNED;
writel(val, base + ext_cap_offset);
- }
-
- /* If the BIOS owns the HC, signal that the OS wants it, and wait */
- if (val & XHCI_HC_BIOS_OWNED) {
+ } else {
+ /*
+ * Perform the standard handoff and leave OS ownership set to
+ * keep the BIOS at bay during subsequent suspends.
+ */
writel(val | XHCI_HC_OS_OWNED, base + ext_cap_offset);
/* Wait for 1 second with 10 microsecond polling interval */
@@ -1210,7 +1211,9 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
dev_warn(&pdev->dev,
"xHCI BIOS handoff failed (BIOS bug ?) %08x\n",
val);
- writel(val & ~XHCI_HC_BIOS_OWNED, base + ext_cap_offset);
+ writel((val | XHCI_HC_OS_OWNED) &
+ ~XHCI_HC_BIOS_OWNED,
+ base + ext_cap_offset);
}
}
base-commit: abf8c33470f78e2226ee3dcdc69004660020ab47
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v6] usb: pci-quirks: always assert xHCI OS ownership
2026-10-30 19:36 [PATCH v6] usb: pci-quirks: always assert xHCI OS ownership Rishabh Jain
@ 2026-10-30 19:44 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-30 19:44 UTC (permalink / raw)
To: Rishabh Jain; +Cc: linux-usb
> The xHCI ownership protocol requires the OS driver to assert the HC OS
> Owned semaphore before using the host controller, then wait for HC BIOS
> Owned to clear if firmware owns it.
>
> quirk_usb_handoff_xhci() currently asserts OS Owned only when BIOS Owned
> is already set. If firmware leaves BIOS Owned clear, Linux uses the xHC
> while both ownership semaphores remain clear.
>
> The timeout fallback also clears BIOS Owned using the original register
> value, which can clear OS Owned at the same time.
>
> On an AMD PROM21 xHCI controller (1022:43fc), this caused every S3
> resume to terminate Controller Restore State with USBSTS 0x401. Linux
> then reset the host controller, both root hubs and the USB Bluetooth
> adapter.
> [ ... ]
> Tested-by: McKenna Fan <blue_sun@tuta.io>
> Tested-by: Quinn Schive <quinnschive@hotmail.com>
> Tested-by: Bruno Filipe <bmilreu@gmail.com>
> Tested-by: Maciej Zonski <me@zonni.pl>
> Signed-off-by: Rishabh Jain <rishabh.jain1198@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/179338900780.73175.16604680938007633313@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-30 19:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 19:36 [PATCH v6] usb: pci-quirks: always assert xHCI OS ownership Rishabh Jain
2026-10-30 19:44 ` sashiko-bot
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.