Skip to content

Commit 280a904

Browse files
Eugene Korenevskygregkh
authored andcommitted
ehci: fix EHCI host controller initialization sequence
According to EHCI spec, EHCI HC clears USBSTS.HCHalted whenever USBCMD.RS=1. However, it is a good practice to wait some time after setting USBCMD.RS (approximately 100ms) until USBSTS.HCHalted become zero. Without this waiting, VirtualBox's EHCI virtual HC accidentally hangs (see BugLink). BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=211095 Acked-by: Alan Stern <[email protected]> Signed-off-by: Eugene Korenevsky <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5f8e084 commit 280a904

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/usb/host/ehci-hcd.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ static int ehci_run (struct usb_hcd *hcd)
574574
struct ehci_hcd *ehci = hcd_to_ehci (hcd);
575575
u32 temp;
576576
u32 hcc_params;
577+
int rc;
577578

578579
hcd->uses_new_polling = 1;
579580

@@ -629,9 +630,20 @@ static int ehci_run (struct usb_hcd *hcd)
629630
down_write(&ehci_cf_port_reset_rwsem);
630631
ehci->rh_state = EHCI_RH_RUNNING;
631632
ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
633+
634+
/* Wait until HC become operational */
632635
ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
633636
msleep(5);
637+
rc = ehci_handshake(ehci, &ehci->regs->status, STS_HALT, 0, 100 * 1000);
638+
634639
up_write(&ehci_cf_port_reset_rwsem);
640+
641+
if (rc) {
642+
ehci_err(ehci, "USB %x.%x, controller refused to start: %d\n",
643+
((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), rc);
644+
return rc;
645+
}
646+
635647
ehci->last_periodic_enable = ktime_get_real();
636648

637649
temp = HC_VERSION(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));

0 commit comments

Comments
 (0)