pci-swiotlb.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_sg_for_cpu = swiotlb_sync_sg_for_cpu,
  30. .sync_sg_for_device = swiotlb_sync_sg_for_device,
  31. .dma_supported = swiotlb_dma_supported,
  32. .mapping_error = swiotlb_dma_mapping_error,
  33. };
  34. void __init swiotlb_dma_init(void)
  35. {
  36. dma_ops = &swiotlb_dma_ops;
  37. swiotlb_init(1);
  38. }
  39. void __init pci_swiotlb_init(void)
  40. {
  41. if (!iommu_detected) {
  42. #ifdef CONFIG_IA64_GENERIC
  43. swiotlb = 1;
  44. printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
  45. machvec_init("dig");
  46. swiotlb_init(1);
  47. dma_ops = &swiotlb_dma_ops;
  48. #else
  49. panic("Unable to find Intel IOMMU");
  50. #endif
  51. }
  52. }