diff options
author | jhb <jhb@FreeBSD.org> | 2007-04-17 21:05:34 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2007-04-17 21:05:34 +0000 |
commit | ed9ca08793c6e93d24f5106ab2102b83217657e6 (patch) | |
tree | bdefb9f63d869c0f367f2239b3f3799ea1913447 | |
parent | 934b1fc38b7f6579acc5a3c08451320417880ce3 (diff) | |
download | FreeBSD-src-ed9ca08793c6e93d24f5106ab2102b83217657e6.zip FreeBSD-src-ed9ca08793c6e93d24f5106ab2102b83217657e6.tar.gz |
Honor the BUS_DMA_NOCACHE flag to bus_dmamem_alloc() on amd64 and i386 by
mapping the pages as UC (uncacheable) using pmap_change_attr().
MFC after: 1 week
Requested by: ariff
Reviewed by: scottl
-rw-r--r-- | sys/amd64/amd64/busdma_machdep.c | 5 | ||||
-rw-r--r-- | sys/i386/i386/busdma_machdep.c | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/sys/amd64/amd64/busdma_machdep.c b/sys/amd64/amd64/busdma_machdep.c index 03e3c5c..a2b19d6 100644 --- a/sys/amd64/amd64/busdma_machdep.c +++ b/sys/amd64/amd64/busdma_machdep.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include <machine/atomic.h> #include <machine/bus.h> #include <machine/md_var.h> +#include <machine/specialreg.h> #define MAX_BPAGES 8192 @@ -522,6 +523,9 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, } else if ((uintptr_t)*vaddr & (dmat->alignment - 1)) { printf("bus_dmamem_alloc failed to align memory properly.\n"); } + if (flags & BUS_DMA_NOCACHE) + pmap_change_attr((vm_offset_t)*vaddr, dmat->maxsize, + PAT_UNCACHEABLE); CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", __func__, dmat, dmat->flags, ENOMEM); return (0); @@ -540,6 +544,7 @@ bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) */ if (map != NULL) panic("bus_dmamem_free: Invalid map freed\n"); + pmap_change_attr((vm_offset_t)vaddr, dmat->maxsize, PAT_WRITE_BACK); if ((dmat->maxsize <= PAGE_SIZE) && (dmat->alignment < dmat->maxsize) && dmat->lowaddr >= ptoa((vm_paddr_t)Maxmem)) diff --git a/sys/i386/i386/busdma_machdep.c b/sys/i386/i386/busdma_machdep.c index ab5b66c..b11805b 100644 --- a/sys/i386/i386/busdma_machdep.c +++ b/sys/i386/i386/busdma_machdep.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include <machine/atomic.h> #include <machine/bus.h> #include <machine/md_var.h> +#include <machine/specialreg.h> #define MAX_BPAGES 512 #define BUS_DMA_COULD_BOUNCE BUS_DMA_BUS3 @@ -530,6 +531,9 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, } else if ((uintptr_t)*vaddr & (dmat->alignment - 1)) { printf("bus_dmamem_alloc failed to align memory properly.\n"); } + if (flags & BUS_DMA_NOCACHE) + pmap_change_attr((vm_offset_t)*vaddr, dmat->maxsize, + PAT_UNCACHEABLE); CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", __func__, dmat, dmat->flags, ENOMEM); return (0); @@ -548,6 +552,7 @@ bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) */ if (map != NULL) panic("bus_dmamem_free: Invalid map freed\n"); + pmap_change_attr((vm_offset_t)vaddr, dmat->maxsize, PAT_WRITE_BACK); if ((dmat->maxsize <= PAGE_SIZE) && (dmat->alignment < dmat->maxsize) && dmat->lowaddr >= ptoa((vm_paddr_t)Maxmem)) |