Skip to contentSkip to conversation

x86: handle legacy PIC interrupts on all the cpu's

PATCH In review Suresh Siddha 3 participants 10 messages Mar 15, 2010 – Mar 16, 2010 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: handle legacy PIC interrupts on all the cpu's

Ingo Molnar reported that with the recent changes of not statically blocking IRQ0_VECTOR..IRQ15_VECTOR's on all the cpu's, broke an AMD platform (with Nvidia chipset) boot when "noapic" boot option is used.

On this platform, legacy PIC interrupts are getting delivered to all the cpu's instead of just the boot cpu. Thus not initializing the vector to irq mapping for the legacy irq's resulted in not handling certain interrupts causing boot hang.

Fix this by initializing the vector to irq mapping on all the logical cpu's, if the legacy IRQ is handled by the legacy PIC.

---

arch/x86/include/asm/hw_irq.h +1 -0
index a929c9e..46c0fe0 100644
@@ -133,6 +133,7 @@ extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
 
 typedef int vector_irq_t[NR_VECTORS];
 DECLARE_PER_CPU(vector_irq_t, vector_irq);
+extern void setup_vector_irq(int cpu);
 
 #ifdef CONFIG_X86_IO_APIC
 extern void lock_vector_lock(void);
arch/x86/kernel/apic/io_apic.c +8 -0
index e4e0ddc..10f0a1a 100644
@@ -1268,6 +1268,14 @@ void __setup_vector_irq(int cpu)
 	/* Mark the inuse vectors */
 	for_each_irq_desc(irq, desc) {
 		cfg = desc->chip_data;
+
+		/*
+		 * If it is a legacy IRQ handled by the legacy PIC, this cpu
+		 * will be part of the irq_cfg's domain.
+		 */
+		if (irq < legacy_pic->nr_legacy_irqs && !IO_APIC_IRQ(irq))
+			cpumask_set_cpu(cpu, cfg->domain);
+
 		if (!cpumask_test_cpu(cpu, cfg->domain))
 			continue;
 		vector = cfg->vector;
arch/x86/kernel/irqinit.c +21 -0
index ef257fc..daaf413 100644
@@ -141,6 +141,27 @@ void __init init_IRQ(void)
 	x86_init.irqs.intr_init();
 }
 
