From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 C3D08387375 for ; Wed, 2 Sep 2026 05:39:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788327569; cv=none; b=ukYItXkO/PsR85CsXDkojQrHAe3kH8uo6PqDHOGRB0GX8AjZaKzspSbccquY28l4iRJRr+zreIPkvEw8Fg/OnE7G3TOsVjDojQrBlPQFwQ49iWipWYWqJm4KTEzjeQVsHgi0TFl1+mXs9pIhoGsj/3CzoJ7Q4BL5qW1lGQYNT/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788327569; c=relaxed/simple; bh=D2qpkwtyTf3w93woN4RfdqDyYYM4IpV1kr43tBMElaA=; h=In-Reply-To:References:From:Date:Subject:To:Cc:Message-ID; b=k9oChvSaG4XrLCtLkseDoMn+Q9dNGyPvRKXKYABZ3EL4BUwEfoVpyqykD43Posy8BblDs/6bkuMwVA2ImgXCuFYnzKg66LzHdCPdTJvur+NwH7v+Zl04LN8poiZQ05mko9MIpXmTVjafsbsCRU/JgKUR8aWE/VC6QrllqiKNzAU= 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=YIDi+tXW; arc=none smtp.client-ip=209.85.216.41 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="YIDi+tXW" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-398fb0feb91so101644a91.0 for ; Tue, 01 Sep 2026 22:39:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788327567; x=1788932367; darn=vger.kernel.org; h=message-id:cc:to:subject:date:from:references:in-reply-to:from:to :cc:subject:date:message-id:reply-to:content-type; bh=H3Gzfs+DJpEpqKw65mjqsmh8Qaprer5Io+JTzhX9dEA=; b=YIDi+tXWCmGM7DzM58ZNt9EVTpiKVquzQfLrL3PVJ9WEkowF0OTCZUP6mCalDTJBxO UxeLw6KsOvnuRRJf2kIZ7pZToLPTUF+TZRo1+qT0CUBjdtu1OHzLE8RKW3eWDCCMw4gM bXkDeSBR2zPMPtZxZti/BlnhOYmLO6WzZ30isEHWDMKgo4YK8rNTxtUvF40r11TpWPPN +I2V+ZTScPN8gQhzSjp7cmx7XIlfSx0owFxUzRk11ug+SdPSRUr5zOZ82ZH1uOXrICkD Ileue6r9XSS064TBJKDM2+bpbH61LwjFQCguSGkMZ7Z7WWRYfocZRX9Uf+itbKBLYyR+ lghw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788327567; x=1788932367; h=message-id:cc:to:subject:date:from:references:in-reply-to:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=H3Gzfs+DJpEpqKw65mjqsmh8Qaprer5Io+JTzhX9dEA=; b=pV389O55y0KkKS7S62P3Yi5AaI/+ZR938QqbFRNb1bQLpmW/jkdYaEjQEf+X7tZvk5 QklaRdf/W6qAx/uNTOC4uo/XDGJ9f+hYndf2g4ZLCTg50TxKasnzKhWNjucSOH1v9et/ q1zYJmGJTTedaddcfC/nvdbksZJcwlGccID4CjmzE2BXxglxr4iXnXUSp5JjBwACahQm gffKA6Mdldx2kWf9xJI6XyTo9oDeftEg/Ie9Ansl52Kq3C+6M8n6EJyNFgquaXlHusWI sn6S3y1wwvZmnvdcSfbJDRis3kSvxoU5FHx2cKKy2MwjziSgvxiiBdiVV2VdI+typ+fW uppA== X-Forwarded-Encrypted: i=1; AKwUvBzeO9jP0uirJPv2uv7LzjpcwFDbG/XMseQW+4XQNq7TO2qyFVojBeI/qNgPrdXqR25tUrUta319G8c=@vger.kernel.org X-Gm-Message-State: AFuF++nFx6yu0UnHcvY/jvvAjE7MOCoozetI1pDJ9Hl6HR2bJRrpM+Z6 5xaBo1MSHvTccpHPQbeXuI//BA8wl5eV+i+KWwfsJWNnlM24/Jua/qjuHo9X/Gna X-Gm-Gg: AYBFou0NEQNkBch9RkIdaMg/KlOLSqzTNsYlx/aRsi1PI+koAwskgR4tQ2RjWFrNqmJ dBmaLnUmFLQlGDpALU02mDIwJO2N9VP9FYuq8nzmNpNKUAL8Fqknzf32p8y5DhJluTcReYnnLpO XhImm+TbvuILvuC2hDtFXeuMv/k0+oWO1E7TWoX50vYu8WIUZutohN6FaBHvkfwG32QQzZlGKSV iI2CLRuXY9qljChpKP3yhElC/Ok/3TerIpEfYcWlCQxqIod2tIihhwUf9dIciSu2JU9EnQ6i3Ft loZTUk6zjTPInfqiBgu6u4cLmPZkidCBn8as+9XGrzf4ekOqI7g+VSeDNqOuVFBvAu55ZLXDky+ aNmlQurnxU9iozU0lvWcs/Pz84AKxQmivC4kQm9Qeenf+fFqPJZAytGjptkHOmjD/kJEQz8wdO+ kuIKJN5FPquty644ildZC8illzD44ur+S92M5bRWdfzlQ9voBxy/AOpaIuAkKxG3/8yEVyf0UUZ /S6ZcjTdsU/jWYt42JoJ5O4uGEP7dTEL0H064DPY/tPXuhOByivcY9CVNQlpcOhK+F+a3yGrMEd LSJ+T5nDIfUqOzzBh4k92c6XCdAbBLvoru/+y7N1RtVeoDOPi8BJsfTBSb8mmTY+8oUjJrzOLpA dcEM7/COUhca38wS/VJY= X-Received: by 2002:a17:90b:4408:b0:396:63a8:699b with SMTP id 98e67ed59e1d1-39aedebbbacmr2123907a91.1.1788327566984; Tue, 01 Sep 2026 22:39:26 -0700 (PDT) Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa (c-98-47-46-163.hsd1.ca.comcast.net. [98.47.46.163]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1430e9eb4dasm5213580c88.2.2026.09.01.22.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 22:39:26 -0700 (PDT) In-Reply-To: <20260902052631.75c6068b.michal.pecio@gmail.com> References: <20260902052631.75c6068b.michal.pecio@gmail.com> From: Rishabh Jain Date: Tue, 01 Sep 2026 22:39:18 -0700 Subject: [PATCH v5] usb: pci-quirks: always assert xHCI OS ownership To: Mathias Nyman Cc: Greg Kroah-Hartman , Mario Limonciello , Michal Pecio , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Rishabh Jain Message-ID: <178832755831.50581.1058201741431375556@gmail.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Assisted-by: LLM Signed-off-by: Rishabh Jain --- I kept val unchanged for the error log, restored the original handshake formatting, and explicitly preserve OS Owned when forcing BIOS Owned clear after a timeout. Documented timeout issue in commit message. I repeated the same S3 test on the unmodified 7.1.8-ogc1.1.fc44.x86_64 distribution kernel using the test module, with the same successful result. Changes in v5: - Preserve the original ownership value for error logging. - Restore the original handshake formatting. - Explicitly retain OS Owned in the timeout fallback. 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 0404489c2f6a..2b12a35e6f10 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -1193,10 +1193,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 */ @@ -1208,7 +1209,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); } } -- 2.50.1 (Apple Git-155)