Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pci-swiotlb.c
Go to the documentation of this file.
1 /* Glue code to lib/swiotlb.c */
2 
3 #include <linux/pci.h>
4 #include <linux/gfp.h>
5 #include <linux/cache.h>
6 #include <linux/module.h>
7 #include <linux/dma-mapping.h>
8 
9 #include <asm/swiotlb.h>
10 #include <asm/dma.h>
11 #include <asm/iommu.h>
12 #include <asm/machvec.h>
13 
16 
17 static void *ia64_swiotlb_alloc_coherent(struct device *dev, size_t size,
19  struct dma_attrs *attrs)
20 {
21  if (dev->coherent_dma_mask != DMA_BIT_MASK(64))
22  gfp |= GFP_DMA;
23  return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
24 }
25 
26 static void ia64_swiotlb_free_coherent(struct device *dev, size_t size,
27  void *vaddr, dma_addr_t dma_addr,
28  struct dma_attrs *attrs)
29 {
30  swiotlb_free_coherent(dev, size, vaddr, dma_addr);
31 }
32 
34  .alloc = ia64_swiotlb_alloc_coherent,
35  .free = ia64_swiotlb_free_coherent,
36  .map_page = swiotlb_map_page,
37  .unmap_page = swiotlb_unmap_page,
38  .map_sg = swiotlb_map_sg_attrs,
39  .unmap_sg = swiotlb_unmap_sg_attrs,
40  .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
41  .sync_single_for_device = swiotlb_sync_single_for_device,
42  .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
43  .sync_sg_for_device = swiotlb_sync_sg_for_device,
44  .dma_supported = swiotlb_dma_supported,
45  .mapping_error = swiotlb_dma_mapping_error,
46 };
47 
49 {
51  swiotlb_init(1);
52 }
53 
55 {
56  if (!iommu_detected) {
57 #ifdef CONFIG_IA64_GENERIC
58  swiotlb = 1;
59  printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
60  machvec_init("dig");
61  swiotlb_init(1);
63 #else
64  panic("Unable to find Intel IOMMU");
65 #endif
66  }
67 }