Message ID | 20231228014220.3562640-8-samuel.holland@sifive.com (mailing list archive) |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | Unified cross-architecture kernel-mode FPU API | expand |
Context | Check | Description |
---|---|---|
conchuod/vmtest-fixes-PR | fail | merge-conflict |
Hi, Samuel, On Thu, Dec 28, 2023 at 9:42 AM Samuel Holland <samuel.holland@sifive.com> wrote: > > LoongArch already provides kernel_fpu_begin() and kernel_fpu_end() in > asm/fpu.h, so it only needs to add kernel_fpu_available() and export > the CFLAGS adjustments. > > Acked-by: WANG Xuerui <git@xen0n.name> > Reviewed-by: Christoph Hellwig <hch@lst.de> > Signed-off-by: Samuel Holland <samuel.holland@sifive.com> > --- > > (no changes since v1) > > arch/loongarch/Kconfig | 1 + > arch/loongarch/Makefile | 5 ++++- > arch/loongarch/include/asm/fpu.h | 1 + > 3 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig > index ee123820a476..65d4475565b8 100644 > --- a/arch/loongarch/Kconfig > +++ b/arch/loongarch/Kconfig > @@ -15,6 +15,7 @@ config LOONGARCH > select ARCH_HAS_CPU_FINALIZE_INIT > select ARCH_HAS_FORTIFY_SOURCE > select ARCH_HAS_KCOV > + select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU > select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS > select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE > select ARCH_HAS_PTE_SPECIAL > diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile > index 4ba8d67ddb09..1afe28feaba5 100644 > --- a/arch/loongarch/Makefile > +++ b/arch/loongarch/Makefile > @@ -25,6 +25,9 @@ endif > 32bit-emul = elf32loongarch > 64bit-emul = elf64loongarch > > +CC_FLAGS_FPU := -mfpu=64 > +CC_FLAGS_NO_FPU := -msoft-float We will add LoongArch32 support later, maybe it should be -mfpu=32 in that case, and do other archs have the case that only support FP32? Huacai > + > ifdef CONFIG_DYNAMIC_FTRACE > KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY > CC_FLAGS_FTRACE := -fpatchable-function-entry=2 > @@ -46,7 +49,7 @@ ld-emul = $(64bit-emul) > cflags-y += -mabi=lp64s > endif > > -cflags-y += -pipe -msoft-float > +cflags-y += -pipe $(CC_FLAGS_NO_FPU) > LDFLAGS_vmlinux += -static -n -nostdlib > > # When the assembler supports explicit relocation hint, we must use it. > diff --git a/arch/loongarch/include/asm/fpu.h b/arch/loongarch/include/asm/fpu.h > index c2d8962fda00..3177674228f8 100644 > --- a/arch/loongarch/include/asm/fpu.h > +++ b/arch/loongarch/include/asm/fpu.h > @@ -21,6 +21,7 @@ > > struct sigcontext; > > +#define kernel_fpu_available() cpu_has_fpu > extern void kernel_fpu_begin(void); > extern void kernel_fpu_end(void); > > -- > 2.42.0 > >
Hi Huacai, On 2024-01-04 3:55 AM, Huacai Chen wrote: > Hi, Samuel, > > On Thu, Dec 28, 2023 at 9:42 AM Samuel Holland > <samuel.holland@sifive.com> wrote: >> >> LoongArch already provides kernel_fpu_begin() and kernel_fpu_end() in >> asm/fpu.h, so it only needs to add kernel_fpu_available() and export >> the CFLAGS adjustments. >> >> Acked-by: WANG Xuerui <git@xen0n.name> >> Reviewed-by: Christoph Hellwig <hch@lst.de> >> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> >> --- >> >> (no changes since v1) >> >> arch/loongarch/Kconfig | 1 + >> arch/loongarch/Makefile | 5 ++++- >> arch/loongarch/include/asm/fpu.h | 1 + >> 3 files changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig >> index ee123820a476..65d4475565b8 100644 >> --- a/arch/loongarch/Kconfig >> +++ b/arch/loongarch/Kconfig >> @@ -15,6 +15,7 @@ config LOONGARCH >> select ARCH_HAS_CPU_FINALIZE_INIT >> select ARCH_HAS_FORTIFY_SOURCE >> select ARCH_HAS_KCOV >> + select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU >> select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS >> select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE >> select ARCH_HAS_PTE_SPECIAL >> diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile >> index 4ba8d67ddb09..1afe28feaba5 100644 >> --- a/arch/loongarch/Makefile >> +++ b/arch/loongarch/Makefile >> @@ -25,6 +25,9 @@ endif >> 32bit-emul = elf32loongarch >> 64bit-emul = elf64loongarch >> >> +CC_FLAGS_FPU := -mfpu=64 >> +CC_FLAGS_NO_FPU := -msoft-float > We will add LoongArch32 support later, maybe it should be -mfpu=32 in > that case, and do other archs have the case that only support FP32? Do you mean that LoongArch32 does not support double-precision FP in hardware? At least both of the consumers in this series use double-precision, so my first thought is that LoongArch32 could not select ARCH_HAS_KERNEL_FPU_SUPPORT. Regards, Samuel
On Thu, Jan 4, 2024 at 11:58 PM Samuel Holland <samuel.holland@sifive.com> wrote: > > Hi Huacai, > > On 2024-01-04 3:55 AM, Huacai Chen wrote: > > Hi, Samuel, > > > > On Thu, Dec 28, 2023 at 9:42 AM Samuel Holland > > <samuel.holland@sifive.com> wrote: > >> > >> LoongArch already provides kernel_fpu_begin() and kernel_fpu_end() in > >> asm/fpu.h, so it only needs to add kernel_fpu_available() and export > >> the CFLAGS adjustments. > >> > >> Acked-by: WANG Xuerui <git@xen0n.name> > >> Reviewed-by: Christoph Hellwig <hch@lst.de> > >> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> > >> --- > >> > >> (no changes since v1) > >> > >> arch/loongarch/Kconfig | 1 + > >> arch/loongarch/Makefile | 5 ++++- > >> arch/loongarch/include/asm/fpu.h | 1 + > >> 3 files changed, 6 insertions(+), 1 deletion(-) > >> > >> diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig > >> index ee123820a476..65d4475565b8 100644 > >> --- a/arch/loongarch/Kconfig > >> +++ b/arch/loongarch/Kconfig > >> @@ -15,6 +15,7 @@ config LOONGARCH > >> select ARCH_HAS_CPU_FINALIZE_INIT > >> select ARCH_HAS_FORTIFY_SOURCE > >> select ARCH_HAS_KCOV > >> + select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU > >> select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS > >> select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE > >> select ARCH_HAS_PTE_SPECIAL > >> diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile > >> index 4ba8d67ddb09..1afe28feaba5 100644 > >> --- a/arch/loongarch/Makefile > >> +++ b/arch/loongarch/Makefile > >> @@ -25,6 +25,9 @@ endif > >> 32bit-emul = elf32loongarch > >> 64bit-emul = elf64loongarch > >> > >> +CC_FLAGS_FPU := -mfpu=64 > >> +CC_FLAGS_NO_FPU := -msoft-float > > We will add LoongArch32 support later, maybe it should be -mfpu=32 in > > that case, and do other archs have the case that only support FP32? > > Do you mean that LoongArch32 does not support double-precision FP in hardware? > At least both of the consumers in this series use double-precision, so my first > thought is that LoongArch32 could not select ARCH_HAS_KERNEL_FPU_SUPPORT. Then is it possible to introduce CC_FLAGS_SP_FPU and CC_FLAGS_DP_FPU? I think there may be some place where SP FP is enough. Huacai > > Regards, > Samuel >
On Sun, Jan 07, 2024 at 10:39:07AM +0800, Huacai Chen wrote: > > Do you mean that LoongArch32 does not support double-precision FP in hardware? > > At least both of the consumers in this series use double-precision, so my first > > thought is that LoongArch32 could not select ARCH_HAS_KERNEL_FPU_SUPPORT. > Then is it possible to introduce CC_FLAGS_SP_FPU and CC_FLAGS_DP_FPU? > I think there may be some place where SP FP is enough. Let's defer that until it is actually neeed.
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index ee123820a476..65d4475565b8 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -15,6 +15,7 @@ config LOONGARCH select ARCH_HAS_CPU_FINALIZE_INIT select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PTE_SPECIAL diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index 4ba8d67ddb09..1afe28feaba5 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -25,6 +25,9 @@ endif 32bit-emul = elf32loongarch 64bit-emul = elf64loongarch +CC_FLAGS_FPU := -mfpu=64 +CC_FLAGS_NO_FPU := -msoft-float + ifdef CONFIG_DYNAMIC_FTRACE KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY CC_FLAGS_FTRACE := -fpatchable-function-entry=2 @@ -46,7 +49,7 @@ ld-emul = $(64bit-emul) cflags-y += -mabi=lp64s endif -cflags-y += -pipe -msoft-float +cflags-y += -pipe $(CC_FLAGS_NO_FPU) LDFLAGS_vmlinux += -static -n -nostdlib # When the assembler supports explicit relocation hint, we must use it. diff --git a/arch/loongarch/include/asm/fpu.h b/arch/loongarch/include/asm/fpu.h index c2d8962fda00..3177674228f8 100644 --- a/arch/loongarch/include/asm/fpu.h +++ b/arch/loongarch/include/asm/fpu.h @@ -21,6 +21,7 @@ struct sigcontext; +#define kernel_fpu_available() cpu_has_fpu extern void kernel_fpu_begin(void); extern void kernel_fpu_end(void);