Page MenuHomeFreeBSD

MTL-graphics-reproduction-20260929-full-context.md

Authored By
oleglelchuk_gmail.com
Tue, Sep 29, 3:40 PM
Size
12 KB
Referenced Files
None
Subscribers
None

MTL-graphics-reproduction-20260929-full-context.md

# Meteor Lake graphics mapping reproduction notes — 2026-09-29
This publishes the graphics changes from my working FreeBSD amd64 laptop as
separate reviewable pieces. The LLM prepared the code and validation. My running
kernel also contains local USB, networking, Bluetooth and delayed-work changes;
this guide does not distribute them or claim they are graphics dependencies.
A kernel containing only the graphics patches below has not had a full desktop
boot test. The current integration evidence is from the larger local combination.
## What each change addresses
| Change | Purpose | Publication |
| --- | --- | --- |
| General LinuxKPI `vmap()` patch | Honor requested cache policy and retain it across compatible tracked kernel aliases | [D60130](https://reviews.freebsd.org/D60130) |
| DRM aperture/framebuffer changes | Prevent CPU accesses through MTL stolen BAR2 from being mistaken for a CPU GGTT aperture; map shmem fbdev through its real pages | [drm-kmod PR 496](https://github.com/freebsd/drm-kmod/pull/496) |
| DRM capture correction | Capture actual backing-page contents for future hang analysis | Separate final commit in PR 496 |
| Local PFN ownership patch | Address the distinct shmem ownership/reclamation problem | [D59481 full-context diff 188009](https://reviews.freebsd.org/differential/diff/188009/) |
| Optional PFN/`vmap()` coordination | Defer that PFN implementation's cache restoration while a tracked kernel alias survives | [coordination patch](https://reviews.freebsd.org/F173953364) |
The general patch follows up Austin Shafer's [D59436](https://reviews.freebsd.org/D59436).
It is a complete replacement for the original D59436 implementation, not a patch
to stack on top of it. The [comparison-only delta](https://reviews.freebsd.org/file/data/ivi63p23pdhhxtpbphnq/PHID-FILE-izjaibnjv4raqbkum5q4/linuxkpi-vmap-lifetime-after-D59436.patch) applies after
exact D59436 diff 185902 for reviewers who want to inspect the added handling.
Use one route or the other, never both. The primary route below uses the complete
general patch and needs no separate D59436 download.
The optional PFN patch is still a local approach. [D59883](https://reviews.freebsd.org/D59883)
is a separate upstream effort; no claim is made that the PFN-coordination patch
applies to D59883. On my laptop I currently need both ownership and mapping fixes.
## Pinned source revisions
| Repository | Revision |
| --- | --- |
| [FreeBSD src](https://git.freebsd.org/src.git) | `d2018cedb414ef17e77b7fc2fa19fd81328da46b` |
| [drm-kmod](https://github.com/freebsd/drm-kmod) base | `f252a30f27d157d9c763cd408850775096a6263f` (DRM 6.13) |
| [DRM PR series head](https://github.com/JustAnotherHumanBeing/drm-kmod/commit/6c36f4abff3c1b1a2160e10d5ff32c024ce952ff) | `6c36f4abff3c1b1a2160e10d5ff32c024ce952ff` |
| [drm-kmod-firmware](https://github.com/freebsd/drm-kmod-firmware) | `2c12915d69954673c782a9a55c6ec39c19cfea93` |
The PR preserves its original commit, merges the pinned upstream base, and adds
separate aperture (`79f9218107a5`), framebuffer (`f6978c27a1ef`) and capture
(`6c36f4abff3c`) commits. Use the complete series. Its five changed files are
byte-for-byte the source used by my current working DRM build.
## Obtain and apply the patches in a new workspace
These commands use fresh checkouts, leaving any existing source trees untouched.
Run the checkout/patch steps as a regular user. Replace the example directory
with an empty location with enough space for a kernel build.
```sh
mkdir -p ~/mtl-graphics-test/patches
cd ~/mtl-graphics-test
workdir="$(pwd)"
patchdir="$workdir/patches"
git clone https://git.freebsd.org/src.git freebsd-src
git -C freebsd-src checkout --detach d2018cedb414ef17e77b7fc2fa19fd81328da46b
fetch -o "$patchdir/pfnmap-D59481-main-d2018cedb414-20260929.patch" \
"https://reviews.freebsd.org/file/data/obam3jkud7ph4jp56fyz/PHID-FILE-7jqq2znrvgp7v5gjeeur/pfnmap-D59481-main-d2018cedb414-20260929.patch"
fetch -o "$patchdir/linuxkpi-vmap-lifetime-main-d2018cedb414.patch" \
"https://reviews.freebsd.org/file/data/jpa4o7e77mpn774j6occ/PHID-FILE-cvosocpzcie6qmekynrr/linuxkpi-vmap-lifetime-main-d2018cedb414.patch"
fetch -o "$patchdir/linuxkpi-vmap-D59481-coordination.patch" \
"https://reviews.freebsd.org/file/data/4hl7wzmi6oaq2se32oog/PHID-FILE-or7xfoge6iqqjdqgp5cp/linuxkpi-vmap-D59481-coordination.patch"
```
Expected SHA-256 hashes:
| Patch | SHA-256 |
| --- | --- |
| `pfnmap-D59481-main-d2018cedb414-20260929.patch` | `64b0634b2a5d48d1580f16dc288c55356865072d8d95a180c8bfcbedcd224b9d` |
| `linuxkpi-vmap-lifetime-main-d2018cedb414.patch` | `59da17714861986f39cbc95006ff3ccde70d4d1730e59f34bc16a1ee6693abd3` |
| `linuxkpi-vmap-D59481-coordination.patch` | `6f453b0e6be23abed6c934f49d2ab42545c9deabae6560c197c0d8c9e4e5a746` |
For the **graphics combination used on my laptop**, apply in this order:
```sh
git -C freebsd-src apply --check "$patchdir/pfnmap-D59481-main-d2018cedb414-20260929.patch"
git -C freebsd-src apply "$patchdir/pfnmap-D59481-main-d2018cedb414-20260929.patch"
git -C freebsd-src apply --check "$patchdir/linuxkpi-vmap-lifetime-main-d2018cedb414.patch"
git -C freebsd-src apply "$patchdir/linuxkpi-vmap-lifetime-main-d2018cedb414.patch"
git -C freebsd-src apply --check "$patchdir/linuxkpi-vmap-D59481-coordination.patch"
git -C freebsd-src apply "$patchdir/linuxkpi-vmap-D59481-coordination.patch"
git -C freebsd-src diff --check
git clone https://github.com/JustAnotherHumanBeing/drm-kmod.git drm-kmod
git -C drm-kmod checkout --detach 6c36f4abff3c1b1a2160e10d5ff32c024ce952ff
git clone https://github.com/freebsd/drm-kmod-firmware.git drm-kmod-firmware
git -C drm-kmod-firmware checkout --detach 2c12915d69954673c782a9a55c6ec39c19cfea93
```
For reviewing the **general kernel change alone**, start from a fresh pristine
checkout and apply only `linuxkpi-vmap-lifetime-main-d2018cedb414.patch`. Omit both
the PFN patch and its coordination patch. That variant has source/model and
module-build checks, but not the full desktop boot evidence of my combination.
The optional PFN patch and coordination patch must stay paired when reproducing
my local ownership implementation alongside the general `vmap()` change.
The complete [DRM patch](https://reviews.freebsd.org/file/data/x3xu757rbgplycqyz5w3/PHID-FILE-wqsbtpqtv5zd3vdi2i7v/drm-kmod-mtl-mapping-and-capture-f252a30f27d1.patch) is an alternative to checking out the PR head:
apply it to exactly `f252a30f27d1`, not on top of the PR commits.
## Build a matching kernel and Intel modules
Use a FreeBSD-CURRENT amd64 build environment appropriate for the pinned source.
If the installed toolchain is too old, follow FreeBSD's normal buildworld/kernel
upgrade procedure first. Keep the generated kernel build directory: external
modules must use that configuration and the same patched source tree.
```sh
kernel_src="$workdir/freebsd-src"
build_obj="$workdir/obj"
MAKEOBJDIRPREFIX="$build_obj" make -C "$kernel_src" -j8 buildkernel \
KERNCONF=GENERIC __MAKE_CONF=/dev/null SRCCONF=/dev/null SRC_ENV_CONF=/dev/null
kernel_obj="$build_obj$kernel_src/amd64.amd64/sys/GENERIC"
MAKEOBJDIRPREFIX="$workdir/drm-obj" make -C "$workdir/drm-kmod" -j8 \
-m "$kernel_src/share/mk" SRCTOP="$kernel_src" SYSDIR="$kernel_src/sys" \
KERNBUILDDIR="$kernel_obj" KMODS="dmabuf ttm drm i915" DEBUG_FLAGS=-g \
__MAKE_CONF=/dev/null SRCCONF=/dev/null obj
MAKEOBJDIRPREFIX="$workdir/drm-obj" make -C "$workdir/drm-kmod" -j8 \
-m "$kernel_src/share/mk" SRCTOP="$kernel_src" SYSDIR="$kernel_src/sys" \
KERNBUILDDIR="$kernel_obj" KMODS="dmabuf ttm drm i915" DEBUG_FLAGS=-g \
__MAKE_CONF=/dev/null SRCCONF=/dev/null all
MAKEOBJDIRPREFIX="$workdir/firmware-obj" make -C "$workdir/drm-kmod-firmware" -j8 \
-m "$kernel_src/share/mk" SRCTOP="$kernel_src" SYSDIR="$kernel_src/sys" \
KERNBUILDDIR="$kernel_obj" KMODS=i915kmsfw __MAKE_CONF=/dev/null obj
MAKEOBJDIRPREFIX="$workdir/firmware-obj" make -C "$workdir/drm-kmod-firmware" -j8 \
-m "$kernel_src/share/mk" SRCTOP="$kernel_src" SYSDIR="$kernel_src/sys" \
KERNBUILDDIR="$kernel_obj" KMODS=i915kmsfw __MAKE_CONF=/dev/null all
```
Eight jobs were used on my laptop; choose a count suited to the test machine.
Only Intel graphics modules/firmware are selected. Retain INVARIANTS/WITNESS and
debug symbols for development tests. Do not mix previously installed modules
with this kernel's ABI.
For installation, use a **separate boot directory** such as
`/boot/kernel.mtl-mapping-test`: `installkernel` supports
`INSTKERNNAME=kernel.mtl-mapping-test`. Run each external module's `install`
target with its same build variables and `KMODDIR` pointing to that directory.
Installation needs root. Before selecting it for boot, verify that it contains
the kernel, its base modules, matched `dmabuf`/`ttm`/`drm`/`i915kms` modules and
Intel firmware. Make the boot selection/module search path and any rc.conf
module-loading paths use that bundle; check `kldstat -v` after boot. Keep the
previous working bundle available for rollback. This publication does not
automatically install or select anything on the reader's system.
## Validation and interpretation
The [test bundle](https://reviews.freebsd.org/file/data/2tlwwi4cosaqe2hrclht/PHID-FILE-rk6mfpy3bvpxtxgmf2p7/mtl-vmap-fbdev-tests-20260929.tar.gz) contains reproducible source-extracted ASan/UBSan
tests and the native overlapping-map fixture with its original output. The
included READMEs explain their commands and limits. All fresh model tests and
the separated generic LinuxKPI module build passed on 2026-09-29. Patch
application/reversal was verified, including the D59436 comparison-delta route.
The native test was run on 2026-09-28 against private wired pages, using the exact
D59436 mapping bodies and native amd64 pmap. It showed a surviving WC mapping
with a WB direct-map alias after removing the first overlapping mapping. The
expanded implementation retained matching attributes. No GPU hang was induced,
and no normal i915 caller reaching that overlap has yet been established.
The working graphics combination passed live checks for 143 command-ring pages
and 4,557 firmware-framebuffer pages. A bounded Intel GPU compute/readback test
verified 8,388,608 integer results over 32 rounds on 2026-09-27. After the
2026-09-29 kernel/PFN update, boot/live-mapping and healthy capture checks passed
again. The bounded GPU test was not rerun as part of publication preparation.
These results support the specific mapping correction. They do not prove that
every GPU hang is fixed, isolate one patch as the sole reason for improvement,
or establish equivalent behavior on other machines/architectures. The general
`vmap()` proposal tracks its own aliases, not arbitrary native mappings; the
page owner still has responsibilities. Review of that contract remains open.
## Full-file context for reviewers
The current D60130 and D59481 review diffs were regenerated with `git diff -U9999`.
Both complete file versions are present for every changed file. The code is
identical to the preceding uploads; this is a context-only correction.
The review web interface may collapse unchanged sections, and its ordinary raw
export can shorten context again. The explicitly labeled full-context downloads
below retain all lines and were checked by an anonymous download.
Full-context downloads:
- [General vmap change](https://reviews.freebsd.org/F173957114)
- [Comparison after exact D59436](https://reviews.freebsd.org/F173957116)
- [Standalone PFN change](https://reviews.freebsd.org/F173957124)
- [PFN/vmap coordination](https://reviews.freebsd.org/F173957120)
- [DRM changes](https://reviews.freebsd.org/F173957126)
The earlier download commands and SHA-256 hashes above intentionally retain the
application patches used to validate the documented sequence. A standalone diff
with full-file context can reject an otherwise independent earlier patch to the
same file. Use the documented application versions for that sequence; use the
expanded copies to read all surrounding code. Each expanded copy was checked
against its exact input tree, and its full output tree and reverse application
match the corresponding original patch. The test bundle and test results remain
applicable because no source code changed.
Complete DRM source files are also available on the pinned PR branch:
[browse the five changed files in their source tree](https://github.com/JustAnotherHumanBeing/drm-kmod/tree/6c36f4abff3c1b1a2160e10d5ff32c024ce952ff/drivers/gpu/drm/i915).

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39953461
Default Alt Text
MTL-graphics-reproduction-20260929-full-context.md (12 KB)

Event Timeline