New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unified cross-architecture kernel-mode FPU API #803
Conversation
Upstream branch: 4cece76 |
Upstream branch: 4cece76 |
12077fc
to
ecc874c
Compare
Upstream branch: 4cece76 |
ecc874c
to
b2f17f6
Compare
Upstream branch: 4cece76 |
b2f17f6
to
e683d65
Compare
Several architectures provide an API to enable the FPU and run floating-point SIMD code in kernel space. However, the function names, header locations, and semantics are inconsistent across architectures, and FPU support may be gated behind other Kconfig options. Provide a standard way for architectures to declare that kernel space FPU support is available. Architectures selecting this option must implement what is currently the most common API (kernel_fpu_begin() and kernel_fpu_end(), plus a new function kernel_fpu_available()) and provide the appropriate CFLAGS for compiling floating-point C code. Suggested-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
ARM provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. Add a wrapper header, and export CFLAGS adjustments as found in lib/raid6/Makefile. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Now that CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
arm64 provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. Add a wrapper header, and export CFLAGS adjustments as found in lib/raid6/Makefile. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Now that CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Now that CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
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> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
PowerPC provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. The PowerPC API also requires a non-preemptible context. Add a wrapper header, and export the CFLAGS adjustments. Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc) Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
The include guard should match the filename, or it will conflict with the newly-added asm/fpu.h. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
x86 already provides kernel_fpu_begin() and kernel_fpu_end(), but in a different header. Add a wrapper header, and export the CFLAGS adjustments as found in lib/Makefile. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
This is motivated by the amdgpu DRM driver, which needs floating-point code to support recent hardware. That code is not performance-critical, so only provide a minimal non-preemptible implementation for now. Support is limited to riscv64 because riscv32 requires runtime (libgcc) assistance to convert between doubles and 64-bit integers. Acked-by: Palmer Dabbelt <palmer@rivosinc.com> Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
The compiler flags enable altivec, but that is not required; hard-float is sufficient for the code to build and function. Drop altivec from the compiler flags and adjust the enable/disable code to only enable FPU use. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Now that all previously-supported architectures select ARCH_HAS_KERNEL_FPU_SUPPORT, this code can depend on that symbol instead of the existing list of architectures. It can also take advantage of the common kernel-mode FPU API and method of adjusting CFLAGS. Acked-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
This ensures no compiler-generated floating-point code can appear outside kernel_fpu_{begin,end}() sections, and some architectures enforce this separation. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Now that ARCH_HAS_KERNEL_FPU_SUPPORT provides a common way to compile and run floating-point code, this test is no longer x86-specific. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Upstream branch: 4cece76 |
e683d65
to
617253b
Compare
At least one diff in series https://patchwork.kernel.org/project/linux-riscv/list/?series=839689 irrelevant now. Closing PR. |
Pull request for series with
subject: Unified cross-architecture kernel-mode FPU API
version: 3
url: https://patchwork.kernel.org/project/linux-riscv/list/?series=839059