Linux IOMMU Development
 help / color / mirror / Atom feed
* [RFC Patch V1 0/9] Simplify initialization of IR on x86 platforms
@ 2014-12-10  6:47 Jiang Liu
       [not found] ` <1418194071-13785-1-git-send-email-jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Jiang Liu @ 2014-12-10  6:47 UTC (permalink / raw)
  To: H. Peter Anvin, Thomas Gleixner, Joerg Roedel, David Woodhouse,
	Borislav Petkov
  Cc: x86-DgEjT+Ai2ygdnm+yROfE0A,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Tony Luck,
	Jiang Liu, linux-kernel-u79uwXL29TY76Z2rM5mHXA

This is a following-on patch set to simplify initialization of interrupt
remapping subsystem on x86 platforms. Please refer to
	https://lkml.org/lkml/2014/12/5/114
for the whole story.

With this patch set applied, there are three steps to initialize IR on x86:
1) "Detect" stage to detect ACPI table for IR at early booting stage
2) "Prepare" stage to allocate resources for IR
3) "Enable" stage to program hardware device to enable IR

Patch 1-3 clean up the code to initialize IR and X2APIC on x86
Patch 4-5 kill the irq_remapping_supported() and related code
Patch 6-9 clean up IR code further.

It's based on tip/x86/apic branch and could be pulled from:
https://github.com/jiangliu/linux.git irq_remapping_v1

It has been tested on Intel platform with X2APIC enabled and disabled.
It also passes Fengguang's 0day test suite. Tests on AMD platform are
welcomed!

Jiang Liu (9):
  x86, apic: Kill useless variable x2apic_enabled in function
    enable_IR_x2apic()
  x86, apic: Correctly detect X2APIC status in function enable_IR()
  x86, apic: Refine enable_IR_x2apic() and related functions
  iommu/vt-d: Prepare for killing function irq_remapping_supported()
  iommu/irq_remapping: Kill function irq_remapping_supported() and
    related code
  iommu/irq_remapping: Refine function irq_remapping_prepare() for
    maintenance
  iommu/irq_remapping: Change variable disable_irq_remap to be static
  iommu/irq_remapping: Normailize the way to detect whether IR is
    enabled
  iommu/irq_remapping: Kill unused function irq_remapping_print_chip()

 arch/x86/include/asm/irq_remapping.h |    4 --
 arch/x86/kernel/apic/apic.c          |   89 +++++++++++++++-------------------
 drivers/iommu/amd_iommu.c            |    1 -
 drivers/iommu/amd_iommu_init.c       |   10 +---
 drivers/iommu/amd_iommu_proto.h      |    1 -
 drivers/iommu/intel_irq_remapping.c  |   59 ++++++++--------------
 drivers/iommu/irq_remapping.c        |   74 +++++++++-------------------
 drivers/iommu/irq_remapping.h        |    5 --
 8 files changed, 84 insertions(+), 159 deletions(-)

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [RFC Patch V1 1/9] x86, apic: Kill useless variable x2apic_enabled in function enable_IR_x2apic()
       [not found] ` <1418194071-13785-1-git-send-email-jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2014-12-10  6:47   ` Jiang Liu
  2014-12-10  6:47   ` [RFC Patch V1 2/9] x86, apic: Correctly detect X2APIC status in function enable_IR() Jiang Liu
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-12-10  6:47 UTC (permalink / raw)
  To: H. Peter Anvin, Thomas Gleixner, Joerg Roedel, David Woodhouse,
	Borislav Petkov, Ingo Molnar, x86-DgEjT+Ai2ygdnm+yROfE0A,
	Jiang Liu, David Rientjes, HATAYAMA Daisuke, Jan Beulich,
	Richard Weinberger, Oren Twaig
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Tony Luck,
	H. Peter Anvin, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Ingo Molnar

Local variable x2apic_enabled has been assigned to but never referred,
so kill it.

Signed-off-by: Jiang Liu <jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 arch/x86/kernel/apic/apic.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 141f1031013d..e7a426a589df 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1594,7 +1594,7 @@ int __init enable_IR(void)
 void __init enable_IR_x2apic(void)
 {
 	unsigned long flags;
-	int ret, x2apic_enabled = 0;
+	int ret;
 	int hardware_init_ret;
 
 	hardware_init_ret = irq_remapping_prepare();
@@ -1644,8 +1644,6 @@ void __init enable_IR_x2apic(void)
 		goto skip_x2apic;
 	}
 
-	x2apic_enabled = 1;
-
 	if (x2apic_supported() && !x2apic_mode) {
 		x2apic_mode = 1;
 		enable_x2apic();
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC Patch V1 2/9] x86, apic: Correctly detect X2APIC status in function enable_IR()
       [not found] ` <1418194071-13785-1-git-send-email-jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  2014-12-10  6:47   ` [RFC Patch V1 1/9] x86, apic: Kill useless variable x2apic_enabled in function enable_IR_x2apic() Jiang Liu
@ 2014-12-10  6:47   ` Jiang Liu
  2014-12-10  6:47   ` [RFC Patch V1 3/9] x86, apic: Refine enable_IR_x2apic() and related functions Jiang Liu
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-12-10  6:47 UTC (permalink / raw)
  To: H. Peter Anvin, Thomas Gleixner, Joerg Roedel, David Woodhouse,
	Borislav Petkov, Ingo Molnar, x86-DgEjT+Ai2ygdnm+yROfE0A,
	Jiang Liu, David Rientjes, HATAYAMA Daisuke, Jan Beulich,
	Richard Weinberger, Oren Twaig
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Tony Luck,
	H. Peter Anvin, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Ingo Molnar

X2APIC will be disabled if user specifies "nox2apic" on kernel command
line, even when x2apic_preenabled is true. So correctly detect X2APIC
status by using x2apic_enabled() instead of x2apic_preenabled.

Signed-off-by: Jiang Liu <jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 arch/x86/kernel/apic/apic.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index e7a426a589df..b6c473b97c5c 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1580,7 +1580,7 @@ int __init enable_IR(void)
 		return -1;
 	}
 
