Changeset 2755a622 in mainline


Ignore:
Timestamp:
2018-01-17T01:36:46Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
740dafc
Parents:
3f44312
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-16 23:24:28)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-17 01:36:46)
Message:

uhci: fix transfer aborting

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

Legend:

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

    r3f44312 r2755a622  
    329329        uhci_transfer_batch_t *batch = NULL;
    330330
     331        // Check for the roothub, as it does not schedule into lists
     332        if (ep->device->speed == USB_SPEED_MAX) {
     333                // FIXME: We shall check the roothub for active transfer. But
     334                // as it is polling, there is no way to make it stop doing so.
     335                // Return after rewriting uhci rh.
     336                return;
     337        }
     338
     339        transfer_list_t *list = hc->transfers[ep->device->speed][ep->transfer_type];
     340        assert(list);
     341
     342        // To avoid ABBA deadlock, we need to take the list first
     343        fibril_mutex_lock(&list->guard);
    331344        fibril_mutex_lock(&ep->guard);
    332345        if (ep->active_batch) {
    333346                batch = uhci_transfer_batch_get(ep->active_batch);
    334 
    335                 transfer_list_t *list = hc->transfers[ep->device->speed][ep->transfer_type];
    336                 assert(list);
    337 
    338                 fibril_mutex_lock(&list->guard);
     347                endpoint_deactivate_locked(ep);
    339348                transfer_list_remove_batch(list, batch);
    340                 fibril_mutex_unlock(&list->guard);
    341 
     349        }
     350        fibril_mutex_unlock(&ep->guard);
     351        fibril_mutex_unlock(&list->guard);
     352
     353        if (batch) {
     354                // The HW could have been looking at the batch.
     355                // Better wait two frames before we release the buffers.
    342356                endpoint_wait_timeout_locked(ep, 2000);
    343 
    344                 batch = uhci_transfer_batch_get(ep->active_batch);
    345                 if (ep->active_batch) {
    346                         endpoint_deactivate_locked(ep);
    347                 }
    348         }
    349         fibril_mutex_unlock(&ep->guard);
    350 
    351         if (batch) {
    352357                batch->base.error = EINTR;
    353358                batch->base.transfered_size = 0;
  • uspace/drv/bus/usb/uhci/transfer_list.c

    r3f44312 r2755a622  
    173173
    174174                if (uhci_transfer_batch_check_completed(batch)) {
    175                         /* Save for processing */
     175                        /* Remove from schedule, save for processing */
     176                        fibril_mutex_lock(&batch->base.ep->guard);
     177                        assert(batch->base.ep->active_batch == &batch->base);
     178                        endpoint_deactivate_locked(batch->base.ep);
    176179                        transfer_list_remove_batch(instance, batch);
     180                        fibril_mutex_unlock(&batch->base.ep->guard);
     181
    177182                        list_append(current, done);
    178183                }
     
    212217        assert(uhci_batch->qh);
    213218        assert(fibril_mutex_is_locked(&instance->guard));
     219        assert(!list_empty(&instance->batch_list));
    214220
    215221        usb_log_debug2("Batch %p removing from queue %s.",
  • uspace/drv/bus/usb/uhci/uhci_batch.c

    r3f44312 r2755a622  
    179179
    180180                        batch->ep->toggle = td_toggle(&uhci_batch->tds[i]);
    181                         if (i > 0)
    182                                 goto substract_ret;
    183                         return true;
     181                        goto substract_ret;
    184182                }
    185183
     
    190188        }
    191189substract_ret:
    192         if (batch->ep->transfer_type == USB_TRANSFER_CONTROL)
     190        if (batch->transfered_size > 0 && batch->ep->transfer_type == USB_TRANSFER_CONTROL) {
     191                assert(batch->transfered_size >= USB_SETUP_PACKET_SIZE);
    193192                batch->transfered_size -= USB_SETUP_PACKET_SIZE;
    194 
    195         fibril_mutex_lock(&batch->ep->guard);
    196         endpoint_deactivate_locked(batch->ep);
    197         fibril_mutex_unlock(&batch->ep->guard);
     193        }
    198194
    199195        if (batch->dir == USB_DIRECTION_IN) {
Note: See TracChangeset for help on using the changeset viewer.