Browse Source

[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 years ago
parent
commit
3de0ffc887
1 changed files with 10 additions and 10 deletions
  1. 10
    10
      src/drivers/usb/xhci.c

+ 10
- 10
src/drivers/usb/xhci.c View File

556
  * Claim ownership from BIOS
556
  * Claim ownership from BIOS
557
  *
557
  *
558
  * @v xhci		xHCI device
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
 	uint32_t ctlsts;
561
 	uint32_t ctlsts;
563
 	uint8_t bios;
562
 	uint8_t bios;
564
 	unsigned int i;
563
 	unsigned int i;
565
 
564
 
566
 	/* Do nothing unless legacy support capability is present */
565
 	/* Do nothing unless legacy support capability is present */
567
 	if ( ! xhci->legacy )
566
 	if ( ! xhci->legacy )
568
-		return 0;
567
+		return;
569
 
568
 
570
 	/* Claim ownership */
569
 	/* Claim ownership */
571
 	writeb ( XHCI_USBLEGSUP_OS_OWNED,
570
 	writeb ( XHCI_USBLEGSUP_OS_OWNED,
585
 				DBGC ( xhci, "XHCI %p warning: BIOS retained "
584
 				DBGC ( xhci, "XHCI %p warning: BIOS retained "
586
 				       "SMIs: %08x\n", xhci, ctlsts );
585
 				       "SMIs: %08x\n", xhci, ctlsts );
587
 			}
586
 			}
588
-			return 0;
587
+			return;
589
 		}
588
 		}
590
 
589
 
591
 		/* Delay */
590
 		/* Delay */
592
 		mdelay ( 1 );
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
 
3107
 
3106
 	/* Initialise USB legacy support and claim ownership */
3108
 	/* Initialise USB legacy support and claim ownership */
3107
 	xhci_legacy_init ( xhci );
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
 	/* Fix Intel PCH-specific quirks, if applicable */
3112
 	/* Fix Intel PCH-specific quirks, if applicable */
3112
 	if ( pci->id->driver_data & XHCI_PCH )
3113
 	if ( pci->id->driver_data & XHCI_PCH )
3148
 	if ( pci->id->driver_data & XHCI_PCH )
3149
 	if ( pci->id->driver_data & XHCI_PCH )
3149
 		xhci_pch_undo ( xhci, pci );
3150
 		xhci_pch_undo ( xhci, pci );
3150
 	xhci_legacy_release ( xhci );
3151
 	xhci_legacy_release ( xhci );
3151
- err_legacy_claim:
3152
 	iounmap ( xhci->regs );
3152
 	iounmap ( xhci->regs );
3153
  err_ioremap:
3153
  err_ioremap:
3154
 	free ( xhci );
3154
 	free ( xhci );

Loading…
Cancel
Save