-	if (!x2apic_preenabled && skip_ioapic_setup) {
+	if (!x2apic_enabled() && skip_ioapic_setup) {
 		pr_info("Skipped enabling intr-remap because of skipping "
 			"io-apic setup\n");
 		return -1;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC Patch V1 3/9] x86, apic: Refine enable_IR_x2apic() and related functions
       [not found] ` <1418194071-13785-1-git-send-email-jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  2014-12-10  6:47   ` [RFC Patch V1 1/9] x86, apic: Kill useless variable x2apic_enabled in function enable_IR_x2apic() Jiang Liu
  2014-12-10  6:47   ` [RFC Patch V1 2/9] x86, apic: Correctly detect X2APIC status in function enable_IR() Jiang Liu
@ 2014-12-10  6:47   ` Jiang Liu
  2014-12-10  6:47   ` [RFC Patch V1 4/9] iommu/vt-d: Prepare for killing function irq_remapping_supported() Jiang Liu
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-12-10  6:47 UTC (permalink / raw)
  To: H. Peter Anvin, Thomas Gleixner, Joerg Roedel, David Woodhouse,
	Borislav Petkov, Ingo Molnar, x86-DgEjT+Ai2ygdnm+yROfE0A,
	Jiang Liu, David Rientjes, HATAYAMA Daisuke, Jan Beulich,
	Richard Weinberger, Oren Twaig
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Tony Luck,
	H. Peter Anvin, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Ingo Molnar

Refine enable_IR_x2apic() and related functions for better maintenence.
It also changes the way to treat IR in XAPIC mode as the same as IR is
disabled when enabling X2APIC.

Signed-off-by: Jiang Liu <jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 arch/x86/kernel/apic/apic.c |   78 ++++++++++++++++++++-----------------------
 1 file changed, 37 insertions(+), 41 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index b6c473b97c5c..2a9bac837be4 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1572,7 +1572,7 @@ void enable_x2apic(void)
 }
 #endif /* CONFIG_X86_X2APIC */
 
-int __init enable_IR(void)
+static int __init try_to_enable_IR(void)
 {
 #ifdef CONFIG_IRQ_REMAP
 	if (!irq_remapping_supported()) {
@@ -1585,44 +1585,18 @@ int __init enable_IR(void)
 			"io-apic setup\n");
 		return -1;
 	}
+#endif
 
 	return irq_remapping_enable();
-#endif
-	return -1;
 }
 
-void __init enable_IR_x2apic(void)
+static __init void try_to_enable_x2apic(int ir_stat)
 {
-	unsigned long flags;
-	int ret;
-	int hardware_init_ret;
-
-	hardware_init_ret = irq_remapping_prepare();
-	if (hardware_init_ret && !x2apic_supported())
-		return;
-
-	ret = save_ioapic_entries();
-	if (ret) {
-		pr_info("Saving IO-APIC state failed: %d\n", ret);
-		return;
-	}
-
-	local_irq_save(flags);
-	legacy_pic->mask_all();
-	mask_ioapic_entries();
-
-	if (x2apic_preenabled && nox2apic)
-		disable_x2apic();
-
-	if (hardware_init_ret)
-		ret = -1;
-	else
-		ret = enable_IR();
-
+#ifdef CONFIG_X86_X2APIC
 	if (!x2apic_supported())
-		goto skip_x2apic;
+		return;
 
-	if (ret < 0) {
+	if (ir_stat != IRQ_REMAP_X2APIC_MODE) {
 		/* IR is required if there is APIC ID > 255 even when running
 		 * under KVM
 		 */
@@ -1630,8 +1604,9 @@ void __init enable_IR_x2apic(void)
 		    !hypervisor_x2apic_available()) {
 			if (x2apic_preenabled)
 				disable_x2apic();
-			goto skip_x2apic;
+			return;
 		}
+
 		/*
 		 * without IR all CPUs can be addressed by IOAPIC/MSI
 		 * only in physical mode
@@ -1639,19 +1614,40 @@ void __init enable_IR_x2apic(void)
 		x2apic_force_phys();
 	}
 
-	if (ret == IRQ_REMAP_XAPIC_MODE) {
-		pr_info("x2apic not enabled, IRQ remapping is in xapic mode\n");
-		goto skip_x2apic;
-	}
-
-	if (x2apic_supported() && !x2apic_mode) {
+	if (!x2apic_mode) {
 		x2apic_mode = 1;
 		enable_x2apic();
 		pr_info("Enabled x2apic\n");
 	}
+#endif
+}
+
+void __init enable_IR_x2apic(void)
+{
+	unsigned long flags;
+	int ret, ir_stat;
+
+	ir_stat = irq_remapping_prepare();
+	if (ir_stat < 0 && !x2apic_supported())
+		return;
+
+	ret = save_ioapic_entries();
+	if (ret) {
+		pr_info("Saving IO-APIC state failed: %d\n", ret);
+		return;
+	}
+
+	local_irq_save(flags);
+	legacy_pic->mask_all();
+	mask_ioapic_entries();
+
+	if (x2apic_preenabled && nox2apic)
+		disable_x2apic();
+	if (ir_stat >= 0)
+		ir_stat = try_to_enable_IR();
+	try_to_enable_x2apic(ir_stat);
 
-skip_x2apic:
-	if (ret < 0) /* IR enabling failed */
+	if (ir_stat < 0) /* IR enabling failed */
 		restore_ioapic_entries();
 	legacy_pic->restore_mask();
 	local_irq_restore(flags);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC Patch V1 4/9] iommu/vt-d: Prepare for killing function irq_remapping_supported()
       [not found] ` <1418194071-13785-1-git-send-email-jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
                     ` (2 preceding siblings ...)
  2014-12-10  6:47   ` [RFC Patch V1 3/9] x86, apic: Refine enable_IR_x2apic() and related functions Jiang Liu
@ 2014-12-10  6:47   ` Jiang Liu
  2014-12-10  6:47   ` [RFC Patch V1 5/9] iommu/irq_remapping: Kill function irq_remapping_supported() and related code Jiang Liu
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-12-10  6:47 UTC (permalink / raw)
  To: H. Peter Anvin, Thomas Gleixner, Joerg Roedel, David Woodhouse,
	Borislav Petkov
  Cc: x86-DgEjT+Ai2ygdnm+yROfE0A,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Tony Luck,
	Jiang Liu, linux-kernel-u79uwXL29TY76Z2rM5mHXA

Prepare for killing function irq_remapping_supported() by moving code
from intel_irq_remapping_supported() into intel_prepare_irq_remapping().

Signed-off-by: Jiang Liu <jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/iommu/intel_irq_remapping.c |   54 ++++++++++++++---------------------
 1 file changed, 21 insertions(+), 33 deletions(-)

diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
index ff35b0336d2b..9e102168d8ae 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -512,30 +512,6 @@ static int __init dmar_x2apic_optout(void)
 
 static int __init intel_irq_remapping_supported(void)
 {
-	struct dmar_drhd_unit *drhd;
-	struct intel_iommu *iommu;
-
-	if (disable_irq_remap)
-		return 0;
-	if (irq_remap_broken) {
-		printk(KERN_WARNING
-			"This system BIOS has enabled interrupt remapping\n"
-			"on a chipset that contains an erratum making that\n"
-			"feature unstable.  To maintain system stability\n"
-			"interrupt remapping is being disabled.  Please\n"
-			"contact your BIOS vendor for an update\n");
-		add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);
-		disable_irq_remap = 1;
-		return 0;
-	}
-
-	if (!dmar_ir_support())
-		return 0;
-
-	for_each_iommu(iommu, drhd)
-		if (!ecap_ir_support(iommu->ecap))
-			return 0;
-
 	return 1;
 }
 
@@ -560,26 +536,38 @@ static int __init intel_prepare_irq_remapping(void)
 	struct dmar_drhd_unit *drhd;
 	struct intel_iommu *iommu;
 
+	if (irq_remap_broken) {
+		printk(KERN_WARNING
+			"This system BIOS has enabled interrupt remapping\n"
+			"on a chipset that contains an erratum making that\n"
+			"feature unstable.  To maintain system stability\n"
+			"interrupt remapping is being disabled.  Please\n"
+			"contact your BIOS vendor for an update\n");
+		add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);
+		disable_irq_remap = 1;
+		return -ENODEV;
+	}
+
 	if (dmar_table_init() < 0)
-		return -1;
+		return -ENODEV;
+
+	if (!dmar_ir_support())
+		return -ENODEV;
 
 	if (parse_ioapics_under_ir() != 1) {
 		printk(KERN_INFO "Not enabling interrupt remapping\n");
 		goto error;
 	}
 
-	for_each_iommu(iommu, drhd) {
-		if (!ecap_ir_support(iommu->ecap))
-			continue;
-
-		/* Do the allocations early */
-		if (intel_setup_irq_remapping(iommu))
+	for_each_iommu(iommu, drhd)
+		if (!ecap_ir_support(iommu->ecap) ||
+		    intel_setup_irq_remapping(iommu))
 			goto error;
-	}
 	return 0;
+
 error:
 	intel_cleanup_irq_remapping();
-	return -1;
+	return -ENODEV;
 }
 
 static int __init intel_enable_irq_remapping(void)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC Patch V1 5/9] iommu/irq_remapping: Kill function irq_remapping_supported() and related code
       [not found] ` <1418194071-13785-1-git-send-email-jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
                     ` (3 preceding siblings ...)
  2014-12-10  6:47   ` [RFC Patch V1 4/9] iommu/vt-d: Prepare for killing function irq_remapping_supported() Jiang Liu
@ 2014-12-10  6:47   ` Jiang Liu
  2014-12-10  6:47   ` [RFC Patch V1 6/9] iommu/irq_remapping: Refine function irq_remapping_prepare() for maintenance Jiang Liu
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-12-10  6:47 UTC (permalink / raw)
  To: H. Peter Anvin, Thomas Gleixner, Joerg Roedel, David Woodhouse,
	Borislav Petkov, Ingo Molnar, x86-DgEjT+Ai2ygdnm+yROfE0A,
	Jiang Liu, David Rientjes, HATAYAMA Daisuke, Jan Beulich,
	Richard Weinberger, Oren Twaig
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Tony Luck,
	H. Peter Anvin, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Ingo Molnar

Simplify irq_remapping code by killing irq_remapping_supported() and
related interfaces.

Signed-off-by: Jiang Liu <jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 arch/x86/include/asm/irq_remapping.h |    2 --
 arch/x86/kernel/apic/apic.c          |    7 +------
 drivers/iommu/amd_iommu.c            |    1 -
 drivers/iommu/amd_iommu_init.c       |    5 -----
 drivers/iommu/amd_iommu_proto.h      |    1 -
 drivers/iommu/intel_irq_remapping.c  |    6 ------
 drivers/iommu/irq_remapping.c        |   12 ++----------
 drivers/iommu/irq_remapping.h        |    3 ---
 8 files changed, 3 insertions(+), 34 deletions(-)

diff --git a/arch/x86/include/asm/irq_remapping.h b/arch/x86/include/asm/irq_remapping.h
index ab3bd0f54ba9..f2f52a8bb14e 100644
--- a/arch/x86/include/asm/irq_remapping.h
+++ b/arch/x86/include/asm/irq_remapping.h
@@ -31,7 +31,6 @@ struct irq_alloc_info;
 
 #ifdef CONFIG_IRQ_REMAP
 
-extern int irq_remapping_supported(void);
 extern void set_irq_remapping_broken(void);
 extern int irq_remapping_prepare(void);
 extern int irq_remapping_enable(void);
@@ -57,7 +56,6 @@ static inline struct irq_domain *arch_get_ir_parent_domain(void)
 
 #else  /* CONFIG_IRQ_REMAP */
 
-static inline int irq_remapping_supported(void) { return 0; }
 static inline void set_irq_remapping_broken(void) { }
 static inline int irq_remapping_prepare(void) { return -ENODEV; }
 static inline int irq_remapping_enable(void) { return -ENODEV; }
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 2a9bac837be4..4549695b8df0 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1574,12 +1574,7 @@ void enable_x2apic(void)
 
 static int __init try_to_enable_IR(void)
 {
-#ifdef CONFIG_IRQ_REMAP
-	if (!irq_remapping_supported()) {
-		pr_debug("intr-remapping not supported\n");
-		return -1;
-	}
-
+#ifdef CONFIG_X86_IO_APIC
 	if (!x2apic_enabled() && skip_ioapic_setup) {
 		pr_info("Skipped enabling intr-remap because of skipping "
 			"io-apic setup\n");
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index a5c59b434c77..05ffb7c8bfe3 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -4114,7 +4114,6 @@ static struct irq_domain *get_irq_domain(struct irq_alloc_info *info)
 }
 
 struct irq_remap_ops amd_iommu_irq_ops = {
-	.supported		= amd_iommu_supported,
 	.prepare		= amd_iommu_prepare,
 	.enable			= amd_iommu_enable,
 	.disable		= amd_iommu_disable,
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index de3390a7d345..fc047a4ee661 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -2130,11 +2130,6 @@ int __init amd_iommu_prepare(void)
 	return iommu_go_to_state(IOMMU_ACPI_FINISHED);
 }
 
-int __init amd_iommu_supported(void)
-{
-	return amd_iommu_irq_remap ? 1 : 0;
-}
-
 int __init amd_iommu_enable(void)
 {
 	int ret;
diff --git a/drivers/iommu/amd_iommu_proto.h b/drivers/iommu/amd_iommu_proto.h
index 612a22192fa0..fcf61cae53d6 100644
--- a/drivers/iommu/amd_iommu_proto.h
+++ b/drivers/iommu/amd_iommu_proto.h
@@ -33,7 +33,6 @@ extern void amd_iommu_init_notifier(void);
 extern void amd_iommu_init_api(void);
 
 /* Needed for interrupt remapping */
-extern int amd_iommu_supported(void);
 extern int amd_iommu_prepare(void);
 extern int amd_iommu_enable(void);
 extern void amd_iommu_disable(void);
diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
index 9e102168d8ae..c2255927766b 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -510,11 +510,6 @@ static int __init dmar_x2apic_optout(void)
 	return dmar->flags & DMAR_X2APIC_OPT_OUT;
 }
 
-static int __init intel_irq_remapping_supported(void)
-{
-	return 1;
-}
-
 static void __init intel_cleanup_irq_remapping(void)
 {
 	struct dmar_drhd_unit *drhd;
@@ -958,7 +953,6 @@ static struct irq_domain *intel_get_irq_domain(struct irq_alloc_info *info)
 }
 
 struct irq_remap_ops intel_irq_remap_ops = {
-	.supported		= intel_irq_remapping_supported,
 	.prepare		= intel_prepare_irq_remapping,
 	.enable			= intel_enable_irq_remapping,
 	.disable		= disable_irq_remapping,
diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
index 66517e7d42f0..2d75f0d69b76 100644
--- a/drivers/iommu/irq_remapping.c
+++ b/drivers/iommu/irq_remapping.c
@@ -80,19 +80,11 @@ void set_irq_remapping_broken(void)
 	irq_remap_broken = 1;
 }
 
-int irq_remapping_supported(void)
+int __init irq_remapping_prepare(void)
 {
 	if (disable_irq_remap)
-		return 0;
-
-	if (!remap_ops || !remap_ops->supported)
-		return 0;
+		return -ENOSYS;
 
-	return remap_ops->supported();
-}
-
-int __init irq_remapping_prepare(void)
-{
 	remap_ops = &intel_irq_remap_ops;
 
 #ifdef CONFIG_AMD_IOMMU
diff --git a/drivers/iommu/irq_remapping.h b/drivers/iommu/irq_remapping.h
index 4bd791d72e5e..961dc49305e1 100644
--- a/drivers/iommu/irq_remapping.h
+++ b/drivers/iommu/irq_remapping.h
@@ -36,9 +36,6 @@ extern int no_x2apic_optout;
 extern int irq_remapping_enabled;
 
 struct irq_remap_ops {
-	/* Check whether Interrupt Remapping is supported */
-	int (*supported)(void);
-
 	/* Initializes hardware and makes it ready for remapping interrupts */
 	int  (*prepare)(void);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC Patch V1 6/9] iommu/irq_remapping: Refine function irq_remapping_prepare() for maintenance
       [not found] ` <1418194071-13785-1-git-send-email-jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
                     ` (4 preceding siblings ...)
  2014-12-10  6:47   ` [RFC Patch V1 5/9] iommu/irq_remapping: Kill function irq_remapping_supported() and related code Jiang Liu
