I have this typical requirement here:
There’s a file in kernel /arch/arm/lib/csumpartial.S which has a function named csumpartial() which computes 16-bit checksum ( which obviously is assembly coded), and this function is exported with the EXPORT symbol.
I have now implemented the same function with NEON optimizations using intrinsics which is in a file named csumpartial.c
I have the following requirements:
-
Now I want my version of function ‘csumpartial’ to be called by the calling kernel functions instead of the assembly version.
–To achieve this, should I replace the csumpartial.S file with my csumpartial.C file? But then how to replace ( what all things need to be taken care of)?
-
This csumpartial.c file should be compiled with a special compiler flags
-mfpu=neon -mfloat-abi=softfp -flax-vector-conversions -O3for NEON optimization.— So where and how to mention this compiler flag?
In short, the assembly version should be completely deprecated and the c version should be compiled with the -mfpu=neon -mfloat-abi=softfp -flax-vector-conversions -O3 flags while the kernel is compiled. And the c version of the function should be called, when someone from kernel calls csumpartial
Early help would be much appreciated.
Few inputs:
- Linux version 2.6.37
- cross compiling for arm using cross compiler tools ( cgt_a8/arm-2009q1)
- coding for ARM cortex-a8
Let me know for any more inputs
Note: Only I’ll be using this edited kernel, so I understand the risks involved with such a replacement
I have resolved this with a hack, here are the things I did to get it working:
Figured out two alternate ways to do this:
Replaced the
csumpartial.Swithcsumpartial.cunderarch/arm/lib/and sincecsumpartial.ccontains NEON instructions and has to be compiled with special compiler flags, add this line to Makefile:CFLAGS_csumpartial.o += -mfpu=neon -mfloag-abi=softfp -mflax-vector-conversions -O3(in some case this shouldn’t work, due to conflicting compiler flags to that of neon flags , during the compile time)
we can filter out the conflicting compiler flags, by using
filter-outfunction in the Makefile, but then we will have another issue that the filtered out flags wont be available for other files as well (since we want to negate out the compiler flags only for csumpartial file, so this will be a problem)so I figured out alternate way (2)
To be very clear, I did the following steps:
a. Delete the csumpartial.S from
arch/arm/libb. Remove the
csumpartial.oentry from the Makefile under this folderc. Create a new folder
neonunderarch/arm/libd. add the
csumpartial.cfile here also create a Makefile and add this to the Makefilearch/arm/lib/neon/Makefile
KBUILD_CFLAGS += -mfpu=neon -mfloat-abi=softfp -flax-vector-conversions -O3,as to negate the conflicting compiler flags during the compile time, use the following lines:
KBUILD_FLAGS := $(filter-out -compiler-flags-to-negate, $(KBUILD_FLAGS))lib-y := csumpartial.oe. to the topmost Makefile i.e.
arch/arm/Makefileadd thislibs-y+=arch/arm/lib/ arch/arm/lib/neon/that worked for me.