Ignore:
Timestamp:
2018-01-11T04:14:37Z (7 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/ddf_helpers.c

    rbad4a05 r0892663a  
    336336        assert(device);
    337337
    338         hc_device_t *hcd = dev_to_hcd(device);
    339         assert(hcd);
    340         assert(hcd->bus);
     338        device_t *victim = NULL;
    341339
    342340        fibril_mutex_lock(&hub->guard);
    343 
    344         device_t *victim = NULL;
    345 
    346341        list_foreach(hub->devices, link, device_t, it) {
    347342                if (it->port == port) {
     
    350345                }
    351346        }
    352         if (victim) {
    353                 assert(victim->fun);
    354                 assert(victim->port == port);
    355                 assert(victim->hub == hub);
    356                 list_remove(&victim->link);
    357                 fibril_mutex_unlock(&hub->guard);
    358                 const int ret = ddf_fun_unbind(victim->fun);
    359                 if (ret == EOK) {
    360                         bus_device_remove(victim);
    361                         ddf_fun_destroy(victim->fun);
    362                 } else {
    363                         usb_log_warning("Failed to unbind device `%s': %s\n",
    364                             ddf_fun_get_name(victim->fun), str_error(ret));
    365                 }
    366                 return EOK;
    367         }
    368347        fibril_mutex_unlock(&hub->guard);
    369         return ENOENT;
     348
     349        if (!victim)
     350                return ENOENT;
     351
     352        assert(victim->fun);
     353        assert(victim->port == port);
     354        assert(victim->hub == hub);
     355
     356        bus_device_remove(victim);
     357        return EOK;
    370358}
    371359
     
    477465        }
    478466
    479         fibril_mutex_lock(&hub->guard);
    480         list_append(&dev->link, &hub->devices);
    481         fibril_mutex_unlock(&hub->guard);
    482 
    483467        return EOK;
    484468
Note: See TracChangeset for help on using the changeset viewer.