Skip to contentSkip to conversation

drm/amdgpu: drop the long-double-128 powerpc check/hack

PATCH In review Daniel Kolesa 5 participants 6 messages Feb 1, 2023 – Dec 7, 2023

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: drop the long-double-128 powerpc check/hack

Commit c653c591789b ("drm/amdgpu: Re-enable DCN for 64-bit powerpc") introduced this check as a workaround for the driver not building with toolchains that default to 64-bit long double.

The reason things worked on 128-bit-long-double toolchains and not otherwise was however largely accidental. The real issue was that some files containing floating point code were compiled without -mhard-float, while others were compiled with -mhard-float.

The PowerPC compilers tag object files that use long doubles with a special ABI tag in order to differentiate 64-bit long double, IBM long double and IEEE 128-bit long double. When no long double is used in a source file, the file does not receive the ABI tag. Since only regular doubles are used in the AMDGPU source, there is no ABI tag on the soft-float object files with 128-bit-ldbl compilers, and therefore no error. With 64-bit long double, the double and long double types are equal, and an ABI tag is introduced.

Of course, this resulted in the real bug, which was mixing of hard and soft float object files, getting hidden, which makes this check technically incorrect.

Since then, work has been done to ensure that all float code is separately compiled. This was also necessary in order to enable AArch64 support in the display stack, as AArch64 does not have any soft-float ABI, and all code that does not explicitly conatain floats is compiled with -mgeneral-regs-only, which prevents float-using code from being compiled at all. That means AArch64 support will from now on always safeguard against such cases happening ever again.

In mainline, this work is now fully done, so this check is fully redundant and does not do anything except preventing AMDGPU DC from being built on systems such as those using musl libc. The last piece of work to enable this was commit c92b7fe0d92a ("drm/amd/display: move remaining FPU code to dml folder") and this has since been backported to 6.1 stable (in 6.1.7).

Relevant issue: https://gitlab.freedesktop.org/drm/amd/-/issues/2288

---
 arch/powerpc/Kconfig                | 4 ----
 drivers/gpu/drm/amd/display/Kconfig | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)
arch/powerpc/Kconfig +0 -4
index b8c4ac56b..267805072 100644
@@ -289,10 +289,6 @@ config PPC
 	# Please keep this list sorted alphabetically.
 	#
 
-config PPC_LONG_DOUBLE_128
-	depends on PPC64 && ALTIVEC
-	def_bool $(success,test "$(shell,echo __LONG_DOUBLE_128__ | $(CC) -E -P -)" = 1)
-
 config PPC_BARRIER_NOSPEC
 	bool
 	default y
drivers/gpu/drm/amd/display/Kconfig +1 -1
index 2efe93f74..94645b6ef 100644
@@ -8,7 +8,7 @@ config DRM_AMD_DC
 	depends on BROKEN || !CC_IS_CLANG || X86_64 || SPARC64 || ARM64
 	select SND_HDA_COMPONENT if SND_HDA_CORE
 	# !CC_IS_CLANG: https://github.com/ClangBuiltLinux/linux/issues/1752
-	select DRM_AMD_DC_DCN if (X86 || PPC_LONG_DOUBLE_128 || (ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG))
+	select DRM_AMD_DC_DCN if (X86 || PPC64 || (ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG))
 	help
 	  Choose this option if you want to use the new display engine
 	  support for AMDGPU. This adds required support for Vega and
Signature · 1 line
2.34.1
#1 lore raw
FYI: kernel test robot notices the stable kernel rule is not satisfied.

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

Rule: 'Cc: [email protected]' or 'commit <sha1> upstream.'
Subject: [PATCH] drm/amdgpu: drop the long-double-128 powerpc check/hack

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Daniel Kolesa

[Public]

Quoted 48 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Daniel Kolesa
Sent: Wednesday, February 1, 2023 1:46 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] drm/amdgpu: drop the long-double-128 powerpc check/hack

Commit c653c591789b ("drm/amdgpu: Re-enable DCN for 64-bit powerpc") introduced this check as a workaround for the driver not building with toolchains that default to 64-bit long double.

The reason things worked on 128-bit-long-double toolchains and not otherwise was however largely accidental. The real issue was that some files containing floating point code were compiled without -mhard-float, while others were compiled with -mhard-float.

The PowerPC compilers tag object files that use long doubles with a special ABI tag in order to differentiate 64-bit long double, IBM long double and IEEE 128-bit long double. When no long double is used in a source file, the file does not receive the ABI tag.
Since only regular doubles are used in the AMDGPU source, there is no ABI tag on the soft-float object files with 128-bit-ldbl compilers, and therefore no error. With 64-bit long double, the double and long double types are equal, and an ABI tag is introduced.

Of course, this resulted in the real bug, which was mixing of hard and soft float object files, getting hidden, which makes this check technically incorrect.

Since then, work has been done to ensure that all float code is separately compiled. This was also necessary in order to enable
AArch64 support in the display stack, as AArch64 does not have any soft-float ABI, and all code that does not explicitly conatain floats is compiled with - mgeneral-regs-only, which prevents float-using code from being compiled at all. That means AArch64 support will from now on always safeguard against such cases happening ever again.

In mainline, this work is now fully done, so this check is fully redundant and does not do anything except preventing AMDGPU DC from being built on systems such as those using musl libc. The last piece of work to enable this was commit c92b7fe0d92a
("drm/amd/display: move remaining FPU code to dml folder") and this has since been backported to 6.1 stable (in 6.1.7).

Quoted 3 lines

Relevant issue: https://gitlab.freedesktop.org/drm/amd/-/issues/2288

Quoted 42 lines
---
 arch/powerpc/Kconfig                | 4 ----
 drivers/gpu/drm/amd/display/Kconfig | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)
arch/powerpc/Kconfig index renamed from arch/powerpc/Kconfig +0 -0

b8c4ac56b..267805072 100644

arch/powerpc/Kconfig +0 -4
@@ -289,10 +289,6 @@ config PPC
 	# Please keep this list sorted alphabetically.
 	#
 
-config PPC_LONG_DOUBLE_128
-	depends on PPC64 && ALTIVEC
-	def_bool $(success,test "$(shell,echo __LONG_DOUBLE_128__ |
 $(CC) -E -P -)" = 1)
-
 config PPC_BARRIER_NOSPEC
 	bool
arch/powerpc/Kconfig +0 -0
 	default y
drivers/gpu/drm/amd/display/Kconfig +0 -0
index 2efe93f74..94645b6ef 100644
@@ -8,7 +8,7 @@ config DRM_AMD_DC
 	depends on BROKEN || !CC_IS_CLANG || X86_64 || SPARC64 ||

ARM64

drivers/gpu/drm/amd/display/Kconfig +0 -0
 	select SND_HDA_COMPONENT if SND_HDA_CORE
 	# !CC_IS_CLANG:

https://github.com/ClangBuiltLinux/linux/issues/1752

drivers/gpu/drm/amd/display/Kconfig +0 -1
-	select DRM_AMD_DC_DCN if (X86 || PPC_LONG_DOUBLE_128 ||

(ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG))

drivers/gpu/drm/amd/display/Kconfig +1 -0
+	select DRM_AMD_DC_DCN if (X86 || PPC64 || (ARM64 &&

KERNEL_MODE_NEON
+&& !CC_IS_CLANG))

drivers/gpu/drm/amd/display/Kconfig +0 -1
 	help
 	  Choose this option if you want to use the new display engine
 	  support for AMDGPU. This adds required support for Vega and
--

2.34.1

#3 lore raw
In reply to Daniel Kolesa
Quoted 3 lines · Daniel Kolesa

Commit c653c591789b ("drm/amdgpu: Re-enable DCN for 64-bit powerpc") introduced this check as a workaround for the driver not building with toolchains that default to 64-bit long double.

...

Quoted 8 lines

In mainline, this work is now fully done, so this check is fully redundant and does not do anything except preventing AMDGPU DC from being built on systems such as those using musl libc. The last piece of work to enable this was commit c92b7fe0d92a ("drm/amd/display: move remaining FPU code to dml folder") and this has since been backported to 6.1 stable (in 6.1.7).

Relevant issue: https://gitlab.freedesktop.org/drm/amd/-/issues/2288

I looked to pick this up for 6.3 but was still seeing build errors with some compilers. I assumed that was due to some fixes coming in linux-next that I didn't have.

But applying the patch on v6.3-rc4 I still see build errors. This is building allyesconfig with the kernel.org GCC 12.2.0 / binutils 2.39 toolchain:

powerpc64le-linux-gnu-ld: drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.o uses hard float, arch/powerpc/lib/test_emulate_step.o uses soft float
powerpc64le-linux-gnu-ld: failed to merge target specific data of file drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.o

