Repository navigation
drm/apple: ask software-rendering clients for a shadow buffer - #2571
Conversation
appledrm's dumb buffers come from the DMA GEM helpers and are mapped write-combined to user space. A compositor that renders in software into them, which is every compositor on a Mac whose GPU driver is not up yet, reads back from uncached memory for every blend. On the M3 MacBook Air (J615) with no GPU driver, GNOME's gnome-shell spends a whole CPU core and presents about one frame a second on the 2880x1800 panel while the DCP completes each swap in 4 to 15 ms. Set mode_config.prefer_shadow, so DRM_CAP_DUMB_PREFER_SHADOW tells those clients to render into a cached shadow buffer and copy the damage. Mutter reads the cap and uses a shadow buffer only when it renders in software; with a hardware renderer nothing changes. Signed-off-by: Ryan Murray <[email protected]>
|
Tested on an M2 MacBook Air (J413, T8112), kernel 7.3.0-aurora-fleet76, GNOME 50 / mutter 50.6, Aurora Mesa 26.3. Method: the same fleet76 tree built twice (stock appledrm.ko and appledrm.ko with this diff, W=1 with no warnings), one plain boot of each, with checks taken while the GNOME session was running. Mutter prints
Assisted-by: LLM (Claude:Opus 5.5) |
|
Merge-train adversarial review (MERGETRAIN-LINUX2) at 81282b6: NO BLOCKERS. Code read only, nothing built here. Before the merge it still needs Dj's verdict at this head; the missing rows are listed below. Full review#2571 drm/apple: ask software-rendering clients for a shadow buffer @81282b64VERDICT: NO BLOCKERS drivers/gpu/drm/apple/apple_drv.c:1721-1726 sets Nits:
Missing rows: J616s or Neo (other DCP generation, |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR checklist review at 81282b6451d121f9a1da7add0448d805d8d45292 (§1–§6): 0 blockers — APPROVE.
Code & Source Verification
drivers/gpu/drm/apple/apple_drv.c:1726unconditionally setsapple->drm.mode_config.prefer_shadow = trueduringapple_drm_init(), matching the DMA GEM write-combined dumb-buffer mapping (apple_drm_gem_dumb_create->drm_gem_dma_dumb_create_internal).- Verified across
drivers/gpu/drm/that the sole in-kernel reader ofmode_config.prefer_shadowisdrivers/gpu/drm/drm_ioctl.c:273(DRM_CAP_DUMB_PREFER_SHADOW). - Verified
drivers/gpu/drm/drm_fbdev_dma.c:306selects shadowed fbdev strictly fromfb->funcs->dirty, so in-kernelfbconis unaffected.
Checklist Summary
- §1 No model gating: Pass — unconditional across all
appledrmdevices; no chip/SoC/board/firmware gating. - §2 Production-ready: Pass — works on default command line with no parameters, delays, or workarounds.
- §3 Safety: Pass — no hardware safety limits or protection paths touched.
- §4 Clean-room & attribution: Pass — commit
81282b64carries human author/committer andSigned-off-by: Ryan Murray <[email protected]>with no AI trailers;Assisted-by:is in the PR body. - §5 Evidence: Pass — covers both affected paths on this exact diff: software-renderer A/B on J615 (M3 Air, 0.8/s -> 5.4/s swaps, 60.000 Hz pure-KMS unchanged) and hardware-renderer A/B on J413 (M2 Air,
7.3.0-aurora-fleet76, GNOME 50 / Aurora Mesa 26.3: cap 0 -> 1, GPU-imported scanout unchanged, idle CPU unchanged, 0 kernel errors / 0 AVC / 0 failed units). - §6 Naming: Pass.
- CI:
host-testsSUCCESS on live head81282b64.
Non-blocking note: hardware-renderer testing covers single-device Mutter (GNOME); KWin/Plasma, Xorg modesetting, and external-display copy paths were not sampled, though advertising DRM_CAP_DUMB_PREFER_SHADOW for write-combined dumb buffers is standard DRM behavior.
Assisted-by: LLM (Gemini 4 Neon)
Problem. appledrm's dumb buffers come from the DMA GEM helpers and are mapped write-combined to user space. A compositor that renders in software draws straight into them and reads back from uncached memory on every blend. Every compositor renders in software on a Mac whose GPU driver isn't up yet, e.g. the M3 MacBook Air on macOS 27.2 firmware tonight. GNOME on the J615 (2880x1800) used a whole core and presented about one frame a second, while the DCP finished each swap in 4-15 ms.
Change. Set
mode_config.prefer_shadow.DRM_CAP_DUMB_PREFER_SHADOWthen tells such clients to render into a cached shadow buffer and copy. Mutter logs the cap at start-up for every KMS device, but acts on it only when it renders in software:should_force_shadow_fb()(meta-renderer-native.c) returns before reading it when the renderer is hardware. With a hardware renderer nothing changes.Testing. J615 (MacBook Air 15" M3), macOS 27.2 stub, lab kernel with the 27.2 internal-display series, appledrm.ko with and without this change, GNOME 51 (Mutter software path):
Device '/dev/dri/card1' prefers shadow buffer(not logged before).iomfb_swap_completeevents went from about 0.8/s to 5.4/s (44 in 8.1 s). gnome-shell is still CPU-bound (~98 % of one core), so this is a mitigation until the GPU driver exists, not a fix.Hardware renderer (M2, fleet76, GNOME on the GPU driver). The cap reads 1 with this change, gnome-shell stays on the GPU render node, and the appledrm framebuffer list is the same as with the stock module (gnome-shell's XR30 scanout imported from the GPU, plus fbcon; no dumb or shadow buffers). Idle gnome-shell CPU is unchanged (0.1-0.4 %). Row: #2571 (comment)
Method and evidence
kits/test/20261120-j615-disp/shadow/(module dbac7cc1, built against the j615d1 tree, signed with its key). Rows:shadow-row.sh(gtkhz, a GTK4 fullscreen client queueing a redraw every frame,GSK_RENDERER=cairo, plus a private tracefs instance ondcp:iomfb_swap_complete, plus gnome-shell utime+stime over the window).Assisted-by: LLM (Claude:Opus 5.5)