Changeset 0892663a in mainline for uspace/lib/usbhost/src/endpoint.c


Ignore:
Timestamp:
2018-01-11T04:14:37Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9848c77
Parents:
bad4a05
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-11 03:59:03)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-11 04:14:37)
Message:

usbhost: device removal and off/onlining moved into the library

Also, it is just not possible to make generic transfer abortion. So the
current semantics of endpoint unregistering is also aborting the pending
transfer. As it is not yet implemented in XHCI, and the stub in UHCI is
missing the magic, it breaks offlining interrupt devices, such as mouse.

When finishing this commit, I came across the fact we need some more
synchronization above device. Guard can protect internal structures, but
it cannot synchronize multiple calls to offline, or offline & removal
between each other - they both need to allow driver to unregister
endpoints, and as such must release the guard.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/endpoint.c

    rbad4a05 r0892663a  
    124124
    125125/**
     126 * Wait until the endpoint have no transfer scheduled.
     127 */
     128void endpoint_wait_timeout_locked(endpoint_t *ep, suseconds_t timeout)
     129{
     130        assert(fibril_mutex_is_locked(&ep->guard));
     131
     132        while (ep->active_batch != NULL)
     133                fibril_condvar_wait_timeout(&ep->avail, &ep->guard, timeout);
     134}
     135
     136/**
    126137 * Mark the endpoint as active and block access for further fibrils. If the
    127138 * endpoint is already active, it will block on ep->avail condvar.
     
    138149        assert(batch);
    139150        assert(batch->ep == ep);
    140         assert(fibril_mutex_is_locked(&ep->guard));
    141 
    142         while (ep->active_batch != NULL)
    143                 fibril_condvar_wait(&ep->avail, &ep->guard);
     151
     152        endpoint_wait_timeout_locked(ep, 0);
    144153        ep->active_batch = batch;
    145154}
     
    160169        ep->active_batch = NULL;
    161170        fibril_condvar_signal(&ep->avail);
    162 }
    163 
    164 /**
    165  * Abort an active batch on endpoint, if any.
    166  *
    167  * @param[in] ep endpoint_t structure.
    168  */
    169 void endpoint_abort(endpoint_t *ep)
    170 {
    171         assert(ep);
    172 
    173         fibril_mutex_lock(&ep->guard);
    174         usb_transfer_batch_t *batch = ep->active_batch;
    175         endpoint_deactivate_locked(ep);
    176         fibril_mutex_unlock(&ep->guard);
    177 
    178         if (batch)
    179                 usb_transfer_batch_abort(batch);
    180171}
    181172
Note: See TracChangeset for help on using the changeset viewer.