diff options
Diffstat (limited to 'drivers/usb/host/ehci-sched.c')
-rw-r--r-- | drivers/usb/host/ehci-sched.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 2abf8543f083..2e829fae6482 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -36,6 +36,27 @@ | |||
36 | 36 | ||
37 | static int ehci_get_frame (struct usb_hcd *hcd); | 37 | static int ehci_get_frame (struct usb_hcd *hcd); |
38 | 38 | ||
39 | #ifdef CONFIG_PCI | ||
40 | |||
41 | static unsigned ehci_read_frame_index(struct ehci_hcd *ehci) | ||
42 | { | ||
43 | unsigned uf; | ||
44 | |||
45 | /* | ||
46 | * The MosChip MCS9990 controller updates its microframe counter | ||
47 | * a little before the frame counter, and occasionally we will read | ||
48 | * the invalid intermediate value. Avoid problems by checking the | ||
49 | * microframe number (the low-order 3 bits); if they are 0 then | ||
50 | * re-read the register to get the correct value. | ||
51 | */ | ||
52 | uf = ehci_readl(ehci, &ehci->regs->frame_index); | ||
53 | if (unlikely(ehci->frame_index_bug && ((uf & 7) == 0))) | ||
54 | uf = ehci_readl(ehci, &ehci->regs->frame_index); | ||
55 | return uf; | ||
56 | } | ||
57 | |||
58 | #endif | ||
59 | |||
39 | /*-------------------------------------------------------------------------*/ | 60 | /*-------------------------------------------------------------------------*/ |
40 | 61 | ||
41 | /* | 62 | /* |
@@ -479,10 +500,9 @@ static int enable_periodic (struct ehci_hcd *ehci) | |||
479 | cmd = ehci_readl(ehci, &ehci->regs->command) | CMD_PSE; | 500 | cmd = ehci_readl(ehci, &ehci->regs->command) | CMD_PSE; |
480 | ehci_writel(ehci, cmd, &ehci->regs->command); | 501 | ehci_writel(ehci, cmd, &ehci->regs->command); |
481 | /* posted write ... PSS happens later */ | 502 | /* posted write ... PSS happens later */ |
482 | ehci_to_hcd(ehci)->state = HC_STATE_RUNNING; | ||
483 | 503 | ||
484 | /* make sure ehci_work scans these */ | 504 | /* make sure ehci_work scans these */ |
485 | ehci->next_uframe = ehci_readl(ehci, &ehci->regs->frame_index) | 505 | ehci->next_uframe = ehci_read_frame_index(ehci) |
486 | % (ehci->periodic_size << 3); | 506 | % (ehci->periodic_size << 3); |
487 | if (unlikely(ehci->broken_periodic)) | 507 | if (unlikely(ehci->broken_periodic)) |
488 | ehci->last_periodic_enable = ktime_get_real(); | 508 | ehci->last_periodic_enable = ktime_get_real(); |
@@ -677,7 +697,7 @@ static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
677 | 697 | ||
678 | /* reschedule QH iff another request is queued */ | 698 | /* reschedule QH iff another request is queued */ |
679 | if (!list_empty(&qh->qtd_list) && | 699 | if (!list_empty(&qh->qtd_list) && |
680 | HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) { | 700 | ehci->rh_state == EHCI_RH_RUNNING) { |
681 | rc = qh_schedule(ehci, qh); | 701 | rc = qh_schedule(ehci, qh); |
682 | 702 | ||
683 | /* An error here likely indicates handshake failure | 703 | /* An error here likely indicates handshake failure |
@@ -1409,7 +1429,7 @@ iso_stream_schedule ( | |||
1409 | goto fail; | 1429 | goto fail; |
1410 | } | 1430 | } |
1411 | 1431 | ||
1412 | now = ehci_readl(ehci, &ehci->regs->frame_index) & (mod - 1); | 1432 | now = ehci_read_frame_index(ehci) & (mod - 1); |
1413 | 1433 | ||
1414 | /* Typical case: reuse current schedule, stream is still active. | 1434 | /* Typical case: reuse current schedule, stream is still active. |
1415 | * Hopefully there are no gaps from the host falling behind | 1435 | * Hopefully there are no gaps from the host falling behind |
@@ -2275,8 +2295,8 @@ scan_periodic (struct ehci_hcd *ehci) | |||
2275 | * Touches as few pages as possible: cache-friendly. | 2295 | * Touches as few pages as possible: cache-friendly. |
2276 | */ | 2296 | */ |
2277 | now_uframe = ehci->next_uframe; | 2297 | now_uframe = ehci->next_uframe; |
2278 | if (HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) { | 2298 | if (ehci->rh_state == EHCI_RH_RUNNING) { |
2279 | clock = ehci_readl(ehci, &ehci->regs->frame_index); | 2299 | clock = ehci_read_frame_index(ehci); |
2280 | clock_frame = (clock >> 3) & (ehci->periodic_size - 1); | 2300 | clock_frame = (clock >> 3) & (ehci->periodic_size - 1); |
2281 | } else { | 2301 | } else { |
2282 | clock = now_uframe + mod - 1; | 2302 | clock = now_uframe + mod - 1; |
@@ -2310,7 +2330,7 @@ restart: | |||
2310 | union ehci_shadow temp; | 2330 | union ehci_shadow temp; |
2311 | int live; | 2331 | int live; |
2312 | 2332 | ||
2313 | live = HC_IS_RUNNING (ehci_to_hcd(ehci)->state); | 2333 | live = (ehci->rh_state == EHCI_RH_RUNNING); |
2314 | switch (hc32_to_cpu(ehci, type)) { | 2334 | switch (hc32_to_cpu(ehci, type)) { |
2315 | case Q_TYPE_QH: | 2335 | case Q_TYPE_QH: |
2316 | /* handle any completions */ | 2336 | /* handle any completions */ |
@@ -2435,7 +2455,7 @@ restart: | |||
2435 | * We can't advance our scan without collecting the ISO | 2455 | * We can't advance our scan without collecting the ISO |
2436 | * transfers that are still pending in this frame. | 2456 | * transfers that are still pending in this frame. |
2437 | */ | 2457 | */ |
2438 | if (incomplete && HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) { | 2458 | if (incomplete && ehci->rh_state == EHCI_RH_RUNNING) { |
2439 | ehci->next_uframe = now_uframe; | 2459 | ehci->next_uframe = now_uframe; |
2440 | break; | 2460 | break; |
2441 | } | 2461 | } |
@@ -2451,12 +2471,11 @@ restart: | |||
2451 | if (now_uframe == clock) { | 2471 | if (now_uframe == clock) { |
2452 | unsigned now; | 2472 | unsigned now; |
2453 | 2473 | ||
2454 | if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) | 2474 | if (ehci->rh_state != EHCI_RH_RUNNING |
2455 | || ehci->periodic_sched == 0) | 2475 | || ehci->periodic_sched == 0) |
2456 | break; | 2476 | break; |
2457 | ehci->next_uframe = now_uframe; | 2477 | ehci->next_uframe = now_uframe; |
2458 | now = ehci_readl(ehci, &ehci->regs->frame_index) & | 2478 | now = ehci_read_frame_index(ehci) & (mod - 1); |
2459 | (mod - 1); | ||
2460 | if (now_uframe == now) | 2479 | if (now_uframe == now) |
2461 | break; | 2480 | break; |
2462 | 2481 | ||