From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Mark Saiia <mark.saiia@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] fpu context switch issue
Date: Sat, 08 Nov 2008 17:56:51 +0100 [thread overview]
Message-ID: <4915C4D3.8030304@domain.hid> (raw)
In-Reply-To: <49100825.9000502@domain.hid>
Gilles Chanteperdrix wrote:
> Mark Saiia wrote:
>> Hello,
>>
>> The switchtest output is as follows. This was run on 2.4.5 with 2.6.26.3
>> AMD Geode LX800 board.
>> In order to get it to run, I had to remove modprobe xeno_native from my
>> start-up script. I don't know if that is an expected requirement prior to
>> running the test.
>>
>> == Testing FPU check routines...
>> r0: 1 != 2
>> r1: 1 != 2
>> r2: 1 != 2
>> r3: 1 != 2
>> r4: 1 != 2
>> r5: 1 != 2
>> r6: 1 != 2
>> r7: 1 != 2
>> == FPU check routines: OK.
>> == Threads: sleeper_ufps-0 rtk-1 rtk-2 rtk_fp-3 rtk_fp-4 rtk_fp_ufpp-5
>> rtk_fp_ufpp-6 rtup-7 rtup-8 rtup_ufpp-9 rtup_ufpp-10 rtus-11 rtus-12
>> rtus_ufps-13 rtus_ufps-14 rtuo-15 rtuo-16 rtuo_ufpp-17 rtuo_ufpp-18
>> rtuo_ufps-19 rtuo_ufps-20 rtuo_ufpp_ufps-21 rtuo_ufpp_ufps-22
>> RTT| 00:00:01
>> RTH|ctx switches|-------total
>> RTD| 17250| 17250
>> RTD| 17250| 34500
>> RTD| 17250| 51750
>> RTD| 17250| 69000
>> RTD| 17273| 86273
>> RTD| 17273| 103546
>> RTD| 17273| 120819
>> RTD| 17250| 138069
>> RTD| 17250| 155319
>> RTD| 17273| 172592
>> RTD| 17250| 189842
>> RTD| 17250| 207092
>> RTD| 17273| 224365
>> RTD| 17273| 241638
>> RTD| 17273| 258911
>> RTD| 17250| 276161
>> RTD| 17250| 293411
>> RTD| 17250| 310661
>> RTD| 17273| 327934
>> RTD| 17273| 345207
>> RTD| 17250| 362457
>>
>> Thanks in advance for any help.
>>
>> Mark Saiia
>
>
> Hi,
>
> It seems you do not get the same error with switchtest as you get with
> your test program. I had a look at linux fpu handling, and it seems to
> be very different from Xenomai fpu handling. I need to dig a little bit
> more, but will send you a patch soon.
Here comes the promised patch.
Index: include/asm-x86/bits/pod_32.h
===================================================================
--- include/asm-x86/bits/pod_32.h (revision 4355)
+++ include/asm-x86/bits/pod_32.h (working copy)
@@ -194,16 +194,37 @@ static inline void xnarch_init_thread(xn
static inline void xnarch_init_fpu(xnarchtcb_t * tcb)
{
struct task_struct *task = tcb->user_task;
+ x86_fpu_state *fpup = tcb->fpup;
/* Initialize the FPU for a task. This must be run on behalf of the
task. */
- __asm__ __volatile__("clts; fninit");
+ if (cpu_has_fxsr) {
+ struct i837_fxsave_struct *fx = &fpup->fxsave;
- if (cpu_has_xmm) {
- unsigned long __mxcsr = 0x1f80UL & 0xffbfUL;
- __asm__ __volatile__("ldmxcsr %0"::"m"(__mxcsr));
- }
+ memset(fx, 0, sizeof(*fx));
+ fx->cwd = 0x37f;
+ if (cpu_has_xmm) {
+ unsigned long __mxcsr = 0x1f80UL & 0xffbfUL;
+ fx->mxcsr = __mxcsr;
+ }
+
+ clts();
+
+ __asm__ __volatile__("fxrstor %0": /* no output */ :"m"(*fx));
+ } else {
+ struct i387_fsave_struct *fp = &fpup->fsave;
+
+ memset(fp, 0, sizeof(*fp));
+ fp->cwd = 0xffff037fu;
+ fp->swd = 0xffff0000u;
+ fp->twd = 0xffffffffu;
+ fp->fos = 0xffff0000u;
+
+ clts();
+ __asm__ __volatile__("frstor %0": /* no output */ :"m"(*fp));
+ }
+
if (task) {
/* Real-time shadow FPU initialization: tell Linux that this
thread initialized its FPU hardware. The fpu usage bit is
--
Gilles.
next prev parent reply other threads:[~2008-11-08 16:56 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-03 0:35 [Xenomai-help] fpu context switch issue Steven Seeger
2008-11-03 10:10 ` Gilles Chanteperdrix
2008-11-03 14:21 ` Steven Seeger
2008-11-03 17:04 ` Gilles Chanteperdrix
2008-11-03 20:37 ` Mark Saiia
2008-11-04 8:30 ` Gilles Chanteperdrix
2008-11-08 16:56 ` Gilles Chanteperdrix [this message]
2008-11-11 0:07 ` Mark Saiia
2008-11-11 11:21 ` Gilles Chanteperdrix
2008-11-11 17:43 ` Steven Seeger
2008-11-11 22:32 ` Mark Saiia
2008-11-11 22:39 ` Gilles Chanteperdrix
2008-11-13 11:11 ` Gilles Chanteperdrix
2008-11-14 3:59 ` Mark Saiia
2008-11-14 8:42 ` Gilles Chanteperdrix
2008-11-17 17:27 ` Mark Saiia
2008-11-17 18:54 ` Steven Seeger
2008-11-19 18:51 ` Steven Seeger
2008-11-20 12:43 ` Gilles Chanteperdrix
2008-11-20 13:51 ` Steven Seeger
2008-11-21 17:03 ` Mark Saiia
2008-11-21 17:07 ` Gilles Chanteperdrix
2008-11-26 10:47 ` Gilles Chanteperdrix
2008-11-12 13:48 ` Steven Seeger
2008-11-12 13:52 ` Gilles Chanteperdrix
2008-11-12 13:53 ` Steven Seeger
2008-11-04 9:55 ` Gilles Chanteperdrix
2008-11-04 15:38 ` Steven Seeger
2008-11-04 17:29 ` Mark Saiia
2008-11-04 18:59 ` Gilles Chanteperdrix
2008-11-04 19:01 ` Gilles Chanteperdrix
2008-11-04 21:29 ` Steven Seeger
2008-11-05 17:47 ` Mark Saiia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4915C4D3.8030304@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=mark.saiia@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.