diff options
author | silby <silby@FreeBSD.org> | 2006-06-01 04:49:29 +0000 |
---|---|---|
committer | silby <silby@FreeBSD.org> | 2006-06-01 04:49:29 +0000 |
commit | 89bd691dee2a118dcfed71a96d388f312b9f5998 (patch) | |
tree | 9db4494c456e2f0efa81bd72206eae3a663731fe /sys/ia64 | |
parent | f00265f1ccdb2962efbd975f701707ee440c3d2c (diff) | |
download | FreeBSD-src-89bd691dee2a118dcfed71a96d388f312b9f5998.zip FreeBSD-src-89bd691dee2a118dcfed71a96d388f312b9f5998.tar.gz |
After much discussion with mjacob and scottl, change bus_dmamem_alloc so
that it just warns the user with a printf when it misaligns a piece
of memory that was requested through a busdma tag.
Some drivers (such as mpt, and probably others) were asking for alignments
that could not be satisfied, but as far as driver operation was concerned,
that did not matter. In the theory that other drivers will fall into
this same category, we agreed that panicing or making the allocation
fail will cause more hardship than is necessary. The printf should
be sufficient motivation to get the driver glitch fixed.
Diffstat (limited to 'sys/ia64')
-rw-r--r-- | sys/ia64/ia64/busdma_machdep.c | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/sys/ia64/ia64/busdma_machdep.c b/sys/ia64/ia64/busdma_machdep.c index 4a59f81..b044293 100644 --- a/sys/ia64/ia64/busdma_machdep.c +++ b/sys/ia64/ia64/busdma_machdep.c @@ -410,7 +410,7 @@ int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, bus_dmamap_t *mapp) { - int mflags, malloc_used, swasnull = 0; + int mflags; if (flags & BUS_DMA_NOWAIT) mflags = M_NOWAIT; @@ -423,12 +423,11 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, *mapp = NULL; if (dmat->segments == NULL) { - dmat->segments = (bus_dma_segment_t *) malloc( - sizeof (bus_dma_segment_t) * dmat->nsegments, - M_DEVBUF, M_NOWAIT); + dmat->segments = (bus_dma_segment_t *)malloc( + sizeof(bus_dma_segment_t) * dmat->nsegments, M_DEVBUF, + M_NOWAIT); if (dmat->segments == NULL) return (ENOMEM); - swasnull = 1; } /* @@ -437,13 +436,12 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, * alignment guarantees of malloc need to be nailed down, and the * code below should be rewritten to take that into account. * - * In the meantime, we'll return an error if malloc gets it wrong. + * In the meantime, we'll warn the user if malloc gets it wrong. */ if ((dmat->maxsize <= PAGE_SIZE) && (dmat->alignment < dmat->maxsize) && - dmat->lowaddr >= ptoa((vm_paddr_t)Maxmem)) { + dmat->lowaddr >= ptoa(Maxmem)) { *vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags); - malloc_used = 1; } else { /* * XXX Use Contigmalloc until it is merged into this facility @@ -454,28 +452,11 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, *vaddr = contigmalloc(dmat->maxsize, M_DEVBUF, mflags, 0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul, dmat->boundary); - malloc_used = 0; } - if (*vaddr == NULL) { - if (swasnull) { - free(dmat->segments, M_DEVBUF); - dmat->segments = NULL; - } + if (*vaddr == NULL) return (ENOMEM); - } - if ((uintptr_t)*vaddr & (dmat->alignment - 1)) { + else if ((uintptr_t)*vaddr & (dmat->alignment - 1)) printf("bus_dmamem_alloc failed to align memory properly."); - if (malloc_used) { - free(*vaddr, M_DEVBUF); - } else { - contigfree(*vaddr, dmat->maxsize, M_DEVBUF); - } - if (swasnull) { - free(dmat->segments, M_DEVBUF); - dmat->segments = NULL; - } - return (EINVAL); - } return (0); } @@ -486,18 +467,15 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) { - malloc_used = 0; /* * dmamem does not need to be bounced, so the map should be - if (swasnull) { - free(dmat->segments, M_DEVBUF); - dmat->segments = NULL; - } * NULL */ if (map != NULL) panic("bus_dmamem_free: Invalid map freed\n"); - if ((dmat->maxsize <= PAGE_SIZE) && dmat->lowaddr >= ptoa(Maxmem)) + if ((dmat->maxsize <= PAGE_SIZE) && + (dmat->alignment < dmat->maxsize) && + dmat->lowaddr >= ptoa(Maxmem)) { free(vaddr, M_DEVBUF); else { contigfree(vaddr, dmat->maxsize, M_DEVBUF); |