瀏覽代碼

[xhci] Forcibly disable SMIs if BIOS fails to release ownership

If the BIOS fails to gracefully release ownership of the xHCI
controller, we can forcibly claim it by disabling all SMIs via the
USB legacy support control/status register.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 年之前
父節點
當前提交
3de0ffc887
共有 1 個檔案被更改,包括 10 行新增10 行删除
  1. 10
    10
      src/drivers/usb/xhci.c

+ 10
- 10
src/drivers/usb/xhci.c 查看文件

@@ -556,16 +556,15 @@ static void xhci_legacy_init ( struct xhci_device *xhci ) {
556 556
  * Claim ownership from BIOS
557 557
  *
558 558
  * @v xhci		xHCI device
559
- * @ret rc		Return status code
560 559
  */
561
-static int xhci_legacy_claim ( struct xhci_device *xhci ) {
560
+static void xhci_legacy_claim ( struct xhci_device *xhci ) {
562 561
 	uint32_t ctlsts;
563 562
 	uint8_t bios;
564 563
 	unsigned int i;
565 564
 
566 565
 	/* Do nothing unless legacy support capability is present */
567 566
 	if ( ! xhci->legacy )
568
-		return 0;
567
+		return;
569 568
 
570 569
 	/* Claim ownership */
571 570
 	writeb ( XHCI_USBLEGSUP_OS_OWNED,
@@ -585,16 +584,19 @@ static int xhci_legacy_claim ( struct xhci_device *xhci ) {
585 584
 				DBGC ( xhci, "XHCI %p warning: BIOS retained "
586 585
 				       "SMIs: %08x\n", xhci, ctlsts );
587 586
 			}
588
-			return 0;
587
+			return;
589 588
 		}
590 589
 
591 590
 		/* Delay */
592 591
 		mdelay ( 1 );
593 592
 	}
594 593
 
595
-	DBGC ( xhci, "XHCI %p timed out waiting for BIOS to release "
596
-	       "ownership\n", xhci );
597
-	return -ETIMEDOUT;
594
+	/* BIOS did not release ownership.  Claim it forcibly by
595
+	 * disabling all SMIs.
596
+	 */
597
+	DBGC ( xhci, "XHCI %p could not claim ownership from BIOS: forcibly "
598
+	       "disabling SMIs\n", xhci );
599
+	writel ( 0, xhci->cap + xhci->legacy + XHCI_USBLEGSUP_CTLSTS );
598 600
 }
599 601
 
600 602
 /**
@@ -3105,8 +3107,7 @@ static int xhci_probe ( struct pci_device *pci ) {
3105 3107
 
3106 3108
 	/* Initialise USB legacy support and claim ownership */
3107 3109
 	xhci_legacy_init ( xhci );
3108
-	if ( ( rc = xhci_legacy_claim ( xhci ) ) != 0 )
3109
-		goto err_legacy_claim;
3110
+	xhci_legacy_claim ( xhci );
3110 3111
 
3111 3112
 	/* Fix Intel PCH-specific quirks, if applicable */
3112 3113
 	if ( pci->id->driver_data & XHCI_PCH )
@@ -3148,7 +3149,6 @@ static int xhci_probe ( struct pci_device *pci ) {
3148 3149
 	if ( pci->id->driver_data & XHCI_PCH )
3149 3150
 		xhci_pch_undo ( xhci, pci );
3150 3151
 	xhci_legacy_release ( xhci );
3151
- err_legacy_claim:
3152 3152
 	iounmap ( xhci->regs );
3153 3153
  err_ioremap:
3154 3154
 	free ( xhci );

Loading…
取消
儲存