Changeset 8ad2b0a in mainline
- Timestamp:
- 2018-01-17T17:55:35Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 94f8c363
- Parents:
- d60115a
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-01-17 17:54:41)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-01-17 17:55:35)
- Location:
- uspace/drv/bus/usb
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/ehci_batch.c
rd60115a r8ad2b0a 84 84 85 85 usb_transfer_batch_init(&ehci_batch->base, ep); 86 link_initialize(&ehci_batch->link);87 86 88 87 return ehci_batch; -
uspace/drv/bus/usb/ehci/ehci_batch.h
rd60115a r8ad2b0a 49 49 /** Number of TDs used by the transfer */ 50 50 size_t td_count; 51 /** Link */52 link_t link;53 51 /** Endpoint descriptor of the target endpoint. */ 54 52 qh_t *qh; … … 70 68 void ehci_transfer_batch_destroy(ehci_transfer_batch_t *batch); 71 69 72 static inline ehci_transfer_batch_t *ehci_transfer_batch_from_link(link_t *l)73 {74 assert(l);75 return list_get_instance(l, ehci_transfer_batch_t, link);76 }77 78 70 static inline ehci_transfer_batch_t * ehci_transfer_batch_get(usb_transfer_batch_t *usb_batch) 79 71 { -
uspace/drv/bus/usb/ehci/ehci_bus.c
rd60115a r8ad2b0a 77 77 ehci_ep->qh = ehci_ep->dma_buffer.virt; 78 78 79 link_initialize(&ehci_ep->link); 79 link_initialize(&ehci_ep->eplist_link); 80 link_initialize(&ehci_ep->pending_link); 80 81 return &ehci_ep->base; 81 82 } … … 116 117 bus_t *bus_base = endpoint_get_bus(ep); 117 118 ehci_bus_t *bus = (ehci_bus_t *) bus_base; 119 hc_t *hc = bus->hc; 118 120 assert(bus); 119 121 assert(ep); 120 122 121 123 usb2_bus_ops.endpoint_unregister(ep); 122 hc_dequeue_endpoint(bus->hc, ep); 124 hc_dequeue_endpoint(hc, ep); 125 126 ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep); 127 128 /* 129 * Now we can be sure the active transfer will not be completed. But first, 130 * make sure that the handling fibril won't use its link in pending list. 131 */ 132 fibril_mutex_lock(&hc->guard); 133 if (link_in_use(&ehci_ep->pending_link)) 134 /* pending list reference */ 135 endpoint_del_ref(ep); 136 list_remove(&ehci_ep->pending_link); 137 fibril_mutex_unlock(&hc->guard); 138 139 /* 140 * Finally, the endpoint shall not be used anywhere else. Finish the 141 * pending batch. 142 */ 143 fibril_mutex_lock(&ep->guard); 144 usb_transfer_batch_t * const batch = ep->active_batch; 145 endpoint_deactivate_locked(ep); 146 fibril_mutex_unlock(&ep->guard); 147 148 if (batch) { 149 batch->error = EINTR; 150 batch->transfered_size = 0; 151 usb_transfer_batch_finish(batch); 152 } 123 153 } 124 154 -
uspace/drv/bus/usb/ehci/ehci_bus.h
rd60115a r8ad2b0a 53 53 54 54 dma_buffer_t dma_buffer; 55 /** Linked list used by driver software */ 56 link_t link; 55 56 /** Link in endpoint_list */ 57 link_t eplist_link; 58 59 /** Link in pending_endpoints */ 60 link_t pending_link; 57 61 } ehci_endpoint_t; 58 62 … … 80 84 static inline ehci_endpoint_t * ehci_endpoint_list_instance(link_t *l) 81 85 { 82 return list_get_instance(l, ehci_endpoint_t, link);86 return list_get_instance(l, ehci_endpoint_t, eplist_link); 83 87 } 84 88 -
uspace/drv/bus/usb/ehci/endpoint_list.c
rd60115a r8ad2b0a 124 124 write_barrier(); 125 125 /* Add to the sw list */ 126 list_append(&ep-> link, &instance->endpoint_list);126 list_append(&ep->eplist_link, &instance->endpoint_list); 127 127 128 128 ehci_endpoint_t *first = ehci_endpoint_list_instance( … … 159 159 qh_t *prev_qh; 160 160 /* Remove from the hardware queue */ 161 if (list_first(&instance->endpoint_list) == &ep-> link) {161 if (list_first(&instance->endpoint_list) == &ep->eplist_link) { 162 162 /* I'm the first one here */ 163 163 prev_qh = instance->list_head; 164 164 qpos = "FIRST"; 165 165 } else { 166 prev_qh = ehci_endpoint_list_instance(ep-> link.prev)->qh;166 prev_qh = ehci_endpoint_list_instance(ep->eplist_link.prev)->qh; 167 167 qpos = "NOT FIRST"; 168 168 } … … 176 176 177 177 /* Remove from the endpoint list */ 178 list_remove(&ep-> link);178 list_remove(&ep->eplist_link); 179 179 fibril_mutex_unlock(&instance->guard); 180 180 } -
uspace/drv/bus/usb/ehci/hc.c
rd60115a r8ad2b0a 173 173 + EHCI_RD8(instance->caps->caplength)); 174 174 175 list_initialize(&instance->pending_ batches);175 list_initialize(&instance->pending_endpoints); 176 176 fibril_mutex_initialize(&instance->guard); 177 177 fibril_condvar_initialize(&instance->async_doorbell); … … 299 299 } 300 300 301 endpoint_t * const ep = batch->ep; 302 ehci_endpoint_t * const ehci_ep = ehci_endpoint_get(ep); 303 304 /* creating local reference */ 305 endpoint_add_ref(ep); 306 307 fibril_mutex_lock(&ep->guard); 308 endpoint_activate_locked(ep, batch); 309 301 310 ehci_transfer_batch_t *ehci_batch = ehci_transfer_batch_get(batch); 302 303 311 const int err = ehci_transfer_batch_prepare(ehci_batch); 304 if (err) 312 if (err) { 313 endpoint_deactivate_locked(ep); 314 fibril_mutex_unlock(&ep->guard); 315 /* dropping local reference */ 316 endpoint_del_ref(ep); 305 317 return err; 306 318 } 319 320 usb_log_debug("HC(%p): Committing BATCH(%p)", hc, batch); 321 ehci_transfer_batch_commit(ehci_batch); 322 fibril_mutex_unlock(&ep->guard); 323 324 /* Enqueue endpoint to the checked list */ 307 325 fibril_mutex_lock(&hc->guard); 308 326 usb_log_debug2("HC(%p): Appending BATCH(%p)", hc, batch); 309 list_append(&ehci_batch->link, &hc->pending_batches); 310 usb_log_debug("HC(%p): Committing BATCH(%p)", hc, batch); 311 ehci_transfer_batch_commit(ehci_batch); 312 327 328 /* local reference -> pending list reference */ 329 list_append(&ehci_ep->pending_link, &hc->pending_endpoints); 313 330 fibril_mutex_unlock(&hc->guard); 331 314 332 return EOK; 315 333 } … … 341 359 342 360 if (status & (USB_STS_IRQ_FLAG | USB_STS_ERR_IRQ_FLAG)) { 361 362 LIST_INITIALIZE(completed); 363 343 364 fibril_mutex_lock(&hc->guard); 344 365 345 usb_log_debug2("HC(%p): Scanning %lu pending batches", hc, 346 list_count(&hc->pending_batches)); 347 list_foreach_safe(hc->pending_batches, current, next) { 348 ehci_transfer_batch_t *batch = 349 ehci_transfer_batch_from_link(current); 366 usb_log_debug2("HC(%p): Scanning %lu pending endpoints", hc, 367 list_count(&hc->pending_endpoints)); 368 list_foreach_safe(hc->pending_endpoints, current, next) { 369 ehci_endpoint_t *ep 370 = list_get_instance(current, ehci_endpoint_t, pending_link); 371 372 fibril_mutex_lock(&ep->base.guard); 373 ehci_transfer_batch_t *batch 374 = ehci_transfer_batch_get(ep->base.active_batch); 375 assert(batch); 350 376 351 377 if (ehci_transfer_batch_check_completed(batch)) { 378 endpoint_deactivate_locked(&ep->base); 352 379 list_remove(current); 380 endpoint_del_ref(&ep->base); 353 381 usb_transfer_batch_finish(&batch->base); 354 382 } 383 fibril_mutex_unlock(&ep->base.guard); 355 384 } 356 385 fibril_mutex_unlock(&hc->guard); 386 387 357 388 } 358 389 -
uspace/drv/bus/usb/ehci/hc.h
rd60115a r8ad2b0a 75 75 76 76 /** List of active transfers */ 77 list_t pending_ batches;77 list_t pending_endpoints; 78 78 79 79 /** Guards schedule and endpoint manipulation */ -
uspace/drv/bus/usb/ehci/main.c
rd60115a r8ad2b0a 67 67 { 68 68 log_init(NAME); 69 logctl_set_log_level(NAME, LVL_ NOTE);69 logctl_set_log_level(NAME, LVL_DEBUG2); 70 70 return hc_driver_main(&ehci_driver); 71 71 } -
uspace/drv/bus/usb/uhci/main.c
rd60115a r8ad2b0a 92 92 printf(NAME ": HelenOS UHCI driver.\n"); 93 93 log_init(NAME); 94 logctl_set_log_level(NAME, LVL_ DEBUG2);94 logctl_set_log_level(NAME, LVL_NOTE); 95 95 return hc_driver_main(&uhci_driver); 96 96 }
Note:
See TracChangeset
for help on using the changeset viewer.