Changeset b80c1ab in mainline for uspace/drv/bus/usb/xhci/trb_ring.c
- Timestamp:
- 2017-11-14T23:17:54Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e76c0ea
- Parents:
- cfe4852
- git-author:
- Aearsis <Hlavaty.Ondrej@…> (2017-11-14 23:15:24)
- git-committer:
- Aearsis <Hlavaty.Ondrej@…> (2017-11-14 23:17:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/trb_ring.c
rcfe4852 rb80c1ab 33 33 #include <align.h> 34 34 #include <usb/debug.h> 35 #include <usb/host/utils/malloc32.h>36 35 #include "hw_struct/trb.h" 37 36 #include "trb_ring.h" … … 68 67 * to DMAMEM_4GiB. 69 68 */ 70 static int trb_segment_allocate(trb_segment_t **segment) 71 { 72 uintptr_t phys; 73 int err; 74 75 *segment = AS_AREA_ANY; 76 err = dmamem_map_anonymous(PAGE_SIZE, 77 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys, 78 (void *) segment); 79 80 if (err == EOK) { 81 memset(*segment, 0, PAGE_SIZE); 82 (*segment)->phys = phys; 83 84 usb_log_debug2("Allocated new ring segment."); 85 } 86 87 return err; 69 static int trb_segment_alloc(trb_segment_t **segment) 70 { 71 dma_buffer_t dbuf; 72 73 const int err = dma_buffer_alloc(&dbuf, PAGE_SIZE); 74 if (err) 75 return err; 76 77 *segment = dbuf.virt; 78 memset(*segment, 0, PAGE_SIZE); 79 (*segment)->phys = dbuf.phys; 80 usb_log_debug2("Allocated new ring segment."); 81 return EOK; 82 } 83 84 static void trb_segment_free(trb_segment_t *segment) 85 { 86 dma_buffer_t dbuf = { .virt = segment, .phys = segment->phys }; 87 dma_buffer_free(&dbuf); 88 88 } 89 89 … … 99 99 list_initialize(&ring->segments); 100 100 101 if ((err = trb_segment_alloc ate(&segment)) != EOK)101 if ((err = trb_segment_alloc(&segment)) != EOK) 102 102 return err; 103 103 … … 127 127 list_foreach_safe(ring->segments, cur, next) { 128 128 trb_segment_t *segment = list_get_instance(cur, trb_segment_t, segments_link); 129 dmamem_unmap_anonymous(segment);129 trb_segment_free(segment); 130 130 } 131 131 } … … 264 264 list_initialize(&ring->segments); 265 265 266 if ((err = trb_segment_alloc ate(&segment)) != EOK)266 if ((err = trb_segment_alloc(&segment)) != EOK) 267 267 return err; 268 268 … … 274 274 ring->dequeue_ptr = segment->phys; 275 275 276 ring->erst = malloc32(PAGE_SIZE); 277 if (ring->erst == NULL) 276 if (dma_buffer_alloc(&ring->erst, PAGE_SIZE)) 278 277 return ENOMEM; 279 memset(ring->erst, 0, PAGE_SIZE); 280 281 xhci_fill_erst_entry(&ring->erst[0], segment->phys, SEGMENT_TRB_COUNT); 278 xhci_erst_entry_t *erst = ring->erst.virt; 279 280 memset(erst, 0, PAGE_SIZE); 281 xhci_fill_erst_entry(&erst[0], segment->phys, SEGMENT_TRB_COUNT); 282 282 283 283 ring->ccs = 1; … … 297 297 } 298 298 299 if (ring->erst) 300 free32(ring->erst); 299 dma_buffer_free(&ring->erst); 301 300 } 302 301
Note:
See TracChangeset
for help on using the changeset viewer.