summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorsilby <silby@FreeBSD.org>2006-06-01 04:49:29 +0000
committersilby <silby@FreeBSD.org>2006-06-01 04:49:29 +0000
commit89bd691dee2a118dcfed71a96d388f312b9f5998 (patch)
tree9db4494c456e2f0efa81bd72206eae3a663731fe /sys/amd64
parentf00265f1ccdb2962efbd975f701707ee440c3d2c (diff)
downloadFreeBSD-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/amd64')
-rw-r--r--sys/amd64/amd64/busdma_machdep.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/sys/amd64/amd64/busdma_machdep.c b/sys/amd64/amd64/busdma_machdep.c
index e04ff39..7c91d2f 100644
--- a/sys/amd64/amd64/busdma_machdep.c
+++ b/sys/amd64/amd64/busdma_machdep.c
@@ -469,7 +469,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;
@@ -490,7 +490,6 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
__func__, dmat, dmat->flags, ENOMEM);
return (ENOMEM);
}
- swasnull = 1;
}
/*
@@ -499,13 +498,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)) {
*vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags);
- malloc_used = 1;
} else {
/*
* XXX Use Contigmalloc until it is merged into this facility
@@ -516,29 +514,13 @@ 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;
- }
CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
__func__, dmat, dmat->flags, ENOMEM);
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);
}
CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
__func__, dmat, dmat->flags, ENOMEM);
OpenPOWER on IntegriCloud