Repository navigation
drm/apple: report a firmware 27 ProMotion panel as VRR capable - #3616
Conversation
A firmware 27 internal ProMotion panel (K114s, T6050) already refreshes at the pace of the swaps. Flip timing on the K114s with plain atomic page flips and no mode set: each swap is shown at the first 240 Hz tick after it is submitted, no sooner than one 120 Hz period after the previous one. Steady 48 Hz submits give 20.8 ms flips (a fixed 120 Hz grid would alternate 16.7 and 25 ms), 100 Hz gives 8.3 and 12.5 ms, and 2 Hz gives 500 ms. macOS sends no refresh rate with its swaps on this firmware either. The panel's timing lists its variable refresh range as zeros, so the connector reported no VRR and compositors never let the panel follow a game or a 24/48 fps video. Taking the zeros as the 24-120 Hz range (as on desktop 26.x) is not an option: a mode set that sends that minimum rate crashes the firmware 27 panel's DCP. Report the fixed 120 Hz timing of a firmware 27 panel as variable, with the 24 Hz floor macOS gives these panels, and keep the mode itself fixed. VRR_ENABLED already causes no mode set on these panels, and every path that sends a minimum rate requires a VRR mode, so none is ever sent. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The VRR report read the refresh rate from the published copy of the mode, which the connector owns once dcp_publish_mode() has taken it (the apple-dcp host fixture frees it there: heap-use-after-free in publication-hpd and panel-dimensions). Read it from the driver's own mode list instead. Give the rate fixture drm_mode_vrefresh() and test dcp_refresh_swap_paced() in panel-refresh-range as well. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
K114s row with this exact head (349a2fa): PASS. Setup: Ryan's default kernel 7.3.0-k114sstack7 (bridge8) on a one-shot BLS entry, with a copy of its initramfs carrying appledrm = bridge8 + this diff (build ID e87fffa9 live). Default entry, ESP and Stage 2 untouched.
|
There was a problem hiding this comment.
Verdict: MERGE at 349a2fa5
Blockers: None (await queued hosted CI checks to complete green before merge).
Checked:
dcp_refresh_swap_paced()(drivers/gpu/drm/apple/dcp-refresh.h) and itsdcp_get_modes()caller (drivers/gpu/drm/apple/iomfb.cL2896, L3176–3195) scope the synthetic 24–120 Hz VRR report strictly todcp->fw_compat == DCP_FIRMWARE_V_27_0 && dcp_has_panel(dcp)fixed 120 Hz ProMotion timings (!modes[i].vrr && dcp_refresh_is_promotion(...)). Desktop 26.x, 13.x/14.x panels, non-120 Hz modes, existing VRR timings, and all external displays (including firmware 27 externals) are untouched.- Commit
349a2fa5cleanly resolves the8a885a70use-after-free by computingdrm_mode_vrefresh(&modes[i].mode)on the driver-owned mode copy rather than the connector-owned copy passed todcp_publish_mode(). - Verified
modes[i].vrrstaysfalsethroughout:dcp_crtc_atomic_check()(dcp.cL2457–2458) already suppresses mode-set triggers onVRR_ENABLEDtoggles for firmware 27 panels, and every firmware minimum-rate path iniomfb_template.c(dcp_peer_modeset_v27()L4499,dcp_set_adaptive_sync()L4512–4518,dcp->vrr_enabledL4583,dcp_vrr_update()L4612) gates onmode->vrr/dcp->vrr_enabled, soIOMFBPARAM_ADAPTIVE_SYNCis never sent to the firmware 27 DCP. connector->display_info.monitor_range(min_vfreq = 24,max_vfreq = 120) is populated after the EDID update path (iomfb.cL3215–3219).- Unit/host coverage (
parser_mode_test.cdcp_refresh_swap_paced_test,display.py, andrate.pydrm_mode_vrefreshstub) covers both positive and negative cases, and the exact-head349a2fa5K114s hardware row passed (3024x1986@120.000+vrradvertised and selected by Mutter,VRR_ENABLED0/1 submit-paced flips verified, 0 DCP crashes including GDM restartvrr:0mode set and reboot).
Evidence
drivers/gpu/drm/apple/dcp-refresh.h:dcp_refresh_swap_paced()requiresfw27_panel && !vrr && dcp_refresh_is_promotion(rate), writing*low = 24U << 16,*high = ratewithout modifying caller state onfalse.drivers/gpu/drm/apple/iomfb.c:fw27_panel = dcp->fw_compat == DCP_FIRMWARE_V_27_0 && dcp_has_panel(dcp)(L2896);adaptivetracks reported VRR independently ofmodes[i].vrr(L3176–3194) and populatesvrr_capableandmonitor_range.{min,max}_vfreq.drivers/gpu/drm/apple/dcp.c(L2456–2468) anddrivers/gpu/drm/apple/iomfb_template.c(L4497–4583, L4612): confirmed noVRR_ENABLEDmode-set trigger and noIOMFBPARAM_ADAPTIVE_SYNCcall whenmode->vrr == false.- Reported local verification at
349a2fa5: KUnit 381/382 pass (1 skip), host tests 822/822 pass, exact-head K114s row PASS (traces/display/20261129-k114s-fw27-vrr).
|
Relight + reboot row at 349a2fa (the #3369 crash path): PASS, 0 DCP crashes.
|
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
|
Merge-train note at |
There was a problem hiding this comment.
Verdict: MERGE at 349a2fa5 (K-board adversarial review). One PR-text correction below. It doesn't block the merge, but please fix it before merging.
Checked (what I tried to break):
- Whether any DCP call changes. With VRR reported, a compositor will set
VRR_ENABLED=1, so I followed every user ofcrtc_state->vrr_enabledanddcp->vrr_enablediniomfb_template.c: the mode-setmodeset->vrr(L4185),set_digital_out_mode/ adaptive-sync minimum (L4499, L4512-4516),dcp->vrr_enabled(L4264, L4583),dcp_vrr_update(L4612) and the swap timestamps (L4813). Each one is ANDed withmode->vrr, which stays false because the helper only changes the localadaptive.dcp->vrr_enabledstays 0, so the swap stream doesn't change and no minimum rate is sent: the #3369 crash path is closed. AVRR_ENABLEDtoggle doesn't setmode_changedin the DRM core, andapple_connector_notch_fastsetrefuses a fastset when vrr_enabled changes. So the row's "VRR-on mode set, 0 crash" covers the one path that is left. - The helper. It needs fw27, a panel, no range of its own (
vrrfalse), and a ProMotion rate.drm_mode_vrefresh()rounds 119.88 to 120, which is still inside the +/-0.2 % window. The 24 Hz floor matches the existingdcp_refresh_range()default for ProMotion zeros. The UAF fix (rate read frommodes[i].mode, not the publishedmode) is right.monitor_rangeis still written after the EDID reset (L3216), as before. - Evidence. The flip-timing logs in
traces/display/20261129-k114s-fw27-vrr(ft-hz*.log,rvrr-v0/v1-*) back up the 240 Hz-tick claim: steady 20.8 ms at a 48 Hz submit pace. The exact-head K114s row covers Mutter selecting+vrr, VRR 0/1 flips, 10 relights and 3 reboots with 0 DCP crashes. The 1 KUnit skip is the same pre-existing skip seen on main (#3502/#3542 runs). Onlyreadinessfails on hosted CI, which is the Core-approval gate. The KUnit legs are still queued.
PR-text correction (please fix):
- The
Risk:line saysM5 Pro (K114s), but the condition isfw_compat == DCP_FIRMWARE_V_27_0 && dcp_has_panel(). Any DCP whose firmware-compat is 27 or later reaches that: the genericdcp_firmware_27()path, the T6041 27.2 pin (M4 Pro/Max MacBook Pro) and the T8122 27.2 pin. So every ProMotion MacBook Pro running a 27.x stub would now report VRR 24-120, and only the K114s has been measured to swap-pace. Elsewhere the change only affects what is reported (see above), so the worst case is VRR advertised on a panel that keeps a 120 Hz grid, which gives the flips it gets today. Please widen the line, e.g.Risk: two-way · ProMotion MacBook Pros on firmware 27.x (measured on the K114s; reporting only elsewhere). MERGETRAIN6's 23:15 second-family hold is the right gate for those Macs. In the lab, the J616s on 26.x is outside the condition, so a J616s "vrr_capable unchanged, 0 DCP crash" row is enough there.
Non-blocking: Mutter derives +vrr variants for every mode once the connector is vrr_capable, including the panel's 60 Hz-class timings, which this PR doesn't mark. They stay fixed (no mode->vrr), so that's harmless, but a 60 Hz + VRR selection hasn't been rowed.
|
Merge-train note: KREVIEW points out the Risk line understates the scope. It's any ProMotion MacBook Pro on firmware 27.x, including the T6041 27.2 pin, not only the K114s. Please widen the Risk line; the second-family VRR row ask stands (a J616s inert row is fine as the regression row). |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
J616s regression row (second family, asked by the merge train): PASS, inert. J616s (M4 Pro 14", DCP firmware 26.6.2) on its saved Edge kernel 7.3.0-aurora-edge (933f822), one-shot boot with appledrm rebuilt from 933f822 + this PR's two commits (driver diff identical to the PR), then a plain reboot back to stock. All three boots (stock, lab, stock) match:
So the helper stays off on firmware 26, as intended. Risk line widened as asked. |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
What
Report a firmware 27 internal ProMotion panel (K114s, T6050) as VRR capable (
vrr_capable1, range 24-120 Hz) without making its mode variable. The DCP never gets a minimum rate.Why
On firmware 27 the panel already refreshes when a swap arrives. I measured this on the K114s (7.3.0-k114sstack7, gdm stopped, plain atomic page flips, no mode set after the first; tool
fliptime, kitkits/test/20261129-k114s-vrr-row). Each swap is shown at the first 240 Hz tick (4.167 ms) after it is submitted, and at least one 120 Hz period after the previous one:Flip phase modulo 4.167 ms gives a concentration R of 0.98-0.99 at every pace. Modulo 8.333 ms, R is 0.02 at 48 Hz. macOS traces of the same panel under our HV (DCP-HVTRACE dh8d, CADisplayLink 24/48/60/120 and a 24-120 phase) show no refresh-rate field in the swap either, so ProMotion there is presentation-time pacing too.
The panel's timing lists its VRR range as zero placeholders, so the connector reported no VRR and Mutter/KWin never let the panel follow a game or a 24/48 fps video. #3369 (closed) instead took the zeros as a 24-120 Hz range, which made the mode variable. A mode set that sends that minimum rate (the shutdown fbdev mode set) crashes the firmware 27 DCP.
How
dcp_refresh_swap_paced()(dcp-refresh.h): a firmware 27 panel's fixed ProMotion timing gets a 24-120 Hz range for reporting only.dcp_connector_get_modes-path (iomfb.c): such a timing setsvrr_capableand the connector'smonitor_range.modes[i].vrrstays false.dcp_crtc_atomic_check). Every path that sends a minimum rate (iomfb_modeset,dcp_set_adaptive_sync, peer frames) requiresmode->vrr, so nothing reaches the DCP. The swap stream is byte-for-byte what it was.DCP_FIRMWARE_V_27_0plus a panel plus a 120 Hz timing that has no range of its own.Tested: at 349a2fa: KUnit (appledrm config, arm64 LLVM) 381/382 pass, 1 skip, incl. new
dcp_refresh_swap_paced_test;tools/asahi/run-host-tests.py822/822 (incl. new panel-refresh-range cases; the run caught a use-after-free of the published mode in 8a885a7, fixed in 349a2fa); checkpatch clean; K114s flip-timing measurement above on the unchanged driver; K114s exact-head row PASS (Mutter offers and selects3024x1986@120.000+vrr; VRR_ENABLED 0/1 flips accepted, same submit pacing; 0 DCP crash incl. a VRR-on mode set; relight row (CRTC off->on x10 with VRR_ENABLED=1) + 3 reboots with Mutter VRR on: 0 crash; traces/display/20261129-k114s-fw27-vrr). J616s (desktop 26.x) is outside the condition (KUnit/host negatives).Risk: two-way · every ProMotion MacBook Pro whose DCP runs firmware 27.x: the M5 Pro K114s (tested) and the M4 Pro J614s/J616s on the T6041 27.2 pin (J616s regression row pending). Low: the connector property and range change only on firmware 27 internal ProMotion panels. No DCP call changes. Worst case, a compositor that enables VRR sees the same flips it gets today.