|
36 | 36 |
|
37 | 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 | /* |
@@ -482,7 +503,7 @@ static int enable_periodic (struct ehci_hcd *ehci) |
482 | 503 | ehci_to_hcd(ehci)->state = HC_STATE_RUNNING; |
483 | 504 |
|
484 | 505 | /* make sure ehci_work scans these */ |
485 | | - ehci->next_uframe = ehci_readl(ehci, &ehci->regs->frame_index) |
| 506 | + ehci->next_uframe = ehci_read_frame_index(ehci) |
486 | 507 | % (ehci->periodic_size << 3); |
487 | 508 | if (unlikely(ehci->broken_periodic)) |
488 | 509 | ehci->last_periodic_enable = ktime_get_real(); |
@@ -1409,7 +1430,7 @@ iso_stream_schedule ( |
1409 | 1430 | goto fail; |
1410 | 1431 | } |
1411 | 1432 |
|
1412 | | - now = ehci_readl(ehci, &ehci->regs->frame_index) & (mod - 1); |
| 1433 | + now = ehci_read_frame_index(ehci) & (mod - 1); |
1413 | 1434 |
|
1414 | 1435 | /* Typical case: reuse current schedule, stream is still active. |
1415 | 1436 | * Hopefully there are no gaps from the host falling behind |
@@ -2276,7 +2297,7 @@ scan_periodic (struct ehci_hcd *ehci) |
2276 | 2297 | */ |
2277 | 2298 | now_uframe = ehci->next_uframe; |
2278 | 2299 | if (HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) { |
2279 | | - clock = ehci_readl(ehci, &ehci->regs->frame_index); |
| 2300 | + clock = ehci_read_frame_index(ehci); |
2280 | 2301 | clock_frame = (clock >> 3) & (ehci->periodic_size - 1); |
2281 | 2302 | } else { |
2282 | 2303 | clock = now_uframe + mod - 1; |
@@ -2455,8 +2476,7 @@ scan_periodic (struct ehci_hcd *ehci) |
2455 | 2476 | || ehci->periodic_sched == 0) |
2456 | 2477 | break; |
2457 | 2478 | ehci->next_uframe = now_uframe; |
2458 | | - now = ehci_readl(ehci, &ehci->regs->frame_index) & |
2459 | | - (mod - 1); |
| 2479 | + now = ehci_read_frame_index(ehci) & (mod - 1); |
2460 | 2480 | if (now_uframe == now) |
2461 | 2481 | break; |
2462 | 2482 |
|
|
0 commit comments