Skip to contentSkip to conversation

x2apic, IR: cleanup X86_X2APIC and INTR_REMAP config checks

PATCH Applied Suresh Siddha 5 participants 19 messages Apr 20, 2009 – Apr 22, 2009 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 x2apic, IR: cleanup X86_X2APIC and INTR_REMAP config checks

Add x2apic_supported() to cleanup CONFIG_X86_X2APIC checks.

Fix CONFIG_INTR_REMAP checks.

---

arch/x86/include/asm/apic.h +5 -5
Index: tip/arch/x86/include/asm/apic.h
===================================================================
@@ -107,8 +107,7 @@ extern u32 native_safe_apic_wait_icr_idl
 extern void native_apic_icr_write(u32 low, u32 id);
 extern u64 native_apic_icr_read(void);
 
-#define EIM_8BIT_APIC_ID	0
-#define EIM_32BIT_APIC_ID	1
+extern int x2apic_mode;
 
 #ifdef CONFIG_X86_X2APIC
 /*
@@ -166,7 +165,7 @@ static inline u64 native_x2apic_icr_read
 	return val;
 }
 
-extern int x2apic, x2apic_phys;
+extern int x2apic_phys;
 extern void check_x2apic(void);
 extern void enable_x2apic(void);
 extern void x2apic_icr_write(u32 low, u32 id);
@@ -182,6 +181,8 @@ static inline int x2apic_enabled(void)
 		return 1;
 	return 0;
 }
+
+#define x2apic_supported()	(cpu_has_x2apic)
 #else
 static inline void check_x2apic(void)
 {
@@ -194,9 +195,8 @@ static inline int x2apic_enabled(void)
 	return 0;
 }
 
-#define	x2apic	0
 #define	x2apic_preenabled 0
-
+#define	x2apic_supported()	0
 #endif
 
 extern void enable_IR_x2apic(void);
arch/x86/include/asm/irq_remapping.h +1 -1
Index: tip/arch/x86/include/asm/irq_remapping.h
===================================================================
@@ -1,6 +1,6 @@
 #ifndef _ASM_X86_IRQ_REMAPPING_H
 #define _ASM_X86_IRQ_REMAPPING_H
 
-#define IRTE_DEST(dest) ((x2apic) ? dest : dest << 8)
+#define IRTE_DEST(dest) ((x2apic_mode) ? dest : dest << 8)
 
 #endif	/* _ASM_X86_IRQ_REMAPPING_H */
arch/x86/kernel/apic/apic.c +12 -37

126 lines not on this page · raw message

