aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>2013-10-10 09:41:10 -0400
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>2013-10-10 09:41:10 -0400
commit1b65c4e5a9af1a1c61e792e2d0ed481e0c1f21a9 (patch)
tree15c7b03e6efede8905f3729de488341c9a9da81b /arch
parentd6fe76c58c358498b91d21f0ca8054f6aa6e672d (diff)
swiotlb-xen: use xen_alloc/free_coherent_pages
Use xen_alloc_coherent_pages and xen_free_coherent_pages to allocate or free coherent pages. We need to be careful handling the pointer returned by xen_alloc_coherent_pages, because on ARM the pointer is not equal to phys_to_virt(*dma_handle). In fact virt_to_phys only works for kernel direct mapped RAM memory. In ARM case the pointer could be an ioremap address, therefore passing it to virt_to_phys would give you another physical address that doesn't correspond to it. Make xen_create_contiguous_region take a phys_addr_t as start parameter to avoid the virt_to_phys calls which would be incorrect. Changes in v6: - remove extra spaces. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/xen/mm.c6
-rw-r--r--arch/x86/xen/mmu.c7
2 files changed, 8 insertions, 5 deletions
diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index 0d69b874d249..b0e77de99148 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -16,7 +16,7 @@
16#include <asm/xen/hypercall.h> 16#include <asm/xen/hypercall.h>
17#include <asm/xen/interface.h> 17#include <asm/xen/interface.h>
18 18
19int xen_create_contiguous_region(unsigned long vstart, unsigned int order, 19int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
20 unsigned int address_bits, 20 unsigned int address_bits,
21 dma_addr_t *dma_handle) 21 dma_addr_t *dma_handle)
22{ 22{
@@ -24,12 +24,12 @@ int xen_create_contiguous_region(unsigned long vstart, unsigned int order,
24 return -EINVAL; 24 return -EINVAL;
25 25
26 /* we assume that dom0 is mapped 1:1 for now */ 26 /* we assume that dom0 is mapped 1:1 for now */
27 *dma_handle = virt_to_phys(pstart); 27 *dma_handle = pstart;
28 return 0; 28 return 0;
29} 29}
30EXPORT_SYMBOL_GPL(xen_create_contiguous_region); 30EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
31 31
32void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order) 32void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
33{ 33{
34 return; 34 return;
35} 35}
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 6c34d7c03d5b..883088368ff0 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2328,13 +2328,14 @@ static int xen_exchange_memory(unsigned long extents_in, unsigned int order_in,
2328 return success; 2328 return success;
2329} 2329}
2330 2330
2331int xen_create_contiguous_region(unsigned long vstart, unsigned int order, 2331int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
2332 unsigned int address_bits, 2332 unsigned int address_bits,
2333 dma_addr_t *dma_handle) 2333 dma_addr_t *dma_handle)
2334{ 2334{
2335 unsigned long *in_frames = discontig_frames, out_frame; 2335 unsigned long *in_frames = discontig_frames, out_frame;
2336 unsigned long flags; 2336 unsigned long flags;
2337 int success; 2337 int success;
2338 unsigned long vstart = (unsigned long)phys_to_virt(pstart);
2338 2339
2339 /* 2340 /*
2340 * Currently an auto-translated guest will not perform I/O, nor will 2341 * Currently an auto-translated guest will not perform I/O, nor will
@@ -2374,11 +2375,12 @@ int xen_create_contiguous_region(unsigned long vstart, unsigned int order,
2374} 2375}
2375EXPORT_SYMBOL_GPL(xen_create_contiguous_region); 2376EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
2376 2377
2377void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order) 2378void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
2378{ 2379{
2379 unsigned long *out_frames = discontig_frames, in_frame; 2380 unsigned long *out_frames = discontig_frames, in_frame;
2380 unsigned long flags; 2381 unsigned long flags;
2381 int success; 2382 int success;
2383 unsigned long vstart;
2382 2384
2383 if (xen_feature(XENFEAT_auto_translated_physmap)) 2385 if (xen_feature(XENFEAT_auto_translated_physmap))
2384 return; 2386 return;
@@ -2386,6 +2388,7 @@ void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
2386 if (unlikely(order > MAX_CONTIG_ORDER)) 2388 if (unlikely(order > MAX_CONTIG_ORDER))
2387 return; 2389 return;
2388 2390
2391 vstart = (unsigned long)phys_to_virt(pstart);
2389 memset((void *) vstart, 0, PAGE_SIZE << order); 2392 memset((void *) vstart, 0, PAGE_SIZE << order);
2390 2393
2391 spin_lock_irqsave(&xen_reservation_lock, flags); 2394 spin_lock_irqsave(&xen_reservation_lock, flags);