-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Xen on arm and arm64 needs SWIOTLB_XEN: when running on Xen we need to program the hardware with mfns rather than pfns for dma addresses. Remove SWIOTLB_XEN dependency on X86 and PCI and make XEN select SWIOTLB_XEN on arm and arm64. At the moment always rely on swiotlb-xen, but when Xen starts supporting hardware IOMMUs we'll be able to avoid it conditionally on the presence of an IOMMU on the platform. Implement xen_create_contiguous_region on arm and arm64: for the moment we assume that dom0 has been mapped 1:1 (physical addresses == machine addresses) therefore we don't need to call XENMEM_exchange. Simply return the physical address as dma address. Initialize the xen-swiotlb from xen_early_init (before the native dma_ops are initialized), set xen_dma_ops to &xen_swiotlb_dma_ops. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Changes in v8: - assume dom0 is mapped 1:1, no need to call XENMEM_exchange. Changes in v7: - call __set_phys_to_machine_multi from xen_create_contiguous_region and xen_destroy_contiguous_region to update the P2M; - don't call XENMEM_unpin, it has been removed; - call XENMEM_exchange instead of XENMEM_exchange_and_pin; - set nr_exchanged to 0 before calling the hypercall. Changes in v6: - introduce and export xen_dma_ops; - call xen_mm_init from as arch_initcall. Changes in v4: - remove redefinition of DMA_ERROR_CODE; - update the code to use XENMEM_exchange_and_pin and XENMEM_unpin; - add a note about hardware IOMMU in the commit message. Changes in v3: - code style changes; - warn on XENMEM_put_dma_buf failures.
- Loading branch information
Stefano Stabellini
committed
Oct 10, 2013
1 parent
6990890
commit 83862cc
Showing
9 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
obj-y := enlighten.o hypercall.o grant-table.o p2m.o | ||
obj-y := enlighten.o hypercall.o grant-table.o p2m.o mm.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <linux/bootmem.h> | ||
#include <linux/gfp.h> | ||
#include <linux/export.h> | ||
#include <linux/slab.h> | ||
#include <linux/types.h> | ||
#include <linux/dma-mapping.h> | ||
#include <linux/vmalloc.h> | ||
#include <linux/swiotlb.h> | ||
|
||
#include <xen/xen.h> | ||
#include <xen/interface/memory.h> | ||
#include <xen/swiotlb-xen.h> | ||
|
||
#include <asm/cacheflush.h> | ||
#include <asm/xen/page.h> | ||
#include <asm/xen/hypercall.h> | ||
#include <asm/xen/interface.h> | ||
|
||
int xen_create_contiguous_region(unsigned long vstart, unsigned int order, | ||
unsigned int address_bits, | ||
dma_addr_t *dma_handle) | ||
{ | ||
if (!xen_initial_domain()) | ||
return -EINVAL; | ||
|
||
/* we assume that dom0 is mapped 1:1 for now */ | ||
*dma_handle = virt_to_phys(pstart); | ||
return 0; | ||
} | ||
EXPORT_SYMBOL_GPL(xen_create_contiguous_region); | ||
|
||
void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order) | ||
{ | ||
return; | ||
} | ||
EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region); | ||
|
||
struct dma_map_ops *xen_dma_ops; | ||
EXPORT_SYMBOL_GPL(xen_dma_ops); | ||
|
||
static struct dma_map_ops xen_swiotlb_dma_ops = { | ||
.mapping_error = xen_swiotlb_dma_mapping_error, | ||
.alloc = xen_swiotlb_alloc_coherent, | ||
.free = xen_swiotlb_free_coherent, | ||
.sync_single_for_cpu = xen_swiotlb_sync_single_for_cpu, | ||
.sync_single_for_device = xen_swiotlb_sync_single_for_device, | ||
.sync_sg_for_cpu = xen_swiotlb_sync_sg_for_cpu, | ||
.sync_sg_for_device = xen_swiotlb_sync_sg_for_device, | ||
.map_sg = xen_swiotlb_map_sg_attrs, | ||
.unmap_sg = xen_swiotlb_unmap_sg_attrs, | ||
.map_page = xen_swiotlb_map_page, | ||
.unmap_page = xen_swiotlb_unmap_page, | ||
.dma_supported = xen_swiotlb_dma_supported, | ||
}; | ||
|
||
int __init xen_mm_init(void) | ||
{ | ||
if (!xen_initial_domain()) | ||
return 0; | ||
xen_swiotlb_init(1, false); | ||
xen_dma_ops = &xen_swiotlb_dma_ops; | ||
return 0; | ||
} | ||
arch_initcall(xen_mm_init); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
xen-arm-y += $(addprefix ../../arm/xen/, enlighten.o grant-table.o p2m.o) | ||
xen-arm-y += $(addprefix ../../arm/xen/, enlighten.o grant-table.o p2m.o mm.o) | ||
obj-y := xen-arm.o hypercall.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters