Skip to content

drm/apple: turn framebuffer damage into a commit - #2797

Merged
RyanTheTide merged 3 commits into
mainfrom
isw/fbdev-damage-v2
Nov 29, 2026
Merged

RyanTheTide merged 3 commits into
mainfrom
isw/fbdev-damage-v2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #2319 (same changes, commit trailers fixed).

Fixes #1185

Problem

On the J713 internal panel, a console-only screen (a text greeter on tty1, a VT, a session that fell back to fbcon) freezes about a second after KMS takes over. idle_cache_ms (default 1000) has the DCP present a cached copy of the last frame once nothing has flipped, and leave it only at the next swap. fbcon draws straight into the scanout buffer and never causes a swap: appledrm's framebuffers are created with drm_gem_fb_create, which has no dirty hook, so drm_fbdev_dma sets up its unshadowed path and no damage is ever generated. The only ways back were a commit from somewhere else (fb0 blank/unblank) or appledrm.idle_cache_ms=0 on the command line.

Change

appledrm's fb_create now asks the display backend. dcp_caches_scanout() is true for a firmware interface that may keep presenting a cached copy of the last swapped frame instead of scanning out the framebuffer. Today that is the M4 IOMFB backend with its idle cache. When one of the device's CRTCs is driven by such a backend, apple_fb_create() returns framebuffers with the dirty hook (drm_gem_fb_create_with_dirty, which the dcpext shadow driver already uses). Otherwise it returns plain ones (drm_gem_fb_create), as before.

With the dirty hook:

  • drm_fbdev_dma_driver_fbdev_probe() takes its shadowed, deferred-I/O path. Each damage batch goes through drm_fbdev_dma_helper_fb_dirty() to drm_atomic_helper_dirtyfb(), which is a plane commit of the same framebuffer.
  • On M4 that commit reaches dcp_flush() -> iomfb_m4_present(). That leaves the idle cache (any swap does) and re-arms it through iomfb_m4_idle_cache_kick(). A console that stays static is still cached after idle_cache_ms; one that changes is shown.
  • Userspace DRM_IOCTL_MODE_DIRTYFB callers on those devices get the same behaviour instead of -ENOSYS.

Interfaces that scan the buffer out (M1/M2/M3, and the T8132 firmware-27 path) already show drawing without a swap, so they keep plain framebuffers: no shadow copy and no commit per console update. The T8132 external CRTCs are not apple_crtcs, and their presents never enter the idle cache, so they are skipped.

History: the first commit (d4001bd) gave every board the dirty hook. Its message says "none of them shows drawing it was not given a swap for", which is wrong for the scanout interfaces. The second commit (e4594e2) narrows the hook after the App review and says so. Neither is reworded, because that would need a force push.

