* Re: [PATCH 3/3] drm/amd/display: Support DRM_AMD_DC_FP on RISC-V
[not found] ` <20231122030621.3759313-4-samuel.holland@sifive.com>
@ 2023-11-22 8:40 ` Christoph Hellwig
2023-12-08 4:49 ` Samuel Holland
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2023-11-22 8:40 UTC (permalink / raw)
To: Samuel Holland
Cc: Peter Zijlstra, Catalin Marinas, dri-devel, linux-riscv,
David Airlie, Masahiro Yamada, Rodrigo Siqueira, amd-gfx,
Harry Wentland, Nicolas Schier, Will Deacon, linux-kbuild, Leo Li,
Nathan Chancellor, Josh Poimboeuf, linux-arm-kernel, Pan Xinhui,
Nick Desaulniers, linux-kernel, Palmer Dabbelt, Daniel Vetter,
Alex Deucher, linuxppc-dev, Christian König
> - select DRM_AMD_DC_FP if (X86 || LOONGARCH || (PPC64 && ALTIVEC) || (ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG))
> + select DRM_AMD_DC_FP if ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG
> + select DRM_AMD_DC_FP if PPC64 && ALTIVEC
> + select DRM_AMD_DC_FP if RISCV && FPU
> + select DRM_AMD_DC_FP if LOONGARCH || X86
This really is a mess. Can you add a ARCH_HAS_KERNEL_FPU_SUPPORT
symbol that all architetures that have it select instead, and them
make DRM_AMD_DC_FP depend on it?
> -#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH)
> +#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) || defined(CONFIG_RISCV)
> kernel_fpu_begin();
> #elif defined(CONFIG_PPC64)
> if (cpu_has_feature(CPU_FTR_VSX_COMP))
> @@ -122,7 +124,7 @@ void dc_fpu_end(const char *function_name, const int line)
>
> depth = __this_cpu_dec_return(fpu_recursion_depth);
> if (depth == 0) {
> -#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH)
> +#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) || defined(CONFIG_RISCV)
> kernel_fpu_end();
> #elif defined(CONFIG_PPC64)
> if (cpu_has_feature(CPU_FTR_VSX_COMP))
And then this mess can go away. We'll need to decide if we want to
cover all the in-kernel vector support as part of it, which would
seem reasonable to me, or have a separate generic kernel_vector_begin
with it's own option.
> diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile
> index ea7d60f9a9b4..5c8f840ef323 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile
> +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile
> @@ -43,6 +43,12 @@ dml_ccflags := -mfpu=64
> dml_rcflags := -msoft-float
> endif
>
> +ifdef CONFIG_RISCV
> +include $(srctree)/arch/riscv/Makefile.isa
> +# Remove V from the ISA string, like in arch/riscv/Makefile, but keep F and D.
> +dml_ccflags := -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64ima)([^v_]*)v?/\1\2/')
> +endif
> +
> ifdef CONFIG_CC_IS_GCC
> ifneq ($(call gcc-min-version, 70100),y)
> IS_OLD_GCC = 1
And this is again not really something we should be doing.
Instead we need a generic way in Kconfig to enable FPU support
for an object file or set of, that the arch support can hook
into.
Btw, I'm also really worried about folks using the FPU instructions
outside the kernel_fpu_begin/end windows in general (not directly
related to the RISC-V support). Can we have objecttool checks
for that similar to only allowing the unsafe uaccess in the
uaccess begin/end pairs?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3] drm/amd/display: Support DRM_AMD_DC_FP on RISC-V
2023-11-22 8:40 ` [PATCH 3/3] drm/amd/display: Support DRM_AMD_DC_FP on RISC-V Christoph Hellwig
@ 2023-12-08 4:49 ` Samuel Holland
2023-12-12 7:12 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Samuel Holland @ 2023-12-08 4:49 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Peter Zijlstra, Catalin Marinas, dri-devel, linux-riscv,
David Airlie, Masahiro Yamada, Rodrigo Siqueira, amd-gfx,
Harry Wentland, Nicolas Schier, Will Deacon, linux-kbuild, Leo Li,
Nathan Chancellor, Josh Poimboeuf, linux-arm-kernel, Pan Xinhui,
Nick Desaulniers, linux-kernel, Palmer Dabbelt, Daniel Vetter,
Alex Deucher, linuxppc-dev, Christian König
Hi Christoph,
On 2023-11-22 2:40 AM, Christoph Hellwig wrote:
>> - select DRM_AMD_DC_FP if (X86 || LOONGARCH || (PPC64 && ALTIVEC) || (ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG))
>> + select DRM_AMD_DC_FP if ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG
>> + select DRM_AMD_DC_FP if PPC64 && ALTIVEC
>> + select DRM_AMD_DC_FP if RISCV && FPU
>> + select DRM_AMD_DC_FP if LOONGARCH || X86
>
> This really is a mess. Can you add a ARCH_HAS_KERNEL_FPU_SUPPORT
> symbol that all architetures that have it select instead, and them
> make DRM_AMD_DC_FP depend on it?
Yes, I have done this for v2, which I will send shortly.
>> -#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH)
>> +#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) || defined(CONFIG_RISCV)
>> kernel_fpu_begin();
>> #elif defined(CONFIG_PPC64)
>> if (cpu_has_feature(CPU_FTR_VSX_COMP))
>> @@ -122,7 +124,7 @@ void dc_fpu_end(const char *function_name, const int line)
>>
>> depth = __this_cpu_dec_return(fpu_recursion_depth);
>> if (depth == 0) {
>> -#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH)
>> +#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) || defined(CONFIG_RISCV)
>> kernel_fpu_end();
>> #elif defined(CONFIG_PPC64)
>> if (cpu_has_feature(CPU_FTR_VSX_COMP))
>
> And then this mess can go away. We'll need to decide if we want to
> cover all the in-kernel vector support as part of it, which would
> seem reasonable to me, or have a separate generic kernel_vector_begin
> with it's own option.
I think we may want to keep vector separate for performance on architectures
with separate FP and vector register files. For now, I have limited my changes
to FPU support only, which means I have removed VSX/Altivec from here; the
AMDGPU code doesn't need Altivec anyway.
>> diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile
>> index ea7d60f9a9b4..5c8f840ef323 100644
>> --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile
>> +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile
>> @@ -43,6 +43,12 @@ dml_ccflags := -mfpu=64
>> dml_rcflags := -msoft-float
>> endif
>>
>> +ifdef CONFIG_RISCV
>> +include $(srctree)/arch/riscv/Makefile.isa
>> +# Remove V from the ISA string, like in arch/riscv/Makefile, but keep F and D.
>> +dml_ccflags := -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64ima)([^v_]*)v?/\1\2/')
>> +endif
>> +
>> ifdef CONFIG_CC_IS_GCC
>> ifneq ($(call gcc-min-version, 70100),y)
>> IS_OLD_GCC = 1
>
> And this is again not really something we should be doing.
> Instead we need a generic way in Kconfig to enable FPU support
> for an object file or set of, that the arch support can hook
> into.
I've included this in v2 as well.
> Btw, I'm also really worried about folks using the FPU instructions
> outside the kernel_fpu_begin/end windows in general (not directly
> related to the RISC-V support). Can we have objecttool checks
> for that similar to only allowing the unsafe uaccess in the
> uaccess begin/end pairs?
ARM partially enforces this at compile time: it disallows calling
kernel_neon_begin() inside a translation unit that has NEON enabled. That
doesn't prevent the programmer from calling a FPU-enabled function from outside
a begin/end section, but it does prevent the compiler from generating unexpected
FPU usage behind your back. I implemented this same functionality for RISC-V.
Actually tracking all possibly-FPU-tainted functions and their call sites is
probably possible, but a much larger task.
Regards,
Samuel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3] drm/amd/display: Support DRM_AMD_DC_FP on RISC-V
2023-12-08 4:49 ` Samuel Holland
@ 2023-12-12 7:12 ` Christoph Hellwig
2023-12-12 17:42 ` Josh Poimboeuf
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2023-12-12 7:12 UTC (permalink / raw)
To: Samuel Holland
Cc: Peter Zijlstra, Catalin Marinas, dri-devel, linux-riscv,
David Airlie, Masahiro Yamada, Rodrigo Siqueira, amd-gfx,
Christoph Hellwig, Harry Wentland, Nicolas Schier, Will Deacon,
linux-kbuild, Leo Li, Nathan Chancellor, Josh Poimboeuf,
linux-arm-kernel, Pan Xinhui, Nick Desaulniers, linux-kernel,
Palmer Dabbelt, Daniel Vetter, Alex Deucher, linuxppc-dev,
Christian König
On Thu, Dec 07, 2023 at 10:49:53PM -0600, Samuel Holland wrote:
> Actually tracking all possibly-FPU-tainted functions and their call sites is
> probably possible, but a much larger task.
I think objtool should be able to do that reasonably easily, it already
does it for checking section where userspace address access is enabled
or not, which is very similar.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3] drm/amd/display: Support DRM_AMD_DC_FP on RISC-V
2023-12-12 7:12 ` Christoph Hellwig
@ 2023-12-12 17:42 ` Josh Poimboeuf
0 siblings, 0 replies; 4+ messages in thread
From: Josh Poimboeuf @ 2023-12-12 17:42 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Peter Zijlstra, Catalin Marinas, dri-devel, linux-riscv,
David Airlie, Masahiro Yamada, Rodrigo Siqueira, amd-gfx,
Harry Wentland, Nicolas Schier, Will Deacon, linux-kbuild, Leo Li,
Nathan Chancellor, linux-arm-kernel, Pan Xinhui, Nick Desaulniers,
linux-kernel, Samuel Holland, Palmer Dabbelt, Daniel Vetter,
Alex Deucher, linuxppc-dev, Christian König
On Mon, Dec 11, 2023 at 11:12:42PM -0800, Christoph Hellwig wrote:
> On Thu, Dec 07, 2023 at 10:49:53PM -0600, Samuel Holland wrote:
> > Actually tracking all possibly-FPU-tainted functions and their call sites is
> > probably possible, but a much larger task.
>
> I think objtool should be able to do that reasonably easily, it already
> does it for checking section where userspace address access is enabled
> or not, which is very similar.
Yeah, that might be doable. I can look into it.
--
Josh
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-12-12 17:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20231122030621.3759313-1-samuel.holland@sifive.com>
[not found] ` <20231122030621.3759313-4-samuel.holland@sifive.com>
2023-11-22 8:40 ` [PATCH 3/3] drm/amd/display: Support DRM_AMD_DC_FP on RISC-V Christoph Hellwig
2023-12-08 4:49 ` Samuel Holland
2023-12-12 7:12 ` Christoph Hellwig
2023-12-12 17:42 ` Josh Poimboeuf
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).