aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/include/asm/xen/page.h1
-rw-r--r--arch/arm/xen/mm.c15
-rw-r--r--arch/x86/include/asm/xen/page.h5
-rw-r--r--drivers/xen/swiotlb-xen.c2
4 files changed, 22 insertions, 1 deletions
diff --git a/arch/arm/include/asm/xen/page.h b/arch/arm/include/asm/xen/page.h
index 2f7e6ff67d51..0b579b2f4e0e 100644
--- a/arch/arm/include/asm/xen/page.h
+++ b/arch/arm/include/asm/xen/page.h
@@ -110,5 +110,6 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
110bool xen_arch_need_swiotlb(struct device *dev, 110bool xen_arch_need_swiotlb(struct device *dev,
111 unsigned long pfn, 111 unsigned long pfn,
112 unsigned long mfn); 112 unsigned long mfn);
113unsigned long xen_get_swiotlb_free_pages(unsigned int order);
113 114
114#endif /* _ASM_ARM_XEN_PAGE_H */ 115#endif /* _ASM_ARM_XEN_PAGE_H */
diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index 793551d15f1d..498325074a06 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -4,6 +4,7 @@
4#include <linux/gfp.h> 4#include <linux/gfp.h>
5#include <linux/highmem.h> 5#include <linux/highmem.h>
6#include <linux/export.h> 6#include <linux/export.h>
7#include <linux/memblock.h>
7#include <linux/of_address.h> 8#include <linux/of_address.h>
8#include <linux/slab.h> 9#include <linux/slab.h>
9#include <linux/types.h> 10#include <linux/types.h>
@@ -21,6 +22,20 @@
21#include <asm/xen/hypercall.h> 22#include <asm/xen/hypercall.h>
22#include <asm/xen/interface.h> 23#include <asm/xen/interface.h>
23 24
25unsigned long xen_get_swiotlb_free_pages(unsigned int order)
26{
27 struct memblock_region *reg;
28 gfp_t flags = __GFP_NOWARN;
29
30 for_each_memblock(memory, reg) {
31 if (reg->base < (phys_addr_t)0xffffffff) {
32 flags |= __GFP_DMA;
33 break;
34 }
35 }
36 return __get_free_pages(flags, order);
37}
38
24enum dma_cache_op { 39enum dma_cache_op {
25 DMA_UNMAP, 40 DMA_UNMAP,
26 DMA_MAP, 41 DMA_MAP,
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index 358dcd338915..c44a5d53e464 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -269,4 +269,9 @@ static inline bool xen_arch_need_swiotlb(struct device *dev,
269 return false; 269 return false;
270} 270}
271 271
272static inline unsigned long xen_get_swiotlb_free_pages(unsigned int order)
273{
274 return __get_free_pages(__GFP_NOWARN, order);
275}
276
272#endif /* _ASM_X86_XEN_PAGE_H */ 277#endif /* _ASM_X86_XEN_PAGE_H */
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 810ad419e34c..4c549323c605 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -235,7 +235,7 @@ retry:
235#define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT)) 235#define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT))
236#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT) 236#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
237 while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) { 237 while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
238 xen_io_tlb_start = (void *)__get_free_pages(__GFP_NOWARN, order); 238 xen_io_tlb_start = (void *)xen_get_swiotlb_free_pages(order);
239 if (xen_io_tlb_start) 239 if (xen_io_tlb_start)
240 break; 240 break;
241 order--; 241 order--;