@ 2014-12-10  6:47   ` Jiang Liu
  2014-12-10  6:47   ` [RFC Patch V1 7/9] iommu/irq_remapping: Change variable disable_irq_remap to be static Jiang Liu
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-12-10  6:47 UTC (permalink / raw)
  To: H. Peter Anvin, Thomas Gleixner, Joerg Roedel, David Woodhouse,
	Borislav Petkov
  Cc: x86-DgEjT+Ai2ygdnm+yROfE0A,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Tony Luck,
	Jiang Liu, linux-kernel-u79uwXL29TY76Z2rM5mHXA

Do not directly assign intel_irq_remap_ops to remap_ops.

Signed-off-by: Jiang Liu <jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/iommu/irq_remapping.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
index 2d75f0d69b76..a28001af4e15 100644
--- a/drivers/iommu/irq_remapping.c
+++ b/drivers/iommu/irq_remapping.c
@@ -85,15 +85,15 @@ int __init irq_remapping_prepare(void)
 	if (disable_irq_remap)
 		return -ENOSYS;
 
-	remap_ops = &intel_irq_remap_ops;
-
-#ifdef CONFIG_AMD_IOMMU
-	if (amd_iommu_irq_ops.prepare() == 0) {
+	if (intel_irq_remap_ops.prepare() == 0)
+		remap_ops = &intel_irq_remap_ops;
+	else if (IS_ENABLED(CONFIG_AMD_IOMMU) &&
+		 amd_iommu_irq_ops.prepare() == 0)
 		remap_ops = &amd_iommu_irq_ops;
-		return 0;
-	}
-#endif
-	return remap_ops->prepare();
+	else
+		return -ENOSYS;
+
+	return 0;
 }
 
 int __init irq_remapping_enable(void)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC Patch V1 7/9] iommu/irq_remapping: Change variable disable_irq_remap to be static
       [not found] ` <1418194071-13785-1-git-send-email-jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
                     ` (5 preceding siblings ...)
  2014-12-10  6:47   ` [RFC Patch V1 6/9] iommu/irq_remapping: Refine function irq_remapping_prepare() for maintenance Jiang Liu
@ 2014-12-10  6:47   ` Jiang Liu
  2014-12-10  6:47   ` [RFC Patch V1 8/9] iommu/irq_remapping: Normailize the way to detect whether IR is enabled Jiang Liu
  2014-12-10  6:47   ` [RFC Patch V1 9/9] iommu/irq_remapping: Kill unused function irq_remapping_print_chip() Jiang Liu
  8 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-12-10  6:47 UTC (permalink / raw)
  To: H. Peter Anvin, Thomas Gleixner, Joerg Roedel, David Woodhouse,
	Borislav Petkov
  Cc: x86-DgEjT+Ai2ygdnm+yROfE0A,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Tony Luck,
	Jiang Liu, linux-kernel-u79uwXL29TY76Z2rM5mHXA

Change variable disable_irq_remap to be static for easy maintenance.

Signed-off-by: Jiang Liu <jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/iommu/amd_iommu_init.c      |    5 ++---
 drivers/iommu/intel_irq_remapping.c |    1 -
 drivers/iommu/irq_remapping.c       |    3 +--
 drivers/iommu/irq_remapping.h       |    2 --
 4 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index fc047a4ee661..e6c34966cdc2 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -2018,9 +2018,6 @@ static bool detect_ivrs(void)
 	/* Make sure ACS will be enabled during PCI probe */
 	pci_request_acs();
 
-	if (!disable_irq_remap)
-		amd_iommu_irq_remap = true;
-
 	return true;
 }
 
@@ -2127,6 +2124,8 @@ static int __init iommu_go_to_state(enum iommu_init_state state)
 #ifdef CONFIG_IRQ_REMAP
 int __init amd_iommu_prepare(void)
 {
+	amd_iommu_irq_remap = true;
+
 	return iommu_go_to_state(IOMMU_ACPI_FINISHED);
 }
 
diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
index c2255927766b..fba4f7f789a5 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -539,7 +539,6 @@ static int __init intel_prepare_irq_remapping(void)
 			"interrupt remapping is being disabled.  Please\n"
 			"contact your BIOS vendor for an update\n");
 		add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);
-		disable_irq_remap = 1;
 		return -ENODEV;
 	}
 
diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
index a28001af4e15..fbd585e49ebd 100644
--- a/drivers/iommu/irq_remapping.c
+++ b/drivers/iommu/irq_remapping.c
@@ -18,12 +18,11 @@
 #include "irq_remapping.h"
 
 int irq_remapping_enabled;
-
-int disable_irq_remap;
 int irq_remap_broken;
 int disable_sourceid_checking;
 int no_x2apic_optout;
 
+static int disable_irq_remap;
 static struct irq_remap_ops *remap_ops;
 
 static void irq_remapping_disable_io_apic(void)
