Created attachment 251578 [details] cd /usr/ports/graphics/drm-61-kmod && make uname -aKU: FreeBSD powerkek 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC powerpc 1401000 1401000 TLDR: /usr/ports/graphics/drm-61-kmod/work/drm-kmod-drm_v6.1.69_2/drivers/gpu/drm/drm_cache.c:358:10: error: call to undeclared function 'in_interrupt'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 358 | WARN_ON(in_interrupt()); | ^ 1 error generated. *** [drm_cache.o] Error code 1
Created attachment 254592 [details] Allow build on powerpc64
I also tried to build this and discovered that powerpc64 support is broken here and in drm-515-kmod. The attached patch allows you to get past this error but you'll encounter other errors. After, further investigation and troubleshooting t I found missing kernel files in "sys/compat/linuxkpi/common/include/asm". The missing files are cputable.h and switch_to.h (there may be more). This leads me to believe that kernel support for powerpc64, beyond drm-510, is broken. As even after a successfully build, it will does not work. I get a drm version error on boot.
Created attachment 257959 [details] Fix for drm-61-kmod to build This patch should get it building (sort of transcribed it from a poudriere build session, but should be close enough) for powerpc64. However, I never tested the resulting package.
Created attachment 258740 [details] Fix for drm-61-kmod to build and load With this new patch drm-61-kmod builds and loads. I haven't tested if it actually works, as I loaded it in a VM. But it does load, no symbol errors or anything. However, the patch to drm_os_freebsd.c obviously can't be pushed, since it would likely break x86 (and arm64, possibly).
Can't the patch to drm_os_freebsd.c be also put behind #if defined(CONFIG_X86)?
Or maybe #if !defined(CONFIG_PPC64)
(In reply to Piotr Kubaj from comment #6) Probably one of those. This was a starting point just to get it building, so others can test functionality.
Created attachment 268925 [details] poudriere log I am getting a different error with and without the patch: /wrkdirs/usr/ports/graphics/drm-61-kmod/work/drm-kmod-drm_v6.1.128_7/drivers/gpu/drm/drm_cache.c:358:10: error: call to undeclared function 'in_interrupt'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 358 | WARN_ON(in_interrupt()); | ^
It is a Talos II system with an AMD GPU. From pciconf -lv: vgapci0@pci0:3:0:0: class=0x030000 rev=0xc1 hdr=0x00 vendor=0x1002 device=0x66af subvendor=0x1002 subdevice=0x081e vendor = 'Advanced Micro Devices, Inc. [AMD/ATI]' device = 'Vega 20 [Radeon VII]' class = display subclass = VGA Anything I can do to help with drm-kmod?
(In reply to yzrh from comment #9) I have looked into the code base. Unfortunately the drivers have bitrotted for ppc64le. Some nontrivial work will be needed to make them work.
I believe the problem is in LinuxKPI and missing "hidden #includes" to get preempt.h into the files on non-X86 which includes asm/smp.h already to get there. Looking at the patch from #c4 it seems this is not the only problem though with the patch from https://reviews.freebsd.org/D55974 I at least can cross-compile drm-kmod 6.1-lts on main for powerpc[64le]. Can you give that patch a try and let us know if further errors happen?
It builds fine with both patches, but the module does not load correctly: The first time kldload crashed the system and subsequent kldload displays kldload: can't load /boot/modules/amdgpu.ko: No such file or directory in console and KLD amdgpu.ko: depends on drmn - not available or version mismatch in /var/log/messages
(In reply to yzrh from comment #12) > It builds fine with both patches, But in comment #c8 you said you get an error with and without a patch. I'll get the LinuxKPI changes into the tree at least. > KLD amdgpu.ko: depends on drmn - not available or version mismatch might be interesting to know more. Are the modules part of the package? if you check the installed files, do they have the correct date? Do you have another copy lying around? What does dmesg -a | tail -50 say right after you try to kldload amdgpu? Is there a more detailed error?
(In reply to Bjoern A. Zeeb from comment #13) I meant both patches (D55974 and #c4). > might be interesting to know more. Are the modules part of the package? if you check the installed files, do they have the correct date? Do you have another copy lying around? What does dmesg -a | tail -50 say right after you try to kldload amdgpu? Is there a more detailed error? I pkg remove and pkg install drm-kmod again (pulls in drm-61-kmod; built by poudriere) to be sure. When kldload amdgpu, the system reboots immediately just like before. Maybe the crash corrupted the files, which affected subsequent kldload. Now it reboots every time I kldload amdgpu (I executed sync after pkg install this time). I do see entries in dmesg: savecore 84011 - - reboot after panic: mmu_radix_mapdev_attr: Couldn't alloc kernel virtual memory Mar 21 12:58:18 localhost savecore[84011]: reboot after panic: mmu_radix_mapdev_attr: Couldn't alloc kernel virtual memory savecore 84011 - - writing core to /var/crash/vmcore.4 Writing crash summary to /var/crash/core.txt.4. The system is on stable/15-1b7687f053af-dirty.
(In reply to yzrh from comment #12) Which version of FreeBSD do you run? The drm-kmod version must match your kernel. drm-61-kmod is for FreeBSD 14 only.
(In reply to yzrh from comment #14) That's a powerpc issue now. Can you possibly share the /var/crash/core.txt.4 file for the people to look at this? If not the full file (showing processes etc. as well), then at the top there are backtraces up to a first line with ------------------------------------------------------------------------ which may be good to have, and then the section starting with a long line titles "dmesg" as well. Thanks a lot for doing all the testing and helping to debug this!
(In reply to Robert Clausecker from comment #15) The system is on stable/15-1b7687f053af-dirty (patch from D55974). Looking at https://cgit.freebsd.org/ports/tree/graphics/drm-kmod/Makefile graphics/drm-66-kmod seems to support amd64 only. For powerpc64[le], only options are graphics/drm-510-kmod (not available for stable/15) and graphics/drm-61-kmod.
(In reply to Bjoern A. Zeeb from comment #16) The file reads: Unable to find a kernel debugger. Please install the devel/gdb port or gdb package. Let me crash again with gdb (building now).
(In reply to yzrh from comment #17) > graphics/drm-66-kmod seems to support amd64 only. Yes, this is because the DRM code has rotten on powerpc64le and doesn't build. I have tried to make some inroads with fixing it, but didn't have the time to get far.
Created attachment 268982 [details] core.txt
I am not sure what went wrong, but I am getting Failed to open vmcore: invalid corefile I am uploading the corefile as well, just in case it is useful. Too big for bugzilla: https://etc.noema.org/drop/k1rp.xz
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=1d18872c2519d7ca726ddc49735180ab1d8916e0 commit 1d18872c2519d7ca726ddc49735180ab1d8916e0 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2026-03-19 20:29:29 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2026-03-21 21:16:43 +0000 LinuxKPI: add supporting #includes Compiling drm-kmod on !X86 does not include asm/smp.h which includes preempt.h on FreeBSD. In order to compile drm-kmod on other architectures add the secondary #includes for preempt.h to spinlock.h and hardirq.h (which now also gets included from highmem.h) to connect the #include chain. Sponsored by: The FreeBSD Foundation MFC after: 3 days PR: 279864 Reviewed by: jhibbits, emaste Differential Revision: https://reviews.freebsd.org/D55974 sys/compat/linuxkpi/common/include/linux/hardirq.h | 1 + sys/compat/linuxkpi/common/include/linux/highmem.h | 1 + sys/compat/linuxkpi/common/include/linux/spinlock.h | 1 + 3 files changed, 3 insertions(+)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=29dce45d8c50ea5858dc91a4294e83b8d72a2f80 commit 29dce45d8c50ea5858dc91a4294e83b8d72a2f80 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2026-03-19 20:29:29 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2026-03-31 16:22:51 +0000 LinuxKPI: add supporting #includes Compiling drm-kmod on !X86 does not include asm/smp.h which includes preempt.h on FreeBSD. In order to compile drm-kmod on other architectures add the secondary #includes for preempt.h to spinlock.h and hardirq.h (which now also gets included from highmem.h) to connect the #include chain. Sponsored by: The FreeBSD Foundation PR: 279864 Reviewed by: jhibbits, emaste Differential Revision: https://reviews.freebsd.org/D55974 (cherry picked from commit 1d18872c2519d7ca726ddc49735180ab1d8916e0) sys/compat/linuxkpi/common/include/linux/hardirq.h | 1 + sys/compat/linuxkpi/common/include/linux/highmem.h | 1 + sys/compat/linuxkpi/common/include/linux/spinlock.h | 1 + 3 files changed, 3 insertions(+)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=7d069d7846519eb015133758647ee343e7d7f20a commit 7d069d7846519eb015133758647ee343e7d7f20a Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2026-03-19 20:29:29 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2026-04-01 04:33:47 +0000 LinuxKPI: add supporting #includes Compiling drm-kmod on !X86 does not include asm/smp.h which includes preempt.h on FreeBSD. In order to compile drm-kmod on other architectures add the secondary #includes for preempt.h to spinlock.h and hardirq.h (which now also gets included from highmem.h) to connect the #include chain. Sponsored by: The FreeBSD Foundation PR: 279864 Reviewed by: jhibbits, emaste Differential Revision: https://reviews.freebsd.org/D55974 (cherry picked from commit 1d18872c2519d7ca726ddc49735180ab1d8916e0) (cherry picked from commit 29dce45d8c50ea5858dc91a4294e83b8d72a2f80) sys/compat/linuxkpi/common/include/linux/hardirq.h | 1 + sys/compat/linuxkpi/common/include/linux/highmem.h | 1 + sys/compat/linuxkpi/common/include/linux/spinlock.h | 1 + 3 files changed, 3 insertions(+)