+/*
+ * Setup the vector to irq mappings.
+ */
+void setup_vector_irq(int cpu)
+{
+	int irq;
+
+	/*
+	 * On most of the platforms, legacy PIC delivers the interrupts on the
+	 * boot cpu. But there are certain platforms where PIC interrupts are
+	 * delivered to multiple cpu's. If the legacy IRQ is handled by the
+	 * legacy PIC, for the new cpu that is coming online, setup the static
+	 * legacy vector to irq mapping.
+	 */
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		if (!IO_APIC_IRQ(irq))
+			per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+
+	__setup_vector_irq(cpu);
+}
+
 static void __init smp_intr_init(void)
 {
 #ifdef CONFIG_SMP
arch/x86/kernel/smpboot.c +1 -1
index a02e80c..06d98ae 100644
@@ -247,7 +247,7 @@ static void __cpuinit smp_callin(void)
 	/*
 	 * Need to setup vector mappings before we enable interrupts.
 	 */
-	__setup_vector_irq(smp_processor_id());
+	setup_vector_irq(smp_processor_id());
 	/*
 	 * Get our bogomips.
 	 *
#1 lore raw
Quoted 52 lines · Suresh Siddha

Ingo Molnar reported that with the recent changes of not statically blocking IRQ0_VECTOR..IRQ15_VECTOR's on all the cpu's, broke an AMD platform (with Nvidia chipset) boot when "noapic" boot option is used.

On this platform, legacy PIC interrupts are getting delivered to all the cpu's instead of just the boot cpu. Thus not initializing the vector to irq mapping for the legacy irq's resulted in not handling certain interrupts causing boot hang.

Fix this by initializing the vector to irq mapping on all the logical cpu's, if the legacy IRQ is handled by the legacy PIC.

---

arch/x86/include/asm/hw_irq.h +1 -0
index a929c9e..46c0fe0 100644
@@ -133,6 +133,7 @@ extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
 
 typedef int vector_irq_t[NR_VECTORS];
 DECLARE_PER_CPU(vector_irq_t, vector_irq);
+extern void setup_vector_irq(int cpu);
 
 #ifdef CONFIG_X86_IO_APIC
 extern void lock_vector_lock(void);
arch/x86/kernel/apic/io_apic.c +8 -0
index e4e0ddc..10f0a1a 100644
@@ -1268,6 +1268,14 @@ void __setup_vector_irq(int cpu)
 	/* Mark the inuse vectors */
 	for_each_irq_desc(irq, desc) {
 		cfg = desc->chip_data;
+
+		/*
+		 * If it is a legacy IRQ handled by the legacy PIC, this cpu
+		 * will be part of the irq_cfg's domain.
+		 */
+		if (irq < legacy_pic->nr_legacy_irqs && !IO_APIC_IRQ(irq))
+			cpumask_set_cpu(cpu, cfg->domain);
+
 		if (!cpumask_test_cpu(cpu, cfg->domain))
 			continue;
 		vector = cfg->vector;
arch/x86/kernel/irqinit.c +0 -0
index ef257fc..daaf413 100644

arch/x86/kernel/irqinit.c void __init init_IRQ(void) · line 145

Quoted 5 lines
arch/x86/kernel/irqinit.c +2 -0
@@ -141,6 +141,27 @@ void __init init_IRQ(void)
 	x86_init.irqs.intr_init();
 }
 
+/*
+ * Setup the vector to irq mappings.
	> + */
Quoted 4 lines
arch/x86/kernel/irqinit.c +4 -0
+void setup_vector_irq(int cpu)
+{
+	int irq;
+

arch/x86/kernel/irqinit.c void __init init_IRQ(void) · line 160

Quoted 10 lines
arch/x86/kernel/irqinit.c +10 -0
+	/*
+	 * On most of the platforms, legacy PIC delivers the interrupts on the
+	 * boot cpu. But there are certain platforms where PIC interrupts are
+	 * delivered to multiple cpu's. If the legacy IRQ is handled by the
+	 * legacy PIC, for the new cpu that is coming online, setup the static
+	 * legacy vector to irq mapping.
+	 */
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		if (!IO_APIC_IRQ(irq))
+			per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;

seems those three lines are not needed...

YH

#2 lore raw
Quoted 5 lines · Yinghai Lu

arch/x86/kernel/irqinit.c void __init init_IRQ(void) · line 160

Quoted 3 lines
arch/x86/kernel/irqinit.c +3 -0
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		if (!IO_APIC_IRQ(irq))
+			per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;

seems those three lines are not needed...

Those are needed for !CONFIG_X86_IO_APIC case.

thanks,
suresh

#3 lore raw
Quoted 9 lines · Suresh Siddha
Quoted 5 lines · Yinghai Lu

arch/x86/kernel/irqinit.c void __init init_IRQ(void) · line 160

Quoted 3 lines
arch/x86/kernel/irqinit.c +3 -0
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		if (!IO_APIC_IRQ(irq))
+			per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;

seems those three lines are not needed...

Those are needed for !CONFIG_X86_IO_APIC case.

then we can have

+#ifndef CONFIG_X86_IO_APIC
+ for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+ per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+#endif

then we don't punish most setup with ioapic controller.

Yinghai

#4 lore raw
Quoted 17 lines · Yinghai Lu
Quoted 9 lines · Suresh Siddha
Quoted 5 lines · Yinghai Lu

arch/x86/kernel/irqinit.c void __init init_IRQ(void) · line 160

Quoted 3 lines
arch/x86/kernel/irqinit.c +3 -0
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		if (!IO_APIC_IRQ(irq))
+			per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;

seems those three lines are not needed...

Those are needed for !CONFIG_X86_IO_APIC case.

then we can have

arch/x86/kernel/irqinit.c +4 -0
+#ifndef CONFIG_X86_IO_APIC
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+#endif
Quoted 1 line

then we don't punish most setup with ioapic controller.

Ok - i've simplified the code with the above and have added your Acked-by - is that is fine by you?

Thanks,

Ingo

#5 lore raw
Quoted 20 lines · Ingo Molnar
Quoted 17 lines · Yinghai Lu
Quoted 9 lines · Suresh Siddha
Quoted 5 lines · Yinghai Lu

arch/x86/kernel/irqinit.c void __init init_IRQ(void) · line 160

Quoted 3 lines
arch/x86/kernel/irqinit.c +3 -0
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		if (!IO_APIC_IRQ(irq))
+			per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;

seems those three lines are not needed...

Those are needed for !CONFIG_X86_IO_APIC case.

then we can have

arch/x86/kernel/irqinit.c +4 -0
+#ifndef CONFIG_X86_IO_APIC
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+#endif
Quoted 4 lines
Quoted 1 line

then we don't punish most setup with ioapic controller.

Ok - i've simplified the code with the above and have added your Acked-by - is that is fine by you?

btw., the patch fixes the regression on the testbox - thanks Suresh!

Ingo

#6 lore raw
In reply to Ingo Molnar
Quoted 19 lines · Ingo Molnar
Quoted 17 lines · Yinghai Lu
Quoted 9 lines · Suresh Siddha
Quoted 5 lines · Yinghai Lu

Review

Quoted 3 lines
(quoted diff) +3 -0
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		if (!IO_APIC_IRQ(irq))
+			per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;

seems those three lines are not needed...

Those are needed for !CONFIG_X86_IO_APIC case.

then we can have

(quoted diff) +4 -0
+#ifndef CONFIG_X86_IO_APIC
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+#endif
Quoted 4 lines
Quoted 1 line

then we don't punish most setup with ioapic controller.

Ok - i've simplified the code with the above and have added your Acked-by - is that is fine by you?

Ingo, Probably appended one is a better version. Yinghai can you please Ack if it is ok. Thanks.

---
From: Suresh Siddha <[email protected]>
Subject: x86: handle legacy PIC interrupts on all the cpu's

Ingo Molnar reported that with the recent changes of not statically blocking IRQ0_VECTOR..IRQ15_VECTOR's on all the cpu's, broke an AMD platform (with Nvidia chipset) boot when "noapic" boot option is used.

On this platform, legacy PIC interrupts are getting delivered to all the cpu's instead of just the boot cpu. Thus not initializing the vector to irq mapping for the legacy irq's resulted in not handling certain interrupts causing boot hang.

Fix this by initializing the vector to irq mapping on all the logical cpu's, if the legacy IRQ is handled by the legacy PIC.

---

 arch/x86/include/asm/hw_irq.h  |    3 +--
 arch/x86/kernel/apic/io_apic.c |    9 +++++++++
 arch/x86/kernel/irqinit.c      |   20 ++++++++++++++++++++
 3 files changed, 30 insertions(+), 2 deletions(-)
arch/x86/include/asm/hw_irq.h +1 -2
index a929c9e..564a7a1 100644
@@ -133,15 +133,14 @@ extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
 
 typedef int vector_irq_t[NR_VECTORS];
 DECLARE_PER_CPU(vector_irq_t, vector_irq);
+extern void __setup_vector_irq(int cpu);
 
 #ifdef CONFIG_X86_IO_APIC
 extern void lock_vector_lock(void);
 extern void unlock_vector_lock(void);
-extern void __setup_vector_irq(int cpu);
 #else
 static inline void lock_vector_lock(void) {}
 static inline void unlock_vector_lock(void) {}
-static inline void __setup_vector_irq(int cpu) {}
 #endif
 
 #endif /* !ASSEMBLY_ */
arch/x86/kernel/apic/io_apic.c +9 -0
index e4e0ddc..fd3cecd 100644
@@ -1268,6 +1268,15 @@ void __setup_vector_irq(int cpu)
 	/* Mark the inuse vectors */
 	for_each_irq_desc(irq, desc) {
 		cfg = desc->chip_data;
+
+		/*
+		 * If it is a legacy IRQ handled by the legacy PIC, be ready
+		 * to handle it on any CPU, as the PIC interrupts are delivered
+		 * to multiple cpu's on some platforms.
+		 */
+		if (irq < legacy_pic->nr_legacy_irqs && !IO_APIC_IRQ(irq))
+			cpumask_set_cpu(cpu, cfg->domain);
+
 		if (!cpumask_test_cpu(cpu, cfg->domain))
 			continue;
 		vector = cfg->vector;
arch/x86/kernel/irqinit.c +20 -0
index ef257fc..afc3b31 100644
@@ -141,6 +141,26 @@ void __init init_IRQ(void)
 	x86_init.irqs.intr_init();
 }
 
+#ifndef CONFIG_X86_IO_APIC
+/*
+ * Setup the vector to irq mappings.
+ */
+void __setup_vector_irq(int cpu)
+{
+	int irq;
+
+	/*
+	 * On most of the platforms, legacy PIC delivers the interrupts on the
+	 * boot cpu. But there are certain platforms where PIC interrupts are
+	 * delivered to multiple cpu's. For the new cpu that is coming online,
+	 * setup the static legacy vector to irq mapping.
+	 */
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+
+}
+#endif
+
 static void __init smp_intr_init(void)
 {
 #ifdef CONFIG_SMP
Acked-by
#7 lore raw
Quoted 116 lines · Suresh Siddha
Quoted 19 lines · Ingo Molnar
Quoted 17 lines · Yinghai Lu
Quoted 9 lines · Suresh Siddha
Quoted 5 lines · Yinghai Lu

arch/x86/kernel/irqinit.c void __init init_IRQ(void) · line 159

Quoted 3 lines
arch/x86/kernel/irqinit.c +3 -0
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		if (!IO_APIC_IRQ(irq))
+			per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;

seems those three lines are not needed...

Those are needed for !CONFIG_X86_IO_APIC case.

then we can have

arch/x86/kernel/irqinit.c +4 -0
+#ifndef CONFIG_X86_IO_APIC
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+#endif
Quoted 4 lines
Quoted 1 line

then we don't punish most setup with ioapic controller.

Ok - i've simplified the code with the above and have added your Acked-by - is that is fine by you?

Ingo, Probably appended one is a better version. Yinghai can you please Ack if it is ok. Thanks.

---
From: Suresh Siddha <[email protected]>
Subject: x86: handle legacy PIC interrupts on all the cpu's

Ingo Molnar reported that with the recent changes of not statically blocking IRQ0_VECTOR..IRQ15_VECTOR's on all the cpu's, broke an AMD platform (with Nvidia chipset) boot when "noapic" boot option is used.

On this platform, legacy PIC interrupts are getting delivered to all the cpu's instead of just the boot cpu. Thus not initializing the vector to irq mapping for the legacy irq's resulted in not handling certain interrupts causing boot hang.

Fix this by initializing the vector to irq mapping on all the logical cpu's, if the legacy IRQ is handled by the legacy PIC.

---

 arch/x86/include/asm/hw_irq.h  |    3 +--
 arch/x86/kernel/apic/io_apic.c |    9 +++++++++
 arch/x86/kernel/irqinit.c      |   20 ++++++++++++++++++++
 3 files changed, 30 insertions(+), 2 deletions(-)
arch/x86/include/asm/hw_irq.h +1 -2
index a929c9e..564a7a1 100644
@@ -133,15 +133,14 @@ extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
 
 typedef int vector_irq_t[NR_VECTORS];
 DECLARE_PER_CPU(vector_irq_t, vector_irq);
+extern void __setup_vector_irq(int cpu);
 
 #ifdef CONFIG_X86_IO_APIC
 extern void lock_vector_lock(void);
 extern void unlock_vector_lock(void);
-extern void __setup_vector_irq(int cpu);
 #else
 static inline void lock_vector_lock(void) {}
 static inline void unlock_vector_lock(void) {}
-static inline void __setup_vector_irq(int cpu) {}
 #endif
 
 #endif /* !ASSEMBLY_ */
arch/x86/kernel/apic/io_apic.c +9 -0
index e4e0ddc..fd3cecd 100644
@@ -1268,6 +1268,15 @@ void __setup_vector_irq(int cpu)
 	/* Mark the inuse vectors */
 	for_each_irq_desc(irq, desc) {
 		cfg = desc->chip_data;
+
+		/*
+		 * If it is a legacy IRQ handled by the legacy PIC, be ready
+		 * to handle it on any CPU, as the PIC interrupts are delivered
+		 * to multiple cpu's on some platforms.
+		 */
+		if (irq < legacy_pic->nr_legacy_irqs && !IO_APIC_IRQ(irq))
+			cpumask_set_cpu(cpu, cfg->domain);
+
 		if (!cpumask_test_cpu(cpu, cfg->domain))
 			continue;
 		vector = cfg->vector;
arch/x86/kernel/irqinit.c +13 -0
index ef257fc..afc3b31 100644
@@ -141,6 +141,26 @@ void __init init_IRQ(void)
 	x86_init.irqs.intr_init();
 }
 
+#ifndef CONFIG_X86_IO_APIC
+/*
+ * Setup the vector to irq mappings.
+ */
+void __setup_vector_irq(int cpu)
+{
+	int irq;
+
+	/*
+	 * On most of the platforms, legacy PIC delivers the interrupts on the
+	 * boot cpu. But there are certain platforms where PIC interrupts are
+	 * delivered to multiple cpu's. For the new cpu that is coming online,
+	 * setup the static legacy vector to irq mapping.

arch/x86/kernel/irqinit.c void __init init_IRQ(void) · line 166

Quoted 10 lines
arch/x86/kernel/irqinit.c +7 -0
+	 */
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+
+}
+#endif
+
 static void __init smp_intr_init(void)
 {
 #ifdef CONFIG_SMP

yes, less one one function prototype.

Yinghai

#8 lore raw
Quoted 130 lines · Yinghai Lu
Quoted 116 lines · Suresh Siddha
Quoted 19 lines · Ingo Molnar
Quoted 17 lines · Yinghai Lu
Quoted 9 lines · Suresh Siddha
Quoted 5 lines · Yinghai Lu

arch/x86/kernel/irqinit.c void __init init_IRQ(void) · line 159

Quoted 3 lines
arch/x86/kernel/irqinit.c +3 -0
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		if (!IO_APIC_IRQ(irq))
+			per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;

seems those three lines are not needed...

Those are needed for !CONFIG_X86_IO_APIC case.

then we can have

arch/x86/kernel/irqinit.c +4 -0
+#ifndef CONFIG_X86_IO_APIC
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+#endif
Quoted 4 lines
Quoted 1 line

then we don't punish most setup with ioapic controller.

Ok - i've simplified the code with the above and have added your Acked-by - is that is fine by you?

Ingo, Probably appended one is a better version. Yinghai can you please Ack if it is ok. Thanks.

---
From: Suresh Siddha <[email protected]>
Subject: x86: handle legacy PIC interrupts on all the cpu's

Ingo Molnar reported that with the recent changes of not statically blocking IRQ0_VECTOR..IRQ15_VECTOR's on all the cpu's, broke an AMD platform (with Nvidia chipset) boot when "noapic" boot option is used.

On this platform, legacy PIC interrupts are getting delivered to all the cpu's instead of just the boot cpu. Thus not initializing the vector to irq mapping for the legacy irq's resulted in not handling certain interrupts causing boot hang.

Fix this by initializing the vector to irq mapping on all the logical cpu's, if the legacy IRQ is handled by the legacy PIC.

---

 arch/x86/include/asm/hw_irq.h  |    3 +--
 arch/x86/kernel/apic/io_apic.c |    9 +++++++++
 arch/x86/kernel/irqinit.c      |   20 ++++++++++++++++++++
 3 files changed, 30 insertions(+), 2 deletions(-)
arch/x86/include/asm/hw_irq.h +1 -2
index a929c9e..564a7a1 100644
@@ -133,15 +133,14 @@ extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
 
 typedef int vector_irq_t[NR_VECTORS];
 DECLARE_PER_CPU(vector_irq_t, vector_irq);
+extern void __setup_vector_irq(int cpu);
 
 #ifdef CONFIG_X86_IO_APIC
 extern void lock_vector_lock(void);
 extern void unlock_vector_lock(void);
-extern void __setup_vector_irq(int cpu);
 #else
 static inline void lock_vector_lock(void) {}
 static inline void unlock_vector_lock(void) {}
-static inline void __setup_vector_irq(int cpu) {}
 #endif
 
 #endif /* !ASSEMBLY_ */
arch/x86/kernel/apic/io_apic.c +9 -0
index e4e0ddc..fd3cecd 100644
@@ -1268,6 +1268,15 @@ void __setup_vector_irq(int cpu)
 	/* Mark the inuse vectors */
 	for_each_irq_desc(irq, desc) {
 		cfg = desc->chip_data;
+
+		/*
+		 * If it is a legacy IRQ handled by the legacy PIC, be ready
+		 * to handle it on any CPU, as the PIC interrupts are delivered
+		 * to multiple cpu's on some platforms.
+		 */
+		if (irq < legacy_pic->nr_legacy_irqs && !IO_APIC_IRQ(irq))
+			cpumask_set_cpu(cpu, cfg->domain);
+
 		if (!cpumask_test_cpu(cpu, cfg->domain))
 			continue;
 		vector = cfg->vector;
arch/x86/kernel/irqinit.c +13 -0
index ef257fc..afc3b31 100644
@@ -141,6 +141,26 @@ void __init init_IRQ(void)
 	x86_init.irqs.intr_init();
 }
 
+#ifndef CONFIG_X86_IO_APIC
+/*
+ * Setup the vector to irq mappings.
+ */
+void __setup_vector_irq(int cpu)
+{
+	int irq;
+
+	/*
+	 * On most of the platforms, legacy PIC delivers the interrupts on the
+	 * boot cpu. But there are certain platforms where PIC interrupts are
+	 * delivered to multiple cpu's. For the new cpu that is coming online,
+	 * setup the static legacy vector to irq mapping.

arch/x86/kernel/irqinit.c void __init init_IRQ(void) · line 166

Quoted 10 lines
arch/x86/kernel/irqinit.c +7 -0
+	 */
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+
+}
+#endif
+
 static void __init smp_intr_init(void)
 {
 #ifdef CONFIG_SMP

yes, less one one function prototype.

Quoted 1 line

Please submit the cleanup bit separately, we try to keep x86/urgent patches as small as possible.

Thanks,

Ingo

#9 lore raw

[tip:x86/urgent] x86: Handle legacy PIC interrupts on all the cpu's

In reply to Suresh Siddha
Commit-ID:  36e9e1eab777e077f7484d309ff676d0568e27d1
Gitweb:     http://git.kernel.org/tip/36e9e1eab777e077f7484d309ff676d0568e27d1
Author:     Suresh Siddha <[email protected]>
AuthorDate: Mon, 15 Mar 2010 14:33:06 -0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 16 Mar 2010 06:36:35 +0100

x86: Handle legacy PIC interrupts on all the cpu's

Ingo Molnar reported that with the recent changes of not statically blocking IRQ0_VECTOR..IRQ15_VECTOR's on all the cpu's, broke an AMD platform (with Nvidia chipset) boot when "noapic" boot option is used.

On this platform, legacy PIC interrupts are getting delivered to all the cpu's instead of just the boot cpu. Thus not initializing the vector to irq mapping for the legacy irq's resulted in not handling certain interrupts causing boot hang.

Fix this by initializing the vector to irq mapping on all the logical cpu's, if the legacy IRQ is handled by the legacy PIC.

[ -v2: io-apic-enabled improvement ]
Cc Eric W. Biederman <[email protected]>

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/hw_irq.h  |    1 +
 arch/x86/kernel/apic/io_apic.c |    8 ++++++++
 arch/x86/kernel/irqinit.c      |   22 ++++++++++++++++++++++
 arch/x86/kernel/smpboot.c      |    2 +-
 4 files changed, 32 insertions(+), 1 deletions(-)
arch/x86/include/asm/hw_irq.h +1 -0
index a929c9e..46c0fe0 100644
@@ -133,6 +133,7 @@ extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
 
 typedef int vector_irq_t[NR_VECTORS];
 DECLARE_PER_CPU(vector_irq_t, vector_irq);
+extern void setup_vector_irq(int cpu);
 
 #ifdef CONFIG_X86_IO_APIC
 extern void lock_vector_lock(void);
arch/x86/kernel/apic/io_apic.c +8 -0
index e4e0ddc..463de9a 100644
@@ -1268,6 +1268,14 @@ void __setup_vector_irq(int cpu)
 	/* Mark the inuse vectors */
 	for_each_irq_desc(irq, desc) {
 		cfg = desc->chip_data;
+
+		/*
+		 * If it is a legacy IRQ handled by the legacy PIC, this cpu
+		 * will be part of the irq_cfg's domain.
+		 */
+		if (irq < legacy_pic->nr_legacy_irqs && !IO_APIC_IRQ(irq))
+			cpumask_set_cpu(cpu, cfg->domain);
+
 		if (!cpumask_test_cpu(cpu, cfg->domain))
 			continue;
 		vector = cfg->vector;
arch/x86/kernel/irqinit.c +22 -0
index ef257fc..f01d390 100644
@@ -141,6 +141,28 @@ void __init init_IRQ(void)
 	x86_init.irqs.intr_init();
 }
 
+/*
+ * Setup the vector to irq mappings.
+ */
+void setup_vector_irq(int cpu)
+{
+#ifndef CONFIG_X86_IO_APIC
+	int irq;
+
+	/*
+	 * On most of the platforms, legacy PIC delivers the interrupts on the
+	 * boot cpu. But there are certain platforms where PIC interrupts are
+	 * delivered to multiple cpu's. If the legacy IRQ is handled by the
+	 * legacy PIC, for the new cpu that is coming online, setup the static
+	 * legacy vector to irq mapping:
+	 */
+	for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+		per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+#endif
+
+	__setup_vector_irq(cpu);
+}
+
 static void __init smp_intr_init(void)
 {
 #ifdef CONFIG_SMP
arch/x86/kernel/smpboot.c +1 -1
index a02e80c..06d98ae 100644
@@ -247,7 +247,7 @@ static void __cpuinit smp_callin(void)
 	/*
 	 * Need to setup vector mappings before we enable interrupts.
 	 */
-	__setup_vector_irq(smp_processor_id());
+	setup_vector_irq(smp_processor_id());
 	/*
 	 * Get our bogomips.
 	 *