static busdma_bufalloc_t coherent_allocator; /* Cache of coherent buffers */
static busdma_bufalloc_t standard_allocator; /* Cache of standard buffers */
+
+MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata");
+MALLOC_DEFINE(M_BOUNCE, "bounce", "busdma bounce pages");
+
static void
busdma_init(void *dummy)
{
/*
* This init historically used SI_SUB_VM, but now the init code requires
- * malloc(9) using M_DEVBUF memory and the pcpu zones for counter(9), which get
+ * malloc(9) using M_BUSDMA memory and the pcpu zones for counter(9), which get
* set up by SI_SUB_KMEM and SI_ORDER_LAST, so we'll go right after that by
* using SI_SUB_KMEM+1.
*/
/* Return a NULL tag on failure */
*dmat = NULL;
- newtag = (bus_dma_tag_t)malloc(sizeof(*newtag), M_DEVBUF,
+ newtag = (bus_dma_tag_t)malloc(sizeof(*newtag), M_BUSDMA,
M_ZERO | M_NOWAIT);
if (newtag == NULL) {
CTR4(KTR_BUSDMA, "%s returned tag %p tag flags 0x%x error %d",
maxsize = roundup2(maxsize, PAGE_SIZE) + PAGE_SIZE;
if ((error = alloc_bounce_zone(newtag)) != 0) {
- free(newtag, M_DEVBUF);
+ free(newtag, M_BUSDMA);
return (error);
}
bz = newtag->bounce_zone;
newtag->bounce_zone = NULL;
if (error != 0) {
- free(newtag, M_DEVBUF);
+ free(newtag, M_BUSDMA);
} else {
atomic_add_32(&tags_total, 1);
*dmat = newtag;
atomic_subtract_int(&dmat->ref_count, 1);
if (dmat->ref_count == 0) {
atomic_subtract_32(&tags_total, 1);
- free(dmat, M_DEVBUF);
+ free(dmat, M_BUSDMA);
/*
* Last reference count, so
* release our reference
dmat->nsegments, MAX_DMA_SEGMENTS));
segsize = sizeof(struct bus_dma_segment) * dmat->nsegments;
mapsize = sizeof(*map) + sizeof(struct sync_list) * dmat->nsegments;
- map = malloc(mapsize + segsize, M_DEVBUF, mflags | M_ZERO);
+ map = malloc(mapsize + segsize, M_BUSDMA, mflags | M_ZERO);
if (map == NULL) {
CTR3(KTR_BUSDMA, "%s: tag %p error %d", __func__, dmat, ENOMEM);
return (NULL);
*/
error = allocate_bz_and_pages(dmat, map);
if (error != 0) {
- free(map, M_DEVBUF);
+ free(map, M_BUSDMA);
*mapp = NULL;
return (error);
}
if (map->flags & DMAMAP_COHERENT)
atomic_subtract_32(&maps_coherent, 1);
atomic_subtract_32(&maps_total, 1);
- free(map, M_DEVBUF);
+ free(map, M_BUSDMA);
dmat->map_count--;
CTR2(KTR_BUSDMA, "%s: tag %p error 0", __func__, dmat);
return (0);
if (*vaddr == NULL) {
CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
__func__, dmat, dmat->flags, ENOMEM);
- free(map, M_DEVBUF);
+ free(map, M_BUSDMA);
*mapp = NULL;
return (ENOMEM);
}
atomic_subtract_32(&maps_coherent, 1);
atomic_subtract_32(&maps_total, 1);
atomic_subtract_32(&maps_dmamem, 1);
- free(map, M_DEVBUF);
+ free(map, M_BUSDMA);
CTR3(KTR_BUSDMA, "%s: tag %p flags 0x%x", __func__, dmat, dmat->flags);
}
}
}
- if ((bz = (struct bounce_zone *)malloc(sizeof(*bz), M_DEVBUF,
+ if ((bz = (struct bounce_zone *)malloc(sizeof(*bz), M_BUSDMA,
M_NOWAIT | M_ZERO)) == NULL)
return (ENOMEM);
while (numpages > 0) {
struct bounce_page *bpage;
- bpage = (struct bounce_page *)malloc(sizeof(*bpage), M_DEVBUF,
+ bpage = (struct bounce_page *)malloc(sizeof(*bpage), M_BUSDMA,
M_NOWAIT | M_ZERO);
if (bpage == NULL)
break;
- bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_DEVBUF,
+ bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_BOUNCE,
M_NOWAIT, 0ul, bz->lowaddr, PAGE_SIZE, 0);
if (bpage->vaddr == 0) {
- free(bpage, M_DEVBUF);
+ free(bpage, M_BUSDMA);
break;
}
bpage->busaddr = pmap_kextract(bpage->vaddr);