pci-swiotlb.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Glue code to lib/swiotlb.c */
  2. #include <linux/pci.h>
  3. #include <linux/gfp.h>
  4. #include <linux/cache.h>
  5. #include <linux/module.h>
  6. #include <linux/dma-mapping.h>
  7. #include <asm/swiotlb.h>
  8. #include <asm/dma.h>
  9. #include <asm/iommu.h>
  10. #include <asm/machvec.h>
  11. int swiotlb __read_mostly;
  12. EXPORT_SYMBOL(swiotlb);
  13. static void *ia64_swiotlb_alloc_coherent(struct device *dev, size_t size,
  14. dma_addr_t *dma_handle, gfp_t gfp)
  15. {
  16. if (dev->coherent_dma_mask != DMA_BIT_MASK(64))
  17. gfp |= GFP_DMA;
  18. return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
  19. }
  20. struct dma_map_ops swiotlb_dma_ops = {
  21. .alloc_coherent = ia64_swiotlb_alloc_coherent,
  22. .free_coherent = swiotlb_free_coherent,
  23. .map_page = swiotlb_map_page,
  24. .unmap_page = swiotlb_unmap_page,
  25. .map_sg = swiotlb_map_sg_attrs,
  26. .unmap_sg = swiotlb_unmap_sg_attrs,
  27. .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
  28. .sync_single_for_device = swiotlb_sync_single_for_device,
  29. .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
  30. .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
  31. .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
  32. .sync_sg_for_device = swiotlb_sync_sg_for_device,
  33. .dma_supported = swiotlb_dma_supported,
  34. .mapping_error = swiotlb_dma_mapping_error,
  35. };
  36. void __init swiotlb_dma_init(void)
  37. {
  38. dma_ops = &swiotlb_dma_ops;
  39. swiotlb_init(1);
  40. }
  41. void __init pci_swiotlb_init(void)
  42. {
  43. if (!iommu_detected) {
  44. #ifdef CONFIG_IA64_GENERIC
  45. swiotlb = 1;
  46. printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
  47. machvec_init("dig");
  48. swiotlb_init(1);
  49. dma_ops = &swiotlb_dma_ops;
  50. #else
  51. panic("Unable to find Intel IOMMU");
  52. #endif
  53. }
  54. }