graphics/drm-510-kmod is broken on aarch64 (Was: [package - main-arm64-default][graphics/drm-510-kmod] Failed for drm-510-kmod-5.10.113_7 in build)

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Fri, 21 Oct 2022 11:04:19 UTC
pkg-fallout@FreeBSD.org writes:

> /wrkdirs/usr/ports/graphics/drm-510-kmod/work/drm-kmod-drm_v5.10.113_8/drivers/dma-buf/sync_file.c:394:3: error: implicit declaration of function 'cpu_relax' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
>                 cpu_relax();
>                 ^
> /wrkdirs/usr/ports/graphics/drm-510-kmod/work/drm-kmod-drm_v5.10.113_8/drivers/dma-buf/sync_file.c:394:3: note: did you mean 'cpu_reset'?
> ./machine/cpu.h:187:6: note: 'cpu_reset' declared here
> void    cpu_reset(void) __dead2;
>         ^
> 1 error generated.

I wonder why pkg-fallout@ is silent about 13.1. aarch64 (arm64) is Tier1 since 13.0.

https://pkg-status.freebsd.org/ampere3/data/131arm64-default/9f2f3869d429/logs/errors/drm-510-kmod-5.10.113_7.log
https://pkg-status.freebsd.org/ampere1/data/131arm64-quarterly/9b8cd91058a0/logs/errors/drm-510-kmod-5.10.113_7.log

.../drm-kmod-drm_v5.10.113_8/drivers/gpu/drm/amd/display/dc/core/dc.c:741:3: error: implicit declaration of function 'DC_FP_START' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                DC_FP_START();
                ^
.../drm-kmod-drm_v5.10.113_8/drivers/gpu/drm/amd/display/dc/core/dc.c:743:3: error: implicit declaration of function 'DC_FP_END' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                DC_FP_END();
                ^
2 errors generated.

https://github.com/freebsd/drm-kmod/commit/bf687fd43411 can probably be
extended to aarch64. While enough to unbreak 13.1 I can't test runtime
due to no hardware.

diff --git a/drivers/gpu/drm/amd/display/dc/os_types.h b/drivers/gpu/drm/amd/display/dc/os_types.h
index 28ddfad27c..396907a1f2 100644
--- a/drivers/gpu/drm/amd/display/dc/os_types.h
+++ b/drivers/gpu/drm/amd/display/dc/os_types.h
@@ -55,8 +55,7 @@
 #include <asm/fpu/api.h>
 #define DC_FP_START() kernel_fpu_begin()
 #define DC_FP_END() kernel_fpu_end()
-#elif defined(CONFIG_PPC64)
-#ifdef __linux__
+#elif defined(CONFIG_PPC64) && defined(__linux__)
 #include <asm/switch_to.h>
 #include <asm/cputable.h>
 #define DC_FP_START() { \
@@ -83,12 +82,11 @@
 		preempt_enable(); \
 	} \
 }
-#elif defined(__FreeBSD__)
+#else
 #define DC_FP_START()
 #define DC_FP_END()
 #endif
 #endif
-#endif
 
 /*
  *