Changeset f97717d9 in mainline for uspace/drv/uhci-hcd/transfer_list.c


Ignore:
Timestamp:
2011-03-25T16:22:14Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
da3dafc, e6223239
Parents:
d8421c4 (diff), f08c560 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge from development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/transfer_list.c

    rd8421c4 rf97717d9  
    7979        if (!instance->queue_head)
    8080                return;
    81         /* Set both next and element to point to the same QH */
     81        /* Set both queue_head.next to point to the follower */
    8282        qh_set_next_qh(instance->queue_head, next->queue_head_pa);
    83         qh_set_element_qh(instance->queue_head, next->queue_head_pa);
    8483}
    8584/*----------------------------------------------------------------------------*/
     
    9291 * The batch is added to the end of the list and queue.
    9392 */
    94 void transfer_list_add_batch(transfer_list_t *instance, usb_transfer_batch_t *batch)
     93void transfer_list_add_batch(
     94    transfer_list_t *instance, usb_transfer_batch_t *batch)
    9595{
    9696        assert(instance);
     
    9898        usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name, batch);
    9999
    100         const uint32_t pa = addr_to_phys(batch_qh(batch));
    101         assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
    102 
    103         /* New batch will be added to the end of the current list
    104          * so set the link accordingly */
    105         qh_set_next_qh(batch_qh(batch), instance->queue_head->next);
    106 
    107100        fibril_mutex_lock(&instance->guard);
    108101
     102        qh_t *last_qh = NULL;
    109103        /* Add to the hardware queue. */
    110104        if (list_empty(&instance->batch_list)) {
    111105                /* There is nothing scheduled */
    112                 qh_t *qh = instance->queue_head;
    113                 assert(qh->element == qh->next);
    114                 qh_set_element_qh(qh, pa);
     106                last_qh = instance->queue_head;
    115107        } else {
    116108                /* There is something scheduled */
    117109                usb_transfer_batch_t *last = list_get_instance(
    118110                    instance->batch_list.prev, usb_transfer_batch_t, link);
    119                 qh_set_next_qh(batch_qh(last), pa);
    120         }
     111                last_qh = batch_qh(last);
     112        }
     113        const uint32_t pa = addr_to_phys(batch_qh(batch));
     114        assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
     115
     116        /* keep link */
     117        batch_qh(batch)->next = last_qh->next;
     118        qh_set_next_qh(last_qh, pa);
     119
    121120        /* Add to the driver list */
    122121        list_append(&batch->link, &instance->batch_list);
     
    148147        while (current != &instance->batch_list) {
    149148                link_t *next = current->next;
    150                 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link);
     149                usb_transfer_batch_t *batch =
     150                    list_get_instance(current, usb_transfer_batch_t, link);
    151151
    152152                if (batch_is_complete(batch)) {
     
    162162                link_t *item = done.next;
    163163                list_remove(item);
    164                 usb_transfer_batch_t *batch = list_get_instance(item, usb_transfer_batch_t, link);
     164                usb_transfer_batch_t *batch =
     165                    list_get_instance(item, usb_transfer_batch_t, link);
    165166                batch->next_step(batch);
    166167        }
     
    174175{
    175176        fibril_mutex_lock(&instance->guard);
    176         while (list_empty(&instance->batch_list)) {
     177        while (!list_empty(&instance->batch_list)) {
    177178                link_t *current = instance->batch_list.next;
    178                 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link);
     179                usb_transfer_batch_t *batch =
     180                    list_get_instance(current, usb_transfer_batch_t, link);
    179181                transfer_list_remove_batch(instance, batch);
    180182                usb_transfer_batch_finish(batch, EIO);
     
    191193 * Does not lock the transfer list, caller is responsible for that.
    192194 */
    193 void transfer_list_remove_batch(transfer_list_t *instance, usb_transfer_batch_t *batch)
     195void transfer_list_remove_batch(
     196    transfer_list_t *instance, usb_transfer_batch_t *batch)
    194197{
    195198        assert(instance);
     
    197200        assert(batch);
    198201        assert(batch_qh(batch));
     202        assert(fibril_mutex_is_locked(&instance->guard));
     203
    199204        usb_log_debug2(
    200205            "Queue %s: removing batch(%p).\n", instance->name, batch);
    201206
    202         const char * pos = NULL;
     207        const char *qpos = NULL;
    203208        /* Remove from the hardware queue */
    204         if (batch->link.prev == &instance->batch_list) {
     209        if (instance->batch_list.next == &batch->link) {
    205210                /* I'm the first one here */
    206                 qh_set_element_qh(instance->queue_head, batch_qh(batch)->next);
    207                 pos = "FIRST";
     211                assert((instance->queue_head->next & LINK_POINTER_ADDRESS_MASK)
     212                    == addr_to_phys(batch_qh(batch)));
     213                instance->queue_head->next = batch_qh(batch)->next;
     214                qpos = "FIRST";
    208215        } else {
    209216                usb_transfer_batch_t *prev =
    210                     list_get_instance(batch->link.prev, usb_transfer_batch_t, link);
    211                 qh_set_next_qh(batch_qh(prev), batch_qh(batch)->next);
    212                 pos = "NOT FIRST";
    213         }
    214         /* Remove from the driver list */
     217                    list_get_instance(
     218                        batch->link.prev, usb_transfer_batch_t, link);
     219                assert((batch_qh(prev)->next & LINK_POINTER_ADDRESS_MASK)
     220                    == addr_to_phys(batch_qh(batch)));
     221                batch_qh(prev)->next = batch_qh(batch)->next;
     222                qpos = "NOT FIRST";
     223        }
     224        /* Remove from the batch list */
    215225        list_remove(&batch->link);
    216         usb_log_debug("Batch(%p) removed (%s) from %s, next element %x.\n",
    217             batch, pos, instance->name, batch_qh(batch)->next);
     226        usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n",
     227            batch, qpos, instance->name, batch_qh(batch)->next);
    218228}
    219229/**
Note: See TracChangeset for help on using the changeset viewer.