Changes in / [4b39af4:8b74997f] in mainline


Ignore:
Location:
uspace
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/root_hub.c

    r4b39af4 r8b74997f  
    249249                opResult = EINVAL;
    250250        }
    251         usb_transfer_batch_finish_error(request, opResult);
     251        usb_transfer_batch_finish(request, opResult);
    252252        return EOK;
    253253}
     
    863863}
    864864
     865
     866
     867
    865868/**
    866869 * @}
  • uspace/drv/uhci-hcd/hc.c

    r4b39af4 r8b74997f  
    332332            instance->transfers[batch->speed][batch->transfer_type];
    333333        assert(list);
     334        if (batch->transfer_type == USB_TRANSFER_CONTROL) {
     335                usb_device_keeper_use_control(
     336                    &instance->manager, batch->target);
     337        }
    334338        transfer_list_add_batch(list, batch);
    335339
     
    369373                        usb_transfer_batch_t *batch =
    370374                            list_get_instance(item, usb_transfer_batch_t, link);
    371                         usb_transfer_batch_finish(batch);
     375                        switch (batch->transfer_type)
     376                        {
     377                        case USB_TRANSFER_CONTROL:
     378                                usb_device_keeper_release_control(
     379                                    &instance->manager, batch->target);
     380                                break;
     381                        case USB_TRANSFER_INTERRUPT:
     382                        case USB_TRANSFER_ISOCHRONOUS: {
     383/*
     384                                int ret = bandwidth_free(&instance->bandwidth,
     385                                    batch->target.address,
     386                                    batch->target.endpoint,
     387                                    batch->direction);
     388                                if (ret != EOK)
     389                                        usb_log_warning("Failed(%d) to free "
     390                                            "reserved bw: %s.\n", ret,
     391                                            str_error(ret));
     392*/
     393                                }
     394                        default:
     395                                break;
     396                        }
     397                        batch->next_step(batch);
    372398                }
    373399        }
  • uspace/drv/uhci-hcd/transfer_list.c

    r4b39af4 r8b74997f  
    132132}
    133133/*----------------------------------------------------------------------------*/
    134 /** Create list for finished batches.
    135  *
    136  * @param[in] instance List to use.
    137  * @param[in] done list to fill
     134/** Check list for finished batches.
     135 *
     136 * @param[in] instance List to use.
     137 * @return Error code
     138 *
     139 * Creates a local list of finished batches and calls next_step on each and
     140 * every one. This is safer because next_step may theoretically access
     141 * this transfer list leading to the deadlock if its done inline.
    138142 */
    139143void transfer_list_remove_finished(transfer_list_t *instance, link_t *done)
     
    157161        }
    158162        fibril_mutex_unlock(&instance->guard);
     163
    159164}
    160165/*----------------------------------------------------------------------------*/
     
    171176                    list_get_instance(current, usb_transfer_batch_t, link);
    172177                transfer_list_remove_batch(instance, batch);
    173                 usb_transfer_batch_finish_error(batch, EIO);
     178                usb_transfer_batch_finish(batch, EIO);
    174179        }
    175180        fibril_mutex_unlock(&instance->guard);
  • uspace/lib/usb/include/usb/host/batch.h

    r4b39af4 r8b74997f  
    9292void usb_transfer_batch_call_in(usb_transfer_batch_t *instance);
    9393void usb_transfer_batch_call_out(usb_transfer_batch_t *instance);
    94 void usb_transfer_batch_finish(usb_transfer_batch_t *instance);
    95 
    96 static inline void usb_transfer_batch_finish_error(
    97     usb_transfer_batch_t *instance, int error)
    98 {
    99         assert(instance);
    100         instance->error = error;
    101         usb_transfer_batch_finish(instance);
    102 }
     94void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error);
    10395
    10496#endif
  • uspace/lib/usb/include/usb/host/device_keeper.h

    r4b39af4 r8b74997f  
    9696usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance,
    9797    usb_address_t address);
     98
     99void usb_device_keeper_use_control(usb_device_keeper_t *instance,
     100    usb_target_t target);
     101
     102void usb_device_keeper_release_control(usb_device_keeper_t *instance,
     103    usb_target_t target);
     104
    98105#endif
    99106/**
  • uspace/lib/usb/include/usb/host/endpoint.h

    r4b39af4 r8b74997f  
    3939#include <bool.h>
    4040#include <adt/list.h>
    41 #include <fibril_synch.h>
    42 
    4341#include <usb/usb.h>
    4442
     
    5048        usb_speed_t speed;
    5149        size_t max_packet_size;
     50        bool active;
    5251        unsigned toggle:1;
    53         fibril_mutex_t guard;
    54         fibril_condvar_t avail;
    55         volatile bool active;
    5652        link_t same_device_eps;
    5753} endpoint_t;
     
    6258
    6359void endpoint_destroy(endpoint_t *instance);
    64 
    65 void endpoint_use(endpoint_t *instance);
    66 
    67 void endpoint_release(endpoint_t *instance);
    6860
    6961int endpoint_toggle_get(endpoint_t *instance);
  • uspace/lib/usb/src/host/batch.c

    r4b39af4 r8b74997f  
    7979        instance->error = EOK;
    8080        instance->ep = ep;
    81         endpoint_use(instance->ep);
    8281}
    8382/*----------------------------------------------------------------------------*/
     
    8786 *
    8887 */
    89 void usb_transfer_batch_finish(usb_transfer_batch_t *instance)
     88void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error)
    9089{
    9190        assert(instance);
    92         assert(instance->ep);
    93         endpoint_release(instance->ep);
     91        instance->error = error;
    9492        instance->next_step(instance);
    9593}
  • uspace/lib/usb/src/host/device_keeper.c

    r4b39af4 r8b74997f  
    264264        return instance->devices[address].speed;
    265265}
     266/*----------------------------------------------------------------------------*/
     267void usb_device_keeper_use_control(
     268    usb_device_keeper_t *instance, usb_target_t target)
     269{
     270        assert(instance);
     271        const uint16_t ep = 1 << target.endpoint;
     272        fibril_mutex_lock(&instance->guard);
     273        while (instance->devices[target.address].control_used & ep) {
     274                fibril_condvar_wait(&instance->change, &instance->guard);
     275        }
     276        instance->devices[target.address].control_used |= ep;
     277        fibril_mutex_unlock(&instance->guard);
     278}
     279/*----------------------------------------------------------------------------*/
     280void usb_device_keeper_release_control(
     281    usb_device_keeper_t *instance, usb_target_t target)
     282{
     283        assert(instance);
     284        const uint16_t ep = 1 << target.endpoint;
     285        fibril_mutex_lock(&instance->guard);
     286        assert((instance->devices[target.address].control_used & ep) != 0);
     287        instance->devices[target.address].control_used &= ~ep;
     288        fibril_mutex_unlock(&instance->guard);
     289        fibril_condvar_signal(&instance->change);
     290}
    266291/**
    267292 * @}
  • uspace/lib/usb/src/host/endpoint.c

    r4b39af4 r8b74997f  
    3434 */
    3535
    36 #include <assert.h>
    3736#include <errno.h>
    3837#include <usb/host/endpoint.h>
     
    5049        instance->max_packet_size = max_packet_size;
    5150        instance->toggle = 0;
    52         instance->active = false;
    53         fibril_mutex_initialize(&instance->guard);
    54         fibril_condvar_initialize(&instance->avail);
    5551        link_initialize(&instance->same_device_eps);
    5652        return EOK;
     
    6056{
    6157        assert(instance);
    62         assert(!instance->active);
    6358        list_remove(&instance->same_device_eps);
    6459        free(instance);
    65 }
    66 /*----------------------------------------------------------------------------*/
    67 void endpoint_use(endpoint_t *instance)
    68 {
    69         assert(instance);
    70         fibril_mutex_lock(&instance->guard);
    71         while (instance->active)
    72                 fibril_condvar_wait(&instance->avail, &instance->guard);
    73         instance->active = true;
    74         fibril_mutex_unlock(&instance->guard);
    75 }
    76 /*----------------------------------------------------------------------------*/
    77 void endpoint_release(endpoint_t *instance)
    78 {
    79         assert(instance);
    80         fibril_mutex_lock(&instance->guard);
    81         instance->active = false;
    82         fibril_mutex_unlock(&instance->guard);
    83         fibril_condvar_signal(&instance->avail);
    8460}
    8561/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.