linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Questions about FPU and NEON on Cortex-A9 with armv7 instructions!
@ 2010-07-28  6:19 David Yang
  2010-07-28  8:57 ` Martin Guy
  0 siblings, 1 reply; 7+ messages in thread
From: David Yang @ 2010-07-28  6:19 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,everyone

       Because I need use the NEON on Cortex-A9, so I want to add the
parameter : -mfpu=neon -mfloat-abi=softfp to the KBUILD_CFLAGS and
KBUILD_AFLAGS in the Makefile of the top dir like below:

################################################################################################
      ifdef CONFIG_NEON
              KBUILD_CFLAGS   += -march=armv7-a -mtune=cortex-a9
-mfpu=neon -ftree-vectorize -mfloat-abi=softfp -O3
              KBUILD_AFLAGS   += -march=armv7-a -mtune=cortex-a9
-mfpu=neon -ftree-vectorize -mfloat-abi=softfp -O3
      endif
#################################################################################################

But I fount it conflicts with  one parameter in the arch/arm/Makefile,
the parameter: -msoft-float, like below:

#################################################################################################
KBUILD_CFLAGS  +=$(CFLAGS_ABI) $(CFLAGS_THUMB2) $(arch-y) $(tune-y)
$(call cc-option,-mshort-load-bytes,$(call
cc-option,-malignment-traps,)) -msoft-float -Uarm

KBUILD_AFLAGS  +=$(CFLAGS_ABI) $(AFLAGS_THUMB2) $(arch-y) $(tune-y)
-include asm/unified.h -msoft-float
#################################################################################################

When I deleted the -msoft-float in the arch/arm/Makefile,the make of
the kernel could be completed.

My Questions:

1,What should I do to complete the make of the kernel without breaking
the compatible ,I mean do not modify the arch/arm/Makefile
    Or that change is inevitable?

2,I think the NEON is the extension of the VFP unit. If I use
-msoft-float , then the hardware of NEON and VFP will not be used?
   What should I do ,if I want to use both hardware NEON and VFP. Or I
just could use only one of them , with the switch between using
-mfpu=vfp and using -mfpu=neon?


Thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Questions about FPU and NEON on Cortex-A9 with armv7 instructions!
  2010-07-28  6:19 Questions about FPU and NEON on Cortex-A9 with armv7 instructions! David Yang
@ 2010-07-28  8:57 ` Martin Guy
  2010-07-28  9:16   ` David Yang
  0 siblings, 1 reply; 7+ messages in thread
From: Martin Guy @ 2010-07-28  8:57 UTC (permalink / raw)
  To: linux-arm-kernel

On 7/28/10, David Yang <david.yangshuai@gmail.com> wrote:
>        Because I need use the NEON on Cortex-A9, so I want to add the
>  parameter : -mfpu=neon -mfloat-abi=softfp to the KBUILD_CFLAGS and
>  KBUILD_AFLAGS in the Makefile of the top dir like below:

Hi David
   Linux never uses the FPU internally, in fact it doesn't use
floating point at all. Linux's task with the FPU is only to initialize
it so that user-space applications can use it, and to save/restore FP
register contents when two processes are both using it.
   In the kernel itself only integer math is used.

Cheers

    M

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Questions about FPU and NEON on Cortex-A9 with armv7 instructions!
  2010-07-28  8:57 ` Martin Guy
@ 2010-07-28  9:16   ` David Yang
  2010-07-28  9:31     ` Gilles Chanteperdrix
  0 siblings, 1 reply; 7+ messages in thread
From: David Yang @ 2010-07-28  9:16 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,Martin

    I see.

    But I will  try to use FPU in kernel for testing. I hope kernel won't crash.


Thank you?


On Wed, Jul 28, 2010 at 4:57 PM, Martin Guy <martinwguy@gmail.com> wrote:
> On 7/28/10, David Yang <david.yangshuai@gmail.com> wrote:
>> ? ? ? ?Because I need use the NEON on Cortex-A9, so I want to add the
>> ?parameter : -mfpu=neon -mfloat-abi=softfp to the KBUILD_CFLAGS and
>> ?KBUILD_AFLAGS in the Makefile of the top dir like below:
>
> Hi David
> ? Linux never uses the FPU internally, in fact it doesn't use
> floating point at all. Linux's task with the FPU is only to initialize
> it so that user-space applications can use it, and to save/restore FP
> register contents when two processes are both using it.
> ? In the kernel itself only integer math is used.
>
> Cheers
>
> ? ?M
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Questions about FPU and NEON on Cortex-A9 with armv7 instructions!
  2010-07-28  9:16   ` David Yang
@ 2010-07-28  9:31     ` Gilles Chanteperdrix
  2010-07-28 10:06       ` David Yang
  0 siblings, 1 reply; 7+ messages in thread
From: Gilles Chanteperdrix @ 2010-07-28  9:31 UTC (permalink / raw)
  To: linux-arm-kernel

David Yang wrote:
> Hi,Martin
> 
>     I see.
> 
>     But I will  try to use FPU in kernel for testing. I hope kernel won't crash.

You will not get FPU working in kernel-space without any effort. The
kernel handles lazy switching of FPU context for user-space tasks, but
not for the kernel itself. If you start using the FPU at any place in
the kernel, the changes you made would clobber the FPU context of the
user-space task currently running, which is probably not what you want.

What you will have to do is what the x86 kernel does in the RAID code
for instance (file drivers/md/raid6mmx.c), disable preemption, save the
fpu context, do your computations, then restore the fpu context and
re-enable preemption. For the operation to be worth it, the gain you
obtain by using the FPU has to be greater than the time for an fpu
context save and restore, and saving/restoring the fpu context is a
pretty heavy operation. This means that if you want the FPU for a
multiplication or a division, forget it, you will actually be loosing
time, and soft-float will be more efficient.

-- 
					    Gilles.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Questions about FPU and NEON on Cortex-A9 with armv7 instructions!
  2010-07-28  9:31     ` Gilles Chanteperdrix
