Skip to contentSkip to conversation

Replace intel_iommu_gfx_mapped with device_iommu_mapped()

PATCH In review Lu Baolu 1 participant 4 messages Feb 11, 2022 – Mar 8, 2022

Subsystems (3)
lore
Share & tools
lore

Lu Baolu

author maintainer
#0 lore raw

cover Replace intel_iommu_gfx_mapped with device_iommu_mapped()

Hi,

This follows commit cca084692394a ("drm/i915: Use per device iommu check") to convert intel_iommu_gfx_mapped use in agp/intel to device_iommu_mapped(). With this changed, the export intel_iommu_gfx_mapped could be removed.

Best regards,
baolu

Lu Baolu (2):
agp/intel: Use per device iommu check
iommu/vt-d: Remove unnecessary exported symbol

 include/linux/intel-iommu.h  |  1 -
 drivers/char/agp/intel-gtt.c | 17 +++++++----------
 drivers/iommu/intel/iommu.c  |  6 ------
 3 files changed, 7 insertions(+), 17 deletions(-)
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
author maintainer
#1 lore raw

PATCH 1/2 agp/intel: Use per device iommu check

The IOMMU subsystem has already provided an interface to query whether the IOMMU hardware is enabled for a specific device. This changes the check from Intel specific intel_iommu_gfx_mapped (globally exported by the Intel IOMMU driver) to probing the presence of IOMMU on a specific device using the generic device_iommu_mapped().

This follows commit cca084692394a ("drm/i915: Use per device iommu check") which converted drm/i915 driver to use device_iommu_mapped().

---
 drivers/char/agp/intel-gtt.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/char/agp/intel-gtt.c +7 -10
index c53cc9868cd8..9631cbc7002e 100644
@@ -20,7 +20,7 @@
 #include <linux/kernel.h>
 #include <linux/pagemap.h>
 #include <linux/agp_backend.h>
-#include <linux/intel-iommu.h>
+#include <linux/iommu.h>
 #include <linux/delay.h>
 #include <asm/smp.h>
 #include "agp.h"
@@ -573,18 +573,15 @@ static void intel_gtt_cleanup(void)
  */
 static inline int needs_ilk_vtd_wa(void)
 {
-#ifdef CONFIG_INTEL_IOMMU
 	const unsigned short gpu_devid = intel_private.pcidev->device;
 
-	/* Query intel_iommu to see if we need the workaround. Presumably that
-	 * was loaded first.
+	/*
+	 * Query iommu subsystem to see if we need the workaround. Presumably
+	 * that was loaded first.
 	 */
-	if ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG ||
-	     gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) &&
-	     intel_iommu_gfx_mapped)
-		return 1;
-#endif
-	return 0;
+	return ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG ||
+		 gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) &&
+		device_iommu_mapped(&intel_private.pcidev->dev));
 }
 
 static bool intel_gtt_can_wc(void)
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
author maintainer
#2 lore raw

Re: [PATCH 1/2] agp/intel: Use per device iommu check

Quoted 42 lines · Lu Baolu

The IOMMU subsystem has already provided an interface to query whether the IOMMU hardware is enabled for a specific device. This changes the check from Intel specific intel_iommu_gfx_mapped (globally exported by the Intel IOMMU driver) to probing the presence of IOMMU on a specific device using the generic device_iommu_mapped().

This follows commit cca084692394a ("drm/i915: Use per device iommu check") which converted drm/i915 driver to use device_iommu_mapped().

---
  drivers/char/agp/intel-gtt.c | 17 +++++++----------
  1 file changed, 7 insertions(+), 10 deletions(-)
drivers/char/agp/intel-gtt.c +4 -6
index c53cc9868cd8..9631cbc7002e 100644
@@ -20,7 +20,7 @@
  #include <linux/kernel.h>
  #include <linux/pagemap.h>
  #include <linux/agp_backend.h>
-#include <linux/intel-iommu.h>
+#include <linux/iommu.h>
  #include <linux/delay.h>
  #include <asm/smp.h>
  #include "agp.h"
@@ -573,18 +573,15 @@ static void intel_gtt_cleanup(void)
   */
  static inline int needs_ilk_vtd_wa(void)
  {
-#ifdef CONFIG_INTEL_IOMMU
  	const unsigned short gpu_devid = intel_private.pcidev->device;
 
-	/* Query intel_iommu to see if we need the workaround. Presumably that
-	 * was loaded first.
+	/*
+	 * Query iommu subsystem to see if we need the workaround. Presumably
+	 * that was loaded first.
  	 */
-	if ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG ||
-	     gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) &&

drivers/char/agp/intel-gtt.c static void intel_gtt_cleanup(void) · line 587

Quoted 10 lines
drivers/char/agp/intel-gtt.c +3 -4
-	     intel_iommu_gfx_mapped)
-		return 1;
-#endif
-	return 0;
+	return ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG ||
+		 gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) &&
+		device_iommu_mapped(&intel_private.pcidev->dev));
  }
 
  static bool intel_gtt_can_wc(void)

A gentle ping ...:-)

Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author maintainer
#3 lore raw

PATCH 2/2 iommu/vt-d: Remove unnecessary exported symbol

In reply to Lu Baolu

The exported symbol intel_iommu_gfx_mapped is not used anywhere in the tree. Remove it to avoid dead code.

---
 include/linux/intel-iommu.h | 1 -
 drivers/iommu/intel/iommu.c | 6 ------
 2 files changed, 7 deletions(-)
include/linux/intel-iommu.h +0 -1
index 2f8a4517c929..b8b8be58cb6b 100644
@@ -789,7 +789,6 @@ extern int iommu_calculate_agaw(struct intel_iommu *iommu);
 extern int iommu_calculate_max_sagaw(struct intel_iommu *iommu);
 extern int dmar_disabled;
 extern int intel_iommu_enabled;
-extern int intel_iommu_gfx_mapped;
 #else
 static inline int iommu_calculate_agaw(struct intel_iommu *iommu)
 {
drivers/iommu/intel/iommu.c +0 -6
index 4b06f2f365bd..88a53140c7f1 100644
@@ -311,9 +311,6 @@ static int iommu_skip_te_disable;
 #define IDENTMAP_GFX		2
 #define IDENTMAP_AZALIA		4
 
-int intel_iommu_gfx_mapped;
-EXPORT_SYMBOL_GPL(intel_iommu_gfx_mapped);
-
 static DEFINE_XARRAY_ALLOC(device_domain_array);
 
 /* Convert device source ID into the index of device_domain_array. */
@@ -4070,9 +4067,6 @@ int __init intel_iommu_init(void)
 	if (list_empty(&dmar_satc_units))
 		pr_info("No SATC found\n");
 
-	if (dmar_map_gfx)
-		intel_iommu_gfx_mapped = 1;
-
 	init_no_remapping_devices();
 
 	ret = init_dmars();
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu