On Wed, 14 Oct 2026 02:41:17 +0900
Tomoaki AOKI <[email protected]> wrote:
> On Mon, 12 Oct 2026 22:42:27 +0000 (UTC)
> "Bjoern A. Zeeb" <[email protected]> wrote:
>
> > On Tue, 13 Oct 2026, Tomoaki AOKI wrote:
> >
> > > On Mon, 12 Oct 2026 18:13:40 +0000 (UTC)
> > > "Bjoern A. Zeeb" <[email protected]> wrote:
> > >
> > >> On Tue, 13 Oct 2026, Tomoaki AOKI wrote:
> > >>
> > >>> On Mon, 12 Oct 2026 17:21:39 +0200
> > >>> A FreeBSD User <[email protected]> wrote:
> > >>>
> > >>>> Am Tage des Herren Sun, 11 Oct 2026 22:07:36 +0100
> > >>>> Nuno Teixeira <[email protected]> schrieb:
> > >>>>
> > >>>>> Hello,
> > >>>>>
> > >>>>> 37:
> > >>>>>> /usr/src/sys/compat/linuxkpi/common/include/linux/kernel.h:33:10:
> > >>>>>> fatal
> > >>>>>> error: 'opt_linuxkpi.h' file not found
> > >>>>>> 33 | #include "opt_linuxkpi.h"
> > >>>>>> | ^~~~~~~~~~~~~~~~
> > >>>>>
> > >>>>>
> > >>>>> I've reported today at
> > >>>>> https://lists.freebsd.org/archives/dev-commits-src-all/2026-October/082012.html
> > >>>>>
> > >>>>> Cheers,
> > >>>>>
> > >>>>
> > >>>> Ups. I did also for port graphics/drm-612-kmod a few minutes ago. The
> > >>>> header file in question
> > >>>> is simply not in the most recent source tree ... very strange ;-)
> > >>>
> > >>> Good point.
> > >>>
> > >>> It SHOULDN'T be under /usr/src/, but under /usr/obj/, as it's generated
> > >>> on "kernel build time".
> > >>>
> > >>> This means, it shouldn't exist unless you built kernel
> > >>> yourself locally.
> > >>>
> > >>> Thus, I believe it SHOULDN'T be required for out-of-tree
> > >>> kmods (in ports or in the wild).
> > >>>
> > >>> If it's REALLY mandatory for out-of-tree kmod builds
> > >>> and fix in out-of-tree kmod side, error message to request
> > >>> local kernel builds first should be needed.
> > >>>
> > >>> If not, guards for #include NOT to be included except for
> > >>> kernel builds in src side would be the best fix.
> > >>>
> > >>> IIRC, it's the way usually done for this kind of situations,
> > >>> but I'm not enough sure if opt_linuxkpi.h is really mandatory
> > >>> or not for out-of-tree kmod builds.
> > >>>
> > >>> Note that, as far as I could confirm, there are 3 headers
> > >>> attempting to include opt_linuxkpi.h in offending commits
> > >>> (at least). And LINUXKPI_DEBUG could be appropreate to be
> > >>> used for safeguard?
> > >>>
> > >>> /usr/src/sys/compat/linuxkpi/common/include/linux/spinlock.h
> > >>> /usr/src/sys/compat/linuxkpi/common/include/linux/kconfig.h
> > >>> /usr/src/sys/compat/linuxkpi/common/include/linux/kernel.h
> > >>
> > >> The sole problem here is that drm-kmod is handrolling stuff
> > >> instead of using the kmod,mk provided defines.
> > >
> > > I think pulling in something from /usr/obj/ for ports kmods
> > > itself is a bad idea, as it's NOT guaranteed to be existing
> > > on invoking `make` in ports directory when stable/16 and
> > > releng/16.0 are branched in the future for anyone NOT building
> > > base locally.
> >
> > This is all normal "magic" for SRCS.
> >
> > The file will get created (empty) in the obj dir if there is no
> > KERNBUILDDIR set.
> >
> > Given the obj dir for the ports build is set to be in the port's WRKSRC dir:
> >
> > MAKE_ENV+= MAKEOBJDIRPREFIX=${WRKSRC}/obj
>
> Ah, thanks! I've overlooked the functionalitiy.
> And saw several ports (sorry, lost track with which) failed
> to build with the lack of opt_*.h and fixed by introducing
> guards to the #include line for out-of-tree builds before.
>
>
> > >From somehwere in there (I trimmed paths) you can see all these opt_*.h
> > got created and it has nothing to do with /usr/obj.
> >
> > % pwd
> > /ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/obj/
> > % find . -name "opt*" -ls
> > 79776217 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/dmabuf/opt_linuxkpi.h
> > 79776218 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/dmabuf/opt_stack.h
> > 79776219 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/dmabuf/opt_usb.h
> > 79776220 8 -rw-r--r-- 1 root wheel 115 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/dmabuf/opt_global.h
> > 79776259 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/ttm/opt_linuxkpi.h
> > 79776260 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/ttm/opt_stack.h
> > 79776261 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/ttm/opt_usb.h
> > 79776262 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/ttm/opt_drm.h
> > 79776263 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/ttm/opt_vm.h
> > 79776264 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/ttm/opt_syscons.h
> > 79776265 8 -rw-r--r-- 1 root wheel 115 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/ttm/opt_global.h
> > 79776312 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/drm/opt_linuxkpi.h
> > 79776313 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/drm/opt_stack.h
> > 79776314 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/drm/opt_usb.h
> > 79776315 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/drm/opt_teken.h
> > 79776316 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/drm/opt_splash.h
> > 79776317 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/drm/opt_syscons.h
> > 79776318 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/drm/opt_drm.h
> > 79776319 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/drm/opt_vm.h
> > 79776320 8 -rw-r--r-- 1 root wheel 115 Oct 12 10:48
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/drm/opt_global.h
> > 79776514 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:49
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/amd/amdgpu/opt_linuxkpi.h
> > 79776515 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:49
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/amd/amdgpu/opt_stack.h
> > 79776516 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:49
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/amd/amdgpu/opt_usb.h
> > 79776517 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:49
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/amd/amdgpu/opt_drm.h
> > 79776518 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:49
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/amd/amdgpu/opt_vm.h
> > 79776519 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:49
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/amd/amdgpu/opt_syscons.h
> > 79776520 0 -rw-r--r-- 1 root wheel 0 Oct 12 10:49
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/amd/amdgpu/opt_acpi.h
> > 79776521 8 -rw-r--r-- 1 root wheel 115 Oct 12 10:49
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/amd/amdgpu/opt_global.h
> > 79778169 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:00
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/radeon/opt_acpi.h
> > 79778173 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:00
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/radeon/opt_linuxkpi.h
> > 79778174 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:00
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/radeon/opt_stack.h
> > 79778175 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:00
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/radeon/opt_usb.h
> > 79778176 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:00
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/radeon/opt_drm.h
> > 79778177 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:00
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/radeon/opt_vm.h
> > 79778178 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:00
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/radeon/opt_syscons.h
> > 79778179 8 -rw-r--r-- 1 root wheel 115 Oct 12 11:00
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/radeon/opt_global.h
> > 79778402 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:02
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/i915/opt_linuxkpi.h
> > 79778403 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:02
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/i915/opt_stack.h
> > 79778404 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:02
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/i915/opt_usb.h
> > 79778405 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:02
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/i915/opt_acpi.h
> > 79778406 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:02
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/i915/opt_drm.h
> > 79778407 0 -rw-r--r-- 1 root wheel 0 Oct 12 11:02
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/i915/opt_syscons.h
> > 79778408 8 -rw-r--r-- 1 root wheel 115 Oct 12 11:02
> > ./ports/graphics/drm-612-kmod/work/drm-kmod-drm_v6.12.110_1/i915/opt_global.h
> >
> >
> > Whether or not this gives different options than a kernel build is a
> > different
> > story but the same goes for stand-alone builds of modules within
> > src/sys/modules;
> > just check sys/modules/pfsync/Makefile for an example.
> >
> > But you will also find that the generated opt_global.h files do have values
> > set
> > which come out of sys/conf/config.mk defaults.
>
> Yes, pt_global.h alone (but in multiple places) has actual contents,
> and others are 0 in size, including opt_linuxkpi.h on main for me.
>
>
> > >> Apply the changes from the pull request and what's in drm-kmod
> > >> master already and it'll build along with a kernel, as a standalone
> > >> git checkout or from ports. If there's a 4th method, please let me
> > >> know.
> > >
> > > Putting attached file (made the change to fit for files/ without
> > > touching ports Makefile) into files/ directory of each
> > > graphics/drm-*-kmod may be easier to test.
> > >
> > > Confirmed causing no harm on build for graphics/drm-612-kmod
> > > and graphics/nvidia-drm-612-kmod-devel on stable/15 (there's no
> > > opt_linuxkpi.h under /usr/obj/). But unfortunately I don't
> > > have time to switch to main for now.
> >
> > If you followed the github PR you will know you need another
> > change from drm-kmod master to also be dropped into files/
> > for the drm-kmod ports (and the nvidia ones). I'd rather hope
> > someone can roll a new drm-kmod tag for the few branches.
>
> Reconfirmed. Attached patch-conpiler_flags.mk would be it.
> Included in the patch mentioned below.
>
>
> > > Maybe graphics/nvidia-drm-kmod/Makefile.common would need
> > > to have additional hack to pick the patch, as files/ in
> > > each graphics/nvidia-drm-*-kmod* are to be applied to
> > > NVIDIA parts only (DRM parts are extracted along"side").
>
> Turned out graphics/nvidia-drm-*-kmod* (at least
> graphics/nvidia-drm-612-kmod*) need additional work.
> And to simplify changes in graphics/nvidia-drm-kmod/Makefile.common,
> additional (to be backed out later) changes are made.
>
> Does attached
>
> InterimPatchForFixBuild-after-src-main-git-9820afb99e6f-for-drm-kmod-ports-v2.diff
> look reasonable?
>
> As the patches for graphics/drm-*-kmod don't apply normally
> for graphics/drm-515-kmod, currently excluded from the patch.
> And currently doesn't work for graphics/nvidia-drm-{515|61|66}-kmod*
> so need more investigation. Would try later for NVIDIA parts.
Noticed typos (fat fingered!) on broken NVIDIA counterparts
and lack of guard for 515 in graphics/nvidia-drm-kmod/Makefile.common.
Attached should be OK for other than excluded graphics/drm-515-kmod
parts. poudriere builds went fine on stable/15.
Anyway, this patch is interim, not permanent.
graphics/drm-*-kmod part should be removed once these ports
are updated.
And at the same time, abnormal hack to apply graphics/drm-*-kmod
parts of patches onto extracted distfile for NVIDIA counterparts
should be reverted.
So once acutual fixes for graphics/drm-*-kmod part are done,
I'll file a PR / open a review for finished NVIDIA counterparts.
Regards.
> But for 612 (drm) / -devel (nvidia) variants, built and run fine
> on main at commit a3fbf20c0558 and stable/15 at commit 63e5c83e8db3.
>
> Ports other than the two are tried build only on poudriere
> running under stable/15 (builder jail matches with bare-metal).
>
> I don't have poudriere installed on main as of too often
> __FreeBSD_version bumps compared to stable/*, causing forcible
> full builds.
>
> Regards.
>
> > >
> > >
> > >> As a plus (once cleanup gets done beyond initial repair), in the
> > >> future this kind of breakage shouldn't happen anymore and there's
> > >> going to be a single place to track SRCS+= and CFLAGS+= dependencies
> > >> needed to use LinuxKPI.
> > >>
> > >> So yes, please see https://github.com/freebsd/drm-kmod/pull/524
> >
> > --
> > For there shall arise false Christs, and false prophets, and shall shew
> > great signs and wonders; insomuch that, if it were possible, they shall
> > deceive the very elect. Behold, I have told you before. [Mat. 24:24-25]
>
>
> --
> Tomoaki AOKI <[email protected]>
--
Tomoaki AOKI <[email protected]>
diff --git a/graphics/drm-61-kmod/files/patch-compiler_flags.mk b/graphics/drm-61-kmod/files/patch-compiler_flags.mk
new file mode 100644
index 000000000000..1021130ee473
--- /dev/null
+++ b/graphics/drm-61-kmod/files/patch-compiler_flags.mk
@@ -0,0 +1,16 @@
+--- compiler_flags.mk
++++ compiler_flags.mk
+@@ -7,6 +7,13 @@
+ CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/compiler_types.h
+ .endif
+
++# Other headers are always included. See the definition of `$(USERINCLUDE)` in
++# the Makefile at the root of the Linux source tree.
++.if exists(${SYSDIR}/compat/linuxkpi/common/include/linux/compiler-version.h)
++CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/compiler-version.h
++.endif
++CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/kconfig.h
++
+ CWARNFLAGS+= -Wno-pointer-sign
+
+ # Globally silence a new warning from Clang 21.
diff --git a/graphics/drm-61-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7 b/graphics/drm-61-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7
new file mode 100644
index 000000000000..0c55a14991a8
--- /dev/null
+++ b/graphics/drm-61-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7
@@ -0,0 +1,104 @@
+--- amd/amdgpu/Makefile
++++ amd/amdgpu/Makefile
+@@ -1261,7 +1261,8 @@ SRCS+= amd_powerplay.c \
+ SRCS+= amdgpu_pmu.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- amd/amdkfd/Makefile
++++ amd/amdkfd/Makefile
+@@ -39,7 +39,8 @@ SRCS = \
+ kfd_queue.c #\
+ # kfd_topology.c
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- dmabuf/Makefile
++++ dmabuf/Makefile
+@@ -18,7 +18,8 @@ SRCS= dma-buf-kmod.c \
+ dma-resv.c \
+ sync_file.c
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ bus_if.h \
+ vnode_if.h
+
+--- drm/Makefile
++++ drm/Makefile
+@@ -155,7 +155,8 @@ SRCS+= drm_client.c \
+ SRCS+= drm_client_setup.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- dummygfx/Makefile
++++ dummygfx/Makefile
+@@ -14,6 +14,7 @@ SRCS= \
+ dummygfx_debugfs.c
+
+ SRCS += \
++ ${LINUXKPI_GENSRCS} \
+ opt_acpi.h \
+ opt_drm.h \
+ opt_platform.h \
+--- i915/Makefile
++++ i915/Makefile
+@@ -353,6 +353,7 @@ SRCS+= i915_hwmon.c
+ # intel_lpe_audio.c # Need platform and irq_chip support
+
+ SRCS += \
++ ${LINUXKPI_GENSRCS} \
+ opt_acpi.h \
+ opt_drm.h \
+ opt_syscons.h \
+--- linuxkpi_video/Makefile
++++ linuxkpi_video/Makefile
+@@ -20,7 +20,8 @@ SRCS+= aperture.c
+ SRCS+= cmdline.c
+ .endif
+
+-SRCS+= bus_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ bus_if.h \
+ device_if.h \
+ pci_if.h \
+ vnode_if.h \
+--- radeon/Makefile
++++ radeon/Makefile
+@@ -115,7 +115,8 @@ SRCS+= opt_acpi.h \
+ radeon_acpi.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- ttm/Makefile
++++ ttm/Makefile
+@@ -26,7 +26,8 @@ SRCS= ttm_bo.c \
+ SRCS+= ttm_agp_backend.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
diff --git a/graphics/drm-612-kmod/files/patch-compiler_flags.mk b/graphics/drm-612-kmod/files/patch-compiler_flags.mk
new file mode 100644
index 000000000000..1021130ee473
--- /dev/null
+++ b/graphics/drm-612-kmod/files/patch-compiler_flags.mk
@@ -0,0 +1,16 @@
+--- compiler_flags.mk
++++ compiler_flags.mk
+@@ -7,6 +7,13 @@
+ CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/compiler_types.h
+ .endif
+
++# Other headers are always included. See the definition of `$(USERINCLUDE)` in
++# the Makefile at the root of the Linux source tree.
++.if exists(${SYSDIR}/compat/linuxkpi/common/include/linux/compiler-version.h)
++CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/compiler-version.h
++.endif
++CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/kconfig.h
++
+ CWARNFLAGS+= -Wno-pointer-sign
+
+ # Globally silence a new warning from Clang 21.
diff --git a/graphics/drm-612-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7 b/graphics/drm-612-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7
new file mode 100644
index 000000000000..0c55a14991a8
--- /dev/null
+++ b/graphics/drm-612-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7
@@ -0,0 +1,104 @@
+--- amd/amdgpu/Makefile
++++ amd/amdgpu/Makefile
+@@ -1261,7 +1261,8 @@ SRCS+= amd_powerplay.c \
+ SRCS+= amdgpu_pmu.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- amd/amdkfd/Makefile
++++ amd/amdkfd/Makefile
+@@ -39,7 +39,8 @@ SRCS = \
+ kfd_queue.c #\
+ # kfd_topology.c
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- dmabuf/Makefile
++++ dmabuf/Makefile
+@@ -18,7 +18,8 @@ SRCS= dma-buf-kmod.c \
+ dma-resv.c \
+ sync_file.c
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ bus_if.h \
+ vnode_if.h
+
+--- drm/Makefile
++++ drm/Makefile
+@@ -155,7 +155,8 @@ SRCS+= drm_client.c \
+ SRCS+= drm_client_setup.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- dummygfx/Makefile
++++ dummygfx/Makefile
+@@ -14,6 +14,7 @@ SRCS= \
+ dummygfx_debugfs.c
+
+ SRCS += \
++ ${LINUXKPI_GENSRCS} \
+ opt_acpi.h \
+ opt_drm.h \
+ opt_platform.h \
+--- i915/Makefile
++++ i915/Makefile
+@@ -353,6 +353,7 @@ SRCS+= i915_hwmon.c
+ # intel_lpe_audio.c # Need platform and irq_chip support
+
+ SRCS += \
++ ${LINUXKPI_GENSRCS} \
+ opt_acpi.h \
+ opt_drm.h \
+ opt_syscons.h \
+--- linuxkpi_video/Makefile
++++ linuxkpi_video/Makefile
+@@ -20,7 +20,8 @@ SRCS+= aperture.c
+ SRCS+= cmdline.c
+ .endif
+
+-SRCS+= bus_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ bus_if.h \
+ device_if.h \
+ pci_if.h \
+ vnode_if.h \
+--- radeon/Makefile
++++ radeon/Makefile
+@@ -115,7 +115,8 @@ SRCS+= opt_acpi.h \
+ radeon_acpi.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- ttm/Makefile
++++ ttm/Makefile
+@@ -26,7 +26,8 @@ SRCS= ttm_bo.c \
+ SRCS+= ttm_agp_backend.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
diff --git a/graphics/drm-66-kmod/files/patch-compiler_flags.mk b/graphics/drm-66-kmod/files/patch-compiler_flags.mk
new file mode 100644
index 000000000000..1021130ee473
--- /dev/null
+++ b/graphics/drm-66-kmod/files/patch-compiler_flags.mk
@@ -0,0 +1,16 @@
+--- compiler_flags.mk
++++ compiler_flags.mk
+@@ -7,6 +7,13 @@
+ CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/compiler_types.h
+ .endif
+
++# Other headers are always included. See the definition of `$(USERINCLUDE)` in
++# the Makefile at the root of the Linux source tree.
++.if exists(${SYSDIR}/compat/linuxkpi/common/include/linux/compiler-version.h)
++CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/compiler-version.h
++.endif
++CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/kconfig.h
++
+ CWARNFLAGS+= -Wno-pointer-sign
+
+ # Globally silence a new warning from Clang 21.
diff --git a/graphics/drm-66-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7 b/graphics/drm-66-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7
new file mode 100644
index 000000000000..0c55a14991a8
--- /dev/null
+++ b/graphics/drm-66-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7
@@ -0,0 +1,104 @@
+--- amd/amdgpu/Makefile
++++ amd/amdgpu/Makefile
+@@ -1261,7 +1261,8 @@ SRCS+= amd_powerplay.c \
+ SRCS+= amdgpu_pmu.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- amd/amdkfd/Makefile
++++ amd/amdkfd/Makefile
+@@ -39,7 +39,8 @@ SRCS = \
+ kfd_queue.c #\
+ # kfd_topology.c
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- dmabuf/Makefile
++++ dmabuf/Makefile
+@@ -18,7 +18,8 @@ SRCS= dma-buf-kmod.c \
+ dma-resv.c \
+ sync_file.c
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ bus_if.h \
+ vnode_if.h
+
+--- drm/Makefile
++++ drm/Makefile
+@@ -155,7 +155,8 @@ SRCS+= drm_client.c \
+ SRCS+= drm_client_setup.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- dummygfx/Makefile
++++ dummygfx/Makefile
+@@ -14,6 +14,7 @@ SRCS= \
+ dummygfx_debugfs.c
+
+ SRCS += \
++ ${LINUXKPI_GENSRCS} \
+ opt_acpi.h \
+ opt_drm.h \
+ opt_platform.h \
+--- i915/Makefile
++++ i915/Makefile
+@@ -353,6 +353,7 @@ SRCS+= i915_hwmon.c
+ # intel_lpe_audio.c # Need platform and irq_chip support
+
+ SRCS += \
++ ${LINUXKPI_GENSRCS} \
+ opt_acpi.h \
+ opt_drm.h \
+ opt_syscons.h \
+--- linuxkpi_video/Makefile
++++ linuxkpi_video/Makefile
+@@ -20,7 +20,8 @@ SRCS+= aperture.c
+ SRCS+= cmdline.c
+ .endif
+
+-SRCS+= bus_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ bus_if.h \
+ device_if.h \
+ pci_if.h \
+ vnode_if.h \
+--- radeon/Makefile
++++ radeon/Makefile
+@@ -115,7 +115,8 @@ SRCS+= opt_acpi.h \
+ radeon_acpi.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- ttm/Makefile
++++ ttm/Makefile
+@@ -26,7 +26,8 @@ SRCS= ttm_bo.c \
+ SRCS+= ttm_agp_backend.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
diff --git a/graphics/drm-latest-kmod/files/patch-compiler_flags.mk b/graphics/drm-latest-kmod/files/patch-compiler_flags.mk
new file mode 100644
index 000000000000..1021130ee473
--- /dev/null
+++ b/graphics/drm-latest-kmod/files/patch-compiler_flags.mk
@@ -0,0 +1,16 @@
+--- compiler_flags.mk
++++ compiler_flags.mk
+@@ -7,6 +7,13 @@
+ CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/compiler_types.h
+ .endif
+
++# Other headers are always included. See the definition of `$(USERINCLUDE)` in
++# the Makefile at the root of the Linux source tree.
++.if exists(${SYSDIR}/compat/linuxkpi/common/include/linux/compiler-version.h)
++CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/compiler-version.h
++.endif
++CFLAGS+= -include ${SYSDIR}/compat/linuxkpi/common/include/linux/kconfig.h
++
+ CWARNFLAGS+= -Wno-pointer-sign
+
+ # Globally silence a new warning from Clang 21.
diff --git a/graphics/drm-latest-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7 b/graphics/drm-latest-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7
new file mode 100644
index 000000000000..0c55a14991a8
--- /dev/null
+++ b/graphics/drm-latest-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7
@@ -0,0 +1,104 @@
+--- amd/amdgpu/Makefile
++++ amd/amdgpu/Makefile
+@@ -1261,7 +1261,8 @@ SRCS+= amd_powerplay.c \
+ SRCS+= amdgpu_pmu.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- amd/amdkfd/Makefile
++++ amd/amdkfd/Makefile
+@@ -39,7 +39,8 @@ SRCS = \
+ kfd_queue.c #\
+ # kfd_topology.c
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- dmabuf/Makefile
++++ dmabuf/Makefile
+@@ -18,7 +18,8 @@ SRCS= dma-buf-kmod.c \
+ dma-resv.c \
+ sync_file.c
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ bus_if.h \
+ vnode_if.h
+
+--- drm/Makefile
++++ drm/Makefile
+@@ -155,7 +155,8 @@ SRCS+= drm_client.c \
+ SRCS+= drm_client_setup.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- dummygfx/Makefile
++++ dummygfx/Makefile
+@@ -14,6 +14,7 @@ SRCS= \
+ dummygfx_debugfs.c
+
+ SRCS += \
++ ${LINUXKPI_GENSRCS} \
+ opt_acpi.h \
+ opt_drm.h \
+ opt_platform.h \
+--- i915/Makefile
++++ i915/Makefile
+@@ -353,6 +353,7 @@ SRCS+= i915_hwmon.c
+ # intel_lpe_audio.c # Need platform and irq_chip support
+
+ SRCS += \
++ ${LINUXKPI_GENSRCS} \
+ opt_acpi.h \
+ opt_drm.h \
+ opt_syscons.h \
+--- linuxkpi_video/Makefile
++++ linuxkpi_video/Makefile
+@@ -20,7 +20,8 @@ SRCS+= aperture.c
+ SRCS+= cmdline.c
+ .endif
+
+-SRCS+= bus_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ bus_if.h \
+ device_if.h \
+ pci_if.h \
+ vnode_if.h \
+--- radeon/Makefile
++++ radeon/Makefile
+@@ -115,7 +115,8 @@ SRCS+= opt_acpi.h \
+ radeon_acpi.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
+--- ttm/Makefile
++++ ttm/Makefile
+@@ -26,7 +26,8 @@ SRCS= ttm_bo.c \
+ SRCS+= ttm_agp_backend.c
+ .endif
+
+-SRCS+= device_if.h \
++SRCS+= ${LINUXKPI_GENSRCS} \
++ device_if.h \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
diff --git a/graphics/nvidia-drm-515-kmod/Makefile b/graphics/nvidia-drm-515-kmod/Makefile
index 0766514f6d54..3e7a23f8bce3 100644
--- a/graphics/nvidia-drm-515-kmod/Makefile
+++ b/graphics/nvidia-drm-515-kmod/Makefile
@@ -5,6 +5,8 @@ CATEGORIES= graphics
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-515-kmod
CONFLICTS_INSTALL= nvidia-drm-61-kmod* nvidia-drm-66-kmod* nvidia-drm-612-kmod* nvidia-drm-latest-kmod*
+DRM_VER= 515
+
.include "${.CURDIR}/../drm-515-kmod/Makefile.version"
.include "${.CURDIR}/../nvidia-drm-kmod/Makefile.common"
diff --git a/graphics/nvidia-drm-515-kmod/files/patch-Makefile b/graphics/nvidia-drm-515-kmod/files/patch-Makefile
new file mode 100644
index 000000000000..88c79bbfc963
--- /dev/null
+++ b/graphics/nvidia-drm-515-kmod/files/patch-Makefile
@@ -0,0 +1,11 @@
+--- Makefile.orig
++++ Makefile
+@@ -24,7 +24,7 @@
+ # get our conftest and sources lists from here
+ .include "nvidia-drm-sources.mk"
+
+-GENERATED_KMOD_SRCS += device_if.h \
++GENERATED_KMOD_SRCS += ${LINUXKPI_GENSRCS} \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
diff --git a/graphics/nvidia-drm-61-kmod/Makefile b/graphics/nvidia-drm-61-kmod/Makefile
index 8f941b48148d..36edd81c80b4 100644
--- a/graphics/nvidia-drm-61-kmod/Makefile
+++ b/graphics/nvidia-drm-61-kmod/Makefile
@@ -5,6 +5,8 @@ CATEGORIES= graphics
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-61-kmod
CONFLICTS_INSTALL= nvidia-drm-515-kmod* nvidia-drm-66-kmod* nvidia-drm-612-kmod* nvidia-drm-latest-kmod*
+DRM_VER= 61
+
.include "${.CURDIR}/../drm-61-kmod/Makefile.version"
.include "${.CURDIR}/../nvidia-drm-kmod/Makefile.common"
diff --git a/graphics/nvidia-drm-61-kmod/files/patch-Makefile b/graphics/nvidia-drm-61-kmod/files/patch-Makefile
new file mode 100644
index 000000000000..88c79bbfc963
--- /dev/null
+++ b/graphics/nvidia-drm-61-kmod/files/patch-Makefile
@@ -0,0 +1,11 @@
+--- Makefile.orig
++++ Makefile
+@@ -24,7 +24,7 @@
+ # get our conftest and sources lists from here
+ .include "nvidia-drm-sources.mk"
+
+-GENERATED_KMOD_SRCS += device_if.h \
++GENERATED_KMOD_SRCS += ${LINUXKPI_GENSRCS} \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
diff --git a/graphics/nvidia-drm-612-kmod/Makefile b/graphics/nvidia-drm-612-kmod/Makefile
index daae7c7620d9..f16f61761e4c 100644
--- a/graphics/nvidia-drm-612-kmod/Makefile
+++ b/graphics/nvidia-drm-612-kmod/Makefile
@@ -5,6 +5,8 @@ CATEGORIES= graphics
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-612-kmod
CONFLICTS_INSTALL= nvidia-drm-515-kmod* nvidia-drm-61-kmod* nvidia-drm-66-kmod* nvidia-drm-latest-kmod*
+DRM_VER= 612
+
.include "${.CURDIR}/../drm-612-kmod/Makefile.version"
.include "${.CURDIR}/../nvidia-drm-kmod/Makefile.common"
diff --git a/graphics/nvidia-drm-612-kmod/files/patch-Makefile b/graphics/nvidia-drm-612-kmod/files/patch-Makefile
new file mode 100644
index 000000000000..88c79bbfc963
--- /dev/null
+++ b/graphics/nvidia-drm-612-kmod/files/patch-Makefile
@@ -0,0 +1,11 @@
+--- Makefile.orig
++++ Makefile
+@@ -24,7 +24,7 @@
+ # get our conftest and sources lists from here
+ .include "nvidia-drm-sources.mk"
+
+-GENERATED_KMOD_SRCS += device_if.h \
++GENERATED_KMOD_SRCS += ${LINUXKPI_GENSRCS} \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
diff --git a/graphics/nvidia-drm-66-kmod/Makefile b/graphics/nvidia-drm-66-kmod/Makefile
index f9149f513ad0..a9fe78a66491 100644
--- a/graphics/nvidia-drm-66-kmod/Makefile
+++ b/graphics/nvidia-drm-66-kmod/Makefile
@@ -5,6 +5,8 @@ CATEGORIES= graphics
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-66-kmod
CONFLICTS_INSTALL= nvidia-drm-515-kmod* nvidia-drm-61-kmod* nvidia-drm-612-kmod* nvidia-drm-latest-kmod*
+DRM_VER= 66
+
.include "${.CURDIR}/../drm-66-kmod/Makefile.version"
.include "${.CURDIR}/../nvidia-drm-kmod/Makefile.common"
diff --git a/graphics/nvidia-drm-66-kmod/files/patch-Makefile b/graphics/nvidia-drm-66-kmod/files/patch-Makefile
new file mode 100644
index 000000000000..88c79bbfc963
--- /dev/null
+++ b/graphics/nvidia-drm-66-kmod/files/patch-Makefile
@@ -0,0 +1,11 @@
+--- Makefile.orig
++++ Makefile
+@@ -24,7 +24,7 @@
+ # get our conftest and sources lists from here
+ .include "nvidia-drm-sources.mk"
+
+-GENERATED_KMOD_SRCS += device_if.h \
++GENERATED_KMOD_SRCS += ${LINUXKPI_GENSRCS} \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \
diff --git a/graphics/nvidia-drm-kmod/Makefile.common b/graphics/nvidia-drm-kmod/Makefile.common
index 040a3f2aa560..80af8ecb2e52 100644
--- a/graphics/nvidia-drm-kmod/Makefile.common
+++ b/graphics/nvidia-drm-kmod/Makefile.common
@@ -119,6 +119,12 @@ post-patch:
.if ${.CURDIR:M*nvidia-drm-515-kmod*}
${REINPLACE_CMD} -e 's:defined(NV_LINUX_IOSYS_MAP_H_PRESENT):0:' ${WRKSRC}/nvidia-drm-gem.c
.endif
+ # Workaround for graphics/drm-*-kmod failure affecting NVIDIA counterparts
+ # after commit src 9820afb99e6f.
+.if !${.CURDIR:M*nvidia-drm-515-kmod*}
+ ${PATCH} -d ${WRKDIR}/drm-kmod-${DRM_KMOD_GH_TAGNAME} -i ${PORTSDIR}/graphics/drm-${DRM_VER}-kmod/files/patch-compiler_flags.mk
+ ${PATCH} -d ${WRKDIR}/drm-kmod-${DRM_KMOD_GH_TAGNAME} -i ${PORTSDIR}/graphics/drm-${DRM_VER}-kmod/files/patch-fix_build_after_src_main_git_bbfd52dcbeb7
+.endif
# We should support -CURRENT: kill the check (first #if __FreeBSD_version)
linenum=$$(${SED} -ne '/^#if __FreeBSD_version/ { = ; q ; }' \
${WRKSRC}/../nvidia/nv-freebsd.h) ; ${REINPLACE_CMD} \
diff --git a/graphics/nvidia-drm-latest-kmod/Makefile b/graphics/nvidia-drm-latest-kmod/Makefile
index bff909dfdf6b..783dc0d5b4e7 100644
--- a/graphics/nvidia-drm-latest-kmod/Makefile
+++ b/graphics/nvidia-drm-latest-kmod/Makefile
@@ -5,6 +5,8 @@ CATEGORIES= graphics
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-latest-kmod
CONFLICTS_INSTALL= nvidia-drm-515-kmod* nvidia-drm-61-kmod* nvidia-drm-66-kmod* nvidia-drm-612-kmod*
+DRM_VER= latest
+
.include "${.CURDIR}/../drm-latest-kmod/Makefile.version"
.include "${.CURDIR}/../nvidia-drm-kmod/Makefile.common"
diff --git a/graphics/nvidia-drm-latest-kmod/files/patch-Makefile b/graphics/nvidia-drm-latest-kmod/files/patch-Makefile
new file mode 100644
index 000000000000..88c79bbfc963
--- /dev/null
+++ b/graphics/nvidia-drm-latest-kmod/files/patch-Makefile
@@ -0,0 +1,11 @@
+--- Makefile.orig
++++ Makefile
+@@ -24,7 +24,7 @@
+ # get our conftest and sources lists from here
+ .include "nvidia-drm-sources.mk"
+
+-GENERATED_KMOD_SRCS += device_if.h \
++GENERATED_KMOD_SRCS += ${LINUXKPI_GENSRCS} \
+ vnode_if.h \
+ bus_if.h \
+ pci_if.h \