Ignore:
Timestamp:
2011-04-02T15:47:45Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
322a8066, d8987b1
Parents:
969585f (diff), 0053fa38 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Add USB bandwidth control mechanism

Use per endpoint control transfer mutex
Bandwidth control issues warnings, drivers(libusb pipe init?) need to use it first.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/host/device_keeper.c

    r969585f r5542b83  
    5454        for (; i < USB_ADDRESS_COUNT; ++i) {
    5555                instance->devices[i].occupied = false;
    56                 instance->devices[i].control_used = false;
     56                instance->devices[i].control_used = 0;
    5757                instance->devices[i].handle = 0;
    5858                instance->devices[i].toggle_status[0] = 0;
     
    311311/*----------------------------------------------------------------------------*/
    312312void usb_device_keeper_use_control(usb_device_keeper_t *instance,
    313     usb_address_t address)
    314 {
    315         assert(instance);
    316         fibril_mutex_lock(&instance->guard);
    317         while (instance->devices[address].control_used) {
     313    usb_target_t target)
     314{
     315        assert(instance);
     316        const uint16_t ep = 1 << target.endpoint;
     317        fibril_mutex_lock(&instance->guard);
     318        while (instance->devices[target.address].control_used & ep) {
    318319                fibril_condvar_wait(&instance->change, &instance->guard);
    319320        }
    320         instance->devices[address].control_used = true;
     321        instance->devices[target.address].control_used |= ep;
    321322        fibril_mutex_unlock(&instance->guard);
    322323}
    323324/*----------------------------------------------------------------------------*/
    324325void usb_device_keeper_release_control(usb_device_keeper_t *instance,
    325     usb_address_t address)
    326 {
    327         assert(instance);
    328         fibril_mutex_lock(&instance->guard);
    329         instance->devices[address].control_used = false;
     326    usb_target_t target)
     327{
     328        assert(instance);
     329        const uint16_t ep = 1 << target.endpoint;
     330        fibril_mutex_lock(&instance->guard);
     331        assert((instance->devices[target.address].control_used & ep) != 0);
     332        instance->devices[target.address].control_used &= ~ep;
    330333        fibril_mutex_unlock(&instance->guard);
    331334        fibril_condvar_signal(&instance->change);
Note: See TracChangeset for help on using the changeset viewer.