pci-swiotlb.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Glue code to lib/swiotlb.c */
  2. #include <linux/pci.h>
  3. #include <linux/cache.h>
  4. #include <linux/module.h>
  5. #include <linux/dma-mapping.h>
  6. #include <asm/swiotlb.h>
  7. #include <asm/dma.h>
  8. #include <asm/iommu.h>
  9. #include <asm/machvec.h>
  10. int swiotlb __read_mostly;
  11. EXPORT_SYMBOL(swiotlb);
  12. /* Set this to 1 if there is a HW IOMMU in the system */
  13. int iommu_detected __read_mostly;
  14. struct dma_mapping_ops swiotlb_dma_ops = {
  15. .alloc_coherent = swiotlb_alloc_coherent,
  16. .free_coherent = swiotlb_free_coherent,
  17. .map_single = swiotlb_map_single,
  18. .unmap_single = swiotlb_unmap_single,
  19. .map_single_attrs = swiotlb_map_single_attrs,
  20. .unmap_single_attrs = swiotlb_unmap_single_attrs,
  21. .map_sg_attrs = swiotlb_map_sg_attrs,
  22. .unmap_sg_attrs = swiotlb_unmap_sg_attrs,
  23. .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
  24. .sync_single_for_device = swiotlb_sync_single_for_device,
  25. .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
  26. .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
  27. .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
  28. .sync_sg_for_device = swiotlb_sync_sg_for_device,
  29. .map_sg = swiotlb_map_sg,
  30. .unmap_sg = swiotlb_unmap_sg,
  31. .dma_supported_op = swiotlb_dma_supported,
  32. .mapping_error = swiotlb_dma_mapping_error,
  33. };
  34. void __init pci_swiotlb_init(void)
  35. {
  36. if (!iommu_detected) {
  37. #ifdef CONFIG_IA64_GENERIC
  38. swiotlb = 1;
  39. printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
  40. machvec_init("dig");
  41. swiotlb_init();
  42. dma_ops = &swiotlb_dma_ops;
  43. #else
  44. panic("Unable to find Intel IOMMU");
  45. #endif
  46. }
  47. }