Changeset d60115a in mainline for uspace/drv/bus/usb/ohci/hc.c


Ignore:
Timestamp:
2018-01-17T17:55:35Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8ad2b0a
Parents:
ed8575f
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-17 17:54:31)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-17 17:55:35)
Message:

ohci: implement transfer abort on endpoint unregister

File:
1 edited

Legend:

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

    red8575f rd60115a  
    168168            hw_res->mem_ranges.ranges[0].size);
    169169
    170         list_initialize(&instance->pending_batches);
     170        list_initialize(&instance->pending_endpoints);
    171171        fibril_mutex_initialize(&instance->guard);
    172172
     
    304304                return err;
    305305
    306         fibril_mutex_lock(&hc->guard);
    307         list_append(&ohci_batch->link, &hc->pending_batches);
     306        endpoint_t *ep = batch->ep;
     307        ohci_endpoint_t * const ohci_ep = ohci_endpoint_get(ep);
     308
     309        /* creating local reference */
     310        endpoint_add_ref(ep);
     311
     312        fibril_mutex_lock(&ep->guard);
     313        endpoint_activate_locked(ep, batch);
    308314        ohci_transfer_batch_commit(ohci_batch);
     315        fibril_mutex_unlock(&ep->guard);
    309316
    310317        /* Control and bulk schedules need a kick to start working */
     
    320327                break;
    321328        }
     329
     330        fibril_mutex_lock(&hc->guard);
     331        list_append(&ohci_ep->pending_link, &hc->pending_endpoints);
    322332        fibril_mutex_unlock(&hc->guard);
     333
    323334        return EOK;
    324335}
     
    353364                    OHCI_RD(hc->registers->periodic_current));
    354365
    355                 link_t *current = list_first(&hc->pending_batches);
    356                 while (current && current != &hc->pending_batches.head) {
    357                         link_t *next = current->next;
    358                         ohci_transfer_batch_t *batch =
    359                             ohci_transfer_batch_from_link(current);
     366                list_foreach_safe(hc->pending_endpoints, current, next) {
     367                        ohci_endpoint_t *ep
     368                                = list_get_instance(current, ohci_endpoint_t, pending_link);
     369
     370                        fibril_mutex_lock(&ep->base.guard);
     371                        ohci_transfer_batch_t *batch
     372                                = ohci_transfer_batch_get(ep->base.active_batch);
     373                        assert(batch);
    360374
    361375                        if (ohci_transfer_batch_check_completed(batch)) {
     376                                endpoint_deactivate_locked(&ep->base);
    362377                                list_remove(current);
     378                                endpoint_del_ref(&ep->base);
    363379                                usb_transfer_batch_finish(&batch->base);
    364380                        }
    365 
    366                         current = next;
     381                        fibril_mutex_unlock(&ep->base.guard);
    367382                }
    368383                fibril_mutex_unlock(&hc->guard);
Note: See TracChangeset for help on using the changeset viewer.