• Daniel Drake's avatar
    libertas USB: don't set surpriseremoved flag · 9ef9dbea
    Daniel Drake authored
    We found a deadlock in the handling of command failures/reset conditions.
    For example:
    
     1. Two commands are in the queue.
     2. The first command is sent, but causes a timeout, which kicks off an
        asynchronous device reset
     3. The second command is queued (but not yet sent to the hardware)
     4. The device reset kicks in, causing the if_usb disconnect handler to
        set the "surprise removed" flag to be set as the device disappears
        from the bus. This causes lbs_thread to stop processing things
        ("adapter removed; waiting to die"), not processing any further
        commands, leaving the second queued command "in the air", causing a
        deadlock.
    
    Fix this by removing the surpriseremoved flag setting in if_usb. I can't
    see any reason why this needs to be done so early. lbs_remove_card will set
    this flag at an appropriate time - i.e. after all pending commands have
    been completed or cancelled, avoiding this deadlock.
    Signed-off-by: default avatarDaniel Drake <dsd@laptop.org>
    Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
    9ef9dbea
if_usb.c 25.7 KB