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

    rbad4a05 r0892663a  
    135135}
    136136
    137 static int ehci_device_online(device_t *device)
    138 {
    139         int err;
    140 
    141         /* Allow creation of new endpoints and transfers. */
    142         usb_log_info("Device(%d): Going online.", device->address);
    143         fibril_mutex_lock(&device->guard);
    144         device->online = true;
    145         fibril_mutex_unlock(&device->guard);
    146 
    147         if ((err = ddf_fun_online(device->fun))) {
    148                 return err;
    149         }
    150 
    151         return EOK;
    152 }
    153 
    154 static int ehci_device_offline(device_t *device)
    155 {
    156         int err;
    157 
    158         /* Tear down all drivers working with the device. */
    159         if ((err = ddf_fun_offline(device->fun))) {
    160                 return err;
    161         }
    162 
    163         /* At this point, all drivers are assumed to have already terminated
    164          * in a consistent way. The following code just cleans up hanging
    165          * transfers if there are any. */
    166 
    167         /* Block creation of new endpoints and transfers. */
    168         usb_log_info("Device(%d): Going offline.", device->address);
    169         fibril_mutex_lock(&device->guard);
    170         device->online = false;
    171         fibril_mutex_unlock(&device->guard);
    172 
    173         /* FIXME: Abort all transfers to all endpoints. */
    174 
    175         return EOK;
    176 }
    177 
    178137static const bus_ops_t ehci_bus_ops = {
    179138        .parent = &usb2_bus_ops,
     
    190149        .batch_destroy = ehci_destroy_batch,
    191150        .batch_schedule = ehci_hc_schedule,
    192         .device_online = ehci_device_online,
    193         .device_offline = ehci_device_offline,
    194151};
    195152
Note: See TracChangeset for help on using the changeset viewer.