From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6ACD1A680B for ; Sat, 15 Aug 2026 01:45:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786758339; cv=none; b=nNQ1vhJGuoZ+EZZAuCQbrTxiMOzN1EuViTveH1mR0HGzNZGYENesemxP/hWz1JH8C71mR8C0REwEP+M7uK2B4c8tRaArEJd9cBUs30reoQ57rDUodgt+YquXOAmnr/bhQvqNHOuTWW0tiHRMyiyTdPWnnlv2aBaIdDLx6ejaQxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786758339; c=relaxed/simple; bh=kr+DDiC7lwoKjoLKWh3UYa7mUtn9pf/hNo4vbGKht+Y=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ok0zFDSRlRroUWbXsBup/GEosrLWD/gH4S75axfkQpN3OmVOyeyiVpMod8ufD3Vo2w+rLI0gm75kgM3GwxnHpqjmR+j2iS3gowIzHdVbSlqP659xdvI91JwSdelIqc1nVz6Jz0Ubf3o/s7LyeMKSkflxufPMlbjqcKli/HeQUVg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=erjEL8J6; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="erjEL8J6" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2d319b84213so3066915ad.1 for ; Fri, 14 Aug 2026 18:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786758337; x=1787363137; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=2rUTBjQcy9ZWD15hkohvAODksdiIkTujMyPdVWOGcaE=; b=erjEL8J61hrVrmwq2Ld/qdYGrjDQGFOz6/ZJ7Lhcf6ji6cWQ/zDKzzvNfs3aDuEa/W FHH9Hwl8Ga0s3lFEW7dcGprJChfGxeWEgqfQw7lI62Y9Chl614ecNvtYrSHRk4Sgqxc8 /QWPBRWTYQ54/Y0bQNkwPbbjITOF5mmfpxRcGRp3pTI3of3eXkB09ZlleKRSnDRqozGd p9y2Ov6Hq9kfbLnxVq4yJbPTiyA887vKbfidj1R55TR+OnaAA6kDlPSULcUEaivfSYB4 OM/REwqwTuzjl3ALCplwqnbtJ2N2rQClxp0KFOZMANKeleGzYenw1p3hkSNnzBuIMlUL GTSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786758337; x=1787363137; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2rUTBjQcy9ZWD15hkohvAODksdiIkTujMyPdVWOGcaE=; b=clIDILarPjJRaXPL4sr/95J9ormRZxU9XssJRL1gkh5dx8F5+yvhGFEsxktFR7Tk+8 AzIx6J4Q29u08HHBE09595AZqXbwgMIkQ1wglFnKE1WkQBAQH5LPDEN4U8Ljh3uY0Ms6 BgzoNjbKS+CcD3CU6M7Uvn5abx3/0D+TUbsXPEUhAuhLmm5YKDK8pjK6Ls8b9MxCR3GP TW0WX6I6jWbx5jmXs5HSpdncRlSad5wPTdBMnkf1MYdSkyCochJx7Ub1pAMUcL5oNc7D cZ6952A66QGI8xg62f1VVxmYTrLdY/1fuvCr1zzFcEQ8PoTcAYmkULvqRsMkX3EpiLu/ FfDA== X-Forwarded-Encrypted: i=1; AHgh+RrSrcqnCU6uLoJgM3txYVpXrd5uuc8p4gJ5z+n3D2657RZL/VPX6Cyys/TnYyRhawLYxF86e1ZJlyA=@vger.kernel.org X-Gm-Message-State: AOJu0YwcLx6pxYh5MI5qLfOiw3Oh+gg3bTWTjfVcX1EJwHfRRTvqFAeg 1hZmC8LMMNQyF/giT/gx5SlalkKOq64zRk7pdp3yryCJEpqEkzthJE9a X-Gm-Gg: AR+sD11AxBW+rN7cckozTQFOE3SoQPMas6cPOUTm2N9ucbBx7qRGNi3SajyuGwe8Qif PRnbdi8flXyoDYUzZ2SDXAi/ltYVtPKrTlKojDEvG1/aDKfQGot9oIVBBIjFxjPlsL1s5ZdIUrS U3I5fyOBL0O6P+ireIU26U7WvcKZs5FSRPuAWo00BraqGJVQoRHM5d4xOI36isnXICUUfMUOuoD gGDWxWkQxrI+anGNqGc44xMHLvwhrSWVEJljs09/b+KiO4co++DoC/egtBkPtJ84I5vIgVmSUDY 2gwz6yPXaNnFYDQA/XskrL9rw/cVHN/Z4UsF91EIDTHIHXI4CDXJM2dQ2zkQtxA0fX8uwaO6e53 lsjMTjVRIwqXN62NbLRO0dJXi/5QXRC9myWrcCtasrLXN9UcH8EuQaY1SEvQ/ub0ryGCY0zMyrz dK6Vjp/Xei5fkYKRgg8TsJbhrenruPZxKjxO0MUHflMrQRtSsmpy22HsiKnQikwM7bTWRqOMQsz n/X9/Gyn090itp8oHqWnCsG25+EAjoVk6YgRtmAkwL79ojPnhbyJZ5EitBshSdSiwB8tvmQs2j5 vYdJ//Bx7rhxEQBq X-Received: by 2002:a17:90b:1d44:b0:38f:57f0:1f51 with SMTP id 98e67ed59e1d1-3933b84ddd6mr7357225a91.0.1786758337093; Fri, 14 Aug 2026 18:45:37 -0700 (PDT) Received: from localhost.localdomain (c-98-47-46-163.hsd1.ca.comcast.net. [98.47.46.163]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1413889d914sm14230840c88.13.2026.08.14.18.45.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 14 Aug 2026 18:45:36 -0700 (PDT) From: Rishabh Jain To: Mathias Nyman Cc: Greg Kroah-Hartman , Mario Limonciello , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Rishabh Jain Subject: [PATCH] usb: pci-quirks: always assert xHCI OS ownership Date: Fri, 14 Aug 2026 18:45:34 -0700 Message-ID: <20260815014534.77850-1-rishabh.jain1198@gmail.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. 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. Asserting only HC OS Owned changed USBLEGSUP from 0x00000801 to 0x01000801 and eliminated the restore failure across four S3 cycles, including a stock-kernel test. Clearing USBLEGCTLSTS was independently verified to be unnecessary. Always assert OS Owned when the xHCI Legacy Support capability is present. Use the independently accessible ownership byte so firmware can update BIOS Owned without racing a 32-bit read-modify-write. Keep the existing BIOS handoff wait and legacy SMI cleanup unchanged. Fixes: 66d4eadd8d06 ("USB: xhci: BIOS handoff and HW initialization.") Tested-by: Rishabh Jain Cc: stable@vger.kernel.org Signed-off-by: Rishabh Jain --- Additional context: * Kernel Bugzilla #216470 documents the same USBSTS 0x401/reinitialize behavior and its impact on attached USB devices: https://bugzilla.kernel.org/show_bug.cgi?id=216470 * Commit a7d57abcc8a5 ("xhci: workaround CSS timeout on AMD SNPS 3.0 xHC") is related workaround history: it tolerates a distinct AMD CSS timeout and resets the controller on resume: https://github.com/torvalds/linux/commit/a7d57abcc8a5bdeb53bbf8e87558e8e0a2c2a29d The external reports do not record their ownership semaphore values but are included as corroborating failure signatures that this might fix. drivers/usb/host/pci-quirks.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 0404489c2f6a..d76a4791b8f5 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -1185,6 +1185,14 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev) dev_warn(&pdev->dev, "xHCI controller failing to respond"); goto iounmap; } + + /* + * The OS ownership semaphore must be asserted while the OS owns the + * xHC, even if firmware did not assert the BIOS ownership semaphore. + * Update only the OS ownership byte to avoid racing with firmware. + */ + writeb(readb(base + ext_cap_offset + 3) | BIT(0), + base + ext_cap_offset + 3); val = readl(base + ext_cap_offset); /* Auto handoff never worked for these devices. Force it and continue */ @@ -1195,10 +1203,8 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev) writel(val, base + ext_cap_offset); } - /* If the BIOS owns the HC, signal that the OS wants it, and wait */ + /* If the BIOS owns the HC, wait for it to hand over control */ if (val & XHCI_HC_BIOS_OWNED) { - writel(val | XHCI_HC_OS_OWNED, base + ext_cap_offset); - /* Wait for 1 second with 10 microsecond polling interval */ timeout = handshake(base + ext_cap_offset, XHCI_HC_BIOS_OWNED, 0, 1000000, 10); -- 2.50.1 (Apple Git-155)