* [Xenomai-core] x86 FPU switches routines.
@ 2006-10-23 8:24 Gilles Chanteperdrix
2006-10-23 9:01 ` Jan Kiszka
2006-11-11 22:40 ` Philippe Gerum
0 siblings, 2 replies; 4+ messages in thread
From: Gilles Chanteperdrix @ 2006-10-23 8:24 UTC (permalink / raw)
To: xenomai
[-- Attachment #1: Type: text/plain, Size: 536 bytes --]
Hi,
As once discussed with Heikki, and after a first missed attempt, here
is a patch for x86 which attempts to cope correctly with Linux (non
real-time) drivers using FPU in kernel-space.
I tested it on my laptop without drivers using FPU, and it appears to
work correctly, but it would be nice if people that had problems with
the previous attempt (if I remember correctly, on old pentiums and on
AMD processors) could test this patch.
Thanks in advance.
--
Gilles Chanteperdrix
[-- Attachment #2: xeno-i386-fpu-switch-use-cr0-ts.diff --]
[-- Type: text/x-patch, Size: 2067 bytes --]
Index: include/asm-i386/system.h
===================================================================
--- include/asm-i386/system.h (revision 1704)
+++ include/asm-i386/system.h (working copy)
@@ -69,6 +69,7 @@
/* FPU context bits for root thread. */
unsigned is_root: 1;
unsigned ts_usedfpu: 1;
+ unsigned cr0_ts: 1;
} xnarchtcb_t;
Index: include/asm-i386/bits/pod.h
===================================================================
--- include/asm-i386/bits/pod.h (revision 1704)
+++ include/asm-i386/bits/pod.h (working copy)
@@ -44,6 +44,7 @@
/* Remember the preempted Linux task pointer. */
rootcb->user_task = rootcb->active_task = current;
rootcb->ts_usedfpu = wrap_test_fpu_used(current) != 0;
+ rootcb->cr0_ts = (read_cr0() & 8) != 0;
/* So that xnarch_save_fpu() will operate on the right FPU area. */
rootcb->fpup = &rootcb->user_task->thread.i387;
}
@@ -265,12 +266,21 @@
{
struct task_struct *task = tcb->user_task;
- if (task) {
- if (!wrap_test_fpu_used(task))
+ if (!tcb->is_root) {
+ if (task) {
+ /* fpu not used or already saved by __switch_to. */
+ if (!wrap_test_fpu_used(task))
+ return;
+
+ /* Tell Linux that we already saved the state of the FPU
+ hardware of this task. */
+ wrap_clear_fpu_used(task);
+ }
+ } else {
+ if (tcb->cr0_ts ||
+ (tcb->ts_usedfpu && !wrap_test_fpu_used(task)))
return;
- /* Tell Linux that we already saved the state of the FPU
- hardware of this task. */
wrap_clear_fpu_used(task);
}
@@ -298,13 +308,14 @@
wrap_set_fpu_used(task);
}
} else {
- /* Restore state of FPU if TS_USEFPU bit was armed. */
- if (!tcb->ts_usedfpu) {
+ /* Restore state of FPU only if TS bit in cr0 was clear. */
+ if (tcb->cr0_ts) {
stts();
return;
}
- wrap_set_fpu_used(task);
+ if (tcb->ts_usedfpu)
+ wrap_set_fpu_used(task);
}
/* Restore the FPU hardware with valid fp registers from a
@@ -336,7 +347,7 @@
}
}
} else {
- if (!tcb->ts_usedfpu)
+ if (tcb->cr0_ts)
return;
xnarch_restore_fpu(tcb);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-core] x86 FPU switches routines.
2006-10-23 8:24 [Xenomai-core] x86 FPU switches routines Gilles Chanteperdrix
@ 2006-10-23 9:01 ` Jan Kiszka
2006-10-23 9:12 ` Gilles Chanteperdrix
2006-11-11 22:40 ` Philippe Gerum
1 sibling, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2006-10-23 9:01 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 707 bytes --]
Gilles Chanteperdrix wrote:
>
> Hi,
>
> As once discussed with Heikki, and after a first missed attempt, here
> is a patch for x86 which attempts to cope correctly with Linux (non
> real-time) drivers using FPU in kernel-space.
>
> I tested it on my laptop without drivers using FPU, and it appears to
> work correctly, but it would be nice if people that had problems with
> the previous attempt (if I remember correctly, on old pentiums and on
> AMD processors) could test this patch.
Just fired up on a Pentium MMX which used to have problems with the
first approad. Switchtest reports no problems.
What about writing a simple test case for the non-RT in-kernel FPU usage?
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-core] x86 FPU switches routines.
2006-10-23 9:01 ` Jan Kiszka
@ 2006-10-23 9:12 ` Gilles Chanteperdrix
0 siblings, 0 replies; 4+ messages in thread
From: Gilles Chanteperdrix @ 2006-10-23 9:12 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai
Jan Kiszka wrote:
> Gilles Chanteperdrix wrote:
>
>>Hi,
>>
>>As once discussed with Heikki, and after a first missed attempt, here
>>is a patch for x86 which attempts to cope correctly with Linux (non
>>real-time) drivers using FPU in kernel-space.
>>
>>I tested it on my laptop without drivers using FPU, and it appears to
>>work correctly, but it would be nice if people that had problems with
>>the previous attempt (if I remember correctly, on old pentiums and on
>>AMD processors) could test this patch.
>
>
> Just fired up on a Pentium MMX which used to have problems with the
> first approad. Switchtest reports no problems.
>
> What about writing a simple test case for the non-RT in-kernel FPU usage?
I plan to add it to the switchtest driver, but I wanted to make sure
that the new support already works in the usual case.
--
Gilles Chanteperdrix
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-core] x86 FPU switches routines.
2006-10-23 8:24 [Xenomai-core] x86 FPU switches routines Gilles Chanteperdrix
2006-10-23 9:01 ` Jan Kiszka
@ 2006-11-11 22:40 ` Philippe Gerum
1 sibling, 0 replies; 4+ messages in thread
From: Philippe Gerum @ 2006-11-11 22:40 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai
On Mon, 2006-10-23 at 10:24 +0200, Gilles Chanteperdrix wrote:
> Hi,
>
> As once discussed with Heikki, and after a first missed attempt, here
> is a patch for x86 which attempts to cope correctly with Linux (non
> real-time) drivers using FPU in kernel-space.
>
> I tested it on my laptop without drivers using FPU, and it appears to
> work correctly, but it would be nice if people that had problems with
> the previous attempt (if I remember correctly, on old pentiums and on
> AMD processors) could test this patch.
>
Ok, nobody has complained so far, it works for me too on a few test
boxen, so I'm going to merge this patch for 2.3-rc2.
So please everybody, let's give this hell _now_ on as many x86 boxen as
we can, checking out the trunk, so that we won't reiterate the 2.2.3
mess.
--
Philippe.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-11-11 22:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-23 8:24 [Xenomai-core] x86 FPU switches routines Gilles Chanteperdrix
2006-10-23 9:01 ` Jan Kiszka
2006-10-23 9:12 ` Gilles Chanteperdrix
2006-11-11 22:40 ` Philippe Gerum
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.