1 /* Glue code to lib/swiotlb.c */
4 #include <linux/cache.h>
5 #include <linux/module.h>
6 #include <linux/dma-mapping.h>
8 #include <asm/swiotlb.h>
10 #include <asm/iommu.h>
11 #include <asm/machvec.h>
13 int swiotlb __read_mostly
;
14 EXPORT_SYMBOL(swiotlb
);
16 static void *ia64_swiotlb_alloc_coherent(struct device
*dev
, size_t size
,
17 dma_addr_t
*dma_handle
, gfp_t gfp
)
19 if (dev
->coherent_dma_mask
!= DMA_BIT_MASK(64))
21 return swiotlb_alloc_coherent(dev
, size
, dma_handle
, gfp
);
24 struct dma_map_ops swiotlb_dma_ops
= {
25 .alloc_coherent
= ia64_swiotlb_alloc_coherent
,
26 .free_coherent
= swiotlb_free_coherent
,
27 .map_page
= swiotlb_map_page
,
28 .unmap_page
= swiotlb_unmap_page
,
29 .map_sg
= swiotlb_map_sg_attrs
,
30 .unmap_sg
= swiotlb_unmap_sg_attrs
,
31 .sync_single_for_cpu
= swiotlb_sync_single_for_cpu
,
32 .sync_single_for_device
= swiotlb_sync_single_for_device
,
33 .sync_single_range_for_cpu
= swiotlb_sync_single_range_for_cpu
,
34 .sync_single_range_for_device
= swiotlb_sync_single_range_for_device
,
35 .sync_sg_for_cpu
= swiotlb_sync_sg_for_cpu
,
36 .sync_sg_for_device
= swiotlb_sync_sg_for_device
,
37 .dma_supported
= swiotlb_dma_supported
,
38 .mapping_error
= swiotlb_dma_mapping_error
,
41 void __init
swiotlb_dma_init(void)
43 dma_ops
= &swiotlb_dma_ops
;
47 void __init
pci_swiotlb_init(void)
49 if (!iommu_detected
|| iommu_pass_through
) {
50 #ifdef CONFIG_IA64_GENERIC
52 printk(KERN_INFO
"PCI-DMA: Re-initialize machine vector.\n");
55 dma_ops
= &swiotlb_dma_ops
;
57 panic("Unable to find Intel IOMMU");