etc.

All the conflicts are between test_emulate_step.o and some file in drivers/gpu/drm/amd/display/dc/dml.

So even with all the hard-float code isolated in the dml folder, we still hit build errors, because allyesconfig wants to link those hard-float using objects with soft-float objects from elsewhere in the kernel.

It seems like the only workable fix is to force the kernel build to use 128-bit long double. I'll send a patch doing that.

cheers

#4 lore raw

Le 31/03/2023 à 12:53, Michael Ellerman a écrit :

Quoted 29 lines
Quoted 3 lines · Daniel Kolesa

Commit c653c591789b ("drm/amdgpu: Re-enable DCN for 64-bit powerpc") introduced this check as a workaround for the driver not building with toolchains that default to 64-bit long double.

...

Quoted 8 lines

In mainline, this work is now fully done, so this check is fully redundant and does not do anything except preventing AMDGPU DC from being built on systems such as those using musl libc. The last piece of work to enable this was commit c92b7fe0d92a ("drm/amd/display: move remaining FPU code to dml folder") and this has since been backported to 6.1 stable (in 6.1.7).

Relevant issue: https://gitlab.freedesktop.org/drm/amd/-/issues/2288

I looked to pick this up for 6.3 but was still seeing build errors with some compilers. I assumed that was due to some fixes coming in linux-next that I didn't have.

But applying the patch on v6.3-rc4 I still see build errors. This is building allyesconfig with the kernel.org GCC 12.2.0 / binutils 2.39 toolchain:

powerpc64le-linux-gnu-ld: drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.o uses hard float, arch/powerpc/lib/test_emulate_step.o uses soft float
powerpc64le-linux-gnu-ld: failed to merge target specific data of file drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.o

etc.

All the conflicts are between test_emulate_step.o and some file in drivers/gpu/drm/amd/display/dc/dml.

Quoted 8 lines

So even with all the hard-float code isolated in the dml folder, we still hit build errors, because allyesconfig wants to link those hard-float using objects with soft-float objects from elsewhere in the kernel.

It seems like the only workable fix is to force the kernel build to use 128-bit long double. I'll send a patch doing that.

Commit 78f0929884d4 ("powerpc/64: Always build with 128-bit long double") I guess ?

Let's drop this patch from patchwork then.

#5 lore raw
Quoted 35 lines · Christophe Leroy

Le 31/03/2023 à 12:53, Michael Ellerman a écrit :

Quoted 34 lines
Quoted 3 lines · Daniel Kolesa

Commit c653c591789b ("drm/amdgpu: Re-enable DCN for 64-bit powerpc") introduced this check as a workaround for the driver not building with toolchains that default to 64-bit long double.

...

Quoted 8 lines

In mainline, this work is now fully done, so this check is fully redundant and does not do anything except preventing AMDGPU DC from being built on systems such as those using musl libc. The last piece of work to enable this was commit c92b7fe0d92a ("drm/amd/display: move remaining FPU code to dml folder") and this has since been backported to 6.1 stable (in 6.1.7).

Relevant issue: https://gitlab.freedesktop.org/drm/amd/-/issues/2288

I looked to pick this up for 6.3 but was still seeing build errors with some compilers. I assumed that was due to some fixes coming in linux-next that I didn't have.

But applying the patch on v6.3-rc4 I still see build errors. This is building allyesconfig with the kernel.org GCC 12.2.0 / binutils 2.39 toolchain:

powerpc64le-linux-gnu-ld: drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.o uses hard float, arch/powerpc/lib/test_emulate_step.o uses soft float
powerpc64le-linux-gnu-ld: failed to merge target specific data of file drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.o

etc.

All the conflicts are between test_emulate_step.o and some file in drivers/gpu/drm/amd/display/dc/dml.

So even with all the hard-float code isolated in the dml folder, we still hit build errors, because allyesconfig wants to link those hard-float using objects with soft-float objects from elsewhere in the kernel.

Quoted 6 lines
Quoted 3 lines

It seems like the only workable fix is to force the kernel build to use 128-bit long double. I'll send a patch doing that.

Commit 78f0929884d4 ("powerpc/64: Always build with 128-bit long double") I guess ?

Yes.

Quoted 1 line

Let's drop this patch from patchwork then.

Thanks.

cheers