Changeset 19746a96 in mainline


Ignore:
Timestamp:
2011-10-16T17:10:19Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f8dfb40
Parents:
0fe2ff1
Message:

ohci: Add root hub mutex to prevent interrupt request handling race.

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

Legend:

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

    r0fe2ff1 r19746a96  
    3535#include <errno.h>
    3636#include <str_error.h>
     37#include <fibril_synch.h>
    3738
    3839#include <usb/debug.h>
     40#include <usb/dev/request.h>
     41#include <usb/classes/hub.h>
    3942
    4043#include "root_hub.h"
     
    4346#include <usb/dev/driver.h>
    4447#include "ohci_regs.h"
    45 
    46 #include <usb/dev/request.h>
    47 #include <usb/classes/hub.h>
    4848
    4949/**
     
    189189#endif
    190190
     191        fibril_mutex_initialize(&instance->guard);
    191192        rh_init_descriptors(instance);
    192193
     
    216217        case USB_TRANSFER_INTERRUPT:
    217218                usb_log_debug("Root hub got INTERRUPT packet\n");
     219                fibril_mutex_lock(&instance->guard);
     220                assert(instance->unfinished_interrupt_transfer == NULL);
    218221                const uint16_t mask = create_interrupt_mask(instance);
    219222                if (mask == 0) {
    220223                        usb_log_debug("No changes..\n");
    221                         assert(instance->unfinished_interrupt_transfer == NULL);
    222224                        instance->unfinished_interrupt_transfer = request;
     225                        fibril_mutex_unlock(&instance->guard);
    223226                        return;
    224227                }
    225228                usb_log_debug("Processing changes...\n");
    226229                interrupt_request(request, mask, instance->interrupt_mask_size);
     230                fibril_mutex_unlock(&instance->guard);
    227231                break;
    228232
     
    244248        assert(instance);
    245249
    246         if (!instance->unfinished_interrupt_transfer)
    247                 return;
    248 
    249         usb_log_debug("Finalizing interrupt transfer\n");
    250         const uint16_t mask = create_interrupt_mask(instance);
    251         interrupt_request(instance->unfinished_interrupt_transfer,
    252             mask, instance->interrupt_mask_size);
    253         usb_transfer_batch_dispose(instance->unfinished_interrupt_transfer);
    254 
    255         instance->unfinished_interrupt_transfer = NULL;
     250        fibril_mutex_lock(&instance->guard);
     251        if (instance->unfinished_interrupt_transfer) {
     252                usb_log_debug("Finalizing interrupt transfer\n");
     253                const uint16_t mask = create_interrupt_mask(instance);
     254                interrupt_request(instance->unfinished_interrupt_transfer,
     255                    mask, instance->interrupt_mask_size);
     256                usb_transfer_batch_dispose(
     257                    instance->unfinished_interrupt_transfer);
     258                instance->unfinished_interrupt_transfer = NULL;
     259        }
     260        fibril_mutex_unlock(&instance->guard);
    256261}
    257262/*----------------------------------------------------------------------------*/
  • uspace/drv/bus/usb/ohci/root_hub.h

    r0fe2ff1 r19746a96  
    4747 */
    4848typedef struct rh {
     49        fibril_mutex_t guard;
    4950        /** pointer to ohci driver registers */
    5051        ohci_regs_t *registers;
Note: See TracChangeset for help on using the changeset viewer.