1 // SPDX-License-Identifier: GPL-2.0
2 /* Glue code to lib/swiotlb.c */
6 #include <linux/cache.h>
7 #include <linux/module.h>
8 #include <linux/dma-mapping.h>
10 #include <asm/swiotlb.h>
12 #include <asm/iommu.h>
13 #include <asm/machvec.h>
15 int swiotlb __read_mostly
;
16 EXPORT_SYMBOL(swiotlb
);
18 static void *ia64_swiotlb_alloc_coherent(struct device
*dev
, size_t size
,
19 dma_addr_t
*dma_handle
, gfp_t gfp
,
22 if (dev
->coherent_dma_mask
!= DMA_BIT_MASK(64))
24 return swiotlb_alloc_coherent(dev
, size
, dma_handle
, gfp
);
27 static void ia64_swiotlb_free_coherent(struct device
*dev
, size_t size
,
28 void *vaddr
, dma_addr_t dma_addr
,
31 swiotlb_free_coherent(dev
, size
, vaddr
, dma_addr
);
34 const struct dma_map_ops swiotlb_dma_ops
= {
35 .alloc
= ia64_swiotlb_alloc_coherent
,
36 .free
= ia64_swiotlb_free_coherent
,
37 .map_page
= swiotlb_map_page
,
38 .unmap_page
= swiotlb_unmap_page
,
39 .map_sg
= swiotlb_map_sg_attrs
,
40 .unmap_sg
= swiotlb_unmap_sg_attrs
,
41 .sync_single_for_cpu
= swiotlb_sync_single_for_cpu
,
42 .sync_single_for_device
= swiotlb_sync_single_for_device
,
43 .sync_sg_for_cpu
= swiotlb_sync_sg_for_cpu
,
44 .sync_sg_for_device
= swiotlb_sync_sg_for_device
,
45 .dma_supported
= swiotlb_dma_supported
,
46 .mapping_error
= swiotlb_dma_mapping_error
,
49 void __init
swiotlb_dma_init(void)
51 dma_ops
= &swiotlb_dma_ops
;
55 void __init
pci_swiotlb_init(void)
57 if (!iommu_detected
) {
58 #ifdef CONFIG_IA64_GENERIC
60 printk(KERN_INFO
"PCI-DMA: Re-initialize machine vector.\n");
63 dma_ops
= &swiotlb_dma_ops
;
65 panic("Unable to find Intel IOMMU");