Skip to content

Commit

Permalink
xen: make xen_create_contiguous_region return the dma address
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Stefano Stabellini committed Oct 9, 2013
1 parent 2f558d4 commit 6990890
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion arch/x86/xen/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2329,7 +2329,8 @@ static int xen_exchange_memory(unsigned long extents_in, unsigned int order_in,
}

int xen_create_contiguous_region(unsigned long vstart, unsigned int order,
unsigned int address_bits)
unsigned int address_bits,
dma_addr_t *dma_handle)
{
unsigned long *in_frames = discontig_frames, out_frame;
unsigned long flags;
Expand Down Expand Up @@ -2368,6 +2369,7 @@ int xen_create_contiguous_region(unsigned long vstart, unsigned int order,

spin_unlock_irqrestore(&xen_reservation_lock, flags);

*dma_handle = virt_to_machine(vstart).maddr;
return success ? 0 : -ENOMEM;
}
EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
Expand Down
6 changes: 3 additions & 3 deletions drivers/xen/swiotlb-xen.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
{
int i, rc;
int dma_bits;
dma_addr_t dma_handle;

dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT;

Expand All @@ -137,7 +138,7 @@ xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
rc = xen_create_contiguous_region(
(unsigned long)buf + (i << IO_TLB_SHIFT),
get_order(slabs << IO_TLB_SHIFT),
dma_bits);
dma_bits, &dma_handle);
} while (rc && dma_bits++ < max_dma_bits);
if (rc)
return rc;
Expand Down Expand Up @@ -294,11 +295,10 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
*dma_handle = dev_addr;
else {
if (xen_create_contiguous_region(vstart, order,
fls64(dma_mask)) != 0) {
fls64(dma_mask), dma_handle) != 0) {
free_pages(vstart, order);
return NULL;
}
*dma_handle = virt_to_machine(ret).maddr;
}
memset(ret, 0, size);
return ret;
Expand Down
3 changes: 2 additions & 1 deletion include/xen/xen-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ int xen_setup_shutdown_event(void);

extern unsigned long *xen_contiguous_bitmap;
int xen_create_contiguous_region(unsigned long vstart, unsigned int order,
unsigned int address_bits);
unsigned int address_bits,
dma_addr_t *dma_handle);

void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order);

Expand Down

0 comments on commit 6990890

Please sign in to comment.