Skip to contentSkip to conversation

x86-tip: merge irqinit_32/64.c

PATCH In review Cyrill Gorcunov 3 participants 16 messages Mar 29, 2009 – Apr 1, 2009 x86

lore
Share & tools
lore
#0 lore raw

cover x86-tip: merge irqinit_32/64.c

Hi,

here is an attempt to merge irqinit_32/64 with minimum changes by small steps.

Please review. Need serious testing and actually have two problems in which I need help:

1) #include's verification and cleanup
2) APIC MCE assignments seems to be a bit
not clear in general -- at moment I added preprocessor directives to not change current behaviour but in real there should be a review
to check if we don't set vectors without handlers. Maybe I'm just screwed up -- too tired will check tomorrow :)

The patches are on top of -tip

|
| commit 71f60f2853b4ba53da35f51bc3e64ec6ad92ea90
| Merge: 305f38e f5b3ca6
| Author: Ingo Molnar <[email protected]>
| Date:   Sat Mar 28 13:13:08 2009 +0100
|
|    Merge branch 'x86/mce2'

Any comments are quite welcome. Thanks!

Cyrill

#1 lore raw

PATCH 1/6 x86: irqinit - order code snippets for easier merging

In attempt of easier further merging of this files I've order init_ISA_irqs function and a few comments as well. The notable change is that init_ISA_irqs is not static function on x86-64 anymore -- we will use arch quirks later.

---
 arch/x86/kernel/irqinit_32.c |   27 +++++++++++++++++++-------
 arch/x86/kernel/irqinit_64.c |   44 +++++++++++++++++++++----------------------
 2 files changed, 42 insertions(+), 29 deletions(-)
arch/x86/kernel/irqinit_32.c +20 -7
Index: linux-2.6.git/arch/x86/kernel/irqinit_32.c
===================================================================
@@ -54,6 +54,10 @@ static struct irqaction fpu_irq = {
 	.name = "fpu",
 };
 
+/*
+ * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
+ * (these are usually mapped to vectors 0x30-0x3f)
+ */
 void __init init_ISA_irqs(void)
 {
 	int i;
@@ -63,9 +67,7 @@ void __init init_ISA_irqs(void)
 #endif
 	init_8259A(0);
 
-	/*
-	 * 16 old-style INTA-cycle interrupts:
-	 */
+	/* 16 old-style INTA-cycle interrupts */
 	for (i = 0; i < NR_IRQS_LEGACY; i++) {
 		struct irq_desc *desc = irq_to_desc(i);
 
@@ -74,11 +76,22 @@ void __init init_ISA_irqs(void)
 		desc->depth = 1;
 
 		set_irq_chip_and_handler_name(i, &i8259A_chip,
-					      handle_level_irq, "XT");
+					handle_level_irq, "XT");
 	}
 }
 
 /*
+ * The IO-APIC gives us many more interrupt sources. Most of these
+ * are unused but an SMP system is supposed to have enough memory ...
+ * sometimes (mostly wrt. hw bugs) we get corrupted vectors all
+ * across the spectrum, so we really want to be prepared to get all
+ * of these. Plus, more powerful systems might have more than 64
+ * IO-APIC registers.
+ *
+ * (these are usually mapped into the 0x30-0xff vector range)
+ */
+
+/*
  * IRQ2 is cascade interrupt to second interrupt controller
  */
 static struct irqaction irq2 = {
@@ -120,6 +133,9 @@ int vector_used_by_percpu_irq(unsigned i
 	return 0;
 }
 
+/* Overridden in paravirt.c */
+void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ")));
+
 static void __init smp_intr_init(void)
 {
 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_SMP)
@@ -177,9 +193,6 @@ static void __init apic_intr_init(void)
 #endif
 }
 
