[tip:x86/apic] iommu/vt-d: Allow IR works in XAPIC mode though CPU works in X2APIC mode

2015-01-15 Thread tip-bot for Jiang Liu
Commit-ID:  13d09b6603df9df3aa3e410bc2a876889a55c744
Gitweb: http://git.kernel.org/tip/13d09b6603df9df3aa3e410bc2a876889a55c744
Author: Jiang Liu 
AuthorDate: Wed, 7 Jan 2015 15:31:37 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 15 Jan 2015 11:24:23 +0100

iommu/vt-d: Allow IR works in XAPIC mode though CPU works in X2APIC mode

Currently if CPU supports X2APIC, IR hardware must work in X2APIC mode
or disabled. Change the code to support IR working in XAPIC mode when
CPU supports X2APIC. Then the CPU APIC driver will decide how to handle
such as configuration by:
1) Disabling X2APIC mode
2) Forcing X2APIC physical mode

This change also fixes a live locking when
1) BIOS enables CPU X2APIC
2) DMAR table disables X2APIC mode or IR hardware doesn't support X2APIC
with following messages:
[   37.863463] dmar: INTR-REMAP: Request device [[f0:1f.7] fault index 2
[   37.863463] INTR-REMAP:[fault reason 36] Detected reserved fields in the 
IRTE entry
[   37.879372] dmar: INTR-REMAP: Request device [[f0:1f.7] fault index 2
[   37.879372] INTR-REMAP:[fault reason 36] Detected reserved fields in the 
IRTE entry
[   37.895282] dmar: INTR-REMAP: Request device [[f0:1f.7] fault index 2
[   37.895282] INTR-REMAP:[fault reason 36] Detected reserved fields in the 
IRTE entry
[   37.911192] dmar: INTR-REMAP: Request device [[f0:1f.7] fault index 2

Signed-off-by: Jiang Liu 
Tested-by: Joerg Roedel 
Cc: Tony Luck 
Cc: io...@lists.linux-foundation.org
Cc: Benjamin Herrenschmidt 
Cc: Yinghai Lu 
Cc: Borislav Petkov 
Link: 
http://lkml.kernel.org/r/1420615903-28253-11-git-send-email-jiang@linux.intel.com
Signed-off-by: Thomas Gleixner 
---
 drivers/iommu/intel_irq_remapping.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/intel_irq_remapping.c 
b/drivers/iommu/intel_irq_remapping.c
index 137663b..9d67c12 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -32,8 +32,9 @@ struct hpet_scope {
 };
 
 #define IR_X2APIC_MODE(mode) (mode ? (1 << 11) : 0)
-#define IRTE_DEST(dest) ((x2apic_mode) ? dest : dest << 8)
+#define IRTE_DEST(dest) ((eim_mode) ? dest : dest << 8)
 
+static int __read_mostly eim_mode;
 static struct ioapic_scope ir_ioapic[MAX_IO_APICS];
 static struct hpet_scope ir_hpet[MAX_HPET_TBS];
 
@@ -644,8 +645,6 @@ static int __init intel_enable_irq_remapping(void)
int eim = 0;
 
if (x2apic_supported()) {
-   pr_info("Queued invalidation will be enabled to support x2apic 
and Intr-remapping.\n");
-
eim = !dmar_x2apic_optout();
if (!eim)
printk(KERN_WARNING
@@ -683,8 +682,11 @@ static int __init intel_enable_irq_remapping(void)
if (eim && !ecap_eim_support(iommu->ecap)) {
printk(KERN_INFO "DRHD %Lx: EIM not supported by DRHD, "
   " ecap %Lx\n", drhd->reg_base_addr, iommu->ecap);
-   goto error;
+   eim = 0;
}
+   eim_mode = eim;
+   if (eim)
+   pr_info("Queued invalidation will be enabled to support x2apic 
and Intr-remapping.\n");
 
/*
 * Enable queued invalidation for all the DRHD's.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/apic] iommu/vt-d: Allow IR works in XAPIC mode though CPU works in X2APIC mode

2015-01-15 Thread tip-bot for Jiang Liu
Commit-ID:  13d09b6603df9df3aa3e410bc2a876889a55c744
Gitweb: http://git.kernel.org/tip/13d09b6603df9df3aa3e410bc2a876889a55c744
Author: Jiang Liu jiang@linux.intel.com
AuthorDate: Wed, 7 Jan 2015 15:31:37 +0800
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Thu, 15 Jan 2015 11:24:23 +0100

iommu/vt-d: Allow IR works in XAPIC mode though CPU works in X2APIC mode

Currently if CPU supports X2APIC, IR hardware must work in X2APIC mode
or disabled. Change the code to support IR working in XAPIC mode when
CPU supports X2APIC. Then the CPU APIC driver will decide how to handle
such as configuration by:
1) Disabling X2APIC mode
2) Forcing X2APIC physical mode

This change also fixes a live locking when
1) BIOS enables CPU X2APIC
2) DMAR table disables X2APIC mode or IR hardware doesn't support X2APIC
with following messages:
[   37.863463] dmar: INTR-REMAP: Request device [[f0:1f.7] fault index 2
[   37.863463] INTR-REMAP:[fault reason 36] Detected reserved fields in the 
IRTE entry
[   37.879372] dmar: INTR-REMAP: Request device [[f0:1f.7] fault index 2
[   37.879372] INTR-REMAP:[fault reason 36] Detected reserved fields in the 
IRTE entry
[   37.895282] dmar: INTR-REMAP: Request device [[f0:1f.7] fault index 2
[   37.895282] INTR-REMAP:[fault reason 36] Detected reserved fields in the 
IRTE entry
[   37.911192] dmar: INTR-REMAP: Request device [[f0:1f.7] fault index 2

Signed-off-by: Jiang Liu jiang@linux.intel.com
Tested-by: Joerg Roedel j...@8bytes.org
Cc: Tony Luck tony.l...@intel.com
Cc: io...@lists.linux-foundation.org
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Cc: Yinghai Lu ying...@kernel.org
Cc: Borislav Petkov b...@alien8.de
Link: 
http://lkml.kernel.org/r/1420615903-28253-11-git-send-email-jiang@linux.intel.com
Signed-off-by: Thomas Gleixner t...@linutronix.de
---
 drivers/iommu/intel_irq_remapping.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/intel_irq_remapping.c 
b/drivers/iommu/intel_irq_remapping.c
index 137663b..9d67c12 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -32,8 +32,9 @@ struct hpet_scope {
 };
 
 #define IR_X2APIC_MODE(mode) (mode ? (1  11) : 0)
-#define IRTE_DEST(dest) ((x2apic_mode) ? dest : dest  8)
+#define IRTE_DEST(dest) ((eim_mode) ? dest : dest  8)
 
+static int __read_mostly eim_mode;
 static struct ioapic_scope ir_ioapic[MAX_IO_APICS];
 static struct hpet_scope ir_hpet[MAX_HPET_TBS];
 
@@ -644,8 +645,6 @@ static int __init intel_enable_irq_remapping(void)
int eim = 0;
 
if (x2apic_supported()) {
-   pr_info(Queued invalidation will be enabled to support x2apic 
and Intr-remapping.\n);
-
eim = !dmar_x2apic_optout();
if (!eim)
printk(KERN_WARNING
@@ -683,8 +682,11 @@ static int __init intel_enable_irq_remapping(void)
if (eim  !ecap_eim_support(iommu-ecap)) {
printk(KERN_INFO DRHD %Lx: EIM not supported by DRHD, 
ecap %Lx\n, drhd-reg_base_addr, iommu-ecap);
-   goto error;
+   eim = 0;
}
+   eim_mode = eim;
+   if (eim)
+   pr_info(Queued invalidation will be enabled to support x2apic 
and Intr-remapping.\n);
 
/*
 * Enable queued invalidation for all the DRHD's.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/