提交 759d67c9 编写于 作者: E Eugene Korenevsky 提交者: Zheng Zengkai

ehci: fix EHCI host controller initialization sequence

stable inclusion
from stable-5.10.11
commit f270d1d7556350234d370c54304a8760101bfb0c
bugzilla: 47621

--------------------------------

commit 280a9045 upstream.

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=211095Acked-by: NAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: NEugene Korenevsky <ekorenevsky@astralinux.ru>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210110173609.GA17313@himera.homeSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 17420310
...@@ -574,6 +574,7 @@ static int ehci_run (struct usb_hcd *hcd) ...@@ -574,6 +574,7 @@ static int ehci_run (struct usb_hcd *hcd)
struct ehci_hcd *ehci = hcd_to_ehci (hcd); struct ehci_hcd *ehci = hcd_to_ehci (hcd);
u32 temp; u32 temp;
u32 hcc_params; u32 hcc_params;
int rc;
hcd->uses_new_polling = 1; hcd->uses_new_polling = 1;
...@@ -629,9 +630,20 @@ static int ehci_run (struct usb_hcd *hcd) ...@@ -629,9 +630,20 @@ static int ehci_run (struct usb_hcd *hcd)
down_write(&ehci_cf_port_reset_rwsem); down_write(&ehci_cf_port_reset_rwsem);
ehci->rh_state = EHCI_RH_RUNNING; ehci->rh_state = EHCI_RH_RUNNING;
ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
/* Wait until HC become operational */
ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
msleep(5); msleep(5);
rc = ehci_handshake(ehci, &ehci->regs->status, STS_HALT, 0, 100 * 1000);
up_write(&ehci_cf_port_reset_rwsem); up_write(&ehci_cf_port_reset_rwsem);
if (rc) {
ehci_err(ehci, "USB %x.%x, controller refused to start: %d\n",
((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), rc);
return rc;
}
ehci->last_periodic_enable = ktime_get_real(); ehci->last_periodic_enable = ktime_get_real();
temp = HC_VERSION(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); temp = HC_VERSION(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册