Blame view

arch/ia64/kernel/pci-swiotlb.c 1.47 KB
62fdd7678   Fenghua Yu   [IA64] Add Variab...
1
2
3
  /* Glue code to lib/swiotlb.c */
  
  #include <linux/pci.h>
5a0e3ad6a   Tejun Heo   include cleanup: ...
4
  #include <linux/gfp.h>
62fdd7678   Fenghua Yu   [IA64] Add Variab...
5
6
7
8
9
10
11
12
13
14
15
  #include <linux/cache.h>
  #include <linux/module.h>
  #include <linux/dma-mapping.h>
  
  #include <asm/swiotlb.h>
  #include <asm/dma.h>
  #include <asm/iommu.h>
  #include <asm/machvec.h>
  
  int swiotlb __read_mostly;
  EXPORT_SYMBOL(swiotlb);
97d9800de   FUJITA Tomonori   IA64: fix swiotlb...
16
17
18
  static void *ia64_swiotlb_alloc_coherent(struct device *dev, size_t size,
  					 dma_addr_t *dma_handle, gfp_t gfp)
  {
e930438c4   Yang Hongyang   Replace all DMA_n...
19
  	if (dev->coherent_dma_mask != DMA_BIT_MASK(64))
97d9800de   FUJITA Tomonori   IA64: fix swiotlb...
20
21
22
  		gfp |= GFP_DMA;
  	return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
  }
160c1d8e4   FUJITA Tomonori   x86, ia64: conver...
23
  struct dma_map_ops swiotlb_dma_ops = {
97d9800de   FUJITA Tomonori   IA64: fix swiotlb...
24
  	.alloc_coherent = ia64_swiotlb_alloc_coherent,
62fdd7678   Fenghua Yu   [IA64] Add Variab...
25
  	.free_coherent = swiotlb_free_coherent,
160c1d8e4   FUJITA Tomonori   x86, ia64: conver...
26
27
28
29
  	.map_page = swiotlb_map_page,
  	.unmap_page = swiotlb_unmap_page,
  	.map_sg = swiotlb_map_sg_attrs,
  	.unmap_sg = swiotlb_unmap_sg_attrs,
62fdd7678   Fenghua Yu   [IA64] Add Variab...
30
31
  	.sync_single_for_cpu = swiotlb_sync_single_for_cpu,
  	.sync_single_for_device = swiotlb_sync_single_for_device,
62fdd7678   Fenghua Yu   [IA64] Add Variab...
32
33
  	.sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
  	.sync_sg_for_device = swiotlb_sync_sg_for_device,
160c1d8e4   FUJITA Tomonori   x86, ia64: conver...
34
  	.dma_supported = swiotlb_dma_supported,
c82e4417a   FUJITA Tomonori   add dma_mapping_o...
35
  	.mapping_error = swiotlb_dma_mapping_error,
62fdd7678   Fenghua Yu   [IA64] Add Variab...
36
  };
07716e4df   Tony Luck   ia64: fix section...
37
  void __init swiotlb_dma_init(void)
4d9b977ca   FUJITA Tomonori   set up dma_ops ap...
38
39
  {
  	dma_ops = &swiotlb_dma_ops;
ad32e8cb8   FUJITA Tomonori   swiotlb: Defer sw...
40
  	swiotlb_init(1);
4d9b977ca   FUJITA Tomonori   set up dma_ops ap...
41
  }
62fdd7678   Fenghua Yu   [IA64] Add Variab...
42
43
  void __init pci_swiotlb_init(void)
  {
ba6c54870   David Woodhouse   ia64: IOMMU passt...
44
  	if (!iommu_detected) {
62fdd7678   Fenghua Yu   [IA64] Add Variab...
45
46
47
48
49
  #ifdef CONFIG_IA64_GENERIC
  		swiotlb = 1;
  		printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.
  ");
  		machvec_init("dig");
ad32e8cb8   FUJITA Tomonori   swiotlb: Defer sw...
50
  		swiotlb_init(1);
62fdd7678   Fenghua Yu   [IA64] Add Variab...
51
52
53
54
55
56
  		dma_ops = &swiotlb_dma_ops;
  #else
  		panic("Unable to find Intel IOMMU");
  #endif
  	}
  }