Repository navigation
drm/apple: turn framebuffer damage into a commit - #2319
RyanTheTide wants to merge 1 commit into
Conversation
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 Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Hardware row for this change: J715 (MacBook Air 15-inch, M4, 2025), internal panel, firmware 26.6.2. The change tested is the same code change as this PR, the Machine and build
Results
Swap timing on the consoleTo check that the dirty path does not stall the console, a debug build of the same change added timing to Over 92 + 99 + 226 swaps (write, flood and typing runs):
No |
|
Blockers: 1.
The change is sound. drivers/gpu/drm/apple/apple_drv.c:793 gives every appledrm framebuffer a dirty hook, so The change moves fbcon onto a different path on every DCP generation: a vmalloc shadow of the full panel plus one commit per damage batch. M4 is the only generation that has been run. The PR body's own plan lists the other generations, and they are what this needs before it merges. HW row: this head on the M1 Pro (J316s), M2 (J413) and M4 Pro (J616s), on the default command line. Pass: the boot console scrolls on the panel up to switch root, a VT switch from gdm to tty3 shows a live login prompt and typing echoes, switching back restores the session, there are no DCP swap errors or timeouts in the log, 0 AVC, 0 failed units and no new kernel errors. A J713 (M4 Air) run on this exact head would close #1185 on the board it was filed for. Assisted-by: LLM (Claude:Opus 5.5) |
|
Replaced by #2797: the same changes with the commit trailers fixed, on the current integration/aurora.The J715 row from this PR is linked from the new description. |
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 withdrm_gem_fb_create, which has no dirty hook, sodrm_fbdev_dmasets up its unshadowed path and no damage is ever generated. The only ways back were a commit from somewhere else (fb0 blank/unblank) orappledrm.idle_cache_ms=0on the command line.Change
apple_mode_config_funcs.fb_create = drm_gem_fb_create_with_dirty(the dcpext shadow driver already uses it). With a dirty hook:drm_fbdev_dma_driver_fbdev_probe()takes its shadowed, deferred-I/O path; each damage batch goes throughdrm_fbdev_dma_helper_fb_dirty()todrm_atomic_helper_dirtyfb(), a plane commit of the same framebuffer.dcp_flush()->iomfb_m4_present(), which leaves the idle cache (any swap does) and re-arms it throughiomfb_m4_idle_cache_kick(). A console that stays static is still cached afteridle_cache_ms; one that changes is shown.DRM_IOCTL_MODE_DIRTYFBcallers (front-buffer X, simple KMS clients) get the same behaviour instead of-ENOSYS.It is not limited to M4 or to the idle cache: no DCP generation shows drawing it was not given a swap for, so the hook is the default for every board the driver binds. Compositors that flip do not call DIRTYFB and see no change.
Testing
0abc2f385e+ this change: every touched file built for arm64 (gcc, kernel warning flags,-Werror) with no warnings. The full KUnit run is still to do.appledrm.idle_cache_mson the command line); and an fbcon regression row (boot console scrolls, VT switch, no DCP errors) on M1 Pro, M2 and M4 Pro. Draft until those are in.Assisted-by: LLM (Claude:Opus 5.5)