Changeset 2b61945 in mainline for uspace/drv/bus/usb/xhci/hc.c


Ignore:
Timestamp:
2017-10-22T03:47:41Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2e5aea1
Parents:
766043c
Message:

xhci: use device_t for bookkeeping

This started as a little refactoring to move active transfer batch to endpoint. Finding the EP in handler needs devices indexed by slot id. Then I found out we do not use the device_t extendable mechanism. Then there were a lot of errors found while doing all this…

File:
1 edited

Legend:

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

    r766043c r2b61945  
    196196                return ENOMEM;
    197197
    198         hc->dcbaa_virt = malloc((1 + hc->max_slots) * sizeof(xhci_virt_device_ctx_t));
    199         if (!hc->dcbaa_virt) {
    200                 err = ENOMEM;
     198        if ((err = xhci_trb_ring_init(&hc->command_ring)))
    201199                goto err_dcbaa;
    202         }
    203 
    204         if ((err = xhci_trb_ring_init(&hc->command_ring)))
    205                 goto err_dcbaa_virt;
    206200
    207201        if ((err = xhci_event_ring_init(&hc->event_ring)))
     
    214208                goto err_scratch;
    215209
    216         if ((err = xhci_init_transfers(hc)))
     210        if ((err = xhci_rh_init(&hc->rh, hc, device)))
    217211                goto err_cmd;
    218212
    219         if ((err = xhci_rh_init(&hc->rh, hc, device)))
    220                 goto err_transfers;
    221 
    222         if ((err = xhci_bus_init(&hc->bus)))
     213        if ((err = xhci_bus_init(&hc->bus, hc)))
    223214                goto err_rh;
    224215
     
    228219err_rh:
    229220        xhci_rh_fini(&hc->rh);
    230 err_transfers:
    231         xhci_fini_transfers(hc);
    232221err_cmd:
    233222        xhci_fini_commands(hc);
     
    238227err_cmd_ring:
    239228        xhci_trb_ring_fini(&hc->command_ring);
    240 err_dcbaa_virt:
    241         free32(hc->dcbaa_virt);
    242229err_dcbaa:
    243230        free32(hc->dcbaa);
     
    527514        /* Update the ERDP to make room in the ring. */
    528515        usb_log_debug2("Copying from ring finished, updating ERDP.");
    529         hc->event_ring.dequeue_ptr = host2xhci(64, addr_to_phys(hc->event_ring.dequeue_trb));
    530516        uint64_t erdp = hc->event_ring.dequeue_ptr;
    531517        XHCI_REG_WR(intr, XHCI_INTR_ERDP_LO, LOWER32(erdp));
     
    580566static void hc_dcbaa_fini(xhci_hc_t *hc)
    581567{
    582         xhci_trb_ring_t* trb_ring;
    583568        xhci_scratchpad_free(hc);
    584 
    585         /* Idx 0 already deallocated by xhci_scratchpad_free. */
    586         for (unsigned i = 1; i < hc->max_slots + 1; ++i) {
    587                 if (hc->dcbaa_virt[i].dev_ctx) {
    588                         free32(hc->dcbaa_virt[i].dev_ctx);
    589                         hc->dcbaa_virt[i].dev_ctx = NULL;
    590                 }
    591 
    592                 for (unsigned i = 0; i < XHCI_EP_COUNT; ++i) {
    593                         trb_ring = hc->dcbaa_virt[i].trs[i];
    594                         if (trb_ring) {
    595                                 hc->dcbaa_virt[i].trs[i] = NULL;
    596                                 xhci_trb_ring_fini(trb_ring);
    597                                 free32(trb_ring);
    598                         }
    599                 }
    600         }
    601 
    602569        free32(hc->dcbaa);
    603         free32(hc->dcbaa_virt);
    604570}
    605571
     
    610576        xhci_event_ring_fini(&hc->event_ring);
    611577        hc_dcbaa_fini(hc);
    612         xhci_fini_transfers(hc);
    613578        xhci_fini_commands(hc);
    614579        xhci_rh_fini(&hc->rh);
Note: See TracChangeset for help on using the changeset viewer.