[malloc] Rename malloc_dma() to malloc_phys()
The malloc_dma() function allocates memory with specified physical alignment, and is typically (though not exclusively) used to allocate memory for DMA. Rename to malloc_phys() to more closely match the functionality, and to create name space for functions that specifically allocate and map DMA-capable buffers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
+15
-14
@@ -565,8 +565,8 @@ static int ehci_ring_alloc ( struct ehci_device *ehci,
|
||||
}
|
||||
|
||||
/* Allocate queue head */
|
||||
ring->head = malloc_dma ( sizeof ( *ring->head ),
|
||||
ehci_align ( sizeof ( *ring->head ) ) );
|
||||
ring->head = malloc_phys ( sizeof ( *ring->head ),
|
||||
ehci_align ( sizeof ( *ring->head ) ) );
|
||||
if ( ! ring->head ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_queue;
|
||||
@@ -579,7 +579,7 @@ static int ehci_ring_alloc ( struct ehci_device *ehci,
|
||||
|
||||
/* Allocate transfer descriptors */
|
||||
len = ( EHCI_RING_COUNT * sizeof ( ring->desc[0] ) );
|
||||
ring->desc = malloc_dma ( len, sizeof ( ring->desc[0] ) );
|
||||
ring->desc = malloc_phys ( len, sizeof ( ring->desc[0] ) );
|
||||
if ( ! ring->desc ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_desc;
|
||||
@@ -607,10 +607,10 @@ static int ehci_ring_alloc ( struct ehci_device *ehci,
|
||||
return 0;
|
||||
|
||||
err_unreachable_desc:
|
||||
free_dma ( ring->desc, len );
|
||||
free_phys ( ring->desc, len );
|
||||
err_alloc_desc:
|
||||
err_unreachable_queue:
|
||||
free_dma ( ring->head, sizeof ( *ring->head ) );
|
||||
free_phys ( ring->head, sizeof ( *ring->head ) );
|
||||
err_alloc_queue:
|
||||
free ( ring->iobuf );
|
||||
err_alloc_iobuf:
|
||||
@@ -631,10 +631,11 @@ static void ehci_ring_free ( struct ehci_ring *ring ) {
|
||||
assert ( ring->iobuf[i] == NULL );
|
||||
|
||||
/* Free transfer descriptors */
|
||||
free_dma ( ring->desc, ( EHCI_RING_COUNT * sizeof ( ring->desc[0] ) ) );
|
||||
free_phys ( ring->desc, ( EHCI_RING_COUNT *
|
||||
sizeof ( ring->desc[0] ) ) );
|
||||
|
||||
/* Free queue head */
|
||||
free_dma ( ring->head, sizeof ( *ring->head ) );
|
||||
free_phys ( ring->head, sizeof ( *ring->head ) );
|
||||
|
||||
/* Free I/O buffers */
|
||||
free ( ring->iobuf );
|
||||
@@ -1787,8 +1788,8 @@ static int ehci_bus_open ( struct usb_bus *bus ) {
|
||||
assert ( list_empty ( &ehci->periodic ) );
|
||||
|
||||
/* Allocate and initialise asynchronous queue head */
|
||||
ehci->head = malloc_dma ( sizeof ( *ehci->head ),
|
||||
ehci_align ( sizeof ( *ehci->head ) ) );
|
||||
ehci->head = malloc_phys ( sizeof ( *ehci->head ),
|
||||
ehci_align ( sizeof ( *ehci->head ) ) );
|
||||
if ( ! ehci->head ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_head;
|
||||
@@ -1816,7 +1817,7 @@ static int ehci_bus_open ( struct usb_bus *bus ) {
|
||||
/* Allocate periodic frame list */
|
||||
frames = EHCI_PERIODIC_FRAMES ( ehci->flsize );
|
||||
len = ( frames * sizeof ( ehci->frame[0] ) );
|
||||
ehci->frame = malloc_dma ( len, EHCI_PAGE_ALIGN );
|
||||
ehci->frame = malloc_phys ( len, EHCI_PAGE_ALIGN );
|
||||
if ( ! ehci->frame ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_frame;
|
||||
@@ -1836,10 +1837,10 @@ static int ehci_bus_open ( struct usb_bus *bus ) {
|
||||
|
||||
ehci_stop ( ehci );
|
||||
err_unreachable_frame:
|
||||
free_dma ( ehci->frame, len );
|
||||
free_phys ( ehci->frame, len );
|
||||
err_alloc_frame:
|
||||
err_ctrldssegment:
|
||||
free_dma ( ehci->head, sizeof ( *ehci->head ) );
|
||||
free_phys ( ehci->head, sizeof ( *ehci->head ) );
|
||||
err_alloc_head:
|
||||
return rc;
|
||||
}
|
||||
@@ -1861,10 +1862,10 @@ static void ehci_bus_close ( struct usb_bus *bus ) {
|
||||
ehci_stop ( ehci );
|
||||
|
||||
/* Free periodic frame list */
|
||||
free_dma ( ehci->frame, ( frames * sizeof ( ehci->frame[0] ) ) );
|
||||
free_phys ( ehci->frame, ( frames * sizeof ( ehci->frame[0] ) ) );
|
||||
|
||||
/* Free asynchronous schedule */
|
||||
free_dma ( ehci->head, sizeof ( *ehci->head ) );
|
||||
free_phys ( ehci->head, sizeof ( *ehci->head ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+13
-13
@@ -179,7 +179,7 @@ static int uhci_ring_alloc ( struct uhci_ring *ring ) {
|
||||
memset ( ring, 0, sizeof ( *ring ) );
|
||||
|
||||
/* Allocate queue head */
|
||||
ring->head = malloc_dma ( sizeof ( *ring->head ), UHCI_ALIGN );
|
||||
ring->head = malloc_phys ( sizeof ( *ring->head ), UHCI_ALIGN );
|
||||
if ( ! ring->head ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
@@ -194,7 +194,7 @@ static int uhci_ring_alloc ( struct uhci_ring *ring ) {
|
||||
return 0;
|
||||
|
||||
err_unreachable:
|
||||
free_dma ( ring->head, sizeof ( *ring->head ) );
|
||||
free_phys ( ring->head, sizeof ( *ring->head ) );
|
||||
err_alloc:
|
||||
return rc;
|
||||
}
|
||||
@@ -213,7 +213,7 @@ static void uhci_ring_free ( struct uhci_ring *ring ) {
|
||||
assert ( ring->xfer[i] == NULL );
|
||||
|
||||
/* Free queue head */
|
||||
free_dma ( ring->head, sizeof ( *ring->head ) );
|
||||
free_phys ( ring->head, sizeof ( *ring->head ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,7 +263,7 @@ static int uhci_enqueue ( struct uhci_ring *ring, struct io_buffer *iobuf,
|
||||
|
||||
/* Allocate transfer descriptors */
|
||||
len = ( count * sizeof ( xfer->desc[0] ) );
|
||||
xfer->desc = malloc_dma ( len, UHCI_ALIGN );
|
||||
xfer->desc = malloc_phys ( len, UHCI_ALIGN );
|
||||
if ( ! xfer->desc ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_desc;
|
||||
@@ -299,7 +299,7 @@ static int uhci_enqueue ( struct uhci_ring *ring, struct io_buffer *iobuf,
|
||||
return 0;
|
||||
|
||||
err_unreachable_desc:
|
||||
free_dma ( xfer->desc, len );
|
||||
free_phys ( xfer->desc, len );
|
||||
err_alloc_desc:
|
||||
free ( xfer );
|
||||
err_alloc_xfer:
|
||||
@@ -377,7 +377,7 @@ static struct io_buffer * uhci_dequeue ( struct uhci_ring *ring ) {
|
||||
|
||||
/* Free transfer descriptors */
|
||||
len = ( xfer->prod * sizeof ( xfer->desc[0] ) );
|
||||
free_dma ( xfer->desc, len );
|
||||
free_phys ( xfer->desc, len );
|
||||
|
||||
/* Free transfer */
|
||||
free ( xfer );
|
||||
@@ -1312,7 +1312,7 @@ static int uhci_bus_open ( struct usb_bus *bus ) {
|
||||
assert ( list_empty ( &uhci->periodic ) );
|
||||
|
||||
/* Allocate and initialise asynchronous queue head */
|
||||
uhci->head = malloc_dma ( sizeof ( *uhci->head ), UHCI_ALIGN );
|
||||
uhci->head = malloc_phys ( sizeof ( *uhci->head ), UHCI_ALIGN );
|
||||
if ( ! uhci->head ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_head;
|
||||
@@ -1324,8 +1324,8 @@ static int uhci_bus_open ( struct usb_bus *bus ) {
|
||||
uhci_async_schedule ( uhci );
|
||||
|
||||
/* Allocate periodic frame list */
|
||||
uhci->frame = malloc_dma ( sizeof ( *uhci->frame ),
|
||||
sizeof ( *uhci->frame ) );
|
||||
uhci->frame = malloc_phys ( sizeof ( *uhci->frame ),
|
||||
sizeof ( *uhci->frame ) );
|
||||
if ( ! uhci->frame ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_frame;
|
||||
@@ -1343,10 +1343,10 @@ static int uhci_bus_open ( struct usb_bus *bus ) {
|
||||
|
||||
uhci_stop ( uhci );
|
||||
err_unreachable_frame:
|
||||
free_dma ( uhci->frame, sizeof ( *uhci->frame ) );
|
||||
free_phys ( uhci->frame, sizeof ( *uhci->frame ) );
|
||||
err_alloc_frame:
|
||||
err_unreachable_head:
|
||||
free_dma ( uhci->head, sizeof ( *uhci->head ) );
|
||||
free_phys ( uhci->head, sizeof ( *uhci->head ) );
|
||||
err_alloc_head:
|
||||
return rc;
|
||||
}
|
||||
@@ -1367,10 +1367,10 @@ static void uhci_bus_close ( struct usb_bus *bus ) {
|
||||
uhci_stop ( uhci );
|
||||
|
||||
/* Free periodic frame list */
|
||||
free_dma ( uhci->frame, sizeof ( *uhci->frame ) );
|
||||
free_phys ( uhci->frame, sizeof ( *uhci->frame ) );
|
||||
|
||||
/* Free asynchronous schedule */
|
||||
free_dma ( uhci->head, sizeof ( *uhci->head ) );
|
||||
free_phys ( uhci->head, sizeof ( *uhci->head ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+21
-21
@@ -919,7 +919,7 @@ static int xhci_dcbaa_alloc ( struct xhci_device *xhci ) {
|
||||
* with a minimum of 64 bytes).
|
||||
*/
|
||||
len = ( ( xhci->slots + 1 ) * sizeof ( xhci->dcbaa[0] ) );
|
||||
xhci->dcbaa = malloc_dma ( len, xhci_align ( len ) );
|
||||
xhci->dcbaa = malloc_phys ( len, xhci_align ( len ) );
|
||||
if ( ! xhci->dcbaa ) {
|
||||
DBGC ( xhci, "XHCI %s could not allocate DCBAA\n", xhci->name );
|
||||
rc = -ENOMEM;
|
||||
@@ -938,7 +938,7 @@ static int xhci_dcbaa_alloc ( struct xhci_device *xhci ) {
|
||||
return 0;
|
||||
|
||||
err_writeq:
|
||||
free_dma ( xhci->dcbaa, len );
|
||||
free_phys ( xhci->dcbaa, len );
|
||||
err_alloc:
|
||||
return rc;
|
||||
}
|
||||
@@ -961,7 +961,7 @@ static void xhci_dcbaa_free ( struct xhci_device *xhci ) {
|
||||
|
||||
/* Free DCBAA */
|
||||
len = ( ( xhci->slots + 1 ) * sizeof ( xhci->dcbaa[0] ) );
|
||||
free_dma ( xhci->dcbaa, len );
|
||||
free_phys ( xhci->dcbaa, len );
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -1002,7 +1002,7 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) {
|
||||
/* Allocate scratchpad array */
|
||||
array_len = ( xhci->scratchpads * sizeof ( xhci->scratchpad_array[0] ));
|
||||
xhci->scratchpad_array =
|
||||
malloc_dma ( array_len, xhci_align ( array_len ) );
|
||||
malloc_phys ( array_len, xhci_align ( array_len ) );
|
||||
if ( ! xhci->scratchpad_array ) {
|
||||
DBGC ( xhci, "XHCI %s could not allocate scratchpad buffer "
|
||||
"array\n", xhci->name );
|
||||
@@ -1027,7 +1027,7 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) {
|
||||
( virt_to_phys ( xhci->scratchpad_array ) + array_len ) );
|
||||
return 0;
|
||||
|
||||
free_dma ( xhci->scratchpad_array, array_len );
|
||||
free_phys ( xhci->scratchpad_array, array_len );
|
||||
err_alloc_array:
|
||||
ufree ( xhci->scratchpad );
|
||||
err_alloc:
|
||||
@@ -1052,7 +1052,7 @@ static void xhci_scratchpad_free ( struct xhci_device *xhci ) {
|
||||
|
||||
/* Free scratchpad array */
|
||||
array_len = ( xhci->scratchpads * sizeof ( xhci->scratchpad_array[0] ));
|
||||
free_dma ( xhci->scratchpad_array, array_len );
|
||||
free_phys ( xhci->scratchpad_array, array_len );
|
||||
|
||||
/* Free scratchpads */
|
||||
ufree ( xhci->scratchpad );
|
||||
@@ -1202,7 +1202,7 @@ static int xhci_ring_alloc ( struct xhci_device *xhci,
|
||||
}
|
||||
|
||||
/* Allocate TRBs */
|
||||
ring->trb = malloc_dma ( ring->len, xhci_align ( ring->len ) );
|
||||
ring->trb = malloc_phys ( ring->len, xhci_align ( ring->len ) );
|
||||
if ( ! ring->trb ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_trb;
|
||||
@@ -1218,7 +1218,7 @@ static int xhci_ring_alloc ( struct xhci_device *xhci,
|
||||
|
||||
return 0;
|
||||
|
||||
free_dma ( ring->trb, ring->len );
|
||||
free_phys ( ring->trb, ring->len );
|
||||
err_alloc_trb:
|
||||
free ( ring->iobuf );
|
||||
err_alloc_iobuf:
|
||||
@@ -1256,7 +1256,7 @@ static void xhci_ring_free ( struct xhci_trb_ring *ring ) {
|
||||
assert ( ring->iobuf[i] == NULL );
|
||||
|
||||
/* Free TRBs */
|
||||
free_dma ( ring->trb, ring->len );
|
||||
free_phys ( ring->trb, ring->len );
|
||||
|
||||
/* Free I/O buffers */
|
||||
free ( ring->iobuf );
|
||||
@@ -1469,7 +1469,7 @@ static int xhci_event_alloc ( struct xhci_device *xhci ) {
|
||||
/* Allocate event ring */
|
||||
count = ( 1 << XHCI_EVENT_TRBS_LOG2 );
|
||||
len = ( count * sizeof ( event->trb[0] ) );
|
||||
event->trb = malloc_dma ( len, xhci_align ( len ) );
|
||||
event->trb = malloc_phys ( len, xhci_align ( len ) );
|
||||
if ( ! event->trb ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_trb;
|
||||
@@ -1477,8 +1477,8 @@ static int xhci_event_alloc ( struct xhci_device *xhci ) {
|
||||
memset ( event->trb, 0, len );
|
||||
|
||||
/* Allocate event ring segment table */
|
||||
event->segment = malloc_dma ( sizeof ( event->segment[0] ),
|
||||
xhci_align ( sizeof (event->segment[0])));
|
||||
event->segment = malloc_phys ( sizeof ( event->segment[0] ),
|
||||
xhci_align ( sizeof(event->segment[0])));
|
||||
if ( ! event->segment ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_segment;
|
||||
@@ -1508,9 +1508,9 @@ static int xhci_event_alloc ( struct xhci_device *xhci ) {
|
||||
err_writeq_erstba:
|
||||
xhci_writeq ( xhci, 0, xhci->run + XHCI_RUN_ERDP ( 0 ) );
|
||||
err_writeq_erdp:
|
||||
free_dma ( event->trb, len );
|
||||
free_phys ( event->trb, len );
|
||||
err_alloc_segment:
|
||||
free_dma ( event->segment, sizeof ( event->segment[0] ) );
|
||||
free_phys ( event->segment, sizeof ( event->segment[0] ) );
|
||||
err_alloc_trb:
|
||||
return rc;
|
||||
}
|
||||
@@ -1531,12 +1531,12 @@ static void xhci_event_free ( struct xhci_device *xhci ) {
|
||||
xhci_writeq ( xhci, 0, xhci->run + XHCI_RUN_ERDP ( 0 ) );
|
||||
|
||||
/* Free event ring segment table */
|
||||
free_dma ( event->segment, sizeof ( event->segment[0] ) );
|
||||
free_phys ( event->segment, sizeof ( event->segment[0] ) );
|
||||
|
||||
/* Free event ring */
|
||||
count = ( 1 << XHCI_EVENT_TRBS_LOG2 );
|
||||
len = ( count * sizeof ( event->trb[0] ) );
|
||||
free_dma ( event->trb, len );
|
||||
free_phys ( event->trb, len );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1948,7 +1948,7 @@ static int xhci_context ( struct xhci_device *xhci, struct xhci_slot *slot,
|
||||
|
||||
/* Allocate an input context */
|
||||
len = xhci_input_context_offset ( xhci, XHCI_CTX_END );
|
||||
input = malloc_dma ( len, xhci_align ( len ) );
|
||||
input = malloc_phys ( len, xhci_align ( len ) );
|
||||
if ( ! input ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
@@ -1969,7 +1969,7 @@ static int xhci_context ( struct xhci_device *xhci, struct xhci_slot *slot,
|
||||
goto err_command;
|
||||
|
||||
err_command:
|
||||
free_dma ( input, len );
|
||||
free_phys ( input, len );
|
||||
err_alloc:
|
||||
return rc;
|
||||
}
|
||||
@@ -2693,7 +2693,7 @@ static int xhci_device_open ( struct usb_device *usb ) {
|
||||
|
||||
/* Allocate a device context */
|
||||
len = xhci_device_context_offset ( xhci, XHCI_CTX_END );
|
||||
slot->context = malloc_dma ( len, xhci_align ( len ) );
|
||||
slot->context = malloc_phys ( len, xhci_align ( len ) );
|
||||
if ( ! slot->context ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_context;
|
||||
@@ -2710,7 +2710,7 @@ static int xhci_device_open ( struct usb_device *usb ) {
|
||||
return 0;
|
||||
|
||||
xhci->dcbaa[id] = 0;
|
||||
free_dma ( slot->context, len );
|
||||
free_phys ( slot->context, len );
|
||||
err_alloc_context:
|
||||
xhci->slot[id] = NULL;
|
||||
free ( slot );
|
||||
@@ -2750,7 +2750,7 @@ static void xhci_device_close ( struct usb_device *usb ) {
|
||||
|
||||
/* Free slot */
|
||||
if ( slot->context ) {
|
||||
free_dma ( slot->context, len );
|
||||
free_phys ( slot->context, len );
|
||||
xhci->dcbaa[id] = 0;
|
||||
}
|
||||
xhci->slot[id] = NULL;
|
||||
|
||||
Reference in New Issue
Block a user