pci-swiotlb.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. static void *ia64_swiotlb_alloc_coherent(struct device *dev, size_t size,
  13. dma_addr_t *dma_handle, gfp_t gfp)
  14. {
  15. if (dev->coherent_dma_mask != DMA_64BIT_MASK)
  16. gfp |= GFP_DMA;
  17. return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
  18. }
  19. struct dma_map_ops swiotlb_dma_ops = {
  20. .alloc_coherent = ia64_swiotlb_alloc_coherent,
  21. .free_coherent = swiotlb_free_coherent,
  22. .map_page = swiotlb_map_page,
  23. .unmap_page = swiotlb_unmap_page,
  24. .map_sg = swiotlb_map_sg_attrs,
  25. .unmap_sg = swiotlb_unmap_sg_attrs,
  26. .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
  27. .sync_single_for_device = swiotlb_sync_single_for_device,
  28. .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
  29. .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
  30. .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
  31. .sync_sg_for_device = swiotlb_sync_sg_for_device,
  32. .dma_supported = swiotlb_dma_supported,
  33. .mapping_error = swiotlb_dma_mapping_error,
  34. };
  35. void __init swiotlb_dma_init(void)
  36. {
  37. dma_ops = &swiotlb_dma_ops;
  38. swiotlb_init();
  39. }
  40. void __init pci_swiotlb_init(void)
  41. {
  42. if (!iommu_detected) {
  43. #ifdef CONFIG_IA64_GENERIC
  44. swiotlb = 1;
  45. printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
  46. machvec_init("dig");
  47. swiotlb_init();
  48. dma_ops = &swiotlb_dma_ops;
  49. #else
  50. panic("Unable to find Intel IOMMU");
  51. #endif
  52. }
  53. }