blob: fe988c49f01ce6ae844355731ddc50f01fef3df1 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Fenghua Yu62fdd762008-10-17 12:14:13 -07002/*
3 * Dynamic DMA mapping support.
4 */
5
6#include <linux/types.h>
7#include <linux/mm.h>
8#include <linux/string.h>
9#include <linux/pci.h>
10#include <linux/module.h>
11#include <linux/dmar.h>
12#include <asm/iommu.h>
13#include <asm/machvec.h>
14#include <linux/dma-mapping.h>
Fenghua Yu62fdd762008-10-17 12:14:13 -070015#include <linux/kernel.h>
Fenghua Yu62fdd762008-10-17 12:14:13 -070016#include <asm/page.h>
Fenghua Yu62fdd762008-10-17 12:14:13 -070017
Fenghua Yu62fdd762008-10-17 12:14:13 -070018int no_iommu __read_mostly;
19#ifdef CONFIG_IOMMU_DEBUG
20int force_iommu __read_mostly = 1;
21#else
22int force_iommu __read_mostly;
23#endif
24
Fenghua Yuaed5d5f2009-04-30 17:57:11 -070025int iommu_pass_through;
26
Fenghua Yu62fdd762008-10-17 12:14:13 -070027static int __init pci_iommu_init(void)
28{
29 if (iommu_detected)
30 intel_iommu_init();
31
32 return 0;
33}
34
35/* Must execute after PCI subsystem */
36fs_initcall(pci_iommu_init);
37
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090038void __init pci_iommu_alloc(void)
39{
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090040 /*
41 * The order of these functions is important for
42 * fall-back/fail-over reasons
43 */
44 detect_intel_iommu();
45
46#ifdef CONFIG_SWIOTLB
Christoph Hellwig4fac8072017-12-24 13:57:08 +010047 if (!iommu_detected) {
48#ifdef CONFIG_IA64_GENERIC
49 printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
50 machvec_init("dig");
51 swiotlb_dma_init();
52#else
53 panic("Unable to find Intel IOMMU");
54#endif /* CONFIG_IA64_GENERIC */
55 }
56#endif /* CONFIG_SWIOTLB */
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090057}