Xenomai and MSI enabled crashes kernel
Hi everybody,
I have been gone one step back to analyze the issue from the situation is originally occurred. This was the situation that I had a 2.6.20.4 kernel and Xenomai 2.3.1 (included Adeos patch). When I enable MSI in the kernel configuration I get the kernel message:
"spurious APIC interrupt on CPU#0, should never happen."
when trying to enable (ifconfig) the e1000 driver for an onboard PCIe network adapter.
I have now used the very same kernel without Xenomai patch, but using the same kernel config (MSI enabled). This returns the IRQ 223 for the Ethernet adapter.
With 2.6.21 it returns IRQ 219, there seems to be a difference between 2.6.20 and 2.6.21. Well, as I am working with 2.6.20.4, I looked deeper in that.
One interesting thing I found was in arch/i386/kernel/ipipe.c at function __ipipe_enable_pipeline I do not understand the meaning of that code.
At the beginning of that function, there are a couple of calls to ipipe_virtualize_irq(). These MAP the APIC system vectors.
However, the second call that mapsSPURIOUS_APIC_VECTOR - FIRST_EXTERNAL_VECTOR (with is infact 223) is mapped to smp_spurious_interrupt (which leads to the result I see).
However, I am not sure if it is correct to use the VECTOR values here as ipipe_virtualize_irq uses "irq" as second parameter and not a vector. This looks like a vector vs. irq mismatch.
Within the create_irq() function, the e1000 creates irq 223 on vector 201.
When I monitor the calls to set_intr_gate() I see that the vector 32 will end up at the address of irq_entries_start, vector 32 will end up at irq_entries_start + 8 etc.
In entry.S this will end up in writing ~(vector) unto the stack and calling common_interrupt. This finally calls __ipipe_handle_irq.
The means that __ipipe_handle_irq will not be called with the IRQ number but with the vector!! It could be that this is the same for the "old" IRQ vectors (<32).
However for the MSI IRQs this seems to be not correct.
I think that this could be the root cause for the problems I see.
Any feedback on this comment is highly welcome!
Regards
Mathias
Quoted 29 lines · M. Koehrer
Quoted 3 lines
Hi Philippe,
I have restored the original kernel configuration and I got the crash
again.
Quoted 2 lines
As it happens during the boot, it is reproducible.
Enclosed is the console log (including the oops), the relevant disassemblepart,
Quoted 4 lines
the output of "nm vmlinux" and my kernel config. If you like I can mail you privately the vmlinux aswell. What I see from the disassembler listing
c010f10b: e8 5e ae 02 00 callc0139f6e<
__ipipe_walk_pipeline>Quoted 2 lines
c010f110: ff 15 68 70 3d c0 call *0xc03d7068
is thatipipe_walk_pipelineis called followed by a indirect call to
0xc03d7068.Quoted 1 line
I looked at
nm vmlinuxand found out that0xc03d7068is
__ipipe_logical_cpuid.Quoted 3 lines
I hope that helps to get closer to this bug...
Should be ok, thanks. I will have a close look at this.
Signature · 1 line
Philippe.
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 39,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Quoted 13 lines · M. Koehrer
Hi everybody,
I have been gone one step back to analyze the issue from the situation is originally occurred. This was the situation that I had a 2.6.20.4 kernel and Xenomai 2.3.1 (included Adeos patch). When I enable MSI in the kernel configuration I get the kernel message:
"spurious APIC interrupt on CPU#0, should never happen."
when trying to enable (ifconfig) the e1000 driver for an onboard PCIe network adapter.I have now used the very same kernel without Xenomai patch, but using the same kernel config (MSI enabled). This returns the IRQ 223 for the Ethernet adapter.
With 2.6.21 it returns IRQ 219, there seems to be a difference between 2.6.20 and 2.6.21. Well, as I am working with 2.6.20.4, I looked deeper in that.
Quoted 9 lines
One interesting thing I found was in
arch/i386/kernel/ipipe.cat function__ipipe_enable_pipelineI do not understand the meaning of that code.
At the beginning of that function, there are a couple of calls toipipe_virtualize_irq(). These MAP the APIC system vectors.
However, the second call that mapsSPURIOUS_APIC_VECTOR-FIRST_EXTERNAL_VECTOR(with is infact 223) is mapped tosmp_spurious_interrupt(which leads to the result I see).
However, I am not sure if it is correct to use the VECTOR values here asipipe_virtualize_irquses "irq" as second parameter and not a vector. This looks like a vector vs. irq mismatch.
Isn't this the issue Philippe's last patch against ipipe and xenomai fixes?
Quoted 11 lines
Within the
create_irq()function, the e1000 creates irq 223 on vector 201.When I monitor the calls to
set_intr_gate()I see that the vector 32 will end up at the address ofirq_entries_start, vector 32 will end up atirq_entries_start+ 8 etc.
Inentry.Sthis will end up in writing ~(vector) unto the stack and callingcommon_interrupt. This finally calls__ipipe_handle_irq.
The means that__ipipe_handle_irqwill not be called with the IRQ number but with the vector!! It could be that this is the same for the "old" IRQ vectors (<32).
However for the MSI IRQs this seems to be not correct.
I think that this could be the root cause for the problems I see.
Again, please verify that you are not debugging the issue that Philippe may have already fixed, ie. re-evaluate your (very systematic!) findings after applying the ipipe fix.
Jan
Hi Jan,
o.k., now I understand Philippes patch.
However, at one point, I am not quite sure if this is correct:
Within __ipipe_handle_irq()
the patch adds
#ifdef CONFIG_X86_LOCAL_APIC
{
unsigned vector = irq + FIRST_EXTERNAL_VECTOR;
if (vector >= FIRST_SYSTEM_VECTOR)
irq = ipipe_apic_vector_irq(vector);
}#endif
I do not understand the if (vector >= ..) statement.
When I am at this point, the irq value is always the vector and never an irq. Thus, I think I should call ipipe_apic_vector_irq in any case.
I will do a test on that.
Regards
Mathias
----- Original Nachricht ----
Von: Jan Kiszka <[email protected]> An: "M. Koehrer" <[email protected]> Datum: 04.05.2007 09:59 Betreff: Re: [Xenomai-help] Xenomai and MSI enabled crashes kernel
Quoted 59 lines
Quoted 3 lines · M. Koehrer
Hi everybody,
I have been gone one step back to analyze the issue from the situation is
originally occurred.
Quoted 1 line
This was the situation that I had a 2.6.20.4 kernel and Xenomai 2.3.1
(included Adeos patch).
Quoted 3 lines
When I enable MSI in the kernel configuration I get the kernel message:
"spurious APIC interrupt on CPU#0, should never happen." when trying to enable (ifconfig) the e1000 driver for an onboard PCIenetwork adapter.
Quoted 2 lines
I have now used the very same kernel without Xenomai patch, but using the
same kernel config
Quoted 2 lines
(MSI enabled). This returns the IRQ 223 for the Ethernet adapter. With 2.6.21 it returns IRQ 219, there seems to be a difference between
2.6.20 and 2.6.21.
Quoted 3 lines
Well, as I am working with 2.6.20.4, I looked deeper in that.
One interesting thing I found was in
arch/i386/kernel/ipipe.cat function
__ipipe_enable_pipelineQuoted 2 lines
I do not understand the meaning of that code.
At the beginning of that function, there are a couple of calls to
ipipe_virtualize_irq().Quoted 3 lines
These MAP the APIC system vectors.
However, the second call that mapsSPURIOUS_APIC_VECTOR-FIRST_EXTERNAL_VECTOR(with is infact 223) ismapped to
Quoted 2 lines
smp_spurious_interrupt(which leads to the result I see). However, I am not sure if it is correct to use the VECTOR values here as
ipipe_virtualize_irqQuoted 1 line
uses "irq" as second parameter and not a vector. This looks like a vector
vs. irq mismatch.
Isn't this the issue Philippe's last patch against ipipe and xenomai fixes?
Quoted 2 lines
Within the
create_irq()function, the e1000 creates irq 223 on vector201.
Quoted 2 lines
When I monitor the calls to
set_intr_gate()I see that the vector 32 willend up at the address
Quoted 2 lines
of
irq_entries_start, vector 32 will end up atirq_entries_start+ 8 etc. Inentry.Sthis will end up in writing ~(vector) unto the stack andcalling
common_interrupt.Quoted 2 lines
This finally calls
__ipipe_handle_irq.
The means that__ipipe_handle_irqwill not be called with the IRQ numberbut with the vector!!
Quoted 3 lines
It could be that this is the same for the "old" IRQ vectors (<32). However for the MSI IRQs this seems to be not correct. I think that this could be the root cause for the problems I see.
Again, please verify that you are not debugging the issue that Philippe may have already fixed, ie. re-evaluate your (very systematic!) findings after applying the ipipe fix.
Jan
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 39,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Quoted 12 lines · M. Koehrer
Hi Jan,
o.k., now I understand Philippes patch.
However, at one point, I am not quite sure if this is correct:
Within__ipipe_handle_irq()
the patch adds#ifdef CONFIG_X86_LOCAL_APIC { unsigned vector = irq + FIRST_EXTERNAL_VECTOR; if (vector >= FIRST_SYSTEM_VECTOR) irq = ipipe_apic_vector_irq(vector); }
Quoted 3 lines
#endif
I do not understand the if (vector >= ..) statement.
When I am at this point, the irq value is always the vector and never an irq.
No, the trampoline code in entry.S passes us an irq actually. But there is indeed a vector:irq mapping issue with IRQ numbers greater than 206, which still badly conflict with system IRQs (MSI causes high numbered IRQs to be allocated). I'm working on a patch. More later.
Quoted 75 lines
Thus, I think I should call
ipipe_apic_vector_irqin any case. I will do a test on that.Regards
Mathias
----- Original Nachricht ----
Von: Jan Kiszka <[email protected]> An: "M. Koehrer" <[email protected]> Datum: 04.05.2007 09:59 Betreff: Re: [Xenomai-help] Xenomai and MSI enabled crashes kernelQuoted 59 lines
Quoted 3 lines · M. Koehrer
Hi everybody,
I have been gone one step back to analyze the issue from the situation is
originally occurred.
Quoted 1 line
This was the situation that I had a 2.6.20.4 kernel and Xenomai 2.3.1
(included Adeos patch).
Quoted 3 lines
When I enable MSI in the kernel configuration I get the kernel message:
"spurious APIC interrupt on CPU#0, should never happen." when trying to enable (ifconfig) the e1000 driver for an onboard PCIenetwork adapter.
Quoted 2 lines
I have now used the very same kernel without Xenomai patch, but using the
same kernel config
Quoted 2 lines
(MSI enabled). This returns the IRQ 223 for the Ethernet adapter. With 2.6.21 it returns IRQ 219, there seems to be a difference between
2.6.20 and 2.6.21.
Quoted 3 lines
Well, as I am working with 2.6.20.4, I looked deeper in that.
One interesting thing I found was in
arch/i386/kernel/ipipe.cat function
__ipipe_enable_pipelineQuoted 2 lines
I do not understand the meaning of that code.
At the beginning of that function, there are a couple of calls to
ipipe_virtualize_irq().Quoted 3 lines
These MAP the APIC system vectors.
However, the second call that mapsSPURIOUS_APIC_VECTOR-FIRST_EXTERNAL_VECTOR(with is infact 223) ismapped to
Quoted 2 lines
smp_spurious_interrupt(which leads to the result I see). However, I am not sure if it is correct to use the VECTOR values here as
ipipe_virtualize_irqQuoted 1 line
uses "irq" as second parameter and not a vector. This looks like a vector
vs. irq mismatch.
Isn't this the issue Philippe's last patch against ipipe and xenomai fixes?
Quoted 2 lines
Within the
create_irq()function, the e1000 creates irq 223 on vector201.
Quoted 2 lines
When I monitor the calls to
set_intr_gate()I see that the vector 32 willend up at the address
Quoted 2 lines
of
irq_entries_start, vector 32 will end up atirq_entries_start+ 8 etc. Inentry.Sthis will end up in writing ~(vector) unto the stack andcalling
common_interrupt.Quoted 2 lines
This finally calls
__ipipe_handle_irq.
The means that__ipipe_handle_irqwill not be called with the IRQ numberbut with the vector!!
Quoted 3 lines
It could be that this is the same for the "old" IRQ vectors (<32). However for the MSI IRQs this seems to be not correct. I think that this could be the root cause for the problems I see.
Again, please verify that you are not debugging the issue that Philippe may have already fixed, ie. re-evaluate your (very systematic!) findings after applying the ipipe fix.
Jan
Signature · 1 line
Philippe.
Hi Philippe,
I patched the create_irq() function to start the search for unused interrupts not at NR_IRQS -1 but from 127.
And this seems actually to work.
It looks like the right track!
That means, that actually the large IRQ numbers are conflicting with the system interrupts.
However, I wonder why this works with a non-adeos-patched kernel...
Regards
Mathias
Quoted 6 lines
No, the trampoline code in
entry.Spasses us an irq actually. But there is indeed a vector:irq mapping issue with IRQ numbers greater than 206, which still badly conflict with system IRQs (MSI causes high numbered IRQs to be allocated). I'm working on a patch. More later.
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 39,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Quoted 10 lines · M. Koehrer
Hi Philippe,
I patched the
create_irq()function to start the search for unused interrupts not atNR_IRQS-1 but from 127.
And this seems actually to work.
It looks like the right track!
That means, that actually the large IRQ numbers are conflicting with the system interrupts.However, I wonder why this works with a non-adeos-patched kernel...
Because the vanilla kernel does not need to map system vectors to interrupt numbers.
Quoted 14 lines
Regards
Mathias
Quoted 6 lines
No, the trampoline code in
entry.Spasses us an irq actually. But there is indeed a vector:irq mapping issue with IRQ numbers greater than 206, which still badly conflict with system IRQs (MSI causes high numbered IRQs to be allocated). I'm working on a patch. More later.
Signature · 1 line
Philippe.
Quoted 17 lines · Philippe Gerum
Quoted 12 lines · M. Koehrer
Hi Jan,
o.k., now I understand Philippes patch.
However, at one point, I am not quite sure if this is correct:
Within__ipipe_handle_irq()
the patch adds#ifdef CONFIG_X86_LOCAL_APIC { unsigned vector = irq + FIRST_EXTERNAL_VECTOR; if (vector >= FIRST_SYSTEM_VECTOR) irq = ipipe_apic_vector_irq(vector); }Quoted 3 lines
#endif
I do not understand the if (vector >= ..) statement.
When I am at this point, the irq value is always the vector and never an irq.
Quoted 5 lines
No, the trampoline code in
entry.Spasses us an irq actually. But there is indeed a vector:irq mapping issue with IRQ numbers greater than 206, which still badly conflict with system IRQs (MSI causes high numbered IRQs to be allocated). I'm working on a patch. More later.
Does this patch improve things?
http://download.gna.org/adeos/patches/v2.6/i386/adeos-ipipe-2.6.20-i386-1.8-00.patch
Signature · 1 line
Philippe.
Hi Philippe,
as mentioned in my previous mail, the new patch works fine. However, I get the error APIC error on CPU0: 00(20)
APIC error on CPU1: 00(40)
when unloading (rmmod) xeno_native.
I have looked closed to that issue and I have found out that this happens within the inline function xnarch_notify_halt() (file pod.h)
for(cpu=0; cpu < nr_cpus-1; ++cpu)
down(&xnarch_finalize_sync);Perhaps this helps to detect the issue...
Regards
Mathias
Quoted 10 lines
Does this patch improve things?
http://download.gna.org/adeos/patches/v2.6/i386/adeos-ipipe-2.6.20-i386-1.8-
00.patchSignature · 1 line
Philippe.
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 39,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Quoted 9 lines · M. Koehrer
Hi Philippe,
as mentioned in my previous mail, the new patch works fine. However, I get the error APIC error on CPU0: 00(20)
APIC error on CPU1: 00(40)
when unloading (rmmod)xeno_native.
I have looked closed to that issue and I have found out that this happens within the inline functionxnarch_notify_halt()(filepod.h)
Quoted 3 lines
for(cpu=0; cpu < nr_cpus-1; ++cpu)
down(&xnarch_finalize_sync);It's likely happening a few lines earlier, when sending IPI2 to synchronize all CPUs during Xenomai shutdown. Ok, I will have a look asap.
Quoted 16 lines
Perhaps this helps to detect the issue...
Regards
Mathias
Quoted 10 lines
Does this patch improve things?
http://download.gna.org/adeos/patches/v2.6/i386/adeos-ipipe-2.6.20-i386-1.8-
00.patchSignature · 1 line
Philippe.
Signature · 1 line
Philippe.
Hi Philippe,
perhaps one more information regarding that issue:
When I disable SMP, it seems to work fine (APIC and local APIC are enabled).
Regards
Mathias
Quoted 16 lines
Quoted 1 line
as mentioned in my previous mail, the new patch works fine. However, I get
the error
Quoted 9 lines
APIC error on CPU0: 00(20)
APIC error on CPU1: 00(40)
when unloading (rmmod)xeno_native.
I have looked closed to that issue and I have found out that this happens within the inline functionxnarch_notify_halt()(filepod.h)for(cpu=0; cpu < nr_cpus-1; ++cpu) down(&xnarch_finalize_sync);It's likely happening a few lines earlier, when sending IPI2 to synchronize all CPUs during Xenomai shutdown. Ok, I will have a look asap.
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 39,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Quoted 4 lines · M. Koehrer
Hi Philippe,
perhaps one more information regarding that issue:
When I disable SMP, it seems to work fine (APIC and local APIC are enabled).
This sounds reasonable, since IPIs are SMP specific.
Quoted 23 lines
Regards
Mathias
Quoted 16 lines
Quoted 1 line
as mentioned in my previous mail, the new patch works fine. However, I get
the error
Quoted 9 lines
APIC error on CPU0: 00(20)
APIC error on CPU1: 00(40)
when unloading (rmmod)xeno_native.
I have looked closed to that issue and I have found out that this happens within the inline functionxnarch_notify_halt()(filepod.h)for(cpu=0; cpu < nr_cpus-1; ++cpu) down(&xnarch_finalize_sync);It's likely happening a few lines earlier, when sending IPI2 to synchronize all CPUs during Xenomai shutdown. Ok, I will have a look asap.
Signature · 1 line
Philippe.
Quoted 4 lines · M. Koehrer
Hi Philippe,
perhaps one more information regarding that issue:
When I disable SMP, it seems to work fine (APIC and local APIC are enabled).
This should improve things:
arch/i386/kernel/ipipe.c +1 -1
@@ -373,7 +373,7 @@ int fastcall __ipipe_send_ipi (unsigned ipi, cpumask_t cpumask)cpu_clear (cpuid,cpumask);if (!cpus_empty (cpumask)) -send_IPI_mask (cpumask,ipi +FIRST_EXTERNAL_VECTOR ); +send_IPI_mask (cpumask,ipipe_apic_irq_vector (ipi));if (self)ipipe_trigger_irq (ipi);
Signature · 1 line
Philippe.
Hi Philippe,
that's it! Now, everything seems to run really nicely!
The great thing is, that is I have now one of my e1000 (PCIe) running in non real time mode and the other running with rtnet in real time! They have IRQs 223 resp. 222.
As interrupt sharing was one of the main issues I had, this seems to be solved now!
In which Xenomai version will the new adeos patch and the fix from today end up? Or should I use the 2.3.1 and using the new adeos patch + the fix?
Thank you very much for the excellent support!
Regards
Mathias
Quoted 32 lines · M. Koehrer
Quoted 4 lines
Hi Philippe,
perhaps one more information regarding that issue:
When I disable SMP, it seems to work fine (APIC and local APIC areenabled).
This should improve things:
arch/i386/kernel/ipipe.c +1
-1@@ -373,7 +373,7 @@ int fastcall __ipipe_send_ipi (unsigned ipi, cpumask_t cpumask)cpu_clear (cpuid ,cpumask );if (!cpus_empty (cpumask)) -send_IPI_mask (cpumask,ipi +FIRST_EXTERNAL_VECTOR ); +send_IPI_mask (cpumask,ipipe_apic_irq_vector (ipi));if (self)ipipe_trigger_irq(ipi);Signature · 8 lines
Philippe. _______________________________________________ Xenomai-help mailing list [email protected] https://mail.gna.org/listinfo/xenomai-help
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 39,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Quoted 10 lines · M. Koehrer
Hi Philippe,
that's it! Now, everything seems to run really nicely!
The great thing is, that is I have now one of my e1000 (PCIe) running in non real time mode and the other running with rtnet in real time! They have IRQs 223 resp. 222.
As interrupt sharing was one of the main issues I had, this seems to be solved now!
In which Xenomai version will the new adeos patch and the fix from today end up? Or should I use the 2.3.1 and using the new adeos patch + the fix?
I'll roll out I-pipe/x86 1.8-01 including the latest fixes soon. This patch will be available from the next 2.3.x maintenance release (2.3.2) and the trunk.
Quoted 39 lines
Thank you very much for the excellent support!
Regards
Mathias
Quoted 32 lines · M. Koehrer
Quoted 4 lines
Hi Philippe,
perhaps one more information regarding that issue:
When I disable SMP, it seems to work fine (APIC and local APIC areenabled).
This should improve things:
arch/i386/kernel/ipipe.c +1
-1@@ -373,7 +373,7 @@ int fastcall __ipipe_send_ipi (unsigned ipi, cpumask_t cpumask)cpu_clear (cpuid ,cpumask );if (!cpus_empty (cpumask)) -send_IPI_mask (cpumask,ipi +FIRST_EXTERNAL_VECTOR ); +send_IPI_mask (cpumask,ipipe_apic_irq_vector (ipi));if (self)ipipe_trigger_irq(ipi);Signature · 8 lines
Philippe. _______________________________________________ Xenomai-help mailing list [email protected] https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.