Changeset 929599a8 in mainline
- Timestamp:
- 2018-01-11T13:30:37Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4ed803f1
- Parents:
- 351113f
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-01-11 13:30:31)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-01-11 13:30:37)
- Location:
- uspace/drv/bus/usb/uhci
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/hc.c
r351113f r929599a8 53 53 54 54 #include "uhci_batch.h" 55 #include "transfer_list.h" 55 56 #include "hc.h" 56 57 … … 323 324 static void endpoint_unregister(endpoint_t *ep) 324 325 { 326 hc_t * const hc = bus_to_hc(endpoint_get_bus(ep)); 325 327 usb2_bus_ops.endpoint_unregister(ep); 328 329 uhci_transfer_batch_t *batch = NULL; 326 330 327 331 fibril_mutex_lock(&ep->guard); 328 332 if (ep->active_batch) { 329 uhci_transfer_batch_t *ub = uhci_transfer_batch_get(ep->active_batch); 330 uhci_transfer_batch_abort(ub); 331 332 assert(ep->active_batch == NULL); 333 batch = uhci_transfer_batch_get(ep->active_batch); 334 335 transfer_list_t *list = hc->transfers[ep->device->speed][ep->transfer_type]; 336 assert(list); 337 338 fibril_mutex_lock(&list->guard); 339 transfer_list_remove_batch(list, batch); 340 fibril_mutex_unlock(&list->guard); 341 342 endpoint_wait_timeout_locked(ep, 2000); 343 344 batch = uhci_transfer_batch_get(ep->active_batch); 345 if (ep->active_batch) { 346 endpoint_deactivate_locked(ep); 347 } 333 348 } 334 349 fibril_mutex_unlock(&ep->guard); 350 351 if (batch) { 352 batch->base.error = EINTR; 353 batch->base.transfered_size = 0; 354 usb_transfer_batch_finish(&batch->base); 355 } 335 356 } 336 357 … … 486 507 static int hc_schedule(usb_transfer_batch_t *batch) 487 508 { 488 assert(batch); 489 hc_t *instance = bus_to_hc(endpoint_get_bus(batch->ep)); 490 491 if (batch->target.address == uhci_rh_get_address(&instance->rh)) 492 return uhci_rh_schedule(&instance->rh, batch); 493 494 uhci_transfer_batch_t *uhci_batch = (uhci_transfer_batch_t *) batch; 495 if (!uhci_batch) { 496 usb_log_error("Failed to create UHCI transfer structures.\n"); 497 return ENOMEM; 498 } 509 uhci_transfer_batch_t *uhci_batch = uhci_transfer_batch_get(batch); 510 endpoint_t *ep = batch->ep; 511 hc_t *hc = bus_to_hc(endpoint_get_bus(ep)); 512 513 if (batch->target.address == uhci_rh_get_address(&hc->rh)) 514 return uhci_rh_schedule(&hc->rh, batch); 515 499 516 500 517 const int err = uhci_transfer_batch_prepare(uhci_batch); … … 502 519 return err; 503 520 504 transfer_list_t *list = 505 instance->transfers[batch->ep->device->speed][batch->ep->transfer_type]; 521 transfer_list_t *list = hc->transfers[ep->device->speed][ep->transfer_type]; 506 522 assert(list); 507 523 transfer_list_add_batch(list, uhci_batch); 524 525 return EOK; 526 } 527 528 int hc_unschedule_batch(usb_transfer_batch_t *batch) 529 { 508 530 509 531 return EOK; -
uspace/drv/bus/usb/uhci/hc.h
r351113f r929599a8 139 139 } 140 140 141 int hc_unschedule_batch(usb_transfer_batch_t *); 142 141 143 extern int hc_add(hc_device_t *, const hw_res_list_parsed_t *); 142 144 extern int hc_gen_irq_code(irq_code_t *, hc_device_t *, const hw_res_list_parsed_t *); -
uspace/drv/bus/usb/uhci/transfer_list.c
r351113f r929599a8 45 45 #include "transfer_list.h" 46 46 47 static void transfer_list_remove_batch(48 transfer_list_t *instance, uhci_transfer_batch_t *uhci_batch);49 50 47 /** Initialize transfer list structures. 51 48 * -
uspace/drv/bus/usb/uhci/transfer_list.h
r351113f r929599a8 56 56 } transfer_list_t; 57 57 58 void transfer_list_fini(transfer_list_t * instance);59 int transfer_list_init(transfer_list_t * instance, const char *name);60 void transfer_list_set_next(transfer_list_t * instance, transfer_list_t *next);61 void transfer_list_add_batch( 62 transfer_list_t *instance, uhci_transfer_batch_t *batch);63 void transfer_list_remove_finished(transfer_list_t * instance, list_t *done);64 void transfer_list_abort_all(transfer_list_t * instance);58 void transfer_list_fini(transfer_list_t *); 59 int transfer_list_init(transfer_list_t *, const char *); 60 void transfer_list_set_next(transfer_list_t *, transfer_list_t *); 61 void transfer_list_add_batch(transfer_list_t *, uhci_transfer_batch_t *); 62 void transfer_list_remove_batch(transfer_list_t *, uhci_transfer_batch_t *); 63 void transfer_list_remove_finished(transfer_list_t *, list_t *); 64 void transfer_list_abort_all(transfer_list_t *); 65 65 66 66 #endif -
uspace/drv/bus/usb/uhci/uhci_batch.c
r351113f r929599a8 64 64 } 65 65 66 /**67 * Abort a transfer that is currently running.68 * Call with endpoint guard locked.69 */70 void uhci_transfer_batch_abort(uhci_transfer_batch_t *batch)71 {72 assert(batch);73 74 endpoint_t *ep = batch->base.ep;75 assert(ep);76 assert(fibril_mutex_is_locked(&ep->guard));77 assert(ep->active_batch == &batch->base);78 79 /*80 * TODO: Do some magic here to remove the batch from schedule.81 */82 83 /*84 * Wait for 2 frames. If the transfer was being processed,85 * it shall be marked as finished already after 1ms.86 */87 endpoint_wait_timeout_locked(ep, 2000);88 if (ep->active_batch != &batch->base)89 return;90 91 /*92 * Now, we can be sure the transfer is not scheduled,93 * and as such will not be completed. We now own the batch.94 */95 endpoint_deactivate_locked(ep);96 97 /* Leave the critical section for finishing the batch. */98 fibril_mutex_unlock(&ep->guard);99 100 batch->base.error = EINTR;101 batch->base.transfered_size = 0;102 usb_transfer_batch_finish(&batch->base);103 104 fibril_mutex_lock(&ep->guard);105 }106 107 66 /** Allocate memory and initialize internal data structure. 108 67 * -
uspace/drv/bus/usb/uhci/uhci_batch.h
r351113f r929599a8 70 70 int uhci_transfer_batch_prepare(uhci_transfer_batch_t *); 71 71 bool uhci_transfer_batch_check_completed(uhci_transfer_batch_t *); 72 void uhci_transfer_batch_abort(uhci_transfer_batch_t *);73 72 void uhci_transfer_batch_destroy(uhci_transfer_batch_t *); 74 73
Note:
See TracChangeset
for help on using the changeset viewer.