Skip to contentSkip to conversation

iommu/vt-d: Small fixes for 5.2-rc1

PATCH Applied Lu Baolu 2 participants 4 messages May 2, 2019 – May 3, 2019 IOMMU

lore
Share & tools
lore

Lu Baolu

author
#0 lore raw

cover iommu/vt-d: Small fixes for 5.2-rc1

Hi Joerg,

This includes two small fixes for virtual IOMMU running in qemu enviroment. On bare metal, we always have an dedicated IOMMU for Intel integrated graphic device. And some aspects of the driver was designed according to this. Unfortunately, in qemu environment, the virtual IOMMU has only a single include-all IOMMU engine, as the result some interfaces don't work as expected anymore. This includes two fixes for this.

Best regards,
Lu Baolu

Lu Baolu (2):
iommu/vt-d: Set intel_iommu_gfx_mapped correctly iommu/vt-d: Make kernel parameter igfx_off work with vIOMMU

 drivers/iommu/intel-iommu.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/2 iommu/vt-d: Set intel_iommu_gfx_mapped correctly

The intel_iommu_gfx_mapped flag is exported by the Intel IOMMU driver to indicate whether an IOMMU is used for the graphic device. In a virtualized IOMMU environment (e.g. QEMU), an include-all IOMMU is used for graphic device. This flag is found to be clear even the IOMMU is used.

Cc Ashok Raj <[email protected]>
Cc Jacob Pan <[email protected]>
Cc Kevin Tian <[email protected]>
Fixes c0771df8d5297 ("intel-iommu: Export a flag indicating that the IOMMU is used for iGFX.")
---
 drivers/iommu/intel-iommu.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/iommu/intel-iommu.c +4 -3
index e0c0febc6fa5..00ad00193883 100644
@@ -4068,9 +4068,7 @@ static void __init init_no_remapping_devices(void)
 
 		/* This IOMMU has *only* gfx devices. Either bypass it or
 		   set the gfx_mapped flag, as appropriate */
-		if (dmar_map_gfx) {
-			intel_iommu_gfx_mapped = 1;
-		} else {
+		if (!dmar_map_gfx) {
 			drhd->ignored = 1;
 			for_each_active_dev_scope(drhd->devices,
 						  drhd->devices_cnt, i, dev)
@@ -4909,6 +4907,9 @@ int __init intel_iommu_init(void)
 		goto out_free_reserved_range;
 	}
 
+	if (dmar_map_gfx)
+		intel_iommu_gfx_mapped = 1;
+
 	init_no_remapping_devices();
 
 	ret = init_dmars();
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 2/2 iommu/vt-d: Make kernel parameter igfx_off work with vIOMMU

In reply to Lu Baolu

The kernel parameter igfx_off is used by users to disable DMA remapping for the Intel integrated graphic device. It was designed for bare metal cases where a dedicated IOMMU is used for graphic. This doesn't apply to virtual IOMMU case where an include-all IOMMU is used. This makes the kernel parameter work with virtual IOMMU as well.

Cc Ashok Raj <[email protected]>
Cc Jacob Pan <[email protected]>
Fixes c0771df8d5297 ("intel-iommu: Export a flag indicating that the IOMMU is used for iGFX.")
---
 drivers/iommu/intel-iommu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +4 -1
index 00ad00193883..e078b13ce3d8 100644
@@ -3415,9 +3415,12 @@ static int __init init_dmars(void)
 		iommu_identity_mapping |= IDENTMAP_ALL;
 
 #ifdef CONFIG_INTEL_IOMMU_BROKEN_GFX_WA
-	iommu_identity_mapping |= IDENTMAP_GFX;
+	dmar_map_gfx = 0;
 #endif
 
+	if (!dmar_map_gfx)
+		iommu_identity_mapping |= IDENTMAP_GFX;
+
 	check_tylersburg_isoch();
 
 	if (iommu_identity_mapping) {
Signature · 1 line
2.17.1
maintainer Applied
#3 lore raw
In reply to Lu Baolu
Quoted 3 lines · Lu Baolu

Lu Baolu (2):
iommu/vt-d: Set intel_iommu_gfx_mapped correctly iommu/vt-d: Make kernel parameter igfx_off work with vIOMMU

Applied both, thanks.