diff options
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2013-10-09 12:56:32 -0400 |
---|---|---|
committer | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2013-10-09 12:56:32 -0400 |
commit | 69908907b02efee31377af0cefbcd5a3ba66334a (patch) | |
tree | 7348359ef60c91ca9edfd71680a858f28a7d156e | |
parent | 2f558d40911c1b8f929b8a382833ae1da5df3293 (diff) |
xen: make xen_create_contiguous_region return the dma address
Modify xen_create_contiguous_region to return the dma address of the
newly contiguous buffer.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Changes in v4:
- use virt_to_machine instead of virt_to_bus.
-rw-r--r-- | arch/x86/xen/mmu.c | 4 | ||||
-rw-r--r-- | drivers/xen/swiotlb-xen.c | 6 | ||||
-rw-r--r-- | include/xen/xen-ops.h | 3 |
3 files changed, 8 insertions, 5 deletions
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index fdc3ba28ca38..6c34d7c03d5b 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
@@ -2329,7 +2329,8 @@ static int xen_exchange_memory(unsigned long extents_in, unsigned int order_in, | |||
2329 | } | 2329 | } |
2330 | 2330 | ||
2331 | int xen_create_contiguous_region(unsigned long vstart, unsigned int order, | 2331 | int xen_create_contiguous_region(unsigned long vstart, unsigned int order, |
2332 | unsigned int address_bits) | 2332 | unsigned int address_bits, |
2333 | dma_addr_t *dma_handle) | ||
2333 | { | 2334 | { |
2334 | unsigned long *in_frames = discontig_frames, out_frame; | 2335 | unsigned long *in_frames = discontig_frames, out_frame; |
2335 | unsigned long flags; | 2336 | unsigned long flags; |
@@ -2368,6 +2369,7 @@ int xen_create_contiguous_region(unsigned long vstart, unsigned int order, | |||
2368 | 2369 | ||
2369 | spin_unlock_irqrestore(&xen_reservation_lock, flags); | 2370 | spin_unlock_irqrestore(&xen_reservation_lock, flags); |
2370 | 2371 | ||
2372 | *dma_handle = virt_to_machine(vstart).maddr; | ||
2371 | return success ? 0 : -ENOMEM; | 2373 | return success ? 0 : -ENOMEM; |
2372 | } | 2374 | } |
2373 | EXPORT_SYMBOL_GPL(xen_create_contiguous_region); | 2375 | EXPORT_SYMBOL_GPL(xen_create_contiguous_region); |
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index 1b2277c311d2..b72f31c1e018 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c | |||
@@ -126,6 +126,7 @@ xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs) | |||
126 | { | 126 | { |
127 | int i, rc; | 127 | int i, rc; |
128 | int dma_bits; | 128 | int dma_bits; |
129 | dma_addr_t dma_handle; | ||
129 | 130 | ||
130 | dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT; | 131 | dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT; |
131 | 132 | ||
@@ -137,7 +138,7 @@ xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs) | |||
137 | rc = xen_create_contiguous_region( | 138 | rc = xen_create_contiguous_region( |
138 | (unsigned long)buf + (i << IO_TLB_SHIFT), | 139 | (unsigned long)buf + (i << IO_TLB_SHIFT), |
139 | get_order(slabs << IO_TLB_SHIFT), | 140 | get_order(slabs << IO_TLB_SHIFT), |
140 | dma_bits); | 141 | dma_bits, &dma_handle); |
141 | } while (rc && dma_bits++ < max_dma_bits); | 142 | } while (rc && dma_bits++ < max_dma_bits); |
142 | if (rc) | 143 | if (rc) |
143 | return rc; | 144 | return rc; |
@@ -294,11 +295,10 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size, | |||
294 | *dma_handle = dev_addr; | 295 | *dma_handle = dev_addr; |
295 | else { | 296 | else { |
296 | if (xen_create_contiguous_region(vstart, order, | 297 | if (xen_create_contiguous_region(vstart, order, |
297 | fls64(dma_mask)) != 0) { | 298 | fls64(dma_mask), dma_handle) != 0) { |
298 | free_pages(vstart, order); | 299 | free_pages(vstart, order); |
299 | return NULL; | 300 | return NULL; |
300 | } | 301 | } |
301 | *dma_handle = virt_to_machine(ret).maddr; | ||
302 | } | 302 | } |
303 | memset(ret, 0, size); | 303 | memset(ret, 0, size); |
304 | return ret; | 304 | return ret; |
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h index d6fe062cad6b..9ef704d3a9dd 100644 --- a/include/xen/xen-ops.h +++ b/include/xen/xen-ops.h | |||
@@ -20,7 +20,8 @@ int xen_setup_shutdown_event(void); | |||
20 | 20 | ||
21 | extern unsigned long *xen_contiguous_bitmap; | 21 | extern unsigned long *xen_contiguous_bitmap; |
22 | int xen_create_contiguous_region(unsigned long vstart, unsigned int order, | 22 | int xen_create_contiguous_region(unsigned long vstart, unsigned int order, |
23 | unsigned int address_bits); | 23 | unsigned int address_bits, |
24 | dma_addr_t *dma_handle); | ||
24 | 25 | ||
25 | void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order); | 26 | void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order); |
26 | 27 | ||