Changeset 8ad2b0a in mainline for uspace/drv/bus/usb/ehci/hc.c


Ignore:
Timestamp:
2018-01-17T17:55:35Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
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)
Message:

ehci: implement transfer abort on endpoint unregister

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/hc.c

    rd60115a r8ad2b0a  
    173173            + EHCI_RD8(instance->caps->caplength));
    174174
    175         list_initialize(&instance->pending_batches);
     175        list_initialize(&instance->pending_endpoints);
    176176        fibril_mutex_initialize(&instance->guard);
    177177        fibril_condvar_initialize(&instance->async_doorbell);
     
    299299        }
    300300
     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
    301310        ehci_transfer_batch_t *ehci_batch = ehci_transfer_batch_get(batch);
    302 
    303311        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);
    305317                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 */
    307325        fibril_mutex_lock(&hc->guard);
    308326        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);
    313330        fibril_mutex_unlock(&hc->guard);
     331
    314332        return EOK;
    315333}
     
    341359
    342360        if (status & (USB_STS_IRQ_FLAG | USB_STS_ERR_IRQ_FLAG)) {
     361
     362                LIST_INITIALIZE(completed);
     363
    343364                fibril_mutex_lock(&hc->guard);
    344365
    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);
    350376
    351377                        if (ehci_transfer_batch_check_completed(batch)) {
     378                                endpoint_deactivate_locked(&ep->base);
    352379                                list_remove(current);
     380                                endpoint_del_ref(&ep->base);
    353381                                usb_transfer_batch_finish(&batch->base);
    354382                        }
     383                        fibril_mutex_unlock(&ep->base.guard);
    355384                }
    356385                fibril_mutex_unlock(&hc->guard);
     386
     387
    357388        }
    358389
Note: See TracChangeset for help on using the changeset viewer.