Xenomai on Xscale (Linux 2.6.20)
Hi all,
I've found a bug in arch/arm/xenomai/switch.S which solved the problem below. It actually comes from the iWMMXT (Intel Wireless MMX) coprocessor which is an extension of the ARM core in Xscale processor (and of course which is not available in the AT91 series ;-).
When a thread switch occurs, rthal_thread_switch(in arch/arm/xenomai/switch.S) is called to perform switching of registers and stacks between threads. The PXA version must also perform a switch of MMX registers by invoking iwmmxt_task_switch(in arch/arm/kernel/iwmmxt.S). This is done in rthal_task_switch() as well.
However, between Linux 2.6.15 and Linux 2.6.20, the general scheme of low-level task switching procedure changed a little bit: it is now relying on a call chain notifier-based mechanism. Therefore, the iwmmxt_task_switch() function has been updated since the function is called now from the notifier, and not directly from __switch_to() as in 2.6.15. And the ipipe (ARM) patch did not take into account that.. and it fails.
So, as a first workaround, I simply duplicated the iwmmxt_task_switch() function making the version (from 2.6.15) proprietary to ipipe by renaming to iwmmxt_task_switch_from_ipipe(), and modified arch/arm/xenomai/switch.S accordingly (be careful, switch.S is a symlink and actually belongs to Xenomai tree (ksrc/arch/arm).
It seems to work so far, but further tests are needed (and will be done).
I attached a patch to be applied in the (xenomai-patched) Linux tree. (Linux 2.6.20, xenomai from today svn).
Daniel
Quoted 35 lines · On Mon, 2007-10-22 at 19:07 +0200, Jan Kiszka wrote: Patrick wrote:
Quoted 13 lines
Please ignore my first wrong mail ;-)
Hi,
I am trying to found the bug in xenomai for PXA270 machine (xenomai 2.3.4, ipipe 1.7-06 and kernel 2.6.20).
Quoted 6 lines
I have localised that the problem is coming when
rt_task_createcall__ipipe_restore_pipeline_head(called byxnlock_put_irq_restore) inipipe/core.c.I think that the problem is the call to
__clear_bit(IPIPE_STALL_FLAG, &head->cpudata[cpuid].status);Is it the operation itself or the effect on cpudata.status? I mean, can you safely do a
__clear_bitfollowed by a__set_bit, which would rule out an invalid memory access?Quoted 7 lines
If I don't execute this function on the
rt_task_createthe system doesn't freeze (but my application doesn't work correctly).I don't know what the problem is. Do you have an idea or a suggestion?
At least /me is lacking a full picture. So I would suggest, in order to ease the understanding of your scenario for everyone, to
Quoted 8 lines
a) post your modification in form of a patch (diff -up).
b) catch the problematic execution path with the ipipe tracer - now that it no longer fails lethally. Just put anipipe_trace_freezeat a point that is unique and close to the hot spot (e.g. afterrt_task_create.Jan
arch/arm/kernel/iwmmxt.S renamed from linux-2.6.20-col-xenomai.orig/arch/arm/kernel/iwmmxt.S +19 -0
@@ -293,6 +293,25 @@ mrc p15, 0, r1, c2, c0, 0 sub pc, lr, r1, lsr #32 @ cpwait and return +ENTRY(iwmmxt_task_switch_from_ipipe) + + mrc p15, 0, r4, c15, c1, 0 + tst r4, #0x3 @ CP0 and CP1 accessible? + bne 1f @ yes: block them for next task + + ldr r5, =concan_owner + add r6, r2, #(TI_IWMMXT_STATE - TI_CPU_DOMAIN) @ get next task Concan save area + ldr r5, [r5] @ get current Concan owner + teq r5, r6 @ next task owns it? + movne pc, lr @ no: leave Concan disabled + +1: eor r4, r4, #3 @ flip Concan access + mcr p15, 0, r4, c15, c1, 0 + + mrc p15, 0, r4, c2, c0, 0 + sub pc, lr, r4, lsr #32 @ cpwait and return + + /* * Remove Concan ownership of given task *
arch/arm/xenomai/switch.S renamed from linux-2.6.20-col-xenomai.orig/arch/arm/xenomai/switch.S +1 -1
@@ -59,6 +59,9 @@ add ip, r1, #TI_CPU_SAVE ldr r3, [r2, #TI_TP_VALUE] stmia ip!, {r4 - sl, fp, sp, lr} @ Store most regs on stack ldr r6, [r2, #TI_CPU_DOMAIN]! #if __LINUX_ARM_ARCH__ >= 6 #ifdef CONFIG_CPU_MPCORE
@@ -86,7 +89,7 @@ VFPFMXR FPEXC, r4 #endif #if defined(CONFIG_IWMMXT) - bl iwmmxt_task_switch + bl iwmmxt_task_switch_from_ipipe #elif defined(CONFIG_CPU_XSCALE) add r4, r2, #40 @ cpu_context_save->extra ldmib r4, {r4, r5}
Quoted 6 lines · ROSSIER Daniel
Hi all,
I've found a bug in
arch/arm/xenomai/switch.Swhich solved the problem below. It actually comes from the iWMMXT (Intel Wireless MMX) coprocessor which is an extension of the ARM core in Xscale processor (and of course which is not available in the AT91 series ;-).When a thread switch occurs,
rthal_thread_switch(in arch/arm/xenomai/switch.S)is called to perform switching of registers and stacks between threads. The PXA version must also perform a switch of MMX registers by invokingiwmmxt_task_switch(in arch/arm/kernel/iwmmxt.S). This is done inrthal_task_switch()as well.
Quoted 9 lines
However, between Linux 2.6.15 and Linux 2.6.20, the general scheme of low-level task switching procedure changed a little bit: it is now relying on a call chain notifier-based mechanism. Therefore, the
iwmmxt_task_switch()function has been updated since the function is called now from the notifier, and not directly from__switch_to()as in 2.6.15. And the ipipe (ARM) patch did not take into account that.. and it fails.So, as a first workaround, I simply duplicated the
iwmmxt_task_switch()function making the version (from 2.6.15) proprietary to ipipe by renaming toiwmmxt_task_switch_from_ipipe(), and modifiedarch/arm/xenomai/switch.Saccordingly (be careful,switch.Sis a symlink and actually belongs to Xenomai tree (ksrc/arch/arm).It seems to work so far, but further tests are needed (and will be done).
I attached a patch to be applied in the (xenomai-patched) Linux tree. (Linux 2.6.20, xenomai from today svn).
Task switching is not I-pipe's business, and we should refrain from recycling code from older kernel versions into recent ones. AFAICS, we only need to conform to some new internal API. Food for thought below:
arch/arm/switch.S +7 -0
@@ -18,6 +18,7 @@ */ #include <linux/linkage.h> +#include <linux/version.h> #include <asm/assembler.h> #include <asm/asm-offsets.h>
@@ -86,7 +87,13 @@ VFPFMXR FPEXC, r4 #endif #if defined(CONFIG_IWMMXT) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) + mr r0, r2 bl iwmmxt_task_switch + mr r2, r0 +#else + bl iwmmxt_task_switch +#endif #elif defined(CONFIG_CPU_XSCALE) add r4, r2, #40 @ cpu_context_save->extra ldmib r4, {r4, r5}
Signature · 1 line
Philippe.
Quoted 35 lines · Philippe Gerum
Quoted 6 lines · ROSSIER Daniel
Hi all,
I've found a bug in
arch/arm/xenomai/switch.Swhich solved the problem below. It actually comes from the iWMMXT (Intel Wireless MMX) coprocessor which is an extension of the ARM core in Xscale processor (and of course which is not available in the AT91 series ;-).When a thread switch occurs,
rthal_thread_switch(in arch/arm/xenomai/switch.S)is called to perform switching of registers and stacks between threads. The PXA version must also perform a switch of MMX registers by invokingiwmmxt_task_switch(in arch/arm/kernel/iwmmxt.S). This is done inrthal_task_switch()as well.Quoted 9 lines
However, between Linux 2.6.15 and Linux 2.6.20, the general scheme of low-level task switching procedure changed a little bit: it is now relying on a call chain notifier-based mechanism. Therefore, the
iwmmxt_task_switch()function has been updated since the function is called now from the notifier, and not directly from__switch_to()as in 2.6.15. And the ipipe (ARM) patch did not take into account that.. and it fails.So, as a first workaround, I simply duplicated the
iwmmxt_task_switch()function making the version (from 2.6.15) proprietary to ipipe by renaming toiwmmxt_task_switch_from_ipipe(), and modifiedarch/arm/xenomai/switch.Saccordingly (be careful,switch.Sis a symlink and actually belongs to Xenomai tree (ksrc/arch/arm).It seems to work so far, but further tests are needed (and will be done).
I attached a patch to be applied in the (xenomai-patched) Linux tree. (Linux 2.6.20, xenomai from today svn).
Task switching is not I-pipe's business, and we should refrain from recycling code from older kernel versions into recent ones. AFAICS, we only need to conform to some new internal API. Food for thought below:
arch/arm/switch.S (working copy) renamed from arch/arm/switch.S (revision 3095) +1
-0@@ -18,6 +18,7 @@ */ #include <linux/linkage.h> +#include <linux/version.h> #include <asm/assembler.h> #include <asm/asm-offsets.h>@@ -86,7 +87,13 @@ VFPFMXR FPEXC, r4 #endif #if defined(CONFIG_IWMMXT)
arch/arm/switch.S (working copy) line 99
Quoted 10 lines
arch/arm/switch.S (working copy) renamed from arch/arm/switch.S (revision 3095) +6
-0+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) + mr r0, r2 bl iwmmxt_task_switch + mr r2, r0 +#else + bl iwmmxt_task_switch +#endif #elif defined(CONFIG_CPU_XSCALE) add r4, r2, #40 @ cpu_context_save->extra ldmib r4, {r4, r5}
By greping THREAD_NOTIFY_SWITCH there appear to be other functions which should be called upon task switch.
Signature · 1 line
Gilles Chanteperdrix
Quoted 40 lines · Gilles Chanteperdrix
Quoted 39 lines · Philippe Gerum
Quoted 6 lines · ROSSIER Daniel
Hi all,
I've found a bug in
arch/arm/xenomai/switch.Swhich solved the problem below. It actually comes from the iWMMXT (Intel Wireless MMX) coprocessor which is an extension of the ARM core in Xscale processor (and of course which is not available in the AT91 series ;-).When a thread switch occurs,
rthal_thread_switch(in arch/arm/xenomai/switch.S)is called to perform switching of registers and stacks between threads. The PXA version must also perform a switch of MMX registers by invokingiwmmxt_task_switch(in arch/arm/kernel/iwmmxt.S). This is done inrthal_task_switch()as well.Quoted 9 lines
However, between Linux 2.6.15 and Linux 2.6.20, the general scheme of low-level task switching procedure changed a little bit: it is now relying on a call chain notifier-based mechanism. Therefore, the
iwmmxt_task_switch()function has been updated since the function is called now from the notifier, and not directly from__switch_to()as in 2.6.15. And the ipipe (ARM) patch did not take into account that.. and it fails.So, as a first workaround, I simply duplicated the
iwmmxt_task_switch()function making the version (from 2.6.15) proprietary to ipipe by renaming toiwmmxt_task_switch_from_ipipe(), and modifiedarch/arm/xenomai/switch.Saccordingly (be careful,switch.Sis a symlink and actually belongs to Xenomai tree (ksrc/arch/arm).It seems to work so far, but further tests are needed (and will be done).
I attached a patch to be applied in the (xenomai-patched) Linux tree. (Linux 2.6.20, xenomai from today svn).
Task switching is not I-pipe's business, and we should refrain from recycling code from older kernel versions into recent ones. AFAICS, we only need to conform to some new internal API. Food for thought below:
arch/arm/switch.S (working copy) renamed from arch/arm/switch.S (revision 3095) +5
-0@@ -18,6 +18,7 @@ */ #include <linux/linkage.h> +#include <linux/version.h> #include <asm/assembler.h> #include <asm/asm-offsets.h>@@ -86,7 +87,13 @@ VFPFMXR FPEXC, r4 #endif #if defined(CONFIG_IWMMXT) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) + mr r0, r2 bl iwmmxt_task_switch + mr r2, r0 +#else
Quoted 9 lines
arch/arm/switch.S (working copy) line 99
Quoted 5 lines
arch/arm/switch.S (working copy) renamed from arch/arm/switch.S (revision 3095) +2
-0+ bl iwmmxt_task_switch +#endif #elif defined(CONFIG_CPU_XSCALE) add r4, r2, #40 @ cpu_context_save->extra ldmib r4, {r4, r5}By greping
THREAD_NOTIFY_SWITCHthere appear to be other functions which should be called upon task switch.
It looks like per-platform/per-feature stuff. In any case we can't iron the notifier loop (and the leaf code called) to make it usable in primary mode. So I'm afraid we likely need to deal with the few platform dependent spots in our own switch code, since we know which platform/feature we want to support.
Signature · 1 line
Philippe.
I want to use Xenomai on openembedded (2.6.20 or higher) dist. for PXA270 board (compulab CM-X270). The kernel freezes during boottime after the Xenomai nucleus etc is has started, is this bug the cause of this freezing? Must I make the modifications by hand, i can't find them in the svn!
Henk Geraads
--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/message/[email protected]
Quoted 1 line · On Dec 3, 2007 12:56 PM, <[email protected]> wrote:
I want to use Xenomai on openembedded (2.6.20 or higher) dist. for PXA270 board (compulab CM-X270). The kernel freezes during boottime after the Xenomai nucleus etc is has started, is this bug the cause of this freezing? Must I make the modifications by hand, i can't find them in the svn!
If you use xenomai trunk, the bug should be fixed. The fix is in ksrc/arch/arm/switch.S
Signature · 1 line
Gilles Chanteperdrix
I use Xenomai with linux 2.6.20 too on PXA270 machine.
The bug is about context switching with iWMMX coprocessor of PXA and is corrected in Xenomai 2.4-rc7.
Good luck.
Patrick
-----Message d'origine-----
De : [email protected] [mailto:[email protected]] De la part de [email protected]
Envoyé : lundi, 3. décembre 2007 12:56
À : [email protected]
Objet : Re: [Xenomai-core] Xenomai on Xscale (Linux 2.6.20)
I want to use Xenomai on openembedded (2.6.20 or higher) dist. for PXA270 board (compulab CM-X270). The kernel freezes during boottime after the Xenomai nucleus etc is has started, is this bug the cause of this freezing? Must I make the modifications by hand, i can't find them in the svn!
Henk Geraads
--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/message/[email protected]
_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core
Quoted 8 lines · ROSSIER Daniel
Hi all,
I've found a bug in
arch/arm/xenomai/switch.Swhich solved the problem below. It actually comes from the iWMMXT (Intel Wireless MMX) coprocessor which is an extension of the ARM core in Xscale processor (and of course which is not available in the AT91 series ;-).When a thread switch occurs,
rthal_thread_switch(in arch/arm/xenomai/switch.S)is called to perform switching of registers and stacks between threads. The PXA version must also perform a switch of MMX registers by invokingiwmmxt_task_switch(in arch/arm/kernel/iwmmxt.S). This is done inrthal_task_switch()as well.However, between Linux 2.6.15 and Linux 2.6.20, the general scheme of low-level task switching procedure changed a little bit: it is now relying on a call chain notifier-based mechanism. Therefore, the
iwmmxt_task_switch()function has been updated since the function is called now from the notifier, and not directly from__switch_to()as in 2.6.15. And the ipipe (ARM) patch did not take into account that.. and it fails.
Shame to me, I somehow managed to miss this issue completely.
Signature · 1 line
Gilles Chanteperdrix