Skip to content
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

Closed
wants to merge 15 commits into from

Conversation

bjoto
Copy link

@bjoto bjoto commented Mar 27, 2024

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

@bjoto
Copy link
Author

bjoto commented Mar 27, 2024

Upstream branch: 4cece76
series: https://patchwork.kernel.org/project/linux-riscv/list/?series=839059
version: 3

@bjoto
Copy link
Author

bjoto commented Mar 27, 2024

Upstream branch: 4cece76
series: https://patchwork.kernel.org/project/linux-riscv/list/?series=839059
version: 3

@bjoto
Copy link
Author

bjoto commented Mar 27, 2024

Upstream branch: 4cece76
series: https://patchwork.kernel.org/project/linux-riscv/list/?series=839059
version: 3

@bjoto
Copy link
Author

bjoto commented Mar 29, 2024

Upstream branch: 4cece76
series: https://patchwork.kernel.org/project/linux-riscv/list/?series=839689
version: 4

@bjoto bjoto added V4 and removed V3 labels Mar 29, 2024
@bjoto bjoto closed this Apr 2, 2024
SiFiveHolland and others added 14 commits April 2, 2024 09:56
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>
@bjoto bjoto reopened this Apr 2, 2024
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>
@bjoto
Copy link
Author

bjoto commented Apr 2, 2024

Upstream branch: 4cece76
series: https://patchwork.kernel.org/project/linux-riscv/list/?series=839689
version: 4

@bjoto
Copy link
Author

bjoto commented Apr 2, 2024

At least one diff in series https://patchwork.kernel.org/project/linux-riscv/list/?series=839689 irrelevant now. Closing PR.

@bjoto bjoto closed this Apr 2, 2024
@bjoto bjoto deleted the series/808114=>for-next branch April 2, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants