Date: Fri, 23 Oct 2015 22:52:01 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289858 - head/sys/arm/arm Message-ID: <201510232252.t9NMq13R047601@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Fri Oct 23 22:52:00 2015 New Revision: 289858 URL: https://svnweb.freebsd.org/changeset/base/289858 Log: Instead of all memory allocations using M_DEVBUF, use new categories M_BUSDMA for allocations of metadata (tags, maps, segment tracking lists), and M_BOUNCE for bounce pages. Modified: head/sys/arm/arm/busdma_machdep-v6.c Modified: head/sys/arm/arm/busdma_machdep-v6.c ============================================================================== --- head/sys/arm/arm/busdma_machdep-v6.c Fri Oct 23 22:51:48 2015 (r289857) +++ head/sys/arm/arm/busdma_machdep-v6.c Fri Oct 23 22:52:00 2015 (r289858) @@ -217,6 +217,10 @@ static void dma_dcache_sync(struct sync_ 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) { @@ -260,7 +264,7 @@ 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. */ @@ -481,7 +485,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, /* 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", @@ -557,7 +561,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, 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; @@ -577,7 +581,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, newtag->bounce_zone = NULL; if (error != 0) { - free(newtag, M_DEVBUF); + free(newtag, M_BUSDMA); } else { atomic_add_32(&tags_total, 1); *dmat = newtag; @@ -610,7 +614,7 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat) 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 @@ -683,7 +687,7 @@ allocate_map(bus_dma_tag_t dmat, int mfl 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); @@ -717,7 +721,7 @@ bus_dmamap_create(bus_dma_tag_t dmat, in */ error = allocate_bz_and_pages(dmat, map); if (error != 0) { - free(map, M_DEVBUF); + free(map, M_BUSDMA); *mapp = NULL; return (error); } @@ -746,7 +750,7 @@ bus_dmamap_destroy(bus_dma_tag_t dmat, b 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); @@ -830,7 +834,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, voi 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); } @@ -873,7 +877,7 @@ bus_dmamem_free(bus_dma_tag_t dmat, void 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); } @@ -1517,7 +1521,7 @@ alloc_bounce_zone(bus_dma_tag_t dmat) } } - 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); @@ -1588,15 +1592,15 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510232252.t9NMq13R047601>