Changeset 8033f89 in mainline for uspace/drv/bus/usb/xhci/isoch.c
- Timestamp:
- 2018-01-23T12:41:22Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e7e1fd3
- Parents:
- e546142
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/isoch.c
re546142 r8033f89 81 81 fibril_timer_clear_locked(isoch->feeding_timer); 82 82 isoch->last_mf = -1U; 83 usb_log_info("[isoch] Endpoint" XHCI_EP_FMT ": Data flow reset.", XHCI_EP_ARGS(*ep)); 83 usb_log_info("[isoch] Endpoint" XHCI_EP_FMT ": Data flow reset.", 84 XHCI_EP_ARGS(*ep)); 84 85 } 85 86 … … 110 111 static void timer_schedule_reset(xhci_endpoint_t *ep) { 111 112 xhci_isoch_t * const isoch = ep->isoch; 112 const suseconds_t delay = isoch->buffer_count * ep->interval * 125 + RESET_TIMER_DELAY; 113 const suseconds_t delay = isoch->buffer_count * ep->interval * 125 114 + RESET_TIMER_DELAY; 113 115 114 116 fibril_timer_clear_locked(isoch->reset_timer); … … 213 215 const uint32_t reg_mfindex = XHCI_REG_RD(hc->rt_regs, XHCI_RT_MFINDEX); 214 216 /* 215 * If the mfindex is low and the time passed since last mfindex wrap 216 * is too high, we have entered the new epoch already (and haven't received event yet). 217 * If the mfindex is low and the time passed since last mfindex wrap is too 218 * high, we have entered the new epoch already (and haven't received event 219 * yet). 217 220 */ 218 221 uint64_t epoch = hc->wrap_count; 219 if (reg_mfindex < EPOCH_LOW_MFINDEX && get_system_time() - hc->wrap_time > EPOCH_DELAY) { 222 if (reg_mfindex < EPOCH_LOW_MFINDEX 223 && get_system_time() - hc->wrap_time > EPOCH_DELAY) { 220 224 ++epoch; 221 225 } … … 230 234 const xhci_hc_t *hc = bus->hc; 231 235 232 /* Delay the first frame by some time to fill the buffer, but at most 10 miliseconds. */ 236 /* 237 * Delay the first frame by some time to fill the buffer, but at most 10 238 * miliseconds. 239 */ 233 240 const uint64_t delay = min(isoch->buffer_count * ep->interval, 10 * 8); 234 241 it->mfindex = get_current_microframe(hc) + 1 + delay + hc->ist; … … 262 269 * uframes it's off. 263 270 */ 264 static inline void window_decide(window_decision_t *res, xhci_hc_t *hc, uint64_t mfindex) 271 static inline void window_decide(window_decision_t *res, xhci_hc_t *hc, 272 uint64_t mfindex) 265 273 { 266 274 const uint64_t current_mf = get_current_microframe(hc); … … 333 341 334 342 case WINDOW_TOO_LATE: 335 /* Missed the opportunity to schedule. Just mark this transfer as skipped. */ 336 usb_log_debug("[isoch] missed feeding buffer %lu at 0x%llx by %llu uframes", 337 it - isoch->transfers, it->mfindex, wd.offset); 343 /* 344 * Missed the opportunity to schedule. Just mark this transfer as 345 * skipped. 346 */ 347 usb_log_debug("[isoch] missed feeding buffer %lu at 0x%llx by " 348 "%llu uframes", it - isoch->transfers, it->mfindex, wd.offset); 338 349 it->state = ISOCH_COMPLETE; 339 350 it->error = EOK; … … 348 359 if (fed) { 349 360 hc_ring_ep_doorbell(ep, 0); 350 /* The ring may be dead. If no event happens until the delay, reset the endpoint. */ 361 /* 362 * The ring may be dead. If no event happens until the delay, reset the 363 * endpoint. 364 */ 351 365 timer_schedule_reset(ep); 352 366 } … … 405 419 406 420 case WINDOW_TOO_LATE: 407 usb_log_debug("[isoch] missed feeding buffer %lu at 0x%llx by %llu uframes",408 421 usb_log_debug("[isoch] missed feeding buffer %lu at 0x%llx by" 422 "%llu uframes", it - isoch->transfers, it->mfindex, wd.offset); 409 423 /* Missed the opportunity to schedule. Schedule ASAP. */ 410 424 it->mfindex += wd.offset; … … 435 449 if (fed) { 436 450 hc_ring_ep_doorbell(ep, 0); 437 /* The ring may be dead. If no event happens until the delay, reset the endpoint. */ 451 /* 452 * The ring may be dead. If no event happens until the delay, reset the 453 * endpoint. 454 */ 438 455 timer_schedule_reset(ep); 439 456 } … … 502 519 calc_next_mfindex(ep, it); 503 520 isoch->last_mf = it->mfindex; 504 usb_log_debug("[isoch] buffer %zu will be on schedule at 0x%llx", it - isoch->transfers, it->mfindex); 521 usb_log_debug("[isoch] buffer %zu will be on schedule at 0x%llx", 522 it - isoch->transfers, it->mfindex); 505 523 506 524 /* Prepare the transfer. */ … … 543 561 isoch_feed_in(ep); 544 562 545 usb_log_debug("[isoch] waiting for buffer %zu to be completed", it - isoch->transfers); 563 usb_log_debug("[isoch] waiting for buffer %zu to be completed", 564 it - isoch->transfers); 546 565 fibril_condvar_wait(&isoch->avail, &isoch->guard); 547 566 … … 568 587 } 569 588 570 void isoch_handle_transfer_event(xhci_hc_t *hc, xhci_endpoint_t *ep, xhci_trb_t *trb) 589 void isoch_handle_transfer_event(xhci_hc_t *hc, xhci_endpoint_t *ep, 590 xhci_trb_t *trb) 571 591 { 572 592 assert(ep->base.transfer_type == USB_TRANSFER_ISOCHRONOUS); … … 581 601 case XHCI_TRBC_RING_OVERRUN: 582 602 case XHCI_TRBC_RING_UNDERRUN: 583 /* For OUT, there was nothing to process */ 584 /* For IN, the buffer has overfilled, we empty the buffers and readd TRBs */ 603 /* 604 * For OUT, there was nothing to process. 605 * For IN, the buffer has overfilled. 606 * In either case, reset the ring. 607 */ 585 608 usb_log_warning("Ring over/underrun."); 586 609 isoch_reset_no_timer(ep);
Note:
See TracChangeset
for help on using the changeset viewer.