Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ee0ffa6 in mainline


Ignore:
Timestamp:
2018-01-29T15:17:43Z (4 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial
Children:
705f83a
Parents:
ddbd088
Message:

ohci: fix invalid synchronization

Location:
uspace/drv/bus/usb/ohci
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    rddbd088 ree0ffa6  
    460460{
    461461        hc_t *instance = hcd_to_hc(hcd);
    462         ohci_rh_init(&instance->rh, instance->registers, "ohci rh");
     462        ohci_rh_init(&instance->rh, instance->registers, &instance->guard, "ohci rh");
    463463
    464464        /* OHCI guide page 42 */
  • uspace/drv/bus/usb/ohci/ohci_rh.c

    rddbd088 ree0ffa6  
    109109 * initializes internal virtual hub.
    110110 */
    111 int ohci_rh_init(ohci_rh_t *instance, ohci_regs_t *regs, const char *name)
     111int ohci_rh_init(ohci_rh_t *instance, ohci_regs_t *regs,
     112    fibril_mutex_t *guard, const char *name)
    112113{
    113114        assert(instance);
     
    163164        ohci_rh_hub_desc_init(instance);
    164165        instance->status_change_endpoint = NULL;
     166        instance->guard = guard;
    165167        return virthub_base_init(&instance->base, name, &ops, instance,
    166168            NULL, &instance->hub_descriptor.header, HUB_STATUS_CHANGE_PIPE);
     
    183185        if (batch->error == ENAK) {
    184186                /* Lock the HC guard */
    185                 fibril_mutex_lock(batch->ep->guard);
     187                fibril_mutex_lock(instance->guard);
    186188                const int err = endpoint_activate_locked(batch->ep, batch);
    187189                if (err) {
     
    198200                endpoint_add_ref(batch->ep);
    199201                instance->status_change_endpoint = batch->ep;
    200                 fibril_mutex_unlock(batch->ep->guard);
     202                fibril_mutex_unlock(instance->guard);
    201203        } else {
    202204                usb_transfer_batch_finish(batch);
     
    214216int ohci_rh_interrupt(ohci_rh_t *instance)
    215217{
     218        fibril_mutex_lock(instance->guard);
    216219        endpoint_t *ep = instance->status_change_endpoint;
    217         if (!ep)
     220        if (!ep) {
     221                fibril_mutex_unlock(instance->guard);
    218222                return EOK;
    219 
    220         fibril_mutex_lock(ep->guard);
     223        }
     224
    221225        usb_transfer_batch_t * const batch = ep->active_batch;
    222226        endpoint_deactivate_locked(ep);
    223227        instance->status_change_endpoint = NULL;
    224         fibril_mutex_unlock(ep->guard);
     228        fibril_mutex_unlock(instance->guard);
    225229
    226230        endpoint_del_ref(ep);
  • uspace/drv/bus/usb/ohci/ohci_rh.h

    rddbd088 ree0ffa6  
    6363        /** A hacky way to emulate interrupts over polling. See ehci_rh. */
    6464        endpoint_t *status_change_endpoint;
     65        fibril_mutex_t *guard;
    6566} ohci_rh_t;
    6667
    67 int ohci_rh_init(ohci_rh_t *instance, ohci_regs_t *regs, const char *name);
     68int ohci_rh_init(ohci_rh_t *, ohci_regs_t *, fibril_mutex_t *, const char *);
    6869int ohci_rh_schedule(ohci_rh_t *instance, usb_transfer_batch_t *batch);
    6970int ohci_rh_interrupt(ohci_rh_t *instance);
Note: See TracChangeset for help on using the changeset viewer.