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/drv/bus/usb/uhci/uhci_batch.c

    rbad4a05 r0892663a  
    6464}
    6565
     66/**
     67 * Abort a transfer that is currently running.
     68 * Call with endpoint guard locked.
     69 */
     70void uhci_transfer_batch_abort(uhci_transfer_batch_t *batch)
     71{
     72        assert(batch);
     73
     74        endpoint_t *ep = batch->base.ep;
     75        assert(ep);
     76        assert(fibril_mutex_is_locked(&ep->guard));
     77        assert(ep->active_batch == &batch->base);
     78
     79        /*
     80         * TODO: Do some magic here to remove the batch from schedule.
     81         */
     82
     83        /*
     84         * Wait for 2 frames. If the transfer was being processed,
     85         * it shall be marked as finished already after 1ms.
     86         */
     87        endpoint_wait_timeout_locked(ep, 2000);
     88        if (ep->active_batch != &batch->base)
     89                return;
     90
     91        /*
     92         * Now, we can be sure the transfer is not scheduled,
     93         * and as such will not be completed. We now own the batch.
     94         */
     95        endpoint_deactivate_locked(ep);
     96
     97        /* Leave the critical section for finishing the batch. */
     98        fibril_mutex_unlock(&ep->guard);
     99
     100        batch->base.error = EINTR;
     101        batch->base.transfered_size = 0;
     102        usb_transfer_batch_finish(&batch->base);
     103
     104        fibril_mutex_lock(&ep->guard);
     105}
     106
    66107/** Allocate memory and initialize internal data structure.
    67108 *
Note: See TracChangeset for help on using the changeset viewer.