Testing

  • Compile check on integration/aurora 0abc2f385e + this change: every touched file built for arm64 (gcc, kernel warning flags, -Werror) with no warnings. KUnit at ae19de35 (arm64 QEMU, LLVM=1, the CI's kunitconfigs): drivers/gpu/drm/apple/tests/display.kunitconfig 167 passed, 1 skipped (apple_g17_rx_util_min_test, needs CONFIG_UCLAMP_TASK); topology.kunitconfig 208 passed, 1 skipped. No failures. Hosted CI is still queued.
  • Hardware, from drm/apple: turn framebuffer damage into a commit #2319: kazuhidet's J715 row (M4 Air, internal panel, default idle_cache_ms): a VT console idle for over 2 s then typing follows every key (frozen without the change), a 3000-line flood scrolls, VT switches to and from Hyprland work, every swap finishes within one 60 Hz frame, no apple-dcp errors.
  • J713 (M4 Air, T8132). It runs the H17P firmware-27 interface, not the M4 IOMFB backend, so it never had the idle cache. At ae19de35 (every board dirty) 8 of 8 console writes reach the DCP; the saved fleet85 gives 0 of 8. That shows the commits work on H17P; nobody checked whether the panel was frozen before. At e4594e2b it gets plain framebuffers (0 of 8, as designed), smoke PASS.
  • J413 (M2 Air, T8112) at e4594e2b: plain framebuffers, 0 of 8 (the same as fleet89). One 15 s s2idle from the text VT: no new DCP errors. Smoke PASS.
  • Not yet run: a T8132 on the 26.6.2 firmware (the M4 IOMFB backend, where this bug lives) at e4594e2b. Also open: whether an H17P text console freezes, which needs someone to look at the screen.
  • J413 (M2 Air, T8112), at ae19de35 (before the narrowing): 8 of 8 writes commit (0 of 8 on the saved fleet89, expected: M2 has no idle cache and needs no swap). One 15 s s2idle from the text VT with console output written during the suspend: resumes, 4 of 4 writes commit after resume, no new DCP errors. Smoke row PASS, no error-level kernel lines, the reboot back to the saved kernel took 30 s.
  • Not run: M1 Pro (our only one has no panel) and M4 Pro rows; a forced panic from a VT (panic output still goes straight to the scanout buffer through get_scanout_buffer, unchanged by this PR).
  • The return reboot from this test kernel hung once on the J713. The same hang happens on main without this change (dtp2 on 11-27) and is tracked on its own; the J413 reboot was clean.

DCP shows only what a swap hands it. A client that draws into the
scanout buffer without flipping is never seen once the firmware stops
refreshing from that buffer, and on the M4 internal panel it does stop:
after idle_cache_ms (1000 ms by default) without a flip, the DCP
presents a cached copy of the last frame until the next swap.

fbcon is such a client. The fbdev emulation only generates damage when
the framebuffer has a dirty hook, and appledrm's framebuffers had none
(drm_gem_fb_create), so the console wrote straight into the scanout
buffer and never caused a swap. On a J713 with a text greeter on tty1
the panel froze about a second after KMS took over, while input and
writes to /dev/tty1 kept working; blanking and unblanking fb0, which
does commit, brought it back. The same holds for any DIRTYFB caller.

Create framebuffers with drm_gem_fb_create_with_dirty, as the
dcpext shadow driver already does. drm_fbdev_dma then runs the
console through its shadowed, deferred-I/O path, and each damage batch
reaches drm_atomic_helper_dirtyfb(), a plane commit of the same
framebuffer. On M4 that is an ordinary iomfb_m4_present(), which also
leaves the idle cache and re-arms it, so a static console still gets
cached. The hook applies to every DCP generation: none of them shows
drawing it was not given a swap for, and compositors that flip are
unaffected because they do not call DIRTYFB.

This removes the need for appledrm.idle_cache_ms=0 on console-only
systems.

Fixes: a150a02 ("drm/apple: m4: Cache a static frame while nothing is flipping")
Closes: #1185
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at d4001bd (non-author, draft). No blocker; the change does what it says for the frozen console. It also moves the console of every Mac onto the shadowed, deferred path, which the message should say.

  • Merges cleanly onto integration/aurora 6748d83. One commit, human sign-off only. drm/apple: turn framebuffer damage into a commit #2319 is closed.
  • Mechanism checked: the fbdev client's framebuffer is created through mode_config.funcs->fb_create, so it gets the dirty hook; drm_fbdev_dma_driver_fbdev_probe() then takes ..._probe_tail_shadowed() (vmalloc shadow, fbdefio.delay = HZ / 20), and each damage batch is blitted and passed to drm_atomic_helper_dirtyfb(). DRM_IOCTL_MODE_DIRTYFB is master-only, so the new commits cannot be driven by an unprivileged client.
  • Suspend: drm_mode_config_helper_suspend() suspends the fbdev emulation, so the damage worker does not commit into a sleeping DCP.
  • The ARGB console on H17P/27.x firmware (apple_drm_fbdev_probe()) is unaffected: the shadow has the same format and the blit copies the alpha byte.

Points to consider:

  • Panic output is still covered: appledrm's planes set get_scanout_buffer = drm_fb_dma_get_scanout_buffer (plane.c), so the DRM panic screen draws into the real scanout buffer, not the shadow. On the M4 idle cache that screen is only visible if the DCP leaves the cached frame, which no commit during a panic can make it do; that is the same as today and not introduced here, but a forced panic on the J713 would show whether it needs its own follow-up.
  • The sentence "no DCP generation shows drawing it was not given a swap for" does not match the Macs where fbcon scrolls today without any swap. The change is still reasonable for them, but the message should say that it is a behaviour change there (every console update becomes a blit plus an atomic commit, at most 20 per second), not a no-op.

Small points, not blocking:

  • The shadow costs one more framebuffer of vmalloc memory per fbdev client (about 31 MB at 3456x2234).
  • Rows still open, as listed: J713 console row; fbcon regression rows on M1 Pro, M2 and M4 Pro (boot console scrolls, VT switch, no DCP errors); the full KUnit run. Worth adding to each: one s2idle cycle from a VT with console output during suspend, and on one Mac a forced panic from a VT to confirm the panic screen still shows.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J713 console row at ae19de35 (this head = main a561e897 merged in, the PR's file unchanged otherwise). Fixes #1185 on the M4 Air.

  • Without the change (saved fleet85, idle_cache_ms=1000): on a text VT, 0 of 8 writes reach the DCP. Each write followed at least 2.5 s idle, and nothing showed in the dcp_send_msg/iomfb_push trace within 300 ms. A 60-line flood sends nothing either, so the console is frozen. Traffic resumes when GNOME's VT comes back.
  • With the change (one-shot of main + this PR, fleet89 config): 8 of 8 writes produce DCP traffic within 300 ms, and the flood does too. The silent production smoke row passes (display, GPU, input, net, audio sink listing). The only DCP error lines are the known boot ones, plus a dcpext probe timeout with no monitor attached.
  • Return reboot hung. The reboot out of the test kernel did not come back. The journal ends at systemd-shutdown: "Journal stopped", with the 1-minute hardware watchdog armed, and the watchdog never reset the Mac. It was recovered by tether VDM and the saved kernel verified. The same signature hit a main-based kernel without this change on 11-27 (DT-PARITY's dtp2), and that kernel rebooted cleanly tonight. So it looks like an intermittent main/shutdown issue, not this one-line fb_create change. It is still unexplained, so this stays draft.

Still to do before undraft:

  • an fbcon regression row on a second family (M2 or M4 Pro: boot console, VT switch, no DCP errors);
  • the reboot-hang question settled by its owner.
Evidence

Lab store traces/display/20261128-j713-fbcon-1185/ (README): control-fleet85.txt, head-ae19de35/{fbconrow,row,kerr,run.log,shutdown-journal-b-1}.txt. Row script work/airs-gaps/tools/fbconrow.sh, one-shot driver kshot.sh.

control fleet85:   FBCONROW control-fleet85 rounds_flip=0 rounds_noflip=8
head ae19de35:     FBCONROW head-ae19de35 rounds_flip=8 rounds_noflip=0   smoke: VERDICT PASS

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Second-family row (J413, M2 Air) at ae19de35: PASS. Same kernel as the J713 row (main a561e897 + this change), one-shot boot of a non-default entry, then back to the saved fleet89.

  • Without the change (saved fleet89), console writes on a text VT cause no DCP traffic at all (0 of 8). That is expected on M2: there is no idle cache, and the DCP keeps scanning out the buffer fbcon draws into.
  • With the change, 8 of 8 writes commit and the flood commits. An idle text VT now keeps committing for the cursor blink (about 30 DCP trace events a second), which the saved kernel does not do.
  • I ran one 15 s s2idle from the text VT with console output written during the suspend. It resumed, 4 of 4 writes committed after resume, and there were no new DCP errors.
  • The smoke row passed, there were no error-level kernel lines, and the reboot back took 30 s. The J713 return-reboot hang did not happen here.

I updated the PR body to cover the review point about the commit message. Its sentence "none of them shows drawing it was not given a swap for" is wrong for M1/M2; the body now says this is a behaviour change there. The commit is not reworded because that would need a force push. If this is merged with a merge commit, the merge message can carry the corrected paragraph.

Ready for review: rows on T8132 (J713) and T8112 (J413), CI pending. Not run: M1 Pro (ours has no panel), M4 Pro, and a forced panic from a VT. @aurora-silicon/core, this is code-owner review for drivers/gpu/drm/apple/.

Row details
  • Script: fbconrow.sh on VT 6 (tty3/tty4 hold GNOME sessions on that Mac). Each round waits 2.5 s idle, writes one line to the VT, and checks for dcp_send_msg/iomfb_push trace events within 300 ms. Then a 60-line flood, then a switch back to the GNOME VT.
  • s2idle: rtcwake -d rtc1 -m freeze -s 15 (rtc0 on the J413 has no alarm). Suspend success counter 0 -> 1; slept 16 s wall.
  • Smoke row: boot chain, Enforcing, failed units, display/GPU/USB/audio cards (nothing played)/net/hwmon. VERDICT PASS.
  • Saved state after: fleet89 running and saved, boot_success=1, next_entry empty, Enforcing, 0 failed units; the test kernel was removed.
  • These are our own measurements. Nothing here is derived from Apple binaries.

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 27, 2026 16:46
@RyanTheTide
RyanTheTide requested review from a team as code owners November 27, 2026 16:46
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

KUnit at ae19de35, run locally on arm64 QEMU with the CI's kunitconfigs because hosted CI is still queued: display 167 passed / 1 skipped, topology 208 passed / 1 skipped, no failures. The skipped test needs CONFIG_UCLAMP_TASK. The PR body now has these numbers.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge.

Blocker: In drivers/gpu/drm/apple/apple_drv.c, the unconditional fb_create change forces fbdev shadow allocation, copies and atomic commits on backends that already show in-place writes. Please select the dirty helper using a display-backend capability for cached scanout, preserving the existing framebuffer helper when that capability is absent. This should be a backend decision shared across boards.

Checked: The standard GEM helper adds the atomic DIRTYFB callback, and the M4 row shows that damage reaches idle cached scanout. The J413 control confirms that the new commits on a backend without the cache are a behavior change, including after suspend.

Evidence

The PR reports 8/8 commits on J413 with the change against 0/8 on its control. The existing scanout already displays those writes, so the additional framebuffer allocation and recurring cursor-blink commits apply even though that path needs no refresh fix.

The previous change gave every appledrm framebuffer the dirty hook. On
the firmware interfaces that scan the framebuffer out, drawing into it
already shows without a swap, so there it only added a shadow copy per
fbdev client and a blit plus an atomic commit for every console update
(an idle text VT keeps committing for the cursor blink). Its commit
message also said that no DCP generation shows such drawing, which is
wrong for those interfaces.

Ask the backend instead. dcp_caches_scanout() is true for an interface
that may keep presenting a cached copy of the last swapped frame: the M4
IOMFB backend with its idle cache. appledrm's fb_create hands out
framebuffers with the dirty hook when one of its CRTCs is driven by such
a backend, and plain ones otherwise, as before the previous change. The
T8132 external CRTCs are not apple_crtcs and their presents never enter
the idle cache, so they do not count.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Addressed the App review in e4594e2 (one new commit, no force push).

  • dcp_caches_scanout(pdev) is the backend capability. It is true for the M4 IOMFB backend, whose idle cache can keep presenting a copy of the last swapped frame.
  • apple_fb_create() hands out dirty framebuffers only when a CRTC is driven by such a backend. Everything else gets drm_gem_fb_create, as before drm/apple: turn framebuffer damage into a commit #2797. That covers M1/M2/M3, the T8132 firmware-27 path, and devices without an M4 CRTC.
  • The T8132 external CRTCs are skipped. They are not apple_crtcs, so to_apple_crtc() would be wrong for them, and their presents (iomfb_m4_ext_present*) never kick the idle cache. Only the main present and the brightness swaps do.
  • apple_drv.o and dcp.o build without warnings with the fleet config (LLVM=1).

Next: rows at e4594e2 with the same scripts. On the J713 I expect 8/8, because dcp_caches_scanout() should be true there. On the J413 I expect plain framebuffers again: 0 commits and no shadow. I'll post both here.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at e4594e2b pending exact-head CI and hardware evidence. The new scope addresses my previous code finding.

Checked: Framebuffer creation queries the actual IOMFB backend of the already constructed CRTCs. The T8132 external CRTC check guards the Apple CRTC conversion. A DRM device without a caching backend keeps plain framebuffers, preserving its fbdev path. The capability is shared across boards.

Blockers: Attach the current-head cached-panel row and a plain-scanout control together with hosted checks. The prior rows used the globally enabled callback and cannot qualify the restored plain path at this head.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (bot) needs-hw-row No hardware row at the PR head (bot) labels Nov 27, 2026
@github-actions github-actions Bot added needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 27, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Rows at e4594e2b, and a correction to my earlier J713 row.

Correction: our J713 runs the H17P (firmware-27 stub, 26B123) interface, both on its saved fleet85 and on the test kernels. It does not run the M4 IOMFB backend, and the idle cache from #1185 exists only in that backend (it is on the 26.6.2 firmware path). So the J713 numbers I posted at ae19de35 (0/8 without the change, 8/8 with it) show only that console writes now cause a commit. They do not show that the panel was frozen before. I wrote "the console stays frozen"; nobody looked at the panel, so that claim is not supported. Whether an H17P text console freezes is still open, and it needs someone to look at the screen: on a J713 on fleet85, switch to a text VT and type.

At e4594e2b, dcp_caches_scanout() is true only for the M4 IOMFB backend, so all of our Macs get plain framebuffers:

  • J713 (T8132, H17P): 0/8 commits, as designed. Smoke PASS. The reboot back to fleet85 took 31 s.
  • J413 (T8112): 0/8 commits, the same as fleet89. With the VT in the foreground there are no cursor-blink commits. One 15 s s2idle from the text VT resumed with no new DCP errors. Smoke PASS. The reboot back took 30 s.

That means this PR is a no-op at runtime on every Mac we have. The path it changes (a T8132 on the 26.6.2 firmware, where #1185 was found) needs a row on such a Mac, for example the J715 from #2319. If someone sees an H17P console freeze, adding DCP_FIRMWARE_H17P to dcp_caches_scanout() is a one-line follow-up. The ae19de3 row already shows that H17P handles those commits (8/8, smoke PASS).

Evidence (our own measurements; nothing here comes from Apple binaries): fbconrow/smoke/kernel-error logs for both Macs at both heads.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 27, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at e4594e2b: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text, pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at e4594e2b
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:display

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

The hosted checks at e4594e2b completed and the J713/J413 plain-scanout controls are recorded above. The remaining feature row needs a T8132 boot using the cached M4 IOMFB backend (26.6.2 stub), such as the J715 reported in #2319 if it still uses that backend. A useful paired receipt is console redraw after idle on the saved boot and at e4594e2b, with the cache backend identified, followed by a saved-boot return. Our J713 is on H17P and only covers plain scanout for this head.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

code-owner ping @DjDeveloperr: closeout merge at e4594e2b. App approved at this head, CI green. Rows at this head on J713 (T8132) and J413 (T8112): plain framebuffers, 0 of 8 commits as designed, smoke PASS, J413 s2idle clean. The cached-IOMFB path itself only has the #2319 J715 row; an exact-head row on a T8132 with the cached M4 IOMFB (26.6.2) goes to a known-gap issue. Merging under the 6-point rule 1 h from now unless you object.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging under the 6-point rule (Ryan 09:29, permanent), at e4594e2b. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J713+J413@head(runtime-no-op). (5) There's no blocking review. (6) Dj was pinged here 91 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit 2a4d761 into main Nov 29, 2026
21 of 26 checks passed
@RyanTheTide
RyanTheTide deleted the isw/fbdev-damage-v2 branch November 29, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:display Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

j713 (MacBook Air M4): appledrm idle cache freezes a console-only screen (fbcon never swaps)

1 participant