From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795705731; b=URC3PWeF1Wn/X71kg29c9cJZ8G4+Yjv1f5dw3TjUua7Qm7xllRej9G20kN82/kPIl8i1 nKpPgchUdlJeh7mJ/yCvNGx+7olbnSGGZHr58WQfwwL/dA7ysTzz7ccRUX8bBaItPmwh2 uf8rfdQMa3assKl8O0AKbkzqJrxC2rqRtIt1kbttBbQG28UcK/Ju9iDIMOAqlNBqY4ALh r55IkOixx9+3wfrb4RB3482Af98mZzsagTsABt5zkbYcycnBUp/1FHYE5wOVkJjR6jgY9 evnDwLAkmSKTmqogJkH72NHgb8n/NI79mITvZZKydz1DdIAmqLk5k7KOLZ1E9E1aPtg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795705731; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=vS1uHXgtQ3vzw9amGFm+DByDaR7LTYS2rEdglr/xRL8=; b=AvWMIPdpvWu2x87jBZtWPG7dC95aFH34XSuFELkbiziAUPvBqvcc3XMUYwaY6P7Us+dx Idnqpn3mY22lby9dIpHGSR6lx1MdyPj0/GQwCNDkcSs7M2hLkvJTIQQLOrc4iW/RZQDi7 kvWVNZOAsSs5FQLW2HPmPuiP3b8MNPfrxwlJcA+oA/CBYQZr+RZG/z+LkDmiTbT/pDq4W x6Gt/6NSdfWN0hVctk+FGuyGDDfFC+3u9EeuYTj9hrz9++DzXJ2jXco/MWMss3aPs4eh3 9E2zZ4qYETUA99FQYMd/UcYXmwuCsM1ESBCZKXjplSqhqR0JITRXZ+DItg5zDRvCNbw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=J+00SEVg; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68F4D606A31C; Thu, 26 Nov 2026 15:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=J+00SEVg Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9FE41F000EF; Thu, 26 Nov 2026 15:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795705731; bh=vS1uHXgtQ3vzw9amGFm+DByDaR7LTYS2rEdglr/xRL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=J+00SEVg3l50SyhNF7XGoTQs+XzQ5GlPxNSIm9G0pvCpcTs3VqR1qziPEXBnUOIkX 3DwYiDDH4CtLgyaP1bqXT9Gg7rJjXfwKZC3EZ6dPpDf/LnuZiNsmojNlc3xQ7moBI5 DXtDoExptcG32ILbNgW3AmwgcpbAVIKQJh6myccU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Mario Limonciello (AMD)" , McKenna Fan , Quinn Schive , Bruno Filipe , Maciej Zonski , Rishabh Jain , Mathias Nyman Subject: [PATCH 5.15 269/319] usb: pci-quirks: always assert xHCI OS ownership Date: Thu, 26 Nov 2026 15:40:37 +0100 Message-ID: <20261126144012.820290769@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261126144006.732901931@linuxfoundation.org> References: <20261126144006.732901931@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rishabh Jain commit 5550405351199fe78f4a3cd606c07f5ad7220e1b upstream. 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) Tested-by: McKenna Fan Tested-by: Quinn Schive Tested-by: Bruno Filipe Tested-by: Maciej Zonski Signed-off-by: Rishabh Jain Signed-off-by: Mathias Nyman Link: https://patch.msgid.link/20261105175106.241182-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/pci-quirks.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -1184,10 +1184,11 @@ static void quirk_usb_handoff_xhci(struc && 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 */ @@ -1199,7 +1200,9 @@ static void quirk_usb_handoff_xhci(struc 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); } }