Changeset 8ad2b0a in mainline for uspace/drv/bus/usb/ehci/ehci_bus.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:
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/ehci_bus.c

    rd60115a r8ad2b0a  
    7777        ehci_ep->qh = ehci_ep->dma_buffer.virt;
    7878
    79         link_initialize(&ehci_ep->link);
     79        link_initialize(&ehci_ep->eplist_link);
     80        link_initialize(&ehci_ep->pending_link);
    8081        return &ehci_ep->base;
    8182}
     
    116117        bus_t *bus_base = endpoint_get_bus(ep);
    117118        ehci_bus_t *bus = (ehci_bus_t *) bus_base;
     119        hc_t *hc = bus->hc;
    118120        assert(bus);
    119121        assert(ep);
    120122
    121123        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        }
    123153}
    124154
Note: See TracChangeset for help on using the changeset viewer.