The add_bounce_page() can be called from _bus_dmamap_load_phys().
Client virtual address is zero (not valid) in that case. So, client
physical address must be used to get an offset when
BUS_DMA_KEEP_PG_OFFSET flag is set. Note that client physical address
is always valid.

Svatopluk Kraus
diff --git a/sys/arm/arm/busdma_machdep-v6.c b/sys/arm/arm/busdma_machdep-v6.c
index ed501c5..7236c5a 100644
--- a/sys/arm/arm/busdma_machdep-v6.c
+++ b/sys/arm/arm/busdma_machdep-v6.c
@@ -1685,8 +1685,8 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, 
vm_offset_t vaddr,
 
        if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
                /* Page offset needs to be preserved. */
-               bpage->vaddr |= vaddr & PAGE_MASK;
-               bpage->busaddr |= vaddr & PAGE_MASK;
+               bpage->vaddr |= addr & PAGE_MASK;
+               bpage->busaddr |= addr & PAGE_MASK;
        }
        bpage->datavaddr = vaddr;
        bpage->dataaddr = addr;
diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c
index 265292d..acd8f81 100644
--- a/sys/arm/arm/busdma_machdep.c
+++ b/sys/arm/arm/busdma_machdep.c
@@ -1441,8 +1441,8 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, 
vm_offset_t vaddr,
 
        if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
                /* Page offset needs to be preserved. */
-               bpage->vaddr |= vaddr & PAGE_MASK;
-               bpage->busaddr |= vaddr & PAGE_MASK;
+               bpage->vaddr |= addr & PAGE_MASK;
+               bpage->busaddr |= addr & PAGE_MASK;
        }
        bpage->datavaddr = vaddr;
        bpage->dataaddr = addr;
diff --git a/sys/mips/mips/busdma_machdep.c b/sys/mips/mips/busdma_machdep.c
index 083e8f5..90ec399 100644
--- a/sys/mips/mips/busdma_machdep.c
+++ b/sys/mips/mips/busdma_machdep.c
@@ -1359,8 +1359,8 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, 
vm_offset_t vaddr,
 
        if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
                /* Page offset needs to be preserved. */
-               bpage->vaddr |= vaddr & PAGE_MASK;
-               bpage->busaddr |= vaddr & PAGE_MASK;
+               bpage->vaddr |= addr & PAGE_MASK;
+               bpage->busaddr |= addr & PAGE_MASK;
        }
        bpage->datavaddr = vaddr;
        bpage->dataaddr = addr;
diff --git a/sys/powerpc/powerpc/busdma_machdep.c 
b/sys/powerpc/powerpc/busdma_machdep.c
index bd226c8..9ea51ce 100644
--- a/sys/powerpc/powerpc/busdma_machdep.c
+++ b/sys/powerpc/powerpc/busdma_machdep.c
@@ -1121,8 +1121,8 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, 
vm_offset_t vaddr,
 
        if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
                /* Page offset needs to be preserved. */
-               bpage->vaddr |= vaddr & PAGE_MASK;
-               bpage->busaddr |= vaddr & PAGE_MASK;
+               bpage->vaddr |= addr & PAGE_MASK;
+               bpage->busaddr |= addr & PAGE_MASK;
        }
        bpage->datavaddr = vaddr;
        bpage->dataaddr = addr;
diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c
index 1438053..f5c1b92 100644
--- a/sys/x86/x86/busdma_bounce.c
+++ b/sys/x86/x86/busdma_bounce.c
@@ -994,8 +994,8 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, 
vm_offset_t vaddr,
 
        if (dmat->common.flags & BUS_DMA_KEEP_PG_OFFSET) {
                /* Page offset needs to be preserved. */
-               bpage->vaddr |= vaddr & PAGE_MASK;
-               bpage->busaddr |= vaddr & PAGE_MASK;
+               bpage->vaddr |= addr & PAGE_MASK;
+               bpage->busaddr |= addr & PAGE_MASK;
        }
        bpage->datavaddr = vaddr;
        bpage->dataaddr = addr;
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to