Changeset 6455d39 in mainline
- Timestamp:
- 2017-12-14T14:09:31Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 10cd715
- Parents:
- 7d957b2
- Location:
- uspace/drv/bus/usb/xhci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/bus.c
r7d957b2 r6455d39 83 83 ep->isoch_dequeue = XHCI_ISOCH_BUFFER_COUNT - 1; 84 84 ep->isoch_started = false; 85 86 fibril_mutex_initialize(&ep->isoch_guard); 87 fibril_condvar_initialize(&ep->isoch_avail); 85 88 } 86 89 -
uspace/drv/bus/usb/xhci/endpoint.h
r7d957b2 r6455d39 102 102 /** Are isochronous transfers started? */ 103 103 bool isoch_started; 104 105 /** Protects common buffers. */ 106 fibril_mutex_t isoch_guard; 107 108 /** Signals filled buffer. */ 109 fibril_condvar_t isoch_avail; 110 104 111 } xhci_endpoint_t; 105 112 -
uspace/drv/bus/usb/xhci/transfers.c
r7d957b2 r6455d39 280 280 xhci_trb_clean(&trb); 281 281 282 // FIXME add some locks282 fibril_mutex_lock(&xhci_ep->isoch_guard); 283 283 xhci_isoch_transfer_t *isoch_transfer = isoch_transfer_get_enqueue(xhci_ep); 284 284 while (!isoch_transfer) { 285 // FIXME: add condvar sleep; 285 fibril_condvar_wait(&xhci_ep->isoch_avail, &xhci_ep->isoch_guard); 286 isoch_transfer = isoch_transfer_get_enqueue(xhci_ep); 286 287 } 287 288 … … 297 298 &isoch_transfer->interrupt_trb_phys); 298 299 if (err) { 300 fibril_mutex_unlock(&xhci_ep->isoch_guard); 299 301 return err; 300 302 } … … 306 308 const uint8_t target = xhci_endpoint_index(xhci_ep) + 1; /* EP Doorbells start at 1 */ 307 309 err = hc_ring_doorbell(hc, slot_id, target); 308 if (err) {309 return err;310 }311 310 xhci_ep->isoch_started = true; 311 } 312 fibril_mutex_unlock(&xhci_ep->isoch_guard); 313 if (err) { 314 return err; 312 315 } 313 316 … … 322 325 xhci_device_t *xhci_dev) 323 326 { 327 fibril_mutex_lock(&xhci_ep->isoch_guard); 324 328 /* If not yet started, start the isochronous endpoint transfers - before first read */ 325 329 if (!xhci_ep->isoch_started) { … … 328 332 int err = hc_ring_doorbell(hc, slot_id, target); 329 333 if (err) { 334 fibril_mutex_unlock(&xhci_ep->isoch_guard); 330 335 return err; 331 336 } … … 333 338 } 334 339 335 // FIXME add some locks336 340 xhci_isoch_transfer_t *isoch_transfer = isoch_transfer_get_enqueue(xhci_ep); 337 341 while(!isoch_transfer) { 338 // FIXME: add condvar sleep; 342 fibril_condvar_wait(&xhci_ep->isoch_avail, &xhci_ep->isoch_guard); 343 isoch_transfer = isoch_transfer_get_enqueue(xhci_ep); 339 344 } 340 345 … … 364 369 int err = schedule_isochronous_trb(ring, xhci_ep, &trb, isoch_transfer->size, 365 370 &isoch_transfer->interrupt_trb_phys); 371 fibril_mutex_unlock(&xhci_ep->isoch_guard); 372 366 373 if (err) { 367 374 return err; … … 391 398 392 399 static int handle_isochronous_transfer_event(xhci_hc_t *hc, xhci_trb_t *trb, xhci_endpoint_t *ep) { 393 fibril_mutex_lock(&ep->base.guard); 400 fibril_mutex_lock(&ep->isoch_guard); 401 402 int err = EOK; 403 404 const xhci_trb_completion_code_t completion_code = TRB_COMPLETION_CODE(*trb); 405 switch (completion_code) { 406 case XHCI_TRBC_RING_OVERRUN: 407 case XHCI_TRBC_RING_UNDERRUN: 408 // TODO: abort the phone; rings are unscheduled by xHC by now 409 ep->isoch_started = false; 410 err = EIO; 411 break; 412 case XHCI_TRBC_SHORT_PACKET: 413 usb_log_debug("Short transfer."); 414 /* fallthrough */ 415 case XHCI_TRBC_SUCCESS: 416 break; 417 default: 418 usb_log_warning("Transfer not successfull: %u", completion_code); 419 err = EIO; 420 } 394 421 395 422 xhci_isoch_transfer_t *isoch_transfer = isoch_transfer_get_dequeue(ep); … … 397 424 usb_log_error("Non-matching trb to isochronous transfer, skipping."); 398 425 // FIXME: what to do? probably just kill the whole endpoint 399 returnENOENT;426 err = ENOENT; 400 427 } 401 428 … … 405 432 } 406 433 407 // TODO: Send notify to waiting fibrils in case they are waiting here 408 409 fibril_mutex_unlock(&ep->base.guard); 410 return EOK; 434 fibril_condvar_signal(&ep->isoch_avail); 435 fibril_mutex_unlock(&ep->isoch_guard); 436 return err; 411 437 } 412 438
Note:
See TracChangeset
for help on using the changeset viewer.