diff --git a/sys/powerpc/include/bus_dma_impl.h b/sys/powerpc/include/bus_dma_impl.h index e24bd6dd880..80d775f2cf9 100644 --- a/sys/powerpc/include/bus_dma_impl.h +++ b/sys/powerpc/include/bus_dma_impl.h @@ -42,6 +42,7 @@ struct bus_dma_tag_common { int flags; bus_dma_lock_t *lockfunc; void *lockfuncarg; + int domain; }; struct bus_dma_impl { diff --git a/sys/powerpc/powerpc/busdma_bounce.c b/sys/powerpc/powerpc/busdma_bounce.c index cdc25a5d8fb..790903712da 100644 --- a/sys/powerpc/powerpc/busdma_bounce.c +++ b/sys/powerpc/powerpc/busdma_bounce.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,7 @@ #include #include #include +#include #include #include @@ -80,6 +82,7 @@ static MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata"); /* XXX TODO: bounce flags? */ #define dmat_bounce_flags(dmat) (0) #define dmat_boundary(dmat) ((dmat)->common.boundary) +#define dmat_domain(dmat) ((dmat)->common.domain) #define dmat_flags(dmat) ((dmat)->common.flags) #define dmat_highaddr(dmat) ((dmat)->common.highaddr) #define dmat_lowaddr(dmat) ((dmat)->common.lowaddr) @@ -219,6 +222,8 @@ bounce_bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, newtag->iommu = parent->iommu; newtag->iommu_cookie = parent->iommu_cookie; + newtag->common.domain = vm_phys_domain_match(newtag->common.domain, 0ul, + newtag->common.lowaddr); } if (newtag->common.lowaddr < ptoa((vm_paddr_t)Maxmem) && newtag->iommu == NULL) diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c index 8e73e303cb1..aba11e64145 100644 --- a/sys/powerpc/powerpc/busdma_machdep.c +++ b/sys/powerpc/powerpc/busdma_machdep.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -129,6 +130,10 @@ bus_dma_tag_set_domain(bus_dma_tag_t dmat, int domain) struct bus_dma_tag_common *tc; tc = (struct bus_dma_tag_common *)dmat; - + domain = vm_phys_domain_match(domain, 0ul, tc->lowaddr); + /* Only call the callback if it changes. */ + if (domain == tc->domain) + return (0); + tc->domain = domain; return (tc->impl->tag_set_domain(dmat, domain)); }