diff --git a/drivers/iommu/irq_remapping.h b/drivers/iommu/irq_remapping.h
index 961dc49305e1..8621173c7fcb 100644
--- a/drivers/iommu/irq_remapping.h
+++ b/drivers/iommu/irq_remapping.h
@@ -29,7 +29,6 @@ struct msi_msg;
 struct irq_domain;
 struct irq_alloc_info;
 
-extern int disable_irq_remap;
 extern int irq_remap_broken;
 extern int disable_sourceid_checking;
 extern int no_x2apic_optout;
@@ -66,7 +65,6 @@ extern void ir_ack_apic_edge(struct irq_data *data);
 #else  /* CONFIG_IRQ_REMAP */
 
 #define irq_remapping_enabled 0
-#define disable_irq_remap     1
 #define irq_remap_broken      0
 
 #endif /* CONFIG_IRQ_REMAP */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC Patch V1 8/9] iommu/irq_remapping: Normailize the way to detect whether IR is enabled
       [not found] ` <1418194071-13785-1-git-send-email-jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
                     ` (6 preceding siblings ...)
  2014-12-10  6:47   ` [RFC Patch V1 7/9] iommu/irq_remapping: Change variable disable_irq_remap to be static Jiang Liu
@ 2014-12-10  6:47   ` Jiang Liu
  2014-12-10  6:47   ` [RFC Patch V1 9/9] iommu/irq_remapping: Kill unused function irq_remapping_print_chip() Jiang Liu
  8 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-12-10  6:47 UTC (permalink / raw)
  To: H. Peter Anvin, Thomas Gleixner, Joerg Roedel, David Woodhouse,
	Borislav Petkov
  Cc: x86-DgEjT+Ai2ygdnm+yROfE0A,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Tony Luck,
	Jiang Liu, linux-kernel-u79uwXL29TY76Z2rM5mHXA

Refine code by normailizing the way to detect whether IR is enabled.

Signed-off-by: Jiang Liu <jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/iommu/irq_remapping.c |   30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
index fbd585e49ebd..c7ef51a2555a 100644
--- a/drivers/iommu/irq_remapping.c
+++ b/drivers/iommu/irq_remapping.c
@@ -112,22 +112,16 @@ int __init irq_remapping_enable(void)
 
 void irq_remapping_disable(void)
 {
-	if (!irq_remapping_enabled ||
-	    !remap_ops ||
-	    !remap_ops->disable)
-		return;
-
-	remap_ops->disable();
+	if (irq_remapping_enabled && remap_ops->disable)
+		remap_ops->disable();
 }
 
 int irq_remapping_reenable(int mode)
 {
-	if (!irq_remapping_enabled ||
-	    !remap_ops ||
-	    !remap_ops->reenable)
-		return 0;
+	if (irq_remapping_enabled && remap_ops->reenable)
+		return remap_ops->reenable(mode);
 
-	return remap_ops->reenable(mode);
+	return 0;
 }
 
 int __init irq_remap_enable_fault_handling(void)
@@ -135,7 +129,7 @@ int __init irq_remap_enable_fault_handling(void)
 	if (!irq_remapping_enabled)
 		return 0;
 
-	if (!remap_ops || !remap_ops->enable_faulting)
+	if (!remap_ops->enable_faulting)
 		return -ENODEV;
 
 	return remap_ops->enable_faulting();
@@ -176,10 +170,10 @@ void irq_remapping_print_chip(struct irq_data *data, struct seq_file *p)
 struct irq_domain *
 irq_remapping_get_ir_irq_domain(struct irq_alloc_info *info)
 {
-	if (!remap_ops || !remap_ops->get_ir_irq_domain)
-		return NULL;
+	if (irq_remapping_enabled && remap_ops->get_ir_irq_domain)
+		return remap_ops->get_ir_irq_domain(info);
 
-	return remap_ops->get_ir_irq_domain(info);
+	return NULL;
 }
 
 /**
@@ -194,8 +188,8 @@ irq_remapping_get_ir_irq_domain(struct irq_alloc_info *info)
 struct irq_domain *
 irq_remapping_get_irq_domain(struct irq_alloc_info *info)
 {
-	if (!remap_ops || !remap_ops->get_irq_domain)
-		return NULL;
+	if (irq_remapping_enabled && remap_ops->get_irq_domain)
+		return remap_ops->get_irq_domain(info);
 
-	return remap_ops->get_irq_domain(info);
+	return NULL;
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC Patch V1 9/9] iommu/irq_remapping: Kill unused function irq_remapping_print_chip()
       [not found] ` <1418194071-13785-1-git-send-email-jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
                     ` (7 preceding siblings ...)
  2014-12-10  6:47   ` [RFC Patch V1 8/9] iommu/irq_remapping: Normailize the way to detect whether IR is enabled Jiang Liu
