aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>2014-11-21 06:04:39 -0500
committerDavid Vrabel <david.vrabel@citrix.com>2014-12-04 07:41:51 -0500
commita0f2dee0cd651efb5fac6a1d35b0a14460ebcdd4 (patch)
tree744fe380abf1d0c9676cdec3e39e31e3863ef613
parent2e2a7817fdb6304f8c95c29dae0c93e2727240f4 (diff)
xen: add a dma_addr_t dev_addr argument to xen_dma_map_page
dev_addr is the machine address of the page. The new parameter can be used by the ARM and ARM64 implementations of xen_dma_map_page to find out if the page is a local page (pfn == mfn) or a foreign page (pfn != mfn). dev_addr could be retrieved again from the physical address, using pfn_to_mfn, but it requires accessing an rbtree. Since we already have the dev_addr in our hands at the call site there is no need to get the mfn twice. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r--arch/arm/include/asm/xen/page-coherent.h4
-rw-r--r--arch/arm64/include/asm/xen/page-coherent.h4
-rw-r--r--arch/x86/include/asm/xen/page-coherent.h4
-rw-r--r--drivers/xen/swiotlb-xen.c6
4 files changed, 10 insertions, 8 deletions
diff --git a/arch/arm/include/asm/xen/page-coherent.h b/arch/arm/include/asm/xen/page-coherent.h
index 9cfd895eb4bb..a309f42b411c 100644
--- a/arch/arm/include/asm/xen/page-coherent.h
+++ b/arch/arm/include/asm/xen/page-coherent.h
@@ -29,8 +29,8 @@ static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
29} 29}
30 30
31static inline void xen_dma_map_page(struct device *hwdev, struct page *page, 31static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
32 unsigned long offset, size_t size, enum dma_data_direction dir, 32 dma_addr_t dev_addr, unsigned long offset, size_t size,
33 struct dma_attrs *attrs) 33 enum dma_data_direction dir, struct dma_attrs *attrs)
34{ 34{
35 __generic_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs); 35 __generic_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs);
36} 36}
diff --git a/arch/arm64/include/asm/xen/page-coherent.h b/arch/arm64/include/asm/xen/page-coherent.h
index dde3fc9c49f0..d7cd4c2b2fd2 100644
--- a/arch/arm64/include/asm/xen/page-coherent.h
+++ b/arch/arm64/include/asm/xen/page-coherent.h
@@ -20,8 +20,8 @@ static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
20} 20}
21 21
22static inline void xen_dma_map_page(struct device *hwdev, struct page *page, 22static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
23 unsigned long offset, size_t size, enum dma_data_direction dir, 23 dma_addr_t dev_addr, unsigned long offset, size_t size,
24 struct dma_attrs *attrs) 24 enum dma_data_direction dir, struct dma_attrs *attrs)
25{ 25{
26} 26}
27 27
diff --git a/arch/x86/include/asm/xen/page-coherent.h b/arch/x86/include/asm/xen/page-coherent.h
index 7f02fe4e2c7b..acd844c017d3 100644
--- a/arch/x86/include/asm/xen/page-coherent.h
+++ b/arch/x86/include/asm/xen/page-coherent.h
@@ -22,8 +22,8 @@ static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
22} 22}
23 23
24static inline void xen_dma_map_page(struct device *hwdev, struct page *page, 24static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
25 unsigned long offset, size_t size, enum dma_data_direction dir, 25 dma_addr_t dev_addr, unsigned long offset, size_t size,
26 struct dma_attrs *attrs) { } 26 enum dma_data_direction dir, struct dma_attrs *attrs) { }
27 27
28static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle, 28static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
29 size_t size, enum dma_data_direction dir, 29 size_t size, enum dma_data_direction dir,
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index ebd8f218a788..ad2c5eb8a9c7 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -403,7 +403,7 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
403 /* we are not interested in the dma_addr returned by 403 /* we are not interested in the dma_addr returned by
404 * xen_dma_map_page, only in the potential cache flushes executed 404 * xen_dma_map_page, only in the potential cache flushes executed
405 * by the function. */ 405 * by the function. */
406 xen_dma_map_page(dev, page, offset, size, dir, attrs); 406 xen_dma_map_page(dev, page, dev_addr, offset, size, dir, attrs);
407 return dev_addr; 407 return dev_addr;
408 } 408 }
409 409
@@ -417,7 +417,7 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
417 return DMA_ERROR_CODE; 417 return DMA_ERROR_CODE;
418 418
419 xen_dma_map_page(dev, pfn_to_page(map >> PAGE_SHIFT), 419 xen_dma_map_page(dev, pfn_to_page(map >> PAGE_SHIFT),
420 map & ~PAGE_MASK, size, dir, attrs); 420 dev_addr, map & ~PAGE_MASK, size, dir, attrs);
421 dev_addr = xen_phys_to_bus(map); 421 dev_addr = xen_phys_to_bus(map);
422 422
423 /* 423 /*
@@ -574,6 +574,7 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
574 return 0; 574 return 0;
575 } 575 }
576 xen_dma_map_page(hwdev, pfn_to_page(map >> PAGE_SHIFT), 576 xen_dma_map_page(hwdev, pfn_to_page(map >> PAGE_SHIFT),
577 dev_addr,
577 map & ~PAGE_MASK, 578 map & ~PAGE_MASK,
578 sg->length, 579 sg->length,
579 dir, 580 dir,
@@ -584,6 +585,7 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
584 * xen_dma_map_page, only in the potential cache flushes executed 585 * xen_dma_map_page, only in the potential cache flushes executed
585 * by the function. */ 586 * by the function. */
586 xen_dma_map_page(hwdev, pfn_to_page(paddr >> PAGE_SHIFT), 587 xen_dma_map_page(hwdev, pfn_to_page(paddr >> PAGE_SHIFT),
588 dev_addr,
587 paddr & ~PAGE_MASK, 589 paddr & ~PAGE_MASK,
588 sg->length, 590 sg->length,
589 dir, 591 dir,