From: Eugeni Dodonov <eugeni.dodonov@intel.com>
Date: Wed, 23 Nov 2011 16:42:14 -0200
Subject: [PATCH] iommu: Export intel_iommu_enabled to signal when iommu is in use
Git-commit: 8bc1f85c02a20a59956b00b3acea12c04dce9ae8
Patch-mainline: v3.2-rc6
References: bnc#735417

In i915 driver, we do not enable either rc6 or semaphores on SNB when dmar
is enabled. The new 'intel_iommu_enabled' variable signals when the
iommu code is in operation.

[modified to match with 3.0 kernel by tiwai]

Cc: Ted Phelps <phelps@gnusto.com>
Cc: Peter <pab1612@gmail.com>
Cc: Lukas Hejtmanek <xhejtman@fi.muni.cz>
Cc: Andrew Lutomirski <luto@mit.edu>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Eugeni Dodonov <eugeni.dodonov@intel.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/pci/intel-iommu.c     |    5 +++++
 include/linux/dma_remapping.h |    2 ++
 2 files changed, 7 insertions(+)

--- a/include/linux/dma_remapping.h
+++ b/include/linux/dma_remapping.h
@@ -30,6 +30,7 @@
 #ifdef CONFIG_DMAR
 extern int iommu_calculate_agaw(struct intel_iommu *iommu);
 extern int iommu_calculate_max_sagaw(struct intel_iommu *iommu);
+extern int intel_iommu_enabled;
 #else
 static inline int iommu_calculate_agaw(struct intel_iommu *iommu)
 {
@@ -39,6 +40,7 @@
 {
 	return 0;
 }
+#define intel_iommu_enabled (0)
 #endif
 
 extern int dmar_disabled;
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -400,6 +400,9 @@
 int dmar_disabled = 1;
 #endif /*CONFIG_DMAR_DEFAULT_ON*/
 
+int intel_iommu_enabled = 0;
+EXPORT_SYMBOL_GPL(intel_iommu_enabled);
+
 static int dmar_map_gfx = 1;
 static int dmar_forcedac;
 static int intel_iommu_strict;
@@ -3494,6 +3497,8 @@
 
 	bus_register_notifier(&pci_bus_type, &device_nb);
 
+	intel_iommu_enabled = 1;
+
 	return 0;
 }
 