@ 2014-12-10  6:47   ` Jiang Liu
  8 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-12-10  6:47 UTC (permalink / raw)
  To: H. Peter Anvin, Thomas Gleixner, Joerg Roedel, David Woodhouse,
	Borislav Petkov, Ingo Molnar, x86-DgEjT+Ai2ygdnm+yROfE0A,
	Jiang Liu
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Tony Luck,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Now there's no user of irq_remapping_print_chip(), so kill it.

Signed-off-by: Jiang Liu <jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 arch/x86/include/asm/irq_remapping.h |    2 --
 drivers/iommu/irq_remapping.c        |   13 -------------
 2 files changed, 15 deletions(-)

diff --git a/arch/x86/include/asm/irq_remapping.h b/arch/x86/include/asm/irq_remapping.h
index f2f52a8bb14e..022cb635c294 100644
--- a/arch/x86/include/asm/irq_remapping.h
+++ b/arch/x86/include/asm/irq_remapping.h
@@ -43,7 +43,6 @@ extern struct irq_domain *
 irq_remapping_get_ir_irq_domain( struct irq_alloc_info *info);
 extern struct irq_domain *
 irq_remapping_get_irq_domain(struct irq_alloc_info *info);
-extern void irq_remapping_print_chip(struct irq_data *data, struct seq_file *p);
 
 /* Create PCI MSI/MSIx irqdomain, use @parent as the parent irqdomain. */
 extern struct irq_domain *arch_create_msi_irq_domain(struct irq_domain *parent);
@@ -79,6 +78,5 @@ irq_remapping_get_irq_domain(struct irq_alloc_info *info)
 	return NULL;
 }
 
-#define	irq_remapping_print_chip	NULL
 #endif /* CONFIG_IRQ_REMAP */
 #endif /* __X86_IRQ_REMAPPING_H */
diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
index c7ef51a2555a..981f068154de 100644
--- a/drivers/iommu/irq_remapping.c
+++ b/drivers/iommu/irq_remapping.c
@@ -146,19 +146,6 @@ void ir_ack_apic_edge(struct irq_data *data)
 	ack_APIC_irq();
 }
 
-void irq_remapping_print_chip(struct irq_data *data, struct seq_file *p)
-{
-	/*
-	 * Assume interrupt is remapped if the parent irqdomain isn't the
-	 * vector domain, which is true for MSI, HPET and IOAPIC on x86
-	 * platforms.
-	 */
-	if (data->domain && data->domain->parent != arch_get_ir_parent_domain())
-		seq_printf(p, " IR-%s", data->chip->name);
-	else
-		seq_printf(p, " %s", data->chip->name);
-}
-
 /**
  * irq_remapping_get_ir_irq_domain - Get the irqdomain associated with the IOMMU
  *				     device serving request @info
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-12-10  6:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-10  6:47 [RFC Patch V1 0/9] Simplify initialization of IR on x86 platforms Jiang Liu
     [not found] ` <1418194071-13785-1-git-send-email-jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-12-10  6:47   ` [RFC Patch V1 1/9] x86, apic: Kill useless variable x2apic_enabled in function enable_IR_x2apic() Jiang Liu
2014-12-10  6:47   ` [RFC Patch V1 2/9] x86, apic: Correctly detect X2APIC status in function enable_IR() Jiang Liu
2014-12-10  6:47   ` [RFC Patch V1 3/9] x86, apic: Refine enable_IR_x2apic() and related functions Jiang Liu
2014-12-10  6:47   ` [RFC Patch V1 4/9] iommu/vt-d: Prepare for killing function irq_remapping_supported() Jiang Liu
2014-12-10  6:47   ` [RFC Patch V1 5/9] iommu/irq_remapping: Kill function irq_remapping_supported() and related code Jiang Liu
2014-12-10  6:47   ` [RFC Patch V1 6/9] iommu/irq_remapping: Refine function irq_remapping_prepare() for maintenance Jiang Liu
2014-12-10  6:47   ` [RFC Patch V1 7/9] iommu/irq_remapping: Change variable disable_irq_remap to be static Jiang Liu
2014-12-10  6:47   ` [RFC Patch V1 8/9] iommu/irq_remapping: Normailize the way to detect whether IR is enabled Jiang Liu
2014-12-10  6:47   ` [RFC Patch V1 9/9] iommu/irq_remapping: Kill unused function irq_remapping_print_chip() Jiang Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox