PATCH: fix bogus error message "bus_dmamem_alloc failed to align
memory properly"
Neel Natu
neelnatu at gmail.com
Sat Sep 25 01:22:57 UTC 2010
Hi,
This patch fixes the bogus error message from bus_dmamem_alloc() about
the buffer not being aligned properly.
The problem is that the check is against a virtual address as opposed
to the physical address. contigmalloc() makes guarantees about
the alignment of physical addresses but not the virtual address
mapping it.
Any objections if I commit this patch?
best
Neel
Index: sys/powerpc/powerpc/busdma_machdep.c
===================================================================
--- sys/powerpc/powerpc/busdma_machdep.c (revision 213113)
+++ sys/powerpc/powerpc/busdma_machdep.c (working copy)
@@ -529,7 +529,7 @@
CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
__func__, dmat, dmat->flags, ENOMEM);
return (ENOMEM);
- } else if ((uintptr_t)*vaddr & (dmat->alignment - 1)) {
+ } else if (vtophys(*vaddr) & (dmat->alignment - 1)) {
printf("bus_dmamem_alloc failed to align memory properly.\n");
}
#ifdef NOTYET
Index: sys/sparc64/sparc64/bus_machdep.c
===================================================================
--- sys/sparc64/sparc64/bus_machdep.c (revision 213113)
+++ sys/sparc64/sparc64/bus_machdep.c (working copy)
@@ -652,7 +652,7 @@
}
if (*vaddr == NULL)
return (ENOMEM);
- if ((uintptr_t)*vaddr % dmat->dt_alignment)
+ if (vtophys(*vaddr) % dmat->dt_alignment)
printf("%s: failed to align memory properly.\n", __func__);
return (0);
}
Index: sys/ia64/ia64/busdma_machdep.c
===================================================================
--- sys/ia64/ia64/busdma_machdep.c (revision 213113)
+++ sys/ia64/ia64/busdma_machdep.c (working copy)
@@ -455,7 +455,7 @@
}
if (*vaddr == NULL)
return (ENOMEM);
- else if ((uintptr_t)*vaddr & (dmat->alignment - 1))
+ else if (vtophys(*vaddr) & (dmat->alignment - 1))
printf("bus_dmamem_alloc failed to align memory properly.\n");
return (0);
}
Index: sys/i386/i386/busdma_machdep.c
===================================================================
--- sys/i386/i386/busdma_machdep.c (revision 213113)
+++ sys/i386/i386/busdma_machdep.c (working copy)
@@ -540,7 +540,7 @@
CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
__func__, dmat, dmat->flags, ENOMEM);
return (ENOMEM);
- } else if ((uintptr_t)*vaddr & (dmat->alignment - 1)) {
+ } else if (vtophys(*vaddr) & (dmat->alignment - 1)) {
printf("bus_dmamem_alloc failed to align memory properly.\n");
}
if (flags & BUS_DMA_NOCACHE)
Index: sys/amd64/amd64/busdma_machdep.c
===================================================================
--- sys/amd64/amd64/busdma_machdep.c (revision 213113)
+++ sys/amd64/amd64/busdma_machdep.c (working copy)
@@ -526,7 +526,7 @@
CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
__func__, dmat, dmat->flags, ENOMEM);
return (ENOMEM);
- } else if ((uintptr_t)*vaddr & (dmat->alignment - 1)) {
+ } else if (vtophys(*vaddr) & (dmat->alignment - 1)) {
printf("bus_dmamem_alloc failed to align memory properly.\n");
}
if (flags & BUS_DMA_NOCACHE)
More information about the freebsd-hackers
mailing list