@ 2010-07-28 10:06       ` David Yang
  2010-07-28 10:45         ` Gilles Chanteperdrix
  2010-07-28 10:46         ` Arnd Bergmann
  0 siblings, 2 replies; 7+ messages in thread
From: David Yang @ 2010-07-28 10:06 UTC (permalink / raw)
  To: linux-arm-kernel

My God...

The job for the FPU is big enough.

But I am not sure the kernel itself won't use the FPU . And I just
want to use FPU in my driver other than the whole kernel.

If the other kernel code doesn't save and restore the FPU context,then
it's risky.

Can I use FPU just in one C file ?

On Wed, Jul 28, 2010 at 5:31 PM, Gilles Chanteperdrix
<gilles.chanteperdrix@xenomai.org> wrote:
> David Yang wrote:
>> Hi,Martin
>>
>> ? ? I see.
>>
>> ? ? But I will ?try to use FPU in kernel for testing. I hope kernel won't crash.
>
> You will not get FPU working in kernel-space without any effort. The
> kernel handles lazy switching of FPU context for user-space tasks, but
> not for the kernel itself. If you start using the FPU at any place in
> the kernel, the changes you made would clobber the FPU context of the
> user-space task currently running, which is probably not what you want.
>
> What you will have to do is what the x86 kernel does in the RAID code
> for instance (file drivers/md/raid6mmx.c), disable preemption, save the
> fpu context, do your computations, then restore the fpu context and
> re-enable preemption. For the operation to be worth it, the gain you
> obtain by using the FPU has to be greater than the time for an fpu
> context save and restore, and saving/restoring the fpu context is a
> pretty heavy operation. This means that if you want the FPU for a
> multiplication or a division, forget it, you will actually be loosing
> time, and soft-float will be more efficient.
>
> --
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Gilles.
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Questions about FPU and NEON on Cortex-A9 with armv7 instructions!
  2010-07-28 10:06       ` David Yang
@ 2010-07-28 10:45         ` Gilles Chanteperdrix
  2010-07-28 10:46         ` Arnd Bergmann
  1 sibling, 0 replies; 7+ messages in thread
From: Gilles Chanteperdrix @ 2010-07-28 10:45 UTC (permalink / raw)
  To: linux-arm-kernel

David Yang wrote:
> My God...
> 
> The job for the FPU is big enough.
> 
> But I am not sure the kernel itself won't use the FPU .

Of that you are sure: on ARM, the kernel does not use the FPU.

 And I just
> want to use FPU in my driver other than the whole kernel.
> 
> If the other kernel code doesn't save and restore the FPU context,then
> it's risky.
> 
> Can I use FPU just in one C file ?

Apparently, I could not make myself clear. So, looking at the code will
probably help you understand better.
drivers/md/raid6mmx.c and arch/x86/lib/mmx_32.c use fpu in kernel-space.
You just have to do it the same way.


-- 
					    Gilles.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Questions about FPU and NEON on Cortex-A9 with armv7 instructions!
  2010-07-28 10:06       ` David Yang
  2010-07-28 10:45         ` Gilles Chanteperdrix
@ 2010-07-28 10:46         ` Arnd Bergmann
  1 sibling, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2010-07-28 10:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Wednesday 28 July 2010, David Yang wrote:
> If the other kernel code doesn't save and restore the FPU context,then
> it's risky.
> 
> Can I use FPU just in one C file ?

Usually if you need something like this, you're doing something wrong.
Code that does a lot of computation should go generally live in user
space, not a kernel module, though there are a few exceptions.

Take a look at how drivers/md/raid6sse2.c uses kernel_fpu_begin() to
do this on x86.

	Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-07-28 10:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-28  6:19 Questions about FPU and NEON on Cortex-A9 with armv7 instructions! David Yang
2010-07-28  8:57 ` Martin Guy
2010-07-28  9:16   ` David Yang
2010-07-28  9:31     ` Gilles Chanteperdrix
2010-07-28 10:06       ` David Yang
2010-07-28 10:45         ` Gilles Chanteperdrix
2010-07-28 10:46         ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).