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


Ignore:
Timestamp:
2011-04-17T19:17:55Z (14 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63517c2, cfbbe1d3
Parents:
ef354b6 (diff), 8595577b (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:

new report structure fixes

File:
1 edited

Legend:

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

    ref354b6 re50cd7f  
    5757                return ENOMEM;
    5858        }
    59         instance->queue_head_pa = addr_to_phys(instance->queue_head);
     59        uint32_t queue_head_pa = addr_to_phys(instance->queue_head);
    6060        usb_log_debug2("Transfer list %s setup with QH: %p(%p).\n",
    61             name, instance->queue_head, instance->queue_head_pa);
     61            name, instance->queue_head, queue_head_pa);
    6262
    6363        qh_init(instance->queue_head);
     
    6767}
    6868/*----------------------------------------------------------------------------*/
     69/** Dispose transfer list structures.
     70 *
     71 * @param[in] instance Memory place to use.
     72 *
     73 * Frees memory for internal qh_t structure.
     74 */
     75void transfer_list_fini(transfer_list_t *instance)
     76{
     77        assert(instance);
     78        free32(instance->queue_head);
     79}
    6980/** Set the next list in transfer list chain.
    7081 *
     
    8192        if (!instance->queue_head)
    8293                return;
    83         /* Set both queue_head.next to point to the follower */
    84         qh_set_next_qh(instance->queue_head, next->queue_head_pa);
    85 }
    86 /*----------------------------------------------------------------------------*/
    87 /** Submit transfer batch to the list and queue.
     94        /* Set queue_head.next to point to the follower */
     95        qh_set_next_qh(instance->queue_head, next->queue_head);
     96}
     97/*----------------------------------------------------------------------------*/
     98/** Add transfer batch to the list and queue.
    8899 *
    89100 * @param[in] instance List to use.
    90101 * @param[in] batch Transfer batch to submit.
    91  * @return Error code
    92102 *
    93103 * The batch is added to the end of the list and queue.
     
    109119        } else {
    110120                /* There is something scheduled */
    111                 usb_transfer_batch_t *last = list_get_instance(
    112                     instance->batch_list.prev, usb_transfer_batch_t, link);
     121                usb_transfer_batch_t *last =
     122                    usb_transfer_batch_from_link(instance->batch_list.prev);
    113123                last_qh = batch_qh(last);
    114124        }
     
    118128        /* keep link */
    119129        batch_qh(batch)->next = last_qh->next;
    120         qh_set_next_qh(last_qh, pa);
     130        qh_set_next_qh(last_qh, batch_qh(batch));
    121131
    122132        asm volatile ("": : :"memory");
     
    132142}
    133143/*----------------------------------------------------------------------------*/
    134 /** Check list for finished batches.
    135  *
    136  * @param[in] instance List to use.
    137  * @return Error code
    138  *
    139  * Creates a local list of finished batches and calls next_step on each and
    140  * every one. This is safer because next_step may theoretically access
    141  * this transfer list leading to the deadlock if its done inline.
     144/** Add completed bantches to the provided list.
     145 *
     146 * @param[in] instance List to use.
     147 * @param[in] done list to fill
    142148 */
    143149void transfer_list_remove_finished(transfer_list_t *instance, link_t *done)
     
    151157                link_t *next = current->next;
    152158                usb_transfer_batch_t *batch =
    153                     list_get_instance(current, usb_transfer_batch_t, link);
     159                    usb_transfer_batch_from_link(current);
    154160
    155161                if (batch_is_complete(batch)) {
    156                         /* Save for post-processing */
     162                        /* Save for processing */
    157163                        transfer_list_remove_batch(instance, batch);
    158164                        list_append(current, done);
     
    161167        }
    162168        fibril_mutex_unlock(&instance->guard);
    163 
    164 }
    165 /*----------------------------------------------------------------------------*/
    166 /** Walk the list and abort all batches.
     169}
     170/*----------------------------------------------------------------------------*/
     171/** Walk the list and finish all batches with EINTR.
    167172 *
    168173 * @param[in] instance List to use.
     
    174179                link_t *current = instance->batch_list.next;
    175180                usb_transfer_batch_t *batch =
    176                     list_get_instance(current, usb_transfer_batch_t, link);
     181                    usb_transfer_batch_from_link(current);
    177182                transfer_list_remove_batch(instance, batch);
    178                 usb_transfer_batch_finish(batch, EIO);
     183                usb_transfer_batch_finish_error(batch, EINTR);
    179184        }
    180185        fibril_mutex_unlock(&instance->guard);
     
    185190 * @param[in] instance List to use.
    186191 * @param[in] batch Transfer batch to remove.
    187  * @return Error code
    188192 *
    189193 * Does not lock the transfer list, caller is responsible for that.
     
    202206
    203207        const char *qpos = NULL;
     208        qh_t *prev_qh = NULL;
    204209        /* Remove from the hardware queue */
    205210        if (instance->batch_list.next == &batch->link) {
    206211                /* I'm the first one here */
    207                 assert((instance->queue_head->next & LINK_POINTER_ADDRESS_MASK)
    208                     == addr_to_phys(batch_qh(batch)));
    209                 instance->queue_head->next = batch_qh(batch)->next;
     212                prev_qh = instance->queue_head;
    210213                qpos = "FIRST";
    211214        } else {
     215                /* The thing before me is a batch too */
    212216                usb_transfer_batch_t *prev =
    213                     list_get_instance(
    214                         batch->link.prev, usb_transfer_batch_t, link);
    215                 assert((batch_qh(prev)->next & LINK_POINTER_ADDRESS_MASK)
    216                     == addr_to_phys(batch_qh(batch)));
    217                 batch_qh(prev)->next = batch_qh(batch)->next;
     217                    usb_transfer_batch_from_link(batch->link.prev);
     218                prev_qh = batch_qh(prev);
    218219                qpos = "NOT FIRST";
    219220        }
     221        assert((prev_qh->next & LINK_POINTER_ADDRESS_MASK)
     222            == addr_to_phys(batch_qh(batch)));
     223        prev_qh->next = batch_qh(batch)->next;
    220224        asm volatile ("": : :"memory");
    221225        /* Remove from the batch list */
    222226        list_remove(&batch->link);
    223         usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n",
     227        usb_log_debug("Batch(%p) removed (%s) from %s, next: %x.\n",
    224228            batch, qpos, instance->name, batch_qh(batch)->next);
    225229}
Note: See TracChangeset for help on using the changeset viewer.