diff options
-rw-r--r-- | drivers/iommu/Kconfig | 1 | ||||
-rw-r--r-- | drivers/iommu/intel-iommu.c | 32 |
2 files changed, 18 insertions, 15 deletions
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index e15cdcd8cb3c..a4ddeade8ac4 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig | |||
@@ -182,6 +182,7 @@ config INTEL_IOMMU | |||
182 | select IOMMU_IOVA | 182 | select IOMMU_IOVA |
183 | select NEED_DMA_MAP_STATE | 183 | select NEED_DMA_MAP_STATE |
184 | select DMAR_TABLE | 184 | select DMAR_TABLE |
185 | select SWIOTLB | ||
185 | help | 186 | help |
186 | DMA remapping (DMAR) devices support enables independent address | 187 | DMA remapping (DMAR) devices support enables independent address |
187 | translations for Direct Memory Access (DMA) from devices. | 188 | translations for Direct Memory Access (DMA) from devices. |
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index ce6baabc9dcc..0af7b4669264 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -4547,22 +4547,20 @@ const struct attribute_group *intel_iommu_groups[] = { | |||
4547 | NULL, | 4547 | NULL, |
4548 | }; | 4548 | }; |
4549 | 4549 | ||
4550 | static int __init platform_optin_force_iommu(void) | 4550 | static inline bool has_untrusted_dev(void) |
4551 | { | 4551 | { |
4552 | struct pci_dev *pdev = NULL; | 4552 | struct pci_dev *pdev = NULL; |
4553 | bool has_untrusted_dev = false; | ||
4554 | 4553 | ||
4555 | if (!dmar_platform_optin() || no_platform_optin) | 4554 | for_each_pci_dev(pdev) |
4556 | return 0; | 4555 | if (pdev->untrusted) |
4556 | return true; | ||
4557 | 4557 | ||
4558 | for_each_pci_dev(pdev) { | 4558 | return false; |
4559 | if (pdev->untrusted) { | 4559 | } |
4560 | has_untrusted_dev = true; | ||
4561 | break; | ||
4562 | } | ||
4563 | } | ||
4564 | 4560 | ||
4565 | if (!has_untrusted_dev) | 4561 | static int __init platform_optin_force_iommu(void) |
4562 | { | ||
4563 | if (!dmar_platform_optin() || no_platform_optin || !has_untrusted_dev()) | ||
4566 | return 0; | 4564 | return 0; |
4567 | 4565 | ||
4568 | if (no_iommu || dmar_disabled) | 4566 | if (no_iommu || dmar_disabled) |
@@ -4576,9 +4574,6 @@ static int __init platform_optin_force_iommu(void) | |||
4576 | iommu_identity_mapping |= IDENTMAP_ALL; | 4574 | iommu_identity_mapping |= IDENTMAP_ALL; |
4577 | 4575 | ||
4578 | dmar_disabled = 0; | 4576 | dmar_disabled = 0; |
4579 | #if defined(CONFIG_X86) && defined(CONFIG_SWIOTLB) | ||
4580 | swiotlb = 0; | ||
4581 | #endif | ||
4582 | no_iommu = 0; | 4577 | no_iommu = 0; |
4583 | 4578 | ||
4584 | return 1; | 4579 | return 1; |
@@ -4718,7 +4713,14 @@ int __init intel_iommu_init(void) | |||
4718 | up_write(&dmar_global_lock); | 4713 | up_write(&dmar_global_lock); |
4719 | 4714 | ||
4720 | #if defined(CONFIG_X86) && defined(CONFIG_SWIOTLB) | 4715 | #if defined(CONFIG_X86) && defined(CONFIG_SWIOTLB) |
4721 | swiotlb = 0; | 4716 | /* |
4717 | * If the system has no untrusted device or the user has decided | ||
4718 | * to disable the bounce page mechanisms, we don't need swiotlb. | ||
4719 | * Mark this and the pre-allocated bounce pages will be released | ||
4720 | * later. | ||
4721 | */ | ||
4722 | if (!has_untrusted_dev() || intel_no_bounce) | ||
4723 | swiotlb = 0; | ||
4722 | #endif | 4724 | #endif |
4723 | dma_ops = &intel_dma_ops; | 4725 | dma_ops = &intel_dma_ops; |
4724 | 4726 | ||