arch/x86/kernel/apic/probe_64.c +1 -1
Index: tip/arch/x86/kernel/apic/probe_64.c
===================================================================
@@ -50,7 +50,7 @@ static struct apic *apic_probe[] __initd
 void __init default_setup_apic_routing(void)
 {
 #ifdef CONFIG_X86_X2APIC
-	if (x2apic && (apic != &apic_x2apic_phys &&
+	if (x2apic_mode && (apic != &apic_x2apic_phys &&
 #ifdef CONFIG_X86_UV
 		       apic != &apic_x2apic_uv_x &&
 #endif
include/linux/dmar.h +2 -0
Index: tip/include/linux/dmar.h
===================================================================
@@ -158,6 +158,8 @@ static inline struct intel_iommu *map_io
 }
 #define irq_remapped(irq)		(0)
 #define enable_intr_remapping(mode)	(-1)
+#define disable_intr_remapping()	(0)
+#define reenable_intr_remapping(mode)	(0)
 #define intr_remapping_enabled		(0)
 #endif
 
arch/x86/kernel/apic/io_apic.c +0 -2
Index: tip/arch/x86/kernel/apic/io_apic.c
===================================================================
@@ -737,7 +737,6 @@ static int __init ioapic_pirq_setup(char
 __setup("pirq=", ioapic_pirq_setup);
 #endif /* CONFIG_X86_32 */
 
-#ifdef CONFIG_INTR_REMAP
 struct IO_APIC_route_entry **alloc_ioapic_entries(void)
 {
 	int apic;
@@ -858,7 +857,6 @@ void free_ioapic_entries(struct IO_APIC_
 
 	kfree(ioapic_entries);
 }
-#endif
 
 /*
  * Find the IRQ entry number of a certain pin.
arch/x86/include/asm/io_apic.h +0 -2
Index: tip/arch/x86/include/asm/io_apic.h
===================================================================
@@ -161,7 +161,6 @@ extern int io_apic_set_pci_routing(int i
 extern int (*ioapic_renumber_irq)(int ioapic, int irq);
 extern void ioapic_init_mappings(void);
 
-#ifdef CONFIG_X86_64
 extern struct IO_APIC_route_entry **alloc_ioapic_entries(void);
 extern void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries);
 extern int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
@@ -169,7 +168,6 @@ extern void mask_IO_APIC_setup(struct IO
 extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
 extern void reinit_intr_remapped_IO_APIC(int intr_remapping,
 	struct IO_APIC_route_entry **ioapic_entries);
-#endif
 
 extern void probe_nr_irqs_gsi(void);
 
#1 lore raw

PATCH 2/5 x2apic, IR: Fix compiler warning with !CONFIG_INTR_REMAP

Fix complier warning:
arch/x86/kernel/apic/io_apic.c:2543: warning: `eoi_ioapic_irq' defined but not used

---

arch/x86/kernel/apic/io_apic.c +33 -33
Index: tip/arch/x86/kernel/apic/io_apic.c
===================================================================
@@ -2518,39 +2518,6 @@ static void irq_complete_move(struct irq
 static inline void irq_complete_move(struct irq_desc **descp) {}
 #endif
 
-static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg)
-{
-	int apic, pin;
-	struct irq_pin_list *entry;
-
-	entry = cfg->irq_2_pin;
-	for (;;) {
-
-		if (!entry)
-			break;
-
-		apic = entry->apic;
-		pin = entry->pin;
-		io_apic_eoi(apic, pin);
-		entry = entry->next;
-	}
-}
-
-static void
-eoi_ioapic_irq(struct irq_desc *desc)
-{
-	struct irq_cfg *cfg;
-	unsigned long flags;
-	unsigned int irq;
-
-	irq = desc->irq;
-	cfg = desc->chip_data;
-
-	spin_lock_irqsave(&ioapic_lock, flags);
-	__eoi_ioapic_irq(irq, cfg);
-	spin_unlock_irqrestore(&ioapic_lock, flags);
-}
-
 static void ack_apic_edge(unsigned int irq)
 {
 	struct irq_desc *desc = irq_to_desc(irq);
@@ -2660,6 +2627,39 @@ static void ack_apic_level(unsigned int 
 }
 
 #ifdef CONFIG_INTR_REMAP
+static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg)
+{
+	int apic, pin;
+	struct irq_pin_list *entry;
+
+	entry = cfg->irq_2_pin;
+	for (;;) {
+
+		if (!entry)
+			break;
+
+		apic = entry->apic;
+		pin = entry->pin;
+		io_apic_eoi(apic, pin);
+		entry = entry->next;
+	}
+}
+
+static void
+eoi_ioapic_irq(struct irq_desc *desc)
+{
+	struct irq_cfg *cfg;
+	unsigned long flags;
+	unsigned int irq;
+
+	irq = desc->irq;
+	cfg = desc->chip_data;
+
+	spin_lock_irqsave(&ioapic_lock, flags);
+	__eoi_ioapic_irq(irq, cfg);
+	spin_unlock_irqrestore(&ioapic_lock, flags);
+}
+
 static void ir_ack_apic_edge(unsigned int irq)
 {
 	ack_APIC_irq();
#2 lore raw

[tip:x86/apic] x86: x2apic, IR: Move eoi_ioapic_irq() into a CONFIG_INTR_REMAP section

Commit-ID:  25629d810a52176758401184d9b437fbb7f79195
Gitweb:     http://git.kernel.org/tip/25629d810a52176758401184d9b437fbb7f79195
Author:     Suresh Siddha <[email protected]>
AuthorDate: Mon, 20 Apr 2009 13:02:28 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 21 Apr 2009 09:08:26 +0200

x86: x2apic, IR: Move eoi_ioapic_irq() into a CONFIG_INTR_REMAP section

Address the following complier warning:

arch/x86/kernel/apic/io_apic.c:2543: warning: `eoi_ioapic_irq' defined but not used

By moving that function (and eoi_ioapic_irq()) into an existing #ifdef CONFIG_INTR_REMAP section of the code.

[ Impact: cleanup ]

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/apic/io_apic.c |   66 ++++++++++++++++++++--------------------
 1 files changed, 33 insertions(+), 33 deletions(-)
arch/x86/kernel/apic/io_apic.c +33 -33
index 3a45d2e..4baa9cb 100644
@@ -2517,39 +2517,6 @@ static void irq_complete_move(struct irq_desc **descp)
 static inline void irq_complete_move(struct irq_desc **descp) {}
 #endif
 
-static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg)
-{
-	int apic, pin;
-	struct irq_pin_list *entry;
-
-	entry = cfg->irq_2_pin;
-	for (;;) {
-
-		if (!entry)
-			break;
-
-		apic = entry->apic;
-		pin = entry->pin;
-		io_apic_eoi(apic, pin);
-		entry = entry->next;
-	}
-}
-
-static void
-eoi_ioapic_irq(struct irq_desc *desc)
-{
-	struct irq_cfg *cfg;
-	unsigned long flags;
-	unsigned int irq;
-
-	irq = desc->irq;
-	cfg = desc->chip_data;
-
-	spin_lock_irqsave(&ioapic_lock, flags);
-	__eoi_ioapic_irq(irq, cfg);
-	spin_unlock_irqrestore(&ioapic_lock, flags);
-}
-
 static void ack_apic_edge(unsigned int irq)
 {
 	struct irq_desc *desc = irq_to_desc(irq);
@@ -2659,6 +2626,39 @@ static void ack_apic_level(unsigned int irq)
 }
 
 #ifdef CONFIG_INTR_REMAP
+static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg)
+{
+	int apic, pin;
+	struct irq_pin_list *entry;
+
+	entry = cfg->irq_2_pin;
+	for (;;) {
+
+		if (!entry)
+			break;
+
+		apic = entry->apic;
+		pin = entry->pin;
+		io_apic_eoi(apic, pin);
+		entry = entry->next;
+	}
+}
+
+static void
+eoi_ioapic_irq(struct irq_desc *desc)
+{
+	struct irq_cfg *cfg;
+	unsigned long flags;
+	unsigned int irq;
+
+	irq = desc->irq;
+	cfg = desc->chip_data;
+
+	spin_lock_irqsave(&ioapic_lock, flags);
+	__eoi_ioapic_irq(irq, cfg);
+	spin_unlock_irqrestore(&ioapic_lock, flags);
+}
+
 static void ir_ack_apic_edge(unsigned int irq)
 {
 	ack_APIC_irq();
#3 lore raw

Re: [tip:x86/apic] x86: x2apic, IR: Move eoi_ioapic_irq() into a CONFIG_INTR_REMAP section

[tip-bot for Suresh Siddha - Tue, Apr 21, 2009 at 08:07:00AM +0000]

| Commit-ID:  25629d810a52176758401184d9b437fbb7f79195
| Gitweb:     http://git.kernel.org/tip/25629d810a52176758401184d9b437fbb7f79195
| Author:     Suresh Siddha <[email protected]>
| AuthorDate: Mon, 20 Apr 2009 13:02:28 -0700
| Committer:  Ingo Molnar <[email protected]>
| CommitDate: Tue, 21 Apr 2009 09:08:26 +0200
| 
| x86: x2apic, IR: Move eoi_ioapic_irq() into a CONFIG_INTR_REMAP section
| 
| Address the following complier warning:
| 
|    arch/x86/kernel/apic/io_apic.c:2543: warning: `eoi_ioapic_irq' defined but not used
| 
| By moving that function (and eoi_ioapic_irq()) into an existing
| #ifdef CONFIG_INTR_REMAP section of the code.
| 
| [ Impact: cleanup ]
| 
| Signed-off-by: Suresh Siddha <[email protected]>
| Cc: [email protected]
| Cc: Weidong Han <[email protected]>
| LKML-Reference: <[email protected]>
| Signed-off-by: Ingo Molnar <[email protected]>
| Cc: Weidong Han <[email protected]>
| 
| 
| ---
|  arch/x86/kernel/apic/io_apic.c |   66 ++++++++++++++++++++--------------------
|  1 files changed, 33 insertions(+), 33 deletions(-)
| 
...  
|  #ifdef CONFIG_INTR_REMAP
| +static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg)
| +{
| +	int apic, pin;
| +	struct irq_pin_list *entry;
| +
| +	entry = cfg->irq_2_pin;
| +	for (;;) {
| +
| +		if (!entry)
| +			break;
| +
| +		apic = entry->apic;
| +		pin = entry->pin;
| +		io_apic_eoi(apic, pin);
| +		entry = entry->next;
| +	}
| +}
| +

...

Btw, maybe we better could use plain "while(entry) {...}" here?

Cyrill

#4 lore raw

PATCH 3/5 x2apic, IR: cleanup panic() with nox2apic boot option

In reply to Suresh Siddha

Instead of panic() ignore the "nox2apic" boot option when BIOS has already enabled x2apic prior to OS handover.

---

arch/x86/kernel/apic/apic.c +6 -2
Index: tip/arch/x86/kernel/apic/apic.c
===================================================================
@@ -142,8 +142,12 @@ static int x2apic_preenabled;
 static int disable_x2apic;
 static __init int setup_nox2apic(char *str)
 {
-	if (x2apic_enabled())
-		panic("Bios already enabled x2apic, can't enforce nox2apic");
+	if (x2apic_enabled()) {
+		pr_warning("Bios already enabled x2apic, "
+			   "can't enforce nox2apic");
+		return 0;
+	}
+
 	disable_x2apic = 1;
 	setup_clear_cpu_cap(X86_FEATURE_X2APIC);
 	return 0;
#5 lore raw

Re: [patch 3/5] x2apic, IR: cleanup panic() with nox2apic boot option

Quoted 12 lines · Suresh Siddha

Instead of panic() ignore the "nox2apic" boot option when BIOS has already enabled x2apic prior to OS handover.

---

Index: tip/arch/x86/kernel/apic/apic.c
===================================================================

arch/x86/kernel/apic/apic.c static int x2apic_preenabled; · line 147

Quoted 8 lines
arch/x86/kernel/apic/apic.c +3 -2
@@ -142,8 +142,12 @@ static int x2apic_preenabled;
 static int disable_x2apic;
 static __init int setup_nox2apic(char *str)
 {
-	if (x2apic_enabled())
-		panic("Bios already enabled x2apic, can't enforce nox2apic");
+	if (x2apic_enabled()) {
+		pr_warning("Bios already enabled x2apic, "
+			   "can't enforce nox2apic");

Btw., in such cases we dont break printk strings in the middle but ignore the checkpatch warning. I fixed it up in your patch.

The advantage is that if someone, based on a dmesg line, types:

git grep Bios already enabled x2apic, can't enforce nox2apic

the right source code line will be found. In the broken-up-line case this wont work. (grep is fundamentally single-line)

Ingo

#6 lore raw

[tip:x86/apic] x86: x2apic, IR: Clean up panic() with nox2apic boot option

In reply to Suresh Siddha
Commit-ID:  39d83a5d684a457046aa2a6dac60f105966e78e9
Gitweb:     http://git.kernel.org/tip/39d83a5d684a457046aa2a6dac60f105966e78e9
Author:     Suresh Siddha <[email protected]>
AuthorDate: Mon, 20 Apr 2009 13:02:29 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 21 Apr 2009 09:08:26 +0200

x86: x2apic, IR: Clean up panic() with nox2apic boot option

Instead of panic() ignore the "nox2apic" boot option when BIOS has already enabled x2apic prior to OS handover.

[ Impact: printk warning instead of panic() when BIOS has enabled x2apic already ]

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/apic/apic.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
arch/x86/kernel/apic/apic.c +6 -2
index 2b30e52..d32f558 100644
@@ -141,8 +141,12 @@ static int x2apic_preenabled;
 static int disable_x2apic;
 static __init int setup_nox2apic(char *str)
 {
-	if (x2apic_enabled())
-		panic("Bios already enabled x2apic, can't enforce nox2apic");
+	if (x2apic_enabled()) {
+		pr_warning("Bios already enabled x2apic, "
+			   "can't enforce nox2apic");
+		return 0;
+	}
+
 	disable_x2apic = 1;
 	setup_clear_cpu_cap(X86_FEATURE_X2APIC);
 	return 0;
#7 lore raw

PATCH 4/5 x2apic, IR: remove reinit_intr_remapped_IO_APIC()

In reply to Suresh Siddha

When interrupt-remapping is enabled, We are relying on setup_IO_APIC_irqs() to configure remapped entries in the IO-APIC, which comes little bit later after enabling interrupt-remapping.

Meanwhile, Restore of old io-apic entries after enabling interrupt-remapping will not make the interrupts through io-apic functional anyway.

So remove unnecessary reinit_intr_remapped_IO_APIC().

---

arch/x86/include/asm/io_apic.h +0 -2
Index: tip/arch/x86/include/asm/io_apic.h
===================================================================
@@ -166,8 +166,6 @@ extern void free_ioapic_entries(struct I
 extern int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
 extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
 extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
-extern void reinit_intr_remapped_IO_APIC(int intr_remapping,
-	struct IO_APIC_route_entry **ioapic_entries);
 
 extern void probe_nr_irqs_gsi(void);
 
arch/x86/kernel/apic/apic.c +0 -2
Index: tip/arch/x86/kernel/apic/apic.c
===================================================================
@@ -1416,8 +1416,6 @@ end_restore:
 		 * IR enabling failed
 		 */
 		restore_IO_APIC_setup(ioapic_entries);
-	else
-		reinit_intr_remapped_IO_APIC(x2apic_preenabled, ioapic_entries);
 
 	unmask_8259A();
 	local_irq_restore(flags);
arch/x86/kernel/apic/io_apic.c +0 -14
Index: tip/arch/x86/kernel/apic/io_apic.c
===================================================================
@@ -834,20 +834,6 @@ int restore_IO_APIC_setup(struct IO_APIC
 	return 0;
 }
 
-void reinit_intr_remapped_IO_APIC(int intr_remapping,
-	struct IO_APIC_route_entry **ioapic_entries)
-
-{
-	/*
-	 * for now plain restore of previous settings.
-	 * TBD: In the case of OS enabling interrupt-remapping,
-	 * IO-APIC RTE's need to be setup to point to interrupt-remapping
-	 * table entries. for now, do a plain restore, and wait for
-	 * the setup_IO_APIC_irqs() to do proper initialization.
-	 */
-	restore_IO_APIC_setup(ioapic_entries);
-}
-
 void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries)
 {
 	int apic;
#8 lore raw

RE: [patch 4/5] x2apic, IR: remove reinit_intr_remapped_IO_APIC()

Quoted 34 lines · Suresh B

When interrupt-remapping is enabled, We are relying on setup_IO_APIC_irqs()
to configure remapped entries in the IO-APIC, which comes little bit later after enabling interrupt-remapping.

Meanwhile, Restore of old io-apic entries after enabling interrupt-remapping will not make the interrupts through io-apic functional anyway.

So remove unnecessary reinit_intr_remapped_IO_APIC().

---

Index: tip/arch/x86/include/asm/io_apic.h
===================================================================

arch/x86/include/asm/io_apic.h +0 -2
@@ -166,8 +166,6 @@ extern void free_ioapic_entries(struct I
 extern int save_IO_APIC_setup(struct IO_APIC_route_entry
 **ioapic_entries); extern void mask_IO_APIC_setup(struct
 IO_APIC_route_entry **ioapic_entries); extern int
 restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries); 
-extern void reinit_intr_remapped_IO_APIC(int intr_remapping,
-	struct IO_APIC_route_entry **ioapic_entries);
 
 extern void probe_nr_irqs_gsi(void);

Index: tip/arch/x86/kernel/apic/apic.c
===================================================================

arch/x86/kernel/apic/apic.c end_restore: · line 1420

Quoted 5 lines
arch/x86/kernel/apic/apic.c +0 -2
@@ -1416,8 +1416,6 @@ end_restore:
 		 * IR enabling failed
 		 */
 		restore_IO_APIC_setup(ioapic_entries);
-	else
-		reinit_intr_remapped_IO_APIC(x2apic_preenabled, ioapic_entries);

Whether IR enabling succeeds or fails, it always needs to restore old IOAPIC entries. Due to removing reinit_intr_remapped_IO_APIC here, it needs to also remove the "if (ret)" before restore_IO_APIC_setup(ioapic_entries);

Regards,
Weidong

#9 lore raw

Re: [patch 4/5] x2apic, IR: remove reinit_intr_remapped_IO_APIC()

Quoted 30 lines · Han, Weidong
Quoted 29 lines · Suresh B

When interrupt-remapping is enabled, We are relying on setup_IO_APIC_irqs()
to configure remapped entries in the IO-APIC, which comes little bit later after enabling interrupt-remapping.

Meanwhile, Restore of old io-apic entries after enabling interrupt-remapping will not make the interrupts through io-apic functional anyway.

So remove unnecessary reinit_intr_remapped_IO_APIC().

---

Index: tip/arch/x86/include/asm/io_apic.h
===================================================================

arch/x86/include/asm/io_apic.h +0 -2
@@ -166,8 +166,6 @@ extern void free_ioapic_entries(struct I
 extern int save_IO_APIC_setup(struct IO_APIC_route_entry
 **ioapic_entries); extern void mask_IO_APIC_setup(struct
 IO_APIC_route_entry **ioapic_entries); extern int
 restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries); 
-extern void reinit_intr_remapped_IO_APIC(int intr_remapping,
-	struct IO_APIC_route_entry **ioapic_entries);
 
 extern void probe_nr_irqs_gsi(void);
Quoted 15 lines

arch/x86/kernel/apic/apic.c end_restore: · line 1420

Quoted 10 lines

Index: tip/arch/x86/kernel/apic/apic.c
===================================================================

arch/x86/kernel/apic/apic.c +0 -2
@@ -1416,8 +1416,6 @@ end_restore:
 		 * IR enabling failed
 		 */
 		restore_IO_APIC_setup(ioapic_entries);
-	else
-		reinit_intr_remapped_IO_APIC(x2apic_preenabled, ioapic_entries);

Whether IR enabling succeeds or fails, it always needs to restore old IOAPIC entries. Due to removing reinit_intr_remapped_IO_APIC here, it needs to also remove the "if (ret)" before restore_IO_APIC_setup(ioapic_entries);

Ok - i skipped this patch for now.

Ingo

#10 lore raw

Re: [patch 4/5] x2apic, IR: remove reinit_intr_remapped_IO_APIC()

Quoted 48 lines · Ingo Molnar
Quoted 30 lines · Han, Weidong
Quoted 29 lines · Suresh B

When interrupt-remapping is enabled, We are relying on setup_IO_APIC_irqs()
to configure remapped entries in the IO-APIC, which comes little bit later after enabling interrupt-remapping.

Meanwhile, Restore of old io-apic entries after enabling interrupt-remapping will not make the interrupts through io-apic functional anyway.

So remove unnecessary reinit_intr_remapped_IO_APIC().

---

Index: tip/arch/x86/include/asm/io_apic.h
===================================================================

arch/x86/include/asm/io_apic.h +0 -2
@@ -166,8 +166,6 @@ extern void free_ioapic_entries(struct I
 extern int save_IO_APIC_setup(struct IO_APIC_route_entry
 **ioapic_entries); extern void mask_IO_APIC_setup(struct
 IO_APIC_route_entry **ioapic_entries); extern int
 restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries); 
-extern void reinit_intr_remapped_IO_APIC(int intr_remapping,
-	struct IO_APIC_route_entry **ioapic_entries);
 
 extern void probe_nr_irqs_gsi(void);
Quoted 15 lines

arch/x86/kernel/apic/apic.c end_restore: · line 1420

Quoted 10 lines

Index: tip/arch/x86/kernel/apic/apic.c
===================================================================

arch/x86/kernel/apic/apic.c +0 -2
@@ -1416,8 +1416,6 @@ end_restore:
 		 * IR enabling failed
 		 */
 		restore_IO_APIC_setup(ioapic_entries);
-	else
-		reinit_intr_remapped_IO_APIC(x2apic_preenabled, ioapic_entries);

Whether IR enabling succeeds or fails, it always needs to restore old IOAPIC entries. Due to removing reinit_intr_remapped_IO_APIC here, it needs to also remove the "if (ret)" before restore_IO_APIC_setup(ioapic_entries);

Quoted 1 line

Ok - i skipped this patch for now.

Let me clarify what I am doing in this patch:

When interrupt-remapping is enabled, IO-APIC entries need to be setup in the re-mappable format (pointing to interrupt-remapping table entries setup by the OS). This remapping configuration is happening in the same place where we traditionally configure IO-APIC (i.e., in setup_IO_APIC_irqs()).

So when we enable interrupt-remapping successfully, there is no need to restore old io-apic RTE entries before we actually do a complete configuration shortly in setup_IO_APIC_irqs(). Old IO-APIC RTE's may be in traditional format (non re-mappable) or in re-mappable format pointing to interrupt-remapping table entries setup by BIOS. Restoring both of these will not make IO-APIC functional. We have to rely on setup_IO_APIC_irqs() for proper configuration by OS.

So I am removing this unnecessary and broken step.

When enabling interrupt-remapping is not successful, we are doing plain restore of old RTE's (which will still work as we went back to original no-remapping state). Complete IO-APIC configuration will be done shortly in setup_IO_APIC_irqs().

thanks,
suresh

#11 lore raw

RE: [patch 4/5] x2apic, IR: remove reinit_intr_remapped_IO_APIC()

Quoted 66 lines · Suresh B
Quoted 47 lines · Ingo Molnar
Quoted 29 lines · Han, Weidong
Quoted 28 lines · Suresh B

When interrupt-remapping is enabled, We are relying on setup_IO_APIC_irqs() to configure remapped entries in the IO-APIC, which comes little bit later after enabling interrupt-remapping.

Meanwhile, Restore of old io-apic entries after enabling interrupt-remapping will not make the interrupts through io-apic functional anyway.

So remove unnecessary reinit_intr_remapped_IO_APIC().

---

Index: tip/arch/x86/include/asm/io_apic.h
===================================================================

arch/x86/include/asm/io_apic.h +0 -2
@@ -166,8 +166,6 @@ extern void free_ioapic_entries(struct I
 extern int save_IO_APIC_setup(struct IO_APIC_route_entry
 **ioapic_entries); extern void mask_IO_APIC_setup(struct
 IO_APIC_route_entry **ioapic_entries); extern int
 restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
-extern void reinit_intr_remapped_IO_APIC(int intr_remapping,
-	struct IO_APIC_route_entry **ioapic_entries);
 
 extern void probe_nr_irqs_gsi(void);
Quoted 15 lines

arch/x86/kernel/apic/apic.c end_restore: · line 1420

Quoted 10 lines

Index: tip/arch/x86/kernel/apic/apic.c
===================================================================

arch/x86/kernel/apic/apic.c +0 -2
@@ -1416,8 +1416,6 @@ end_restore:
 		 * IR enabling failed
 		 */
 		restore_IO_APIC_setup(ioapic_entries);
-	else
-		reinit_intr_remapped_IO_APIC(x2apic_preenabled, ioapic_entries);

Whether IR enabling succeeds or fails, it always needs to restore old IOAPIC entries. Due to removing reinit_intr_remapped_IO_APIC here, it needs to also remove the "if (ret)" before restore_IO_APIC_setup(ioapic_entries);

Quoted 1 line

Ok - i skipped this patch for now.

Let me clarify what I am doing in this patch:

When interrupt-remapping is enabled, IO-APIC entries need to be setup in the re-mappable format (pointing to interrupt-remapping table entries setup by the OS). This remapping configuration is happening in the same place where we traditionally configure IO-APIC (i.e., in setup_IO_APIC_irqs()).

So when we enable interrupt-remapping successfully, there is no need to restore old io-apic RTE entries before we actually do a complete configuration shortly in setup_IO_APIC_irqs(). Old IO-APIC RTE's may be in traditional format (non re-mappable) or in re-mappable format pointing to interrupt-remapping table entries setup by BIOS. Restoring both of these will not make IO-APIC functional. We have to rely on setup_IO_APIC_irqs() for proper configuration by OS.

Quoted 7 lines

So I am removing this unnecessary and broken step.

When enabling interrupt-remapping is not successful, we are doing plain restore of old RTE's (which will still work as we went back to original no-remapping state). Complete IO-APIC configuration will be done shortly in setup_IO_APIC_irqs().

Clear explanation. I misunderstood it. This patch is fine.

Regards,
Weidong

Quoted 2 lines

thanks,
suresh

Applied
#12 lore raw

Re: [patch 4/5] x2apic, IR: remove reinit_intr_remapped_IO_APIC()

Quoted 69 lines · Han, Weidong
Quoted 68 lines · Suresh B
Quoted 47 lines · Ingo Molnar
Quoted 29 lines · Han, Weidong
Quoted 28 lines · Suresh B

When interrupt-remapping is enabled, We are relying on setup_IO_APIC_irqs() to configure remapped entries in the IO-APIC, which comes little bit later after enabling interrupt-remapping.

Meanwhile, Restore of old io-apic entries after enabling interrupt-remapping will not make the interrupts through io-apic functional anyway.

So remove unnecessary reinit_intr_remapped_IO_APIC().

---

Index: tip/arch/x86/include/asm/io_apic.h
===================================================================

arch/x86/include/asm/io_apic.h +0 -2
@@ -166,8 +166,6 @@ extern void free_ioapic_entries(struct I
 extern int save_IO_APIC_setup(struct IO_APIC_route_entry
 **ioapic_entries); extern void mask_IO_APIC_setup(struct
 IO_APIC_route_entry **ioapic_entries); extern int
 restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
-extern void reinit_intr_remapped_IO_APIC(int intr_remapping,
-	struct IO_APIC_route_entry **ioapic_entries);
 
 extern void probe_nr_irqs_gsi(void);
Quoted 15 lines

arch/x86/kernel/apic/apic.c end_restore: · line 1420

Quoted 10 lines

Index: tip/arch/x86/kernel/apic/apic.c
===================================================================

arch/x86/kernel/apic/apic.c +0 -2
@@ -1416,8 +1416,6 @@ end_restore:
 		 * IR enabling failed
 		 */
 		restore_IO_APIC_setup(ioapic_entries);
-	else
-		reinit_intr_remapped_IO_APIC(x2apic_preenabled, ioapic_entries);

Whether IR enabling succeeds or fails, it always needs to restore old IOAPIC entries. Due to removing reinit_intr_remapped_IO_APIC here, it needs to also remove the "if (ret)" before restore_IO_APIC_setup(ioapic_entries);

Quoted 1 line

Ok - i skipped this patch for now.

Let me clarify what I am doing in this patch:

When interrupt-remapping is enabled, IO-APIC entries need to be setup in the re-mappable format (pointing to interrupt-remapping table entries setup by the OS). This remapping configuration is happening in the same place where we traditionally configure IO-APIC (i.e., in setup_IO_APIC_irqs()).

So when we enable interrupt-remapping successfully, there is no need to restore old io-apic RTE entries before we actually do a complete configuration shortly in setup_IO_APIC_irqs(). Old IO-APIC RTE's may be in traditional format (non re-mappable) or in re-mappable format pointing to interrupt-remapping table entries setup by BIOS. Restoring both of these will not make IO-APIC functional. We have to rely on setup_IO_APIC_irqs() for proper configuration by OS.

So I am removing this unnecessary and broken step.

Quoted 7 lines
Quoted 5 lines

When enabling interrupt-remapping is not successful, we are doing plain restore of old RTE's (which will still work as we went back to original no-remapping state). Complete IO-APIC configuration will be done shortly in setup_IO_APIC_irqs().

Clear explanation. I misunderstood it. This patch is fine.

Applied to tip:x86/apic - thanks guys,

Ingo

#13 lore raw

[tip:x86/apic] x86: x2apic, IR: remove reinit_intr_remapped_IO_APIC()

In reply to Suresh Siddha
Commit-ID:  ff166cb57a17124af75714a9c11f448f56f1a4a3
Gitweb:     http://git.kernel.org/tip/ff166cb57a17124af75714a9c11f448f56f1a4a3
Author:     Suresh Siddha <[email protected]>
AuthorDate: Mon, 20 Apr 2009 13:02:30 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 22 Apr 2009 12:03:04 +0200

x86: x2apic, IR: remove reinit_intr_remapped_IO_APIC()

When interrupt-remapping is enabled, we are relying on setup_IO_APIC_irqs() to configure remapped entries in the IO-APIC, which comes little bit later after enabling interrupt-remapping.

Meanwhile, restoration of old io-apic entries after enabling interrupt-remapping will not make the interrupts through io-apic functional anyway.

So remove the unnecessary reinit_intr_remapped_IO_APIC() step.

The longer story:

When interrupt-remapping is enabled, IO-APIC entries need to be setup in the re-mappable format (pointing to interrupt-remapping table entries setup by the OS). This remapping configuration is happening in the same place where we traditionally configure IO-APIC (i.e., in setup_IO_APIC_irqs()).

So when we enable interrupt-remapping successfully, there is no need to restore old io-apic RTE entries before we actually do a complete configuration shortly in setup_IO_APIC_irqs(). Old IO-APIC RTE's may be in traditional format (non re-mappable) or in re-mappable format pointing to interrupt-remapping table entries setup by BIOS. Restoring both of these will not make IO-APIC functional. We have to rely on setup_IO_APIC_irqs() for proper configuration by OS.

So I am removing this unnecessary and broken step.

[ Impact: remove unnecessary/broken IO-APIC setup step ]

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/io_apic.h |    2 --
 arch/x86/kernel/apic/apic.c    |    2 --
 arch/x86/kernel/apic/io_apic.c |   14 --------------
 3 files changed, 0 insertions(+), 18 deletions(-)
arch/x86/include/asm/io_apic.h +0 -2
index 34eaa37..1cf1450 100644
@@ -166,8 +166,6 @@ extern void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries);
 extern int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
 extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
 extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
-extern void reinit_intr_remapped_IO_APIC(int intr_remapping,
-	struct IO_APIC_route_entry **ioapic_entries);
 
 extern void probe_nr_irqs_gsi(void);
 
arch/x86/kernel/apic/apic.c +0 -2
index d32f558..1386dbe 100644
@@ -1412,8 +1412,6 @@ end_restore:
 		 * IR enabling failed
 		 */
 		restore_IO_APIC_setup(ioapic_entries);
-	else
-		reinit_intr_remapped_IO_APIC(x2apic_preenabled, ioapic_entries);
 
 	unmask_8259A();
 	local_irq_restore(flags);
arch/x86/kernel/apic/io_apic.c +0 -14
index 4baa9cb..8aef5f9 100644
@@ -833,20 +833,6 @@ int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries)
 	return 0;
 }
 
-void reinit_intr_remapped_IO_APIC(int intr_remapping,
-	struct IO_APIC_route_entry **ioapic_entries)
-
-{
-	/*
-	 * for now plain restore of previous settings.
-	 * TBD: In the case of OS enabling interrupt-remapping,
-	 * IO-APIC RTE's need to be setup to point to interrupt-remapping
-	 * table entries. for now, do a plain restore, and wait for
-	 * the setup_IO_APIC_irqs() to do proper initialization.
-	 */
-	restore_IO_APIC_setup(ioapic_entries);
-}
-
 void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries)
 {
 	int apic;
#14 lore raw

PATCH 5/5 x2apic, IR: Make config X86_UV dependent on X86_X2APIC

In reply to Suresh Siddha

Instead of selecting X86_X2APIC, make config X86_UV dependent on X86_X2APIC. This will eliminate enabling CONFIG_X86_X2APIC with out enabling CONFIG_INTR_REMAP.

Cc Weidong Han <[email protected]>
Cc Jack Steiner <[email protected]>

---

arch/x86/Kconfig +1 -1
Index: tip/arch/x86/Kconfig
===================================================================
@@ -356,7 +356,7 @@ config X86_UV
 	depends on X86_64
 	depends on X86_EXTENDED_PLATFORM
 	depends on NUMA
-	select X86_X2APIC
+	depends on X86_X2APIC
 	---help---
 	  This option is needed in order to support SGI Ultraviolet systems.
 	  If you don't have one of these, you should say N here.
Acked-by on v1 5/5
#15 lore raw

Re: [patch 5/5] x2apic, IR: Make config X86_UV dependent on X86_X2APIC

Quoted 7 lines · Suresh Siddha

Instead of selecting X86_X2APIC, make config X86_UV dependent on X86_X2APIC. This will eliminate enabling CONFIG_X86_X2APIC with out enabling CONFIG_INTR_REMAP.

Cc Weidong Han <[email protected]>
Cc Jack Steiner <[email protected]>
Quoted 17 lines

---

Index: tip/arch/x86/Kconfig
===================================================================

arch/x86/Kconfig +1 -1
@@ -356,7 +356,7 @@ config X86_UV
 	depends on X86_64
 	depends on X86_EXTENDED_PLATFORM
 	depends on NUMA
-	select X86_X2APIC
+	depends on X86_X2APIC
 	---help---
 	  This option is needed in order to support SGI Ultraviolet systems.
 	  If you don't have one of these, you should say N here.
Signature · 1 line
-- 
#16 lore raw

[tip:x86/apic] x86: x2apic, IR: Make config X86_UV dependent on X86_X2APIC

In reply to Suresh Siddha
Commit-ID:  9d6c26e73bd248c286bb3597aaf788716e8fcceb
Gitweb:     http://git.kernel.org/tip/9d6c26e73bd248c286bb3597aaf788716e8fcceb
Author:     Suresh Siddha <[email protected]>
AuthorDate: Mon, 20 Apr 2009 13:02:31 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 21 Apr 2009 09:08:27 +0200

x86: x2apic, IR: Make config X86_UV dependent on X86_X2APIC

Instead of selecting X86_X2APIC, make config X86_UV dependent on X86_X2APIC.

This will eliminate enabling CONFIG_X86_X2APIC with out enabling CONFIG_INTR_REMAP.

[ Impact: cleanup ]

LKML-Reference: <[email protected]>

---
 arch/x86/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/Kconfig +1 -1
index c9086e6..58fb7b3 100644
@@ -354,7 +354,7 @@ config X86_UV
 	depends on X86_64
 	depends on X86_EXTENDED_PLATFORM
 	depends on NUMA
-	select X86_X2APIC
+	depends on X86_X2APIC
 	---help---
 	  This option is needed in order to support SGI Ultraviolet systems.
 	  If you don't have one of these, you should say N here.
#17 lore raw
In reply to Suresh Siddha
Quoted 9 lines · Suresh Siddha

Add x2apic_supported() to cleanup CONFIG_X86_X2APIC checks.

Fix CONFIG_INTR_REMAP checks.

---

Index: tip/arch/x86/include/asm/apic.h

Ob'nit'pick: please generate diffstats for future patches as it makes in-email review much easier.

The diffstat is:

 arch/x86/include/asm/apic.h          |   10 +++----
 arch/x86/include/asm/io_apic.h       |    2 -
 arch/x86/include/asm/irq_remapping.h |    2 -
 arch/x86/kernel/apic/apic.c          |   49 ++++++++---------------------------
 arch/x86/kernel/apic/io_apic.c       |    2 -
 arch/x86/kernel/apic/probe_64.c      |    2 -
 include/linux/dmar.h                 |    2 +
 7 files changed, 21 insertions(+), 48 deletions(-)

Which already shows that the patch has a very nice cleanup factor.

I've added an "[ Impact: cleanup ]" tag to it - the patch is not supposed to have any functional side-effects, right? (i.e. has no fixes embedded in it.)

a question:

arch/x86/kernel/apic/apic.c static int lapic_suspend(struct sys_devi · line 2011

Quoted 2 lines
arch/x86/kernel/apic/apic.c +0 -0
 	if (intr_remapping_enabled)
 		disable_intr_remapping();

Could the intr_remapping_enabled check be moved inside disable_intr_remapping(), and thus the ugly 'if (flag)' construct could go away?

arch/x86/kernel/apic/apic.c static int lapic_resume(struct sys_devic · line 2091

Quoted 6 lines
arch/x86/kernel/apic/apic.c +1 -0
 	if (intr_remapping_enabled) {
+		reenable_intr_remapping(x2apic_mode);
 		unmask_8259A();
 		restore_IO_APIC_setup(ioapic_entries);
 		free_ioapic_entries(ioapic_entries);
 	}

Ditto - shouldnt this sequence move into reenable_intr_remapping() - or into a new helper function? (or is it too single-purpose)

Anyway, this already looks good as-is so i can apply it if you do delta patches on top of it to improve it further.

Ingo

#18 lore raw

[tip:x86/apic] x86: x2apic, IR: Clean up X86_X2APIC and INTR_REMAP config checks

In reply to Suresh Siddha
Commit-ID:  fc1edaf9e7cc4d4696f83dee495b8f158d01c4eb
Gitweb:     http://git.kernel.org/tip/fc1edaf9e7cc4d4696f83dee495b8f158d01c4eb
Author:     Suresh Siddha <[email protected]>
AuthorDate: Mon, 20 Apr 2009 13:02:27 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 21 Apr 2009 09:08:25 +0200

x86: x2apic, IR: Clean up X86_X2APIC and INTR_REMAP config checks

Add x2apic_supported() to clean up CONFIG_X86_X2APIC checks.

Fix CONFIG_INTR_REMAP checks.

[ Impact: cleanup ]

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/apic.h          |   10 +++---
 arch/x86/include/asm/io_apic.h       |    2 -
 arch/x86/include/asm/irq_remapping.h |    2 +-
 arch/x86/kernel/apic/apic.c          |   49 ++++++++-------------------------
 arch/x86/kernel/apic/io_apic.c       |    2 -
 arch/x86/kernel/apic/probe_64.c      |    2 +-
 include/linux/dmar.h                 |    2 +
 7 files changed, 21 insertions(+), 48 deletions(-)
arch/x86/include/asm/apic.h +5 -5
index fbdd654..3738438 100644
@@ -107,8 +107,7 @@ extern u32 native_safe_apic_wait_icr_idle(void);
 extern void native_apic_icr_write(u32 low, u32 id);
 extern u64 native_apic_icr_read(void);
 
-#define EIM_8BIT_APIC_ID	0
-#define EIM_32BIT_APIC_ID	1
+extern int x2apic_mode;
 
 #ifdef CONFIG_X86_X2APIC
 /*
@@ -166,7 +165,7 @@ static inline u64 native_x2apic_icr_read(void)
 	return val;
 }
 
-extern int x2apic, x2apic_phys;
+extern int x2apic_phys;
 extern void check_x2apic(void);
 extern void enable_x2apic(void);
 extern void x2apic_icr_write(u32 low, u32 id);
@@ -182,6 +181,8 @@ static inline int x2apic_enabled(void)
 		return 1;
 	return 0;
 }
+
+#define x2apic_supported()	(cpu_has_x2apic)
 #else
 static inline void check_x2apic(void)
 {
@@ -194,9 +195,8 @@ static inline int x2apic_enabled(void)
 	return 0;
 }
 
-#define	x2apic	0
 #define	x2apic_preenabled 0
-
+#define	x2apic_supported()	0
 #endif
 
 extern void enable_IR_x2apic(void);
arch/x86/include/asm/io_apic.h +0 -2
index 9d826e4..34eaa37 100644
@@ -161,7 +161,6 @@ extern int io_apic_set_pci_routing(int ioapic, int pin, int irq,
 extern int (*ioapic_renumber_irq)(int ioapic, int irq);
 extern void ioapic_init_mappings(void);
 
-#ifdef CONFIG_X86_64
 extern struct IO_APIC_route_entry **alloc_ioapic_entries(void);
 extern void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries);
 extern int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
@@ -169,7 +168,6 @@ extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
 extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
 extern void reinit_intr_remapped_IO_APIC(int intr_remapping,
 	struct IO_APIC_route_entry **ioapic_entries);
-#endif
 
 extern void probe_nr_irqs_gsi(void);
 
arch/x86/include/asm/irq_remapping.h +1 -1
index 0396760..f275e22 100644
@@ -1,6 +1,6 @@
 #ifndef _ASM_X86_IRQ_REMAPPING_H
 #define _ASM_X86_IRQ_REMAPPING_H
 
-#define IRTE_DEST(dest) ((x2apic) ? dest : dest << 8)
+#define IRTE_DEST(dest) ((x2apic_mode) ? dest : dest << 8)
 
 #endif	/* _ASM_X86_IRQ_REMAPPING_H */
arch/x86/kernel/apic/apic.c +12 -37

126 lines not on this page · raw message

arch/x86/kernel/apic/io_apic.c +0 -2
index ea22a86..3a45d2e 100644
@@ -736,7 +736,6 @@ static int __init ioapic_pirq_setup(char *str)
 __setup("pirq=", ioapic_pirq_setup);
 #endif /* CONFIG_X86_32 */
 
-#ifdef CONFIG_INTR_REMAP
 struct IO_APIC_route_entry **alloc_ioapic_entries(void)
 {
 	int apic;
@@ -857,7 +856,6 @@ void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries)
 
 	kfree(ioapic_entries);
 }
-#endif
 
 /*
  * Find the IRQ entry number of a certain pin.
arch/x86/kernel/apic/probe_64.c +1 -1
index 1783652..bc3e880 100644
@@ -50,7 +50,7 @@ static struct apic *apic_probe[] __initdata = {
 void __init default_setup_apic_routing(void)
 {
 #ifdef CONFIG_X86_X2APIC
-	if (x2apic && (apic != &apic_x2apic_phys &&
+	if (x2apic_mode && (apic != &apic_x2apic_phys &&
 #ifdef CONFIG_X86_UV
 		       apic != &apic_x2apic_uv_x &&
 #endif
include/linux/dmar.h +2 -0
index 06f592a..10ff5c4 100644
@@ -158,6 +158,8 @@ static inline struct intel_iommu *map_ioapic_to_ir(int apic)
 }
 #define irq_remapped(irq)		(0)
 #define enable_intr_remapping(mode)	(-1)
+#define disable_intr_remapping()	(0)
+#define reenable_intr_remapping(mode)	(0)
 #define intr_remapping_enabled		(0)
 #endif