* [Xenomai] ARM LS1021A SMP Floating point Interrupt Service Routine
@ 2016-03-16 3:41 Henry Bausley
2016-03-16 4:04 ` Gilles Chanteperdrix
0 siblings, 1 reply; 2+ messages in thread
From: Henry Bausley @ 2016-03-16 3:41 UTC (permalink / raw)
To: xenomai
How does one properly permit floating point operations in an ISR in a
kernel driver running on an ARM CPU. Our ISR is on cpu 0 and I thought
that the code below would work. However sometimes the userspace
application using the floating point unit will get a segmentation fault.
The kernel driver running floating point does not have a problem. I am
sure I am missing something here since I can use floating point in
xenomai kernel threads without a problem.
int FloatingPointISR()
{
rthal_vfp_save((union vfp_state*)x, rthal_enable_fpu());
// A bunch of floating point stuff
rthal_vfp_load((union vfp_state*)x, 0);
}
Outbound scan for Spam or Virus by Barracuda at Delta Tau
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Xenomai] ARM LS1021A SMP Floating point Interrupt Service Routine
2016-03-16 3:41 [Xenomai] ARM LS1021A SMP Floating point Interrupt Service Routine Henry Bausley
@ 2016-03-16 4:04 ` Gilles Chanteperdrix
0 siblings, 0 replies; 2+ messages in thread
From: Gilles Chanteperdrix @ 2016-03-16 4:04 UTC (permalink / raw)
To: Henry Bausley; +Cc: xenomai
On Tue, Mar 15, 2016 at 08:41:45PM -0700, Henry Bausley wrote:
> How does one properly permit floating point operations in an ISR in a
> kernel driver running on an ARM CPU. Our ISR is on cpu 0 and I thought
> that the code below would work. However sometimes the userspace
> application using the floating point unit will get a segmentation fault.
> The kernel driver running floating point does not have a problem. I am
> sure I am missing something here since I can use floating point in
> xenomai kernel threads without a problem.
That is because Xenomai takes care of handling the FPU context for
kernel threads. On the other hand, for irqs, you are on your own.
>
> int FloatingPointISR()
> {
> rthal_vfp_save((union vfp_state*)x, rthal_enable_fpu());
>
> // A bunch of floating point stuff
>
> rthal_vfp_load((union vfp_state*)x, 0);
> }
I guess the problem is that you do not restore at the end of the
isr, the fpu context as it was at the beginning. You can try:
int FloatingPointISR()
{
unsigned fpexc = rthal_vfp_fmrx(FPEXC);
rthal_vfp_save((union vfp_state*)x, rthal_enable_fpu());
// A bunch of floating point stuff
rthal_vfp_load((union vfp_state*)x, 0);
rthal_vfp_fmxr(FPEXC, fpexc);
}
ALso note that x can not be a thread backup area. It must be an area
specific to your ISR. And cpu, you can not share the area between
two cpus either. And if the ISR is still reentrant, you have to shut
irqs off around this piece of code, in order to avoid a context
switch (for instance by the timer irq) in the middle.
--
Gilles.
https://click-hack.org
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-16 4:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-16 3:41 [Xenomai] ARM LS1021A SMP Floating point Interrupt Service Routine Henry Bausley
2016-03-16 4:04 ` Gilles Chanteperdrix
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.