-/* Overridden in paravirt.c */
-void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ")));
-
 void __init native_init_IRQ(void)
 {
 	int i;
arch/x86/kernel/irqinit_64.c +22 -22

56 lines not on this page · raw message

#2 lore raw

PATCH 2/6 x86: irqinit - merge smp_intr_init

In reply to Cyrill Gorcunov

All x86-64 CPUs has a local APIC.

---
 arch/x86/kernel/irqinit_32.c |    2 +-
 arch/x86/kernel/irqinit_64.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/irqinit_32.c +1 -1
Index: linux-2.6.git/arch/x86/kernel/irqinit_32.c
===================================================================
@@ -158,7 +158,7 @@ static void __init smp_intr_init(void)
 	/* IPI for generic function call */
 	alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
 
-	/* IPI for single call function */
+	/* IPI for generic single function call */
 	alloc_intr_gate(CALL_FUNCTION_SINGLE_VECTOR,
 				 call_function_single_interrupt);
 
arch/x86/kernel/irqinit_64.c +1 -1
Index: linux-2.6.git/arch/x86/kernel/irqinit_64.c
===================================================================
@@ -107,7 +107,7 @@ void init_IRQ(void) __attribute__((weak,
 
 static void __init smp_intr_init(void)
 {
-#ifdef CONFIG_SMP
+#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_SMP)
 	/*
 	 * The reschedule interrupt is a CPU-to-CPU reschedule-helper
 	 * IPI, driven by wakeup.
#3 lore raw

PATCH 3/6 x86: irqinit - merge apic_intr_init

In reply to Cyrill Gorcunov
---
 arch/x86/kernel/irqinit_32.c |    8 +++++++-
 arch/x86/kernel/irqinit_64.c |   18 ++++++++++++++----
 2 files changed, 21 insertions(+), 5 deletions(-)
arch/x86/kernel/irqinit_32.c +7 -1
Index: linux-2.6.git/arch/x86/kernel/irqinit_32.c
===================================================================
@@ -183,13 +183,19 @@ static void __init apic_intr_init(void)
 	alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
 	alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
 # ifdef CONFIG_PERF_COUNTERS
+	/* Performance monitoring interrupt */
 	alloc_intr_gate(LOCAL_PERF_VECTOR, perf_counter_interrupt);
 # endif
 
-# ifdef CONFIG_X86_MCE_P4THERMAL
+#if defined(CONFIG_X86_MCE_P4THERMAL) || defined(CONFIG_X86_64)
 	/* thermal monitor LVT interrupt */
 	alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
 # endif
+
+# ifdef CONFIG_X86_64
+	alloc_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt);
+# endif
+
 #endif
 }
 
arch/x86/kernel/irqinit_64.c +14 -4
Index: linux-2.6.git/arch/x86/kernel/irqinit_64.c
===================================================================
@@ -141,8 +141,7 @@ static void __init apic_intr_init(void)
 {
 	smp_intr_init();
 
-	alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
-	alloc_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt);
+#ifdef CONFIG_X86_LOCAL_APIC
 
 	/* self generated IPI for local APIC timer */
 	alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
@@ -154,9 +153,20 @@ static void __init apic_intr_init(void)
 	alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
 	alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
 
-	/* Performance monitoring interrupt: */
-#ifdef CONFIG_PERF_COUNTERS
+# ifdef CONFIG_PERF_COUNTERS
+	/* Performance monitoring interrupt */
 	alloc_intr_gate(LOCAL_PERF_VECTOR, perf_counter_interrupt);
+# endif
+
+#if defined(CONFIG_X86_MCE_P4THERMAL) || defined(CONFIG_X86_64)
+	/* thermal monitor LVT interrupt */
+	alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
+# endif
+
+# ifdef CONFIG_X86_64
+	alloc_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt);
+# endif
+
 #endif
 }
 
#4 lore raw

PATCH 4/6 x86: irqinit - merge native_init_IRQ

In reply to Cyrill Gorcunov

For this purpose init_ISA_irqs is called indirectly by x86_quirk_pre_intr_init.

---
 arch/x86/kernel/irqinit_32.c |    4 +++-
 arch/x86/kernel/irqinit_64.c |   22 +++++++++++++++++++++-
 arch/x86/kernel/setup.c      |    8 ++++++++
 3 files changed, 32 insertions(+), 2 deletions(-)
arch/x86/kernel/irqinit_32.c +3 -1
Index: linux-2.6.git/arch/x86/kernel/irqinit_32.c
===================================================================
@@ -215,7 +215,7 @@ void __init native_init_IRQ(void)
 	 */
 	for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
 		int vector = FIRST_EXTERNAL_VECTOR + i;
-		/* SYSCALL_VECTOR was reserved in trap_init. */
+		/* X86-32: SYSCALL_VECTOR was reserved in trap_init. */
 		if (!test_bit(vector, used_vectors))
 			set_intr_gate(vector, interrupt[i]);
 	}
@@ -229,6 +229,7 @@ void __init native_init_IRQ(void)
 	 */
 	x86_quirk_intr_init();
 
