MFC r278074:
Optimise allocation of USB DMA structures. By default don't double map allocations if only one element should be allocated per page cache. Make one allocation per element compile time configurable. Fix a comment while at it.
This commit is contained in:
parent
811636d364
commit
ae29368fe4
@ -663,6 +663,7 @@ USB_HOST_ALIGN opt_usb.h
|
|||||||
USB_REQ_DEBUG opt_usb.h
|
USB_REQ_DEBUG opt_usb.h
|
||||||
USB_TEMPLATE opt_usb.h
|
USB_TEMPLATE opt_usb.h
|
||||||
USB_VERBOSE opt_usb.h
|
USB_VERBOSE opt_usb.h
|
||||||
|
USB_DMA_SINGLE_ALLOC opt_usb.h
|
||||||
USB_EHCI_BIG_ENDIAN_DESC opt_usb.h
|
USB_EHCI_BIG_ENDIAN_DESC opt_usb.h
|
||||||
U3G_DEBUG opt_u3g.h
|
U3G_DEBUG opt_u3g.h
|
||||||
UKBD_DFLT_KEYMAP opt_ukbd.h
|
UKBD_DFLT_KEYMAP opt_ukbd.h
|
||||||
|
@ -237,7 +237,11 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params *parm,
|
|||||||
n_obj = 1;
|
n_obj = 1;
|
||||||
} else {
|
} else {
|
||||||
/* compute number of objects per page */
|
/* compute number of objects per page */
|
||||||
|
#ifdef USB_DMA_SINGLE_ALLOC
|
||||||
|
n_obj = 1;
|
||||||
|
#else
|
||||||
n_obj = (USB_PAGE_SIZE / size);
|
n_obj = (USB_PAGE_SIZE / size);
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Compute number of DMA chunks, rounded up
|
* Compute number of DMA chunks, rounded up
|
||||||
* to nearest one:
|
* to nearest one:
|
||||||
@ -273,15 +277,33 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params *parm,
|
|||||||
&parm->curr_xfer->xroot->dma_parent_tag;
|
&parm->curr_xfer->xroot->dma_parent_tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ppc) {
|
if (ppc != NULL) {
|
||||||
*ppc = parm->xfer_page_cache_ptr;
|
if (n_obj != 1)
|
||||||
|
*ppc = parm->xfer_page_cache_ptr;
|
||||||
|
else
|
||||||
|
*ppc = parm->dma_page_cache_ptr;
|
||||||
}
|
}
|
||||||
r = count; /* set remainder count */
|
r = count; /* set remainder count */
|
||||||
z = n_obj * size; /* set allocation size */
|
z = n_obj * size; /* set allocation size */
|
||||||
pc = parm->xfer_page_cache_ptr;
|
pc = parm->xfer_page_cache_ptr;
|
||||||
pg = parm->dma_page_ptr;
|
pg = parm->dma_page_ptr;
|
||||||
|
|
||||||
for (x = 0; x != n_dma_pc; x++) {
|
if (n_obj == 1) {
|
||||||
|
/*
|
||||||
|
* Avoid mapping memory twice if only a single object
|
||||||
|
* should be allocated per page cache:
|
||||||
|
*/
|
||||||
|
for (x = 0; x != n_dma_pc; x++) {
|
||||||
|
if (usb_pc_alloc_mem(parm->dma_page_cache_ptr,
|
||||||
|
pg, z, align)) {
|
||||||
|
return (1); /* failure */
|
||||||
|
}
|
||||||
|
/* Make room for one DMA page cache and "n_dma_pg" pages */
|
||||||
|
parm->dma_page_cache_ptr++;
|
||||||
|
pg += n_dma_pg;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (x = 0; x != n_dma_pc; x++) {
|
||||||
|
|
||||||
if (r < n_obj) {
|
if (r < n_obj) {
|
||||||
/* compute last remainder */
|
/* compute last remainder */
|
||||||
@ -294,7 +316,7 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params *parm,
|
|||||||
}
|
}
|
||||||
/* Set beginning of current buffer */
|
/* Set beginning of current buffer */
|
||||||
buf = parm->dma_page_cache_ptr->buffer;
|
buf = parm->dma_page_cache_ptr->buffer;
|
||||||
/* Make room for one DMA page cache and one page */
|
/* Make room for one DMA page cache and "n_dma_pg" pages */
|
||||||
parm->dma_page_cache_ptr++;
|
parm->dma_page_cache_ptr++;
|
||||||
pg += n_dma_pg;
|
pg += n_dma_pg;
|
||||||
|
|
||||||
@ -314,6 +336,7 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params *parm,
|
|||||||
}
|
}
|
||||||
mtx_unlock(pc->tag_parent->mtx);
|
mtx_unlock(pc->tag_parent->mtx);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parm->xfer_page_cache_ptr = pc;
|
parm->xfer_page_cache_ptr = pc;
|
||||||
|
Loading…
Reference in New Issue
Block a user