1 From 56b35336153b3d464378fa327278691bff0fa583 Mon Sep 17 00:00:00 2001
2 From: Lu Baolu <baolu.lu@linux.intel.com>
3 Date: Thu, 2 May 2019 09:34:25 +0800
4 Subject: iommu/vt-d: Set intel_iommu_gfx_mapped correctly
6 [ Upstream commit cf1ec4539a50bdfe688caad4615ca47646884316 ]
8 The intel_iommu_gfx_mapped flag is exported by the Intel
9 IOMMU driver to indicate whether an IOMMU is used for the
10 graphic device. In a virtualized IOMMU environment (e.g.
11 QEMU), an include-all IOMMU is used for graphic device.
12 This flag is found to be clear even the IOMMU is used.
14 Cc: Ashok Raj <ashok.raj@intel.com>
15 Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
16 Cc: Kevin Tian <kevin.tian@intel.com>
17 Reported-by: Zhenyu Wang <zhenyuw@linux.intel.com>
18 Fixes: c0771df8d5297 ("intel-iommu: Export a flag indicating that the IOMMU is used for iGFX.")
19 Suggested-by: Kevin Tian <kevin.tian@intel.com>
20 Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
21 Signed-off-by: Joerg Roedel <jroedel@suse.de>
22 Signed-off-by: Sasha Levin <sashal@kernel.org>
24 drivers/iommu/intel-iommu.c | 7 ++++---
25 1 file changed, 4 insertions(+), 3 deletions(-)
27 diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
28 index 3e97c4b2ebed..b965561a4162 100644
29 --- a/drivers/iommu/intel-iommu.c
30 +++ b/drivers/iommu/intel-iommu.c
31 @@ -3983,9 +3983,7 @@ static void __init init_no_remapping_devices(void)
33 /* This IOMMU has *only* gfx devices. Either bypass it or
34 set the gfx_mapped flag, as appropriate */
36 - intel_iommu_gfx_mapped = 1;
38 + if (!dmar_map_gfx) {
40 for_each_active_dev_scope(drhd->devices,
41 drhd->devices_cnt, i, dev)
42 @@ -4694,6 +4692,9 @@ int __init intel_iommu_init(void)
43 goto out_free_reserved_range;
47 + intel_iommu_gfx_mapped = 1;
49 init_no_remapping_devices();