Skip to contentSkip to conversation

Ask help about pre_init_apic_IRQ0()

DISCUSSION Jiang Liu 5 participants 12 messages Sep 11, 2014 – Sep 12, 2014

Subsystems (2)
lore
Share & tools
lore

Jiang Liu

author
#0 lore raw

Hi Thomas,

When converting IOAPIC to hierarchy irqdomain, I ran into trouble when dealing with pre_init_apic_IRQ0(). Currently pre_init_apic_IRQ0() is only used by intel-mid platform and is called before initializing of IOAPIC irqdomains. That really causes headache when converting to hierarchy irqdomain. So could we delay

	io_apic_setup_irq_pin(0, 0, &attr);
        irq_set_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq,
                                      "edge");

to the point of "check_timer()"?

I have no MID hardware at handle so can't experiment with it. Could you please refer someone for help?

/* Enable IOAPIC early just for system timer */
void __init pre_init_apic_IRQ0(void)

{
        struct io_apic_irq_attr attr = { 0, 0, 0, 0 };

        printk(KERN_INFO "Early APIC setup for system timer0\n");
#ifndef CONFIG_SMP
        physid_set_mask_of_physid(boot_cpu_physical_apicid,
                                         &phys_cpu_present_map);
#endif
        setup_local_APIC();

        io_apic_setup_irq_pin(0, 0, &attr);
        irq_set_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq,
                                      "edge");
}

Regards!
Gerry

#1 lore raw
Quoted 7 lines · Jiang Liu

Hi Thomas,

When converting IOAPIC to hierarchy irqdomain, I ran into trouble when dealing with pre_init_apic_IRQ0(). Currently pre_init_apic_IRQ0() is only used by intel-mid platform and is called before initializing of IOAPIC irqdomains. That really causes headache when converting to hierarchy irqdomain. So could we delay

Quoted 7 lines
	io_apic_setup_irq_pin(0, 0, &attr);
        irq_set_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq,
                                      "edge");

to the point of "check_timer()"?

I have no MID hardware at handle so can't experiment with it. Could you please refer someone for help?

Andy (Cc'd) has some MID boards that he uses almost daily basis. Andy can you help Jiang here?

Quoted 20 lines

/* Enable IOAPIC early just for system timer */
void __init pre_init_apic_IRQ0(void)

{
        struct io_apic_irq_attr attr = { 0, 0, 0, 0 };

        printk(KERN_INFO "Early APIC setup for system timer0\n");
#ifndef CONFIG_SMP
        physid_set_mask_of_physid(boot_cpu_physical_apicid,
                                         &phys_cpu_present_map);
#endif
        setup_local_APIC();

        io_apic_setup_irq_pin(0, 0, &attr);
        irq_set_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq,
                                      "edge");
}

Regards!
Gerry

#2 lore raw
Quoted 13 lines · Mika Westerberg
Quoted 12 lines · Jiang Liu

Hi Thomas,

When converting IOAPIC to hierarchy irqdomain, I ran into trouble when dealing with pre_init_apic_IRQ0(). Currently pre_init_apic_IRQ0() is only used by intel-mid platform and is called before initializing of IOAPIC irqdomains. That really causes headache when converting to hierarchy irqdomain. So could we delay

	io_apic_setup_irq_pin(0, 0, &attr);
        irq_set_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq,
                                      "edge");

to the point of "check_timer()"?

Quoted 5 lines
Quoted 2 lines

I have no MID hardware at handle so can't experiment with it. Could you please refer someone for help?

Andy (Cc'd) has some MID boards that he uses almost daily basis. Andy can you help Jiang here?

I'm not familiar with IRQ domains like people Cc'ed here, but I could test any patch you provide to me. Just keep me in Cc list of those patches you would like to be tested on Intel MID, though I have only Intel Medfield based board. For newer stuff would be better to ask David (Cc'ed).

Quoted 21 lines
Quoted 21 lines

/* Enable IOAPIC early just for system timer */
void __init pre_init_apic_IRQ0(void)

{
        struct io_apic_irq_attr attr = { 0, 0, 0, 0 };

        printk(KERN_INFO "Early APIC setup for system timer0\n");
#ifndef CONFIG_SMP
        physid_set_mask_of_physid(boot_cpu_physical_apicid,
                                         &phys_cpu_present_map);
#endif
        setup_local_APIC();

        io_apic_setup_irq_pin(0, 0, &attr);
        irq_set_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq,
                                      "edge");
}

Regards!
Gerry

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#4 lore raw
In reply to Jiang Liu

Jiang,

Quoted 9 lines · Jiang Liu

When converting IOAPIC to hierarchy irqdomain, I ran into trouble when dealing with pre_init_apic_IRQ0(). Currently pre_init_apic_IRQ0() is only used by intel-mid platform and is called before initializing of IOAPIC irqdomains. That really causes headache when converting to hierarchy irqdomain. So could we delay

	io_apic_setup_irq_pin(0, 0, &attr);
        irq_set_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq,
                                      "edge");

to the point of "check_timer()"?

MID has no PIC, but depending on the platform it requires the abt_timer, which is connected to irq0. The timer is set up at late_time_init().

But, looking at the MID code it seems, that there is no reason to do so. The only code which might need the timer working is the TSC calibration code, but thats a non issue on MID as that is using its own empty calibration function. And check_timer() is not invoked either because MID has no PIC and therefor no legacy irqs.

So if you look at intel_mid_time_init() then you'll see that in the ARAT case the timer setup is skipped already. So until the point where x86_init.timers.setup_percpu_clockev() is called for the boot cpu nothing really needs a timer on MID.

According to the MID code the apbt horror is only used for moorestown. Medfield and later use the local apic timer without the apbt nonsense.

The best thing we can do is to drop moorestown support and get rid of that apbt nonsense alltogether.

I don't think anyone deeply cares about it not being supported from 3.18 on. The number of devices which sport a moorestown should be pretty limited and the only relevant use case of those is to act as a pocket heater with short battery life time. Its pretty pointless to update kernels on pocket heaters except for bragging reasons.

If someone at Intel really thinks that we need to keep moorestown alive for other than documentary and sentimental reasons, then we can move the apbt setup to x86_init.timers.setup_percpu_clockev(). At that point the IOAPIC is setup already, so it should just work. Untested patch below.

Thanks,

tglx

------------------

arch/x86/platform/intel-mid/intel-mid.c +13 -5
Index: linux/arch/x86/platform/intel-mid/intel-mid.c
===================================================================
@@ -81,26 +81,34 @@ static unsigned long __init intel_mid_ca
 	return 0;
 }
 
+static void __init intel_mid_setup_bp_timer(void)
+{
+	apbt_time_init();
+	setup_boot_APIC_clock();
+}
+
 static void __init intel_mid_time_init(void)
 {
 	sfi_table_parse(SFI_SIG_MTMR, NULL, NULL, sfi_parse_mtmr);
+
 	switch (intel_mid_timer_options) {
 	case INTEL_MID_TIMER_APBT_ONLY:
 		break;
 	case INTEL_MID_TIMER_LAPIC_APBT:
-		x86_init.timers.setup_percpu_clockev = setup_boot_APIC_clock;
+		/* Use apbt and local apic */
+		x86_init.timers.setup_percpu_clockev = intel_mid_setup_bp_timer;
 		x86_cpuinit.setup_percpu_clockev = setup_secondary_APIC_clock;
-		break;
+		return;
 	default:
 		if (!boot_cpu_has(X86_FEATURE_ARAT))
 			break;
+		/* Lapic only, no apbt */
 		x86_init.timers.setup_percpu_clockev = setup_boot_APIC_clock;
 		x86_cpuinit.setup_percpu_clockev = setup_secondary_APIC_clock;
 		return;
 	}
-	/* we need at least one APB timer */
-	pre_init_apic_IRQ0();
-	apbt_time_init();
+
+	x86_init.timers.setup_percpu_clockev = apbt_time_init;
 }
 
 static void intel_mid_arch_setup(void)
#5 lore raw

On Thu, 2014-09-11 at 14:58 +0200, Thomas Gleixner wrote:
[]

Quoted 5 lines

According to the MID code the apbt horror is only used for moorestown. Medfield and later use the local apic timer without the apbt nonsense.

The best thing we can do is to drop moorestown support and get rid of that apbt nonsense alltogether.

Alan Cox removed Moorestown (as a platform) support in 2012 IIRC. So, AFAIK you may safely remove those leftovers.

Quoted 11 lines

I don't think anyone deeply cares about it not being supported from 3.18 on. The number of devices which sport a moorestown should be pretty limited and the only relevant use case of those is to act as a pocket heater with short battery life time. Its pretty pointless to update kernels on pocket heaters except for bragging reasons.

If someone at Intel really thinks that we need to keep moorestown alive for other than documentary and sentimental reasons, then we can move the apbt setup to x86_init.timers.setup_percpu_clockev(). At that point the IOAPIC is setup already, so it should just work. Untested patch below.

Suddenly I have one priority work to do and my Medfield tablet doesn't boot by some reason. I would try to test it as soon as I can.

Quoted 50 lines

Thanks,

tglx

------------------
Index: linux/arch/x86/platform/intel-mid/intel-mid.c
===================================================================

arch/x86/platform/intel-mid/intel-mid.c +13 -5
@@ -81,26 +81,34 @@ static unsigned long __init intel_mid_ca
 	return 0;
 }
 
+static void __init intel_mid_setup_bp_timer(void)
+{
+	apbt_time_init();
+	setup_boot_APIC_clock();
+}
+
 static void __init intel_mid_time_init(void)
 {
 	sfi_table_parse(SFI_SIG_MTMR, NULL, NULL, sfi_parse_mtmr);
+
 	switch (intel_mid_timer_options) {
 	case INTEL_MID_TIMER_APBT_ONLY:
 		break;
 	case INTEL_MID_TIMER_LAPIC_APBT:
-		x86_init.timers.setup_percpu_clockev = setup_boot_APIC_clock;
+		/* Use apbt and local apic */
+		x86_init.timers.setup_percpu_clockev = intel_mid_setup_bp_timer;
 		x86_cpuinit.setup_percpu_clockev = setup_secondary_APIC_clock;
-		break;
+		return;
 	default:
 		if (!boot_cpu_has(X86_FEATURE_ARAT))
 			break;
+		/* Lapic only, no apbt */
 		x86_init.timers.setup_percpu_clockev = setup_boot_APIC_clock;
 		x86_cpuinit.setup_percpu_clockev = setup_secondary_APIC_clock;
 		return;
 	}
-	/* we need at least one APB timer */
-	pre_init_apic_IRQ0();
-	apbt_time_init();
+
+	x86_init.timers.setup_percpu_clockev = apbt_time_init;
 }
 
 static void intel_mid_arch_setup(void)
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#6 lore raw
Quoted 11 lines · Andy Shevchenko

On Thu, 2014-09-11 at 14:58 +0200, Thomas Gleixner wrote:
[]

Quoted 5 lines

According to the MID code the apbt horror is only used for moorestown. Medfield and later use the local apic timer without the apbt nonsense.

The best thing we can do is to drop moorestown support and get rid of that apbt nonsense alltogether.

Alan Cox removed Moorestown (as a platform) support in 2012 IIRC. So, AFAIK you may safely remove those leftovers.

Good.

Quoted 6 lines
Quoted 6 lines

I don't think anyone deeply cares about it not being supported from 3.18 on. The number of devices which sport a moorestown should be pretty limited and the only relevant use case of those is to act as a pocket heater with short battery life time. Its pretty pointless to update kernels on pocket heaters except for bragging reasons.

Quoted 8 lines
Quoted 5 lines

If someone at Intel really thinks that we need to keep moorestown alive for other than documentary and sentimental reasons, then we can move the apbt setup to x86_init.timers.setup_percpu_clockev(). At that point the IOAPIC is setup already, so it should just work. Untested patch below.

Suddenly I have one priority work to do and my Medfield tablet doesn't boot by some reason. I would try to test it as soon as I can.

The patch wont make a difference, except you add

x86_intel_mid_timer=apbt_only
or
x86_intel_mid_timer=lapic_and_apbt

on the kernel commandline. But even w/o that patch I doubt that anything post moorestown even has that apbt trainwreck implemented. If I'm right then the commandline option will prevent the thing to boot at all, which is an even better reason to remove that crap alltogether.

Thanks,

tglx

#7 lore raw
Quoted 27 lines · Thomas Gleixner
Quoted 11 lines · Andy Shevchenko

On Thu, 2014-09-11 at 14:58 +0200, Thomas Gleixner wrote:
[]

Quoted 5 lines

According to the MID code the apbt horror is only used for moorestown. Medfield and later use the local apic timer without the apbt nonsense.

The best thing we can do is to drop moorestown support and get rid of that apbt nonsense alltogether.

Alan Cox removed Moorestown (as a platform) support in 2012 IIRC. So, AFAIK you may safely remove those leftovers.

Good.

Quoted 12 lines
Quoted 11 lines

I don't think anyone deeply cares about it not being supported from 3.18 on. The number of devices which sport a moorestown should be pretty limited and the only relevant use case of those is to act as a pocket heater with short battery life time. Its pretty pointless to update kernels on pocket heaters except for bragging reasons.

If someone at Intel really thinks that we need to keep moorestown alive for other than documentary and sentimental reasons, then we can move the apbt setup to x86_init.timers.setup_percpu_clockev(). At that point the IOAPIC is setup already, so it should just work. Untested patch below.

Quoted 4 lines
Quoted 2 lines

Suddenly I have one priority work to do and my Medfield tablet doesn't boot by some reason. I would try to test it as soon as I can.

The patch wont make a difference, except you add

With patch nothing happened indeed.

Quoted 1 line

x86_intel_mid_timer=apbt_only

[    0.116839] BUG: unable to handle kernel NULL pointer dereference at
0000003a
[    0.123803] IP: [<c1071c0e>] setup_irq+0xf/0x4d

...

Quoted 2 lines

or
x86_intel_mid_timer=lapic_and_apbt

[    0.116858] BUG: unable to handle kernel NULL pointer dereference at
0000003a
[    0.123820] IP: [<c1071c0e>] setup_irq+0xf/0x4d

...

Quoted 6 lines

on the kernel commandline. But even w/o that patch I doubt that anything post moorestown even has that apbt trainwreck implemented. If I'm right then the commandline option will prevent the thing to boot at all, which is an even better reason to remove that crap alltogether.

See above.

Quoted 8 lines

Thanks,

tglx

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#8 lore raw
Quoted 52 lines · Andy Shevchenko
Quoted 27 lines · Thomas Gleixner
Quoted 11 lines · Andy Shevchenko

On Thu, 2014-09-11 at 14:58 +0200, Thomas Gleixner wrote:
[]

Quoted 5 lines

According to the MID code the apbt horror is only used for moorestown. Medfield and later use the local apic timer without the apbt nonsense.

The best thing we can do is to drop moorestown support and get rid of that apbt nonsense alltogether.

Alan Cox removed Moorestown (as a platform) support in 2012 IIRC. So, AFAIK you may safely remove those leftovers.

Good.

Quoted 12 lines
Quoted 11 lines

I don't think anyone deeply cares about it not being supported from 3.18 on. The number of devices which sport a moorestown should be pretty limited and the only relevant use case of those is to act as a pocket heater with short battery life time. Its pretty pointless to update kernels on pocket heaters except for bragging reasons.

If someone at Intel really thinks that we need to keep moorestown alive for other than documentary and sentimental reasons, then we can move the apbt setup to x86_init.timers.setup_percpu_clockev(). At that point the IOAPIC is setup already, so it should just work. Untested patch below.

Quoted 4 lines
Quoted 2 lines

Suddenly I have one priority work to do and my Medfield tablet doesn't boot by some reason. I would try to test it as soon as I can.

The patch wont make a difference, except you add

With patch nothing happened indeed.

Quoted 1 line

x86_intel_mid_timer=apbt_only

[    0.116839] BUG: unable to handle kernel NULL pointer dereference at
0000003a
[    0.123803] IP: [<c1071c0e>] setup_irq+0xf/0x4d

...

Quoted 2 lines

or
x86_intel_mid_timer=lapic_and_apbt

[    0.116858] BUG: unable to handle kernel NULL pointer dereference at
0000003a
[    0.123820] IP: [<c1071c0e>] setup_irq+0xf/0x4d

...

Quoted 1 line
Quoted 7 lines
Quoted 5 lines

on the kernel commandline. But even w/o that patch I doubt that anything post moorestown even has that apbt trainwreck implemented. If I'm right then the commandline option will prevent the thing to boot at all, which is an even better reason to remove that crap alltogether.

See above.

That was with the patch applied, right? What happens if you undo the patch and add the command line options?

Thanks,

tglx

#3 lore raw
In reply to Andy Shevchenko
Quoted 17 lines · Andy Shevchenko
Quoted 16 lines · Mika Westerberg
Quoted 14 lines · Jiang Liu

Hi Thomas,

When converting IOAPIC to hierarchy irqdomain, I ran into trouble when dealing with pre_init_apic_IRQ0(). Currently pre_init_apic_IRQ0() is only used by intel-mid platform and is called before initializing of IOAPIC irqdomains. That really causes headache when converting to hierarchy irqdomain. So could we delay

	io_apic_setup_irq_pin(0, 0, &attr);
        irq_set_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq,
                                      "edge");

to the point of "check_timer()"?

I have no MID hardware at handle so can't experiment with it. Could you please refer someone for help?

Quoted 8 lines
Quoted 2 lines

Andy (Cc'd) has some MID boards that he uses almost daily basis. Andy can you help Jiang here?

I'm not familiar with IRQ domains like people Cc'ed here, but I could test any patch you provide to me. Just keep me in Cc list of those patches you would like to be tested on Intel MID, though I have only Intel Medfield based board. For newer stuff would be better to ask David (Cc'ed).

I am able to test on newer devices.
Feel free to CC me when sending the patches.

Br, David

Quoted 28 lines
Quoted 22 lines
Quoted 22 lines

/* Enable IOAPIC early just for system timer */
void __init pre_init_apic_IRQ0(void)

{
        struct io_apic_irq_attr attr = { 0, 0, 0, 0 };

        printk(KERN_INFO "Early APIC setup for system timer0\n");
#ifndef CONFIG_SMP
        physid_set_mask_of_physid(boot_cpu_physical_apicid,
                                         &phys_cpu_present_map);
#endif
        setup_local_APIC();

        io_apic_setup_irq_pin(0, 0, &attr);
        irq_set_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq,
                                      "edge");
}

Regards!
Gerry

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#9 lore raw
In reply to Thomas Gleixner

On Thu, 2014-09-11 at 23:59 +0200, Thomas Gleixner wrote:
[]

Quoted 10 lines
Quoted 10 lines

With patch nothing happened indeed.

Quoted 1 line

x86_intel_mid_timer=apbt_only

[    0.116839] BUG: unable to handle kernel NULL pointer dereference at
0000003a
[    0.123803] IP: [<c1071c0e>] setup_irq+0xf/0x4d

...

w/o patch

[    0.000000] Early APIC setup for system timer0
[    0.000000] ------------[ cut here ]------------
[    0.000000] WARNING: CPU: 0 PID: 0 at

arch/x86/kernel/apic/apic.c:1393 setup_local_APIC+0x20c/0x2d9()

...and stuck a bit later

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

or
x86_intel_mid_timer=lapic_and_apbt

[    0.116858] BUG: unable to handle kernel NULL pointer dereference at
0000003a
[    0.123820] IP: [<c1071c0e>] setup_irq+0xf/0x4d

...

w/o patch

[    0.000000] Early APIC setup for system timer0
[    0.000000] ------------[ cut here ]------------
[    0.000000] WARNING: CPU: 0 PID: 0 at

arch/x86/kernel/apic/apic.c:1393 setup_local_APIC+0x20c/0x2d9()

...and boots normally

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

on the kernel commandline. But even w/o that patch I doubt that anything post moorestown even has that apbt trainwreck implemented. If I'm right then the commandline option will prevent the thing to boot at all, which is an even better reason to remove that crap alltogether.

See above.

That was with the patch applied, right?

Correct.

Quoted 2 lines

What happens if you undo the
patch and add the command line options?

See above.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#10 lore raw
Quoted 4 lines · Andy Shevchenko
Quoted 1 line · Thomas Gleixner
Quoted 1 line
Quoted 1 line

x86_intel_mid_timer=apbt_only

Quoted 8 lines

w/o patch

[    0.000000] Early APIC setup for system timer0
[    0.000000] ------------[ cut here ]------------
[    0.000000] WARNING: CPU: 0 PID: 0 at

arch/x86/kernel/apic/apic.c:1393 setup_local_APIC+0x20c/0x2d9()

...and stuck a bit later

Right, because there is no apbt timer in that machine and the commandline tells the kernel to use it and ignore the local apic timer.

Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

or
x86_intel_mid_timer=lapic_and_apbt

[    0.116858] BUG: unable to handle kernel NULL pointer dereference at
0000003a
[    0.123820] IP: [<c1071c0e>] setup_irq+0xf/0x4d

...

Quoted 8 lines

w/o patch

[    0.000000] Early APIC setup for system timer0
[    0.000000] ------------[ cut here ]------------
[    0.000000] WARNING: CPU: 0 PID: 0 at

arch/x86/kernel/apic/apic.c:1393 setup_local_APIC+0x20c/0x2d9()

...and boots normally

Right, because it uses the local apic timer later on.

Thanks for providing the data! I'll queue a removal of this mess.

Thanks,

tglx