+#ifdef CONFIG_X86_32
 	/*
 	 * External FPU? Set up irq13 if so, for
 	 * original braindamaged IBM FERR coupling.
@@ -237,4 +238,5 @@ void __init native_init_IRQ(void)
 		setup_irq(FPU_IRQ, &fpu_irq);
 
 	irq_ctx_init(smp_processor_id());
+#endif
 }
arch/x86/kernel/irqinit_64.c +21 -1
Index: linux-2.6.git/arch/x86/kernel/irqinit_64.c
===================================================================
@@ -21,6 +21,7 @@
 #include <asm/pgtable.h>
 #include <asm/desc.h>
 #include <asm/apic.h>
+#include <asm/setup.h>
 #include <asm/i8259.h>
 
 /*
@@ -174,7 +175,8 @@ void __init native_init_IRQ(void)
 {
 	int i;
 
-	init_ISA_irqs();
+	/* Execute any quirks before the call gates are initialised: */
+	x86_quirk_pre_intr_init();
 
 	apic_intr_init();
 
@@ -185,10 +187,28 @@ void __init native_init_IRQ(void)
 	 */
 	for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
 		int vector = FIRST_EXTERNAL_VECTOR + i;
+		/* X86-32: SYSCALL_VECTOR was reserved in trap_init. */
 		if (!test_bit(vector, used_vectors))
 			set_intr_gate(vector, interrupt[i]);
 	}
 
 	if (!acpi_ioapic)
 		setup_irq(2, &irq2);
+
+	/*
+	 * Call quirks after call gates are initialised (usually add in
+	 * the architecture specific gates):
+	 */
+	x86_quirk_intr_init();
+
+#ifdef CONFIG_X86_32
+	/*
+	 * External FPU? Set up irq13 if so, for
+	 * original braindamaged IBM FERR coupling.
+	 */
+	if (boot_cpu_data.hard_math && !cpu_has_fpu)
+		setup_irq(FPU_IRQ, &fpu_irq);
+
+	irq_ctx_init(smp_processor_id());
+#endif
 }
arch/x86/kernel/setup.c +8 -0
Index: linux-2.6.git/arch/x86/kernel/setup.c
===================================================================
@@ -1087,3 +1087,11 @@ void __init x86_quirk_time_init(void)
 	setup_irq(0, &irq0);
 }
 #endif /* CONFIG_X86_32 */
+
+#ifdef CONFIG_X86_64
+void x86_quirk_pre_intr_init(void)
+{
+	init_ISA_irqs();
+}
+void x86_quirk_intr_init(void) { }
+#endif
#5 lore raw

Re: [patch 4/6] x86: irqinit - merge native_init_IRQ

Quoted 94 lines · Cyrill Gorcunov

For this purpose init_ISA_irqs is called indirectly by x86_quirk_pre_intr_init.

---
 arch/x86/kernel/irqinit_32.c |    4 +++-
 arch/x86/kernel/irqinit_64.c |   22 +++++++++++++++++++++-
 arch/x86/kernel/setup.c      |    8 ++++++++
 3 files changed, 32 insertions(+), 2 deletions(-)

Index: linux-2.6.git/arch/x86/kernel/irqinit_32.c
===================================================================

arch/x86/kernel/irqinit_32.c +3 -1
@@ -215,7 +215,7 @@ void __init native_init_IRQ(void)
 	 */
 	for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
 		int vector = FIRST_EXTERNAL_VECTOR + i;
-		/* SYSCALL_VECTOR was reserved in trap_init. */
+		/* X86-32: SYSCALL_VECTOR was reserved in trap_init. */
 		if (!test_bit(vector, used_vectors))
 			set_intr_gate(vector, interrupt[i]);
 	}
@@ -229,6 +229,7 @@ void __init native_init_IRQ(void)
 	 */
 	x86_quirk_intr_init();
 
+#ifdef CONFIG_X86_32
 	/*
 	 * External FPU? Set up irq13 if so, for
 	 * original braindamaged IBM FERR coupling.
@@ -237,4 +238,5 @@ void __init native_init_IRQ(void)
 		setup_irq(FPU_IRQ, &fpu_irq);
 
 	irq_ctx_init(smp_processor_id());
+#endif
 }

Index: linux-2.6.git/arch/x86/kernel/irqinit_64.c
===================================================================

arch/x86/kernel/irqinit_64.c +21 -1
@@ -21,6 +21,7 @@
 #include <asm/pgtable.h>
 #include <asm/desc.h>
 #include <asm/apic.h>
+#include <asm/setup.h>
 #include <asm/i8259.h>
 
 /*
@@ -174,7 +175,8 @@ void __init native_init_IRQ(void)
 {
 	int i;
 
-	init_ISA_irqs();
+	/* Execute any quirks before the call gates are initialised: */
+	x86_quirk_pre_intr_init();
 
 	apic_intr_init();
 
@@ -185,10 +187,28 @@ void __init native_init_IRQ(void)
 	 */
 	for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
 		int vector = FIRST_EXTERNAL_VECTOR + i;
+		/* X86-32: SYSCALL_VECTOR was reserved in trap_init. */
 		if (!test_bit(vector, used_vectors))
 			set_intr_gate(vector, interrupt[i]);
 	}
 
 	if (!acpi_ioapic)
 		setup_irq(2, &irq2);
+
+	/*
+	 * Call quirks after call gates are initialised (usually add in
+	 * the architecture specific gates):
+	 */
+	x86_quirk_intr_init();
+
+#ifdef CONFIG_X86_32
+	/*
+	 * External FPU? Set up irq13 if so, for
+	 * original braindamaged IBM FERR coupling.
+	 */
+	if (boot_cpu_data.hard_math && !cpu_has_fpu)
+		setup_irq(FPU_IRQ, &fpu_irq);
+
+	irq_ctx_init(smp_processor_id());
+#endif
 }

Index: linux-2.6.git/arch/x86/kernel/setup.c
===================================================================

arch/x86/kernel/setup.c +0 -0
@@ -1087,3 +1087,11 @@ void __init x86_quirk_time_init(void)
 	setup_irq(0, &irq0);

arch/x86/kernel/setup.c void __init x86_quirk_time_init(void) · line 1097

Quoted 10 lines
arch/x86/kernel/setup.c +8 -0
 }
 #endif /* CONFIG_X86_32 */
+
+#ifdef CONFIG_X86_64
+void x86_quirk_pre_intr_init(void)
+{
+	init_ISA_irqs();
+}
+void x86_quirk_intr_init(void) { }
+#endif

Hm, wouldnt it be cleaner to add it as a new quirk function vector in struct x86_quirks? See arch/x86/include/asm/setup.h.

Ingo

#6 lore raw

Re: [patch 4/6] x86: irqinit - merge native_init_IRQ

[Ingo Molnar - Wed, Apr 01, 2009 at 04:53:28PM +0200]
...

| 
| > Index: linux-2.6.git/arch/x86/kernel/setup.c
| > ===================================================================
| > --- linux-2.6.git.orig/arch/x86/kernel/setup.c
| > +++ linux-2.6.git/arch/x86/kernel/setup.c
| > @@ -1087,3 +1087,11 @@ void __init x86_quirk_time_init(void)
| >  	setup_irq(0, &irq0);
| >  }
| >  #endif /* CONFIG_X86_32 */
| > +
| > +#ifdef CONFIG_X86_64
| > +void x86_quirk_pre_intr_init(void)
| > +{
| > +	init_ISA_irqs();
| > +}
| > +void x86_quirk_intr_init(void) { }
| > +#endif
| 
| Hm, wouldnt it be cleaner to add it as a new quirk function vector 
| in struct x86_quirks? See arch/x86/include/asm/setup.h.
| 
| 	Ingo
| 

Will take a look, thanks!

Cyrill

#7 lore raw

Re: [patch 4/6] x86: irqinit - merge native_init_IRQ

In reply to Ingo Molnar

[Ingo Molnar - Wed, Apr 01, 2009 at 04:53:28PM +0200]
...

| > Index: linux-2.6.git/arch/x86/kernel/setup.c
| > ===================================================================
| > --- linux-2.6.git.orig/arch/x86/kernel/setup.c
| > +++ linux-2.6.git/arch/x86/kernel/setup.c
| > @@ -1087,3 +1087,11 @@ void __init x86_quirk_time_init(void)
| >  	setup_irq(0, &irq0);
| >  }
| >  #endif /* CONFIG_X86_32 */
| > +
| > +#ifdef CONFIG_X86_64
| > +void x86_quirk_pre_intr_init(void)
| > +{
| > +	init_ISA_irqs();
| > +}
| > +void x86_quirk_intr_init(void) { }
| > +#endif
| 
| Hm, wouldnt it be cleaner to add it as a new quirk function vector 
| in struct x86_quirks? See arch/x86/include/asm/setup.h.
| 
| 	Ingo
| 

I just remember -- I thought about that and since x86_quirk_pre_intr_init described as external BUT implemented for x86-32 only I needed to indroduce new x86-64 versions for this (and since I know that there no need to do anything else except calling init_ISA_irqs I desided to have separate wrapper for that).

And btw x86-32 already has init_ISA_irqs call and quirks are used in x86-32 mode only so for 64bit it will be just a not needed check. Which means - I could just use original x86_quirk_pre_intr_init function which will call all I need.

Or you meant something else?

Cyrill

#8 lore raw

Re: [patch 4/6] x86: irqinit - merge native_init_IRQ

Quoted 32 lines · Cyrill Gorcunov

[Ingo Molnar - Wed, Apr 01, 2009 at 04:53:28PM +0200]
...

| > Index: linux-2.6.git/arch/x86/kernel/setup.c
| > ===================================================================
| > --- linux-2.6.git.orig/arch/x86/kernel/setup.c
| > +++ linux-2.6.git/arch/x86/kernel/setup.c
| > @@ -1087,3 +1087,11 @@ void __init x86_quirk_time_init(void)
| >  	setup_irq(0, &irq0);
| >  }
| >  #endif /* CONFIG_X86_32 */
| > +
| > +#ifdef CONFIG_X86_64
| > +void x86_quirk_pre_intr_init(void)
| > +{
| > +	init_ISA_irqs();
| > +}
| > +void x86_quirk_intr_init(void) { }
| > +#endif
| 
| Hm, wouldnt it be cleaner to add it as a new quirk function vector 
| in struct x86_quirks? See arch/x86/include/asm/setup.h.
| 
| 	Ingo
| 

I just remember -- I thought about that and since x86_quirk_pre_intr_init described as external BUT implemented for x86-32 only I needed to indroduce new x86-64 versions for this (and since I know that there no need to do anything else except calling init_ISA_irqs I desided to have separate wrapper for that).

Quoted 6 lines

And btw x86-32 already has init_ISA_irqs call and quirks are used in x86-32 mode only so for 64bit it will be just a not needed check. Which means - I could just use original x86_quirk_pre_intr_init function which will call all I need.

Or you meant something else?

The typical solution there is to make the entry NULL in the 64-bit case. All the quirk handlers are conditional like this:

arch/x86/kernel/mpparse.c:      if (x86_quirks->mpc_apic_id)
arch/x86/kernel/mpparse.c:              apicid = x86_quirks->mpc_apic_id(m);

or am i missing something?

Ingo

#9 lore raw

Re: [patch 4/6] x86: irqinit - merge native_init_IRQ

[Ingo Molnar - Wed, Apr 01, 2009 at 06:22:50PM +0200]
...

| > I just remember -- I thought about that and since 
| > x86_quirk_pre_intr_init described as external BUT implemented for 
| > x86-32 only I needed to indroduce new x86-64 versions for this 
| > (and since I know that there no need to do anything else except 
| > calling init_ISA_irqs I desided to have separate wrapper for 
| > that).
| > 
| > And btw x86-32 already has init_ISA_irqs call and quirks are used 
| > in x86-32 mode only so for 64bit it will be just a not needed 
| > check. Which means - I could just use original 
| > x86_quirk_pre_intr_init function which will call all I need.
| > 
| > Or you meant something else?
| 
| The typical solution there is to make the entry NULL in the 64-bit 
| case. All the quirk handlers are conditional like this:
| 
| arch/x86/kernel/mpparse.c:      if (x86_quirks->mpc_apic_id)
| arch/x86/kernel/mpparse.c:              apicid = x86_quirks->mpc_apic_id(m);
| 
| or am i missing something?
| 
| 	Ingo
| 

The problem is that

	x86_quirk_pre_intr_init
	x86_quirk_intr_init
	...

are guarded by CONFIG_X86_32. So I thought to call x86_quirk_pre_intr_init which is implemented as following

void __init x86_quirk_pre_intr_init(void)

{
	if (x86_quirks->arch_pre_intr_init) {
		if (x86_quirks->arch_pre_intr_init())
			return;
	}
	init_ISA_irqs();
}

-- it will call init_ISA_irqs for us. But as I said it's bound by CONFIG_X86_32. So we could remove this limitation and use these function on x86-64 as well and don't call for x86_quirks->arch_pre_intr_init.

The only reason I didn't do that -- we test if x86_quirks->arch_pre_intr_init is defined for nothing -- it's always NULL on x86-64.

Another reason for that -- irqinit_32.c calls for x86_quirk_pre_intr_init and using the same name for x86-64 will make code a bit cleaner I believe.

Maybe I better post a patch for review -- it'll say more then me with my english :) ?

Cyrill

#10 lore raw

Re: [patch 4/6] x86: irqinit - merge native_init_IRQ

Ingo,

here is what I meant. The x86_quirk_pre_intr_init and x86_quirk_intr_init do all we need. The only paid off -- is that on x86-64 the functions will check for x86_quirks->arch_intr_init and x86_quirks->arch_pre_intr_init which are always NULL for x86-64 (at least for now). If that is acceptable -- then apply the patch below for testing please. Othrewise we could eliminate useless check by #ifdef (which would not be that much differ from what I've posted initially in patch series :)

Cyrill
---

x86: irqinit - merge native_init_IRQ

For this purpose on X86-64 init_ISA_irqs is called indirectly via x86_quirk_pre_intr_init (ie the same way as X86-32 do).

---
 arch/x86/kernel/irqinit_32.c |    4 +++-
 arch/x86/kernel/irqinit_64.c |   22 +++++++++++++++++++++-
 arch/x86/kernel/setup.c      |    2 +-
 3 files changed, 25 insertions(+), 3 deletions(-)
arch/x86/kernel/irqinit_32.c +3 -1
Index: linux-2.6.git/arch/x86/kernel/irqinit_32.c
===================================================================
@@ -215,7 +215,7 @@ void __init native_init_IRQ(void)
 	 */
 	for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
 		int vector = FIRST_EXTERNAL_VECTOR + i;
-		/* SYSCALL_VECTOR was reserved in trap_init. */
+		/* X86-32: SYSCALL_VECTOR was reserved in trap_init. */
 		if (!test_bit(vector, used_vectors))
 			set_intr_gate(vector, interrupt[i]);
 	}
@@ -229,6 +229,7 @@ void __init native_init_IRQ(void)
 	 */
 	x86_quirk_intr_init();
 
+#ifdef CONFIG_X86_32
 	/*
 	 * External FPU? Set up irq13 if so, for
 	 * original braindamaged IBM FERR coupling.
@@ -237,4 +238,5 @@ void __init native_init_IRQ(void)
 		setup_irq(FPU_IRQ, &fpu_irq);
 
 	irq_ctx_init(smp_processor_id());
+#endif
 }
arch/x86/kernel/irqinit_64.c +21 -1
Index: linux-2.6.git/arch/x86/kernel/irqinit_64.c
===================================================================
@@ -21,6 +21,7 @@
 #include <asm/pgtable.h>
 #include <asm/desc.h>
 #include <asm/apic.h>
+#include <asm/setup.h>
 #include <asm/i8259.h>
 
 /*
@@ -174,7 +175,8 @@ void __init native_init_IRQ(void)
 {
 	int i;
 
-	init_ISA_irqs();
+	/* Execute any quirks before the call gates are initialised: */
+	x86_quirk_pre_intr_init();
 
 	apic_intr_init();
 
@@ -185,10 +187,28 @@ void __init native_init_IRQ(void)
 	 */
 	for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
 		int vector = FIRST_EXTERNAL_VECTOR + i;
+		/* X86-32: SYSCALL_VECTOR was reserved in trap_init. */
 		if (!test_bit(vector, used_vectors))
 			set_intr_gate(vector, interrupt[i]);
 	}
 
 	if (!acpi_ioapic)
 		setup_irq(2, &irq2);
+
+	/*
+	 * Call quirks after call gates are initialised (usually add in
+	 * the architecture specific gates):
+	 */
+	x86_quirk_intr_init();
+
+#ifdef CONFIG_X86_32
+	/*
+	 * External FPU? Set up irq13 if so, for
+	 * original braindamaged IBM FERR coupling.
+	 */
+	if (boot_cpu_data.hard_math && !cpu_has_fpu)
+		setup_irq(FPU_IRQ, &fpu_irq);
+
+	irq_ctx_init(smp_processor_id());
+#endif
 }
arch/x86/kernel/setup.c +1 -1
Index: linux-2.6.git/arch/x86/kernel/setup.c
===================================================================
@@ -995,7 +995,6 @@ void __init setup_arch(char **cmdline_p)
 #endif
 }
 
-#ifdef CONFIG_X86_32
 
 /**
  * x86_quirk_pre_intr_init - initialisation prior to setting up interrupt vectors
@@ -1032,6 +1031,7 @@ void __init x86_quirk_intr_init(void)
 	}
 }
 
+#ifdef CONFIG_X86_32
 /**
  * x86_quirk_trap_init - initialise system specific traps
  *
#11 lore raw

Re: [patch 4/6] x86: irqinit - merge native_init_IRQ

[Cyrill Gorcunov - Wed, Apr 01, 2009 at 09:22:08PM +0400]

| Ingo,
| 
| here is what I meant. The x86_quirk_pre_intr_init
| and x86_quirk_intr_init do all we need. The only
| paid off -- is that on x86-64 the functions
| will check for x86_quirks->arch_intr_init and
| x86_quirks->arch_pre_intr_init which are always
| NULL for x86-64 (at least for now). If that is
| acceptable -- then apply the patch below for
| testing please. Othrewise we could eliminate
| useless check by #ifdef (which would not be
| that much differ from what I've posted initially
| in patch series :)
| 
|         Cyrill
| ---
| 
| x86: irqinit - merge native_init_IRQ
| 
| For this purpose on X86-64 init_ISA_irqs is called
| indirectly via x86_quirk_pre_intr_init (ie the same
| way as X86-32 do).
| 
| Signed-off-by: Cyrill Gorcunov <[email protected]>
| ---
|  arch/x86/kernel/irqinit_32.c |    4 +++-
|  arch/x86/kernel/irqinit_64.c |   22 +++++++++++++++++++++-
|  arch/x86/kernel/setup.c      |    2 +-
|  3 files changed, 25 insertions(+), 3 deletions(-)
| 

...

Ingo,

here are the reasons I found to vote for _this_ implementation (ie using x86_quirk_intr_init and x86_quirk_pre_intr_init
for both x86-32 and x86-64 platforms instead of direct function pointers)

1) Both are called on x86-32 as a former.
2) For x86-32 among the init_ISA_irqs call
the quirk itself is needed (VISWS code)

Cyrill

#12 lore raw

PATCH 5/6 x86: irqinit - merge math_error_irq and headers

In reply to Cyrill Gorcunov

Though the #include's are to be cleaned up.

---
 arch/x86/kernel/irqinit_32.c |    8 ++++++--
 arch/x86/kernel/irqinit_64.c |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 2 deletions(-)
arch/x86/kernel/irqinit_32.c +6 -2
Index: linux-2.6.git/arch/x86/kernel/irqinit_32.c
===================================================================
@@ -1,19 +1,23 @@
+#include <linux/linkage.h>
 #include <linux/errno.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
+#include <linux/timex.h>
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/init.h>
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
 #include <linux/bitops.h>
+#include <linux/acpi.h>
 #include <linux/io.h>
 #include <linux/delay.h>
 
 #include <asm/atomic.h>
 #include <asm/system.h>
+#include <asm/hw_irq.h>
 #include <asm/timer.h>
 #include <asm/pgtable.h>
 #include <asm/desc.h>
@@ -22,7 +26,7 @@
 #include <asm/i8259.h>
 #include <asm/traps.h>
 
-
+#ifdef CONFIG_X86_32
 /*
  * Note that on a 486, we don't want to do a SIGFPE on an irq13
  * as the irq is unreliable, and exception 16 works correctly
@@ -34,7 +38,6 @@
  * leads to races. IBM designers who came up with it should
  * be shot.
  */
-
 static irqreturn_t math_error_irq(int cpl, void *dev_id)
 {
 	outb(0, 0xF0);
@@ -53,6 +56,7 @@ static struct irqaction fpu_irq = {
 	.mask = CPU_MASK_NONE,
 	.name = "fpu",
 };
+#endif /* CONFIG_X86_32 */
 
 /*
  * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
arch/x86/kernel/irqinit_64.c +35 -0
Index: linux-2.6.git/arch/x86/kernel/irqinit_64.c
===================================================================
@@ -4,6 +4,7 @@
 #include <linux/sched.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
+#include <linux/kprobes.h>
 #include <linux/timex.h>
 #include <linux/slab.h>
 #include <linux/random.h>
@@ -18,11 +19,45 @@
 #include <asm/atomic.h>
 #include <asm/system.h>
 #include <asm/hw_irq.h>
+#include <asm/timer.h>
 #include <asm/pgtable.h>
 #include <asm/desc.h>
 #include <asm/apic.h>
 #include <asm/setup.h>
 #include <asm/i8259.h>
+#include <asm/traps.h>
+
+#ifdef CONFIG_X86_32
+/*
+ * Note that on a 486, we don't want to do a SIGFPE on an irq13
+ * as the irq is unreliable, and exception 16 works correctly
+ * (ie as explained in the intel literature). On a 386, you
+ * can't use exception 16 due to bad IBM design, so we have to
+ * rely on the less exact irq13.
+ *
+ * Careful.. Not only is IRQ13 unreliable, but it is also
+ * leads to races. IBM designers who came up with it should
+ * be shot.
+ */
+static irqreturn_t math_error_irq(int cpl, void *dev_id)
+{
+	outb(0, 0xF0);
+	if (ignore_fpu_irq || !boot_cpu_data.hard_math)
+		return IRQ_NONE;
+	math_error((void __user *)get_irq_regs()->ip);
+	return IRQ_HANDLED;
+}
+
+/*
+ * New motherboards sometimes make IRQ 13 be a PCI interrupt,
+ * so allow interrupt sharing.
+ */
+static struct irqaction fpu_irq = {
+	.handler = math_error_irq,
+	.mask = CPU_MASK_NONE,
+	.name = "fpu",
+};
+#endif /* CONFIG_X86_32 */
 
 /*
  * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
#13 lore raw

PATCH 6/6 x86: irqinit - merge irqinit_32/64.c into irqinit.c

In reply to Cyrill Gorcunov

So the files are merged there is still #include's
mess -- need serious cleanup.

---
 arch/x86/kernel/Makefile     |    2 
 arch/x86/kernel/irqinit.c    |  249 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/irqinit_32.c |  246 ------------------------------------------
 arch/x86/kernel/irqinit_64.c |  249 -------------------------------------------
 4 files changed, 250 insertions(+), 496 deletions(-)
arch/x86/kernel/Makefile +1 -1
Index: linux-2.6.git/arch/x86/kernel/Makefile
===================================================================
@@ -28,7 +28,7 @@ CFLAGS_paravirt.o	:= $(nostackp)
 obj-y			:= process_$(BITS).o signal.o entry_$(BITS).o
 obj-y			+= traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
 obj-y			+= time_$(BITS).o ioport.o ldt.o dumpstack.o
-obj-y			+= setup.o i8259.o irqinit_$(BITS).o
+obj-y			+= setup.o i8259.o irqinit.o
 obj-$(CONFIG_X86_VISWS)	+= visws_quirks.o
 obj-$(CONFIG_X86_32)	+= probe_roms_32.o
 obj-$(CONFIG_X86_32)	+= sys_i386_32.o i386_ksyms_32.o
arch/x86/kernel/irqinit.c new file +249 -0

249 lines not on this page · raw message

arch/x86/kernel/irqinit_32.c deleted +0 -246

246 lines not on this page · raw message

arch/x86/kernel/irqinit_64.c deleted +0 -249

249 lines not on this page · raw message

#14 lore raw

Re: [patch 6/6] x86: irqinit - merge irqinit_32/64.c into irqinit.c

Quoted 10 lines · Cyrill Gorcunov

So the files are merged there is still #include's
mess -- need serious cleanup.

---
 arch/x86/kernel/Makefile     |    2 
 arch/x86/kernel/irqinit.c    |  249 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/irqinit_32.c |  246 ------------------------------------------
 arch/x86/kernel/irqinit_64.c |  249 -------------------------------------------
 4 files changed, 250 insertions(+), 496 deletions(-)

ok, this looks pretty well done.

If you could do the x86_quirk cleanup on top of this i guess we could try it. (no need to redo the unification with the quirk thing, that will break this patch.)

Ingo

#15 lore raw

Re: [patch 6/6] x86: irqinit - merge irqinit_32/64.c into irqinit.c

[Ingo Molnar - Wed, Apr 01, 2009 at 05:01:01PM +0200]

| 
| * Cyrill Gorcunov <[email protected]> wrote:
| 
| > So the files are merged there is still #include's
| > mess -- need serious cleanup.
| > 
| > Signed-off-by: Cyrill Gorcunov <[email protected]>
| > ---
| >  arch/x86/kernel/Makefile     |    2 
| >  arch/x86/kernel/irqinit.c    |  249 +++++++++++++++++++++++++++++++++++++++++++
| >  arch/x86/kernel/irqinit_32.c |  246 ------------------------------------------
| >  arch/x86/kernel/irqinit_64.c |  249 -------------------------------------------
| >  4 files changed, 250 insertions(+), 496 deletions(-)
| 
| ok, this looks pretty well done.
| 
| If you could do the x86_quirk cleanup on top of this i guess we 
| could try it. (no need to redo the unification with the quirk thing, 
| that will break this patch.)
| 
| 	Ingo
| 

ok, will do the quirk cleanup on top of.

Cyrill