fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / x86_64 / kernel / pci-swiotlb.c
1 /* Glue code to lib/swiotlb.c */
2
3 #include <linux/pci.h>
4 #include <linux/cache.h>
5 #include <linux/module.h>
6 #include <linux/dma-mapping.h>
7
8 #include <asm/proto.h>
9 #include <asm/swiotlb.h>
10 #include <asm/dma.h>
11
12 #ifndef CONFIG_XEN
13 int swiotlb __read_mostly;
14 EXPORT_SYMBOL(swiotlb);
15 #endif
16
17 struct dma_mapping_ops swiotlb_dma_ops = {
18 #ifndef CONFIG_XEN
19         .mapping_error = swiotlb_dma_mapping_error,
20         .alloc_coherent = swiotlb_alloc_coherent,
21         .free_coherent = swiotlb_free_coherent,
22         .map_single = swiotlb_map_single,
23         .unmap_single = swiotlb_unmap_single,
24         .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
25         .sync_single_for_device = swiotlb_sync_single_for_device,
26         .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
27         .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
28         .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
29         .sync_sg_for_device = swiotlb_sync_sg_for_device,
30         .map_sg = swiotlb_map_sg,
31         .unmap_sg = swiotlb_unmap_sg,
32         .dma_supported = NULL,
33 #endif
34 };
35
36 void pci_swiotlb_init(void)
37 {
38 #ifdef CONFIG_XEN
39         swiotlb_init();
40         if (swiotlb) {
41                 printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
42                 dma_ops = &swiotlb_dma_ops;
43         }
44 #else
45         /* don't initialize swiotlb if iommu=off (no_iommu=1) */
46         if (!iommu_detected && !no_iommu && end_pfn > MAX_DMA32_PFN)
47                swiotlb = 1;
48         if (swiotlb_force)
49                 swiotlb = 1;
50         if (swiotlb) {
51                 printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
52                 swiotlb_init();
53                 dma_ops = &swiotlb_dma_ops;
54         }
55 #endif /* CONFIG_XEN */
56 }