Commit c5a5dc4c authored by Lu Baolu's avatar Lu Baolu Committed by Joerg Roedel

iommu/vt-d: Don't switch off swiotlb if bounce page is used

The bounce page implementation depends on swiotlb. Hence, don't
switch off swiotlb if the system has untrusted devices or could
potentially be hot-added with any untrusted devices.

Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent e5e04d05
...@@ -182,6 +182,7 @@ config INTEL_IOMMU ...@@ -182,6 +182,7 @@ config INTEL_IOMMU
select IOMMU_IOVA select IOMMU_IOVA
select NEED_DMA_MAP_STATE select NEED_DMA_MAP_STATE
select DMAR_TABLE select DMAR_TABLE
select SWIOTLB
help help
DMA remapping (DMAR) devices support enables independent address DMA remapping (DMAR) devices support enables independent address
translations for Direct Memory Access (DMA) from devices. translations for Direct Memory Access (DMA) from devices.
......
...@@ -4547,22 +4547,20 @@ const struct attribute_group *intel_iommu_groups[] = { ...@@ -4547,22 +4547,20 @@ const struct attribute_group *intel_iommu_groups[] = {
NULL, NULL,
}; };
static int __init platform_optin_force_iommu(void) static inline bool has_untrusted_dev(void)
{ {
struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL;
bool has_untrusted_dev = false;
if (!dmar_platform_optin() || no_platform_optin) for_each_pci_dev(pdev)
return 0; if (pdev->untrusted)
return true;
for_each_pci_dev(pdev) { return false;
if (pdev->untrusted) { }
has_untrusted_dev = true;
break;
}
}
if (!has_untrusted_dev) static int __init platform_optin_force_iommu(void)
{
if (!dmar_platform_optin() || no_platform_optin || !has_untrusted_dev())
return 0; return 0;
if (no_iommu || dmar_disabled) if (no_iommu || dmar_disabled)
...@@ -4576,9 +4574,6 @@ static int __init platform_optin_force_iommu(void) ...@@ -4576,9 +4574,6 @@ static int __init platform_optin_force_iommu(void)
iommu_identity_mapping |= IDENTMAP_ALL; iommu_identity_mapping |= IDENTMAP_ALL;
dmar_disabled = 0; dmar_disabled = 0;
#if defined(CONFIG_X86) && defined(CONFIG_SWIOTLB)
swiotlb = 0;
#endif
no_iommu = 0; no_iommu = 0;
return 1; return 1;
...@@ -4718,7 +4713,14 @@ int __init intel_iommu_init(void) ...@@ -4718,7 +4713,14 @@ int __init intel_iommu_init(void)
up_write(&dmar_global_lock); up_write(&dmar_global_lock);
#if defined(CONFIG_X86) && defined(CONFIG_SWIOTLB) #if defined(CONFIG_X86) && defined(CONFIG_SWIOTLB)
swiotlb = 0; /*
* If the system has no untrusted device or the user has decided
* to disable the bounce page mechanisms, we don't need swiotlb.
* Mark this and the pre-allocated bounce pages will be released
* later.
*/
if (!has_untrusted_dev() || intel_no_bounce)
swiotlb = 0;
#endif #endif
dma_ops = &intel_dma_ops; dma_ops = &intel_dma_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment