pci-dma.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Dynamic DMA mapping support.
  4. */
  5. #include <linux/types.h>
  6. #include <linux/mm.h>
  7. #include <linux/string.h>
  8. #include <linux/pci.h>
  9. #include <linux/module.h>
  10. #include <linux/dmar.h>
  11. #include <asm/iommu.h>
  12. #include <asm/machvec.h>
  13. #include <linux/dma-mapping.h>
  14. #include <linux/kernel.h>
  15. #include <asm/page.h>
  16. int no_iommu __read_mostly;
  17. #ifdef CONFIG_IOMMU_DEBUG
  18. int force_iommu __read_mostly = 1;
  19. #else
  20. int force_iommu __read_mostly;
  21. #endif
  22. int iommu_pass_through;
  23. static int __init pci_iommu_init(void)
  24. {
  25. if (iommu_detected)
  26. intel_iommu_init();
  27. return 0;
  28. }
  29. /* Must execute after PCI subsystem */
  30. fs_initcall(pci_iommu_init);
  31. void __init pci_iommu_alloc(void)
  32. {
  33. /*
  34. * The order of these functions is important for
  35. * fall-back/fail-over reasons
  36. */
  37. detect_intel_iommu();
  38. #ifdef CONFIG_SWIOTLB
  39. if (!iommu_detected) {
  40. #ifdef CONFIG_IA64_GENERIC
  41. printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
  42. machvec_init("dig");
  43. swiotlb_dma_init();
  44. #else
  45. panic("Unable to find Intel IOMMU");
  46. #endif /* CONFIG_IA64_GENERIC */
  47. }
  48. #endif /* CONFIG_SWIOTLB */
  49. }