Make graphics/drm-515-kmod (FreeBSD's backport of the Linux 5.15 DRM stack:
drm.ko, i915kms, amdgpu, radeonkms, ttm) compile and link against
MidnightBSD master. The port officially requires FreeBSD 14.x.
Committed scope: build + link only. Do not kldload. Runtime bring-up
(vt/newcons KMS console handoff, interrupts, suspend/resume, modesetting) is
out of scope.
| Tree | Version | LinuxKPI level |
|---|---|---|
MidnightBSD master (/usr/src) |
__MidnightBSD_version 401002, __FreeBSD_version 1305500 |
ad-hoc fork, ~FreeBSD 13.5-STABLE + selective forward-ports |
FreeBSD 14-STABLE (/home/laffer1/git/freebsd, stable/14) |
__FreeBSD_version 1404501 |
reference target |
MidnightBSD's sys/compat/linuxkpi is a series of ad-hoc partial imports from
FreeBSD 12 → 13 → 13.5, already partly forward-ported (e.g. pci_domain_nr).
-
dma-buf.h/dma-fence.h/dma-resv.hare NOT base gaps. They are absent from both MidnightBSD and FreeBSD 14 base LinuxKPI — the drm-kmod port ships them itself (bundled GPLv2 headers). Not our problem to add. -
A wholesale FreeBSD 14 LinuxKPI import is the WRONG approach. Empirically verified: overlaying FreeBSD 14's
common/{include,src}and building fails on base-kernel API deltas that recur in nearly every file —sched.h→td_ast_pending/TDA_SCHED(FreeBSD 14 AST framework)net.h→pr_peeraddr/pr_sockaddr(FreeBSD 14 protosw refactor)file.h/linux_compat.c→fget_unlocked,fo_stat_t, constfileopsrbtree.h(sys/tree.hmacro arity),kmem_free(void*),qsort_rMidnightBSD's base has none of these. Wholesale import would require backporting the AST framework, the protosw refactor, and the file/fileops API into MidnightBSD's base kernel — a larger, riskier project than the drm port itself, destabilizing unrelated subsystems.
-
MidnightBSD's existing LinuxKPI already correctly targets its 13.5 base. The real gap is the additive FreeBSD 14 files (new headers + new modules), not re-importing existing files.
Keep MidnightBSD's existing, base-compatible LinuxKPI files. Add only the genuinely-new FreeBSD 14 pieces drm needs, and backport individual new symbols into existing headers only where they don't drag base-incompatible changes.
- Import additive FreeBSD 14 headers (
aperture.h,iosys-map.h,hdmi.h,iommu.h,irqdomain.h,ioport.h,io-64-nonatomic-lo-hi.h,cleanup.h,container_of.h,build_bug.h,minmax.h,math.h,limits.h,kstrtox.h,string_helpers.h,nodemask.h,of.h,agp_backend.h,apple-gmux.h,device/,video/, dummysysfb.h). - Add
linuxkpi_hdmiandlinuxkpi_videomodules (HDMI infoframe, ACPI-video/backlight, framebuffer aperture) + register insys/modules/Makefile. Both build clean. - Backport
devm_add_action()/devm_add_action_or_reset()(needed bylinux_aperture.c). - Backport further individual symbols as the drm port build demands them (iterative, localized — keep MidnightBSD base semantics, do NOT pull the AST/protosw/file base reworks).
- Note:
linux_kobject.cis intentionally NOT imported — FreeBSD 14 split it out oflinux_compat.c, which MidnightBSD still carries inline (would dup).
NOTE: /usr/ports here is the upstream FreeBSD ports tree and is not
operational under MidnightBSD make (bsd.port.options.mk not found,
${OPSYS} conditionals malformed). MidnightBSD uses mports at
/usr/mports, which already ships a MidnightBSD-adapted graphics/drm-510-kmod
(uses bsd.mport.options.mk, IGNORE_MidnightBSD_3.x, already
CONFLICTS_INSTALL with drm-515-kmod) and gpu-firmware-kmod.
- Create
graphics/drm-515-kmodby copying mportsdrm-510-kmodand bumpingMakefile.versionto 5.15.160 /drm_v5.15.160_6; refreshdistinfo,pkg-plist, and theextra-patch-linuxkpi-pci(gate decided by build). - Build via mports against
/usr/src(our uplifted LinuxKPI); iterate base-compat backports (Workstream A) as drm source demands them. - mports is a separate git repo (MidnightBSD/mports) → a second PR.
cd /usr/src/sys/modules/linuxkpi{,_hdmi,_video} && make— clean. (done)cd /usr/ports/graphics/drm-515-kmod && make— noIGNORE; producesdrm/i915kms/amdgpu/radeonkms/ttm .ko.nm -uthe.kos for unresolved LinuxKPI symbols against the built kernel.- cppcheck/clang-format sanity on any base-compat backport commits.
kldload, vt/newcons KMS console handoff, interrupts, suspend/resume,
on-hardware modesetting.
All six modules build and link clean against MidnightBSD (__FreeBSD_version 1305500) on amd64, via cd /usr/mports/graphics/drm-515-kmod && make build SRC_BASE=/usr/src:
dmabuf.ko drm.ko ttm.ko amdgpu.ko i915kms.ko radeonkms.ko
(All valid ELF 64-bit LSB relocatable kmods. Not loaded — out of scope.)
Additive FreeBSD 14 import (headers + linuxkpi_hdmi/linuxkpi_video modules) plus targeted backports, each driven by a real build failure:
- single-arg
vm_operations_struct.fault;kernel.h→math64.h devm_add_action()/_or_reset();pcie_aspm_enabled(); INTEL_FAM6 Alder Lakenoinline_for_stack;bitmap_to_arr32();acpi_put_table()- move BUILD_BUG →
build_bug.h; move U*_MAX →limits.h(both included from kernel.h) - self-contained
dmi.herrno; importutil_macros.h,time64.h - tasklet callback API (
tasklet_setup,from_tasklet,->callback) +ZERO_SIZE_PTR - PCI/device power bits (
dev_pm_info,pci_dev.current_state,pci_power_name(),pci_power_names[])
Existing LinuxKPI files were intentionally NOT re-imported wholesale (would require backporting the FreeBSD 14 AST/protosw/file base reworks).
graphics/drm-515-kmod from drm-510-kmod; two source patches for FreeBSD-14
assumptions vs MidnightBSD base (dma_buf_stat thread arg; i915
totalram_pages gated on __MidnightBSD_version).
kldload and runtime bring-up (vt/newcons KMS handoff, IRQs, suspend/resume,
modesetting); powerpc64 acpi_iicbus guard; gpu-firmware-kmod packaging.