blob: 82a0a674a003f815b5d98cd540e56e26f4c332df [file] [log] [blame]
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +01001/* Glue code to lib/swiotlb.c */
2
3#include <linux/pci.h>
4#include <linux/cache.h>
5#include <linux/module.h>
Rolf Eike Beerd6bd3a32006-09-29 01:59:48 -07006#include <linux/dma-mapping.h>
7
Joerg Roedel395624f2007-10-24 12:49:47 +02008#include <asm/gart.h>
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +01009#include <asm/swiotlb.h>
10#include <asm/dma.h>
11
12int swiotlb __read_mostly;
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010013
Stephen Hemmingere6584502007-05-02 19:27:06 +020014const struct dma_mapping_ops swiotlb_dma_ops = {
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010015 .mapping_error = swiotlb_dma_mapping_error,
16 .alloc_coherent = swiotlb_alloc_coherent,
17 .free_coherent = swiotlb_free_coherent,
18 .map_single = swiotlb_map_single,
19 .unmap_single = swiotlb_unmap_single,
20 .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
21 .sync_single_for_device = swiotlb_sync_single_for_device,
22 .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
23 .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
24 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
25 .sync_sg_for_device = swiotlb_sync_sg_for_device,
26 .map_sg = swiotlb_map_sg,
27 .unmap_sg = swiotlb_unmap_sg,
28 .dma_supported = NULL,
29};
30
Jan Beulich563aaf02007-02-05 18:51:25 -080031void __init pci_swiotlb_init(void)
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010032{
33 /* don't initialize swiotlb if iommu=off (no_iommu=1) */
Andi Kleen65f87d82006-07-29 21:42:49 +020034 if (!iommu_detected && !no_iommu && end_pfn > MAX_DMA32_PFN)
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010035 swiotlb = 1;
Andi Kleen65f87d82006-07-29 21:42:49 +020036 if (swiotlb_force)
37 swiotlb = 1;
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010038 if (swiotlb) {
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010039 printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
Jon Mason5b7b6442006-02-03 21:51:59 +010040 swiotlb_init();
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010041 dma_ops = &swiotlb_dma_ops;
42 }
43}