Skip to content

drm/apple: offer a firmware 27 ProMotion panel's fixed rates as paced modes - #3693

Closed
RyanTheTide wants to merge 1 commit into
mainfrom
fix/dcp-fw27-paced-fixed-modes
Closed

RyanTheTide wants to merge 1 commit into
mainfrom
fix/dcp-fw27-paced-fixed-modes

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

What

Offer the fixed refresh rates of a firmware 27 ProMotion panel (T6050, M5 Pro/Max MacBook Pro), the set macOS offers: 120, 60, 59.94, 50, 48 and 47.95 Hz, next to Variable. Until now the panel offered only 120 Hz, and compositors showed its VRR range as 47-120 Hz instead of 24-120.

Why

The firmware lists those rates in its timing catalog (each extra rate is marked IsPromoted), but a mode set away from the 120 Hz timing crashes the T6050 internal DCP, so dcp_mode_settable() hides them. The panel doesn't need that mode set: it shows each swap on the first 240 Hz tick after the swap arrives (the pacing #3616 reports as VRR).

How

  • dcp_find_mode() resolves a paced rate to the 120 Hz catalog entry of its size, so a mode set, dcp_mode_settable() and every firmware call only ever see the 120 Hz timing.
  • apple_connector_rate_fastset(): switching between rates of one timing is no mode set, like the existing notch-geometry fastset.
  • iomfb_pace_hold() holds a paced swap in the IOMFB queue until its due time (hrtimer). Due times are whole periods apart: 60 and 48 Hz are whole panel ticks, and 59.94, 50 and 47.95 Hz keep their average. A swap a period or more late restarts the schedule from the last swap shown. VRR_ENABLED turns pacing off.
  • Only while the panel runs the 120 Hz timing (dcp_paced_rates()); a panel iBoot left at 60 Hz keeps just that timing.
  • The synthesized panel EDID's range minimum now comes from the paced floor (24 Hz) instead of the lowest timing (47.95 Hz).

Tested: KUnit (appledrm config, arm64 LLVM) 357/358 pass, 1 skip, incl. the extended parser_internal_v27_only_120hz and parser_panel_identity cases; tools/asahi/run-host-tests.py 846/846 (host harness stubs updated); checkpatch clean. K114s (M5 Pro 14", firmware 27), lab module on its 7.3.0 kernel: six eDP modes, EDID range 24-121, Mutter lists all six with their Variable variants. Measured flip-event rate per mode with a client flipping as fast as events come (349 flips each): 120.024 / 60.001 / 59.957 / 50.004 / 48.001 / 47.946 Hz; VRR still variable. Live Mutter switches through all six rates: 0 firmware mode sets, 0 DCP crashes. J616s (M4 Pro, firmware 26.6) regression on its Edge kernel with this change: identical modes and Mutter list, measured 120.001 / 60.000 / 59.940 / 49.998 / 48.000 / 47.953 Hz, same as stock.
Risk: two-way · M5 Pro/Max (T6050) internal panel only. Medium: new swap pacing in the firmware 27 IOMFB queue for the non-120 Hz modes; 120 Hz and VRR swaps are not held. Every firmware mode set still uses the 120 Hz timing, so the known DCP crash path stays closed. Other machines: dcp_paced_rates() is false, so the only change is an untaken branch.

… modes

Firmware 27 lists the T6050 internal panel's fixed rates next to its
120 Hz timing: 60, 59.94, 50, 48 and 47.95 Hz, each marked IsPromoted,
the set macOS offers.  Linux offered only 120 Hz, because a mode set
away from the 120 Hz timing crashes the DCP (dcp_mode_settable()).

The panel does not need that mode set: it shows each swap on the first
240 Hz tick after the swap arrives (dcp_refresh_swap_paced()).  So offer
each fixed rate as a mode of its own that keeps the DCP on the 120 Hz
timing of its size, and pace the swaps to the rate:

- dcp_find_mode() gives a paced rate's 120 Hz entry, so a mode set,
  dcp_mode_settable() and every firmware call see that timing only.
- Switching between paced rates of one timing is no mode set
  (apple_connector_rate_fastset()), as with the notch geometries.
- iomfb_pace_hold() holds a paced swap until its due time, kept whole
  periods apart, so 60 and 48 Hz are whole ticks and 59.94, 50 and
  47.95 Hz keep their average.  A swap a period late starts again from
  the last swap shown.  VRR_ENABLED turns the pacing off.

Only while the panel runs the 120 Hz timing; a panel iBoot left at
60 Hz keeps just that.

The panel EDID's range also started at its lowest timing (47 Hz), which
is what compositors show as the VRR range; take the paced floor (24 Hz)
instead.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team and DjDeveloperr as code owners November 30, 2026 08:54
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merge readiness at 76de6e29: not ready yet

Check Detail
CI at head running running: kunit, apple-build, host-tests, KUnit ane-boot, KUnit ane-pm, KUnit dcp-fabric
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 76de6e29
Conflicts ok none
PR text ok Risk: two-way · M5 Pro/Max (T6050) internal panel only. Medium: new swap pacing in the firmware 27 IOMFB queue for the non-120 Hz modes; 120 Hz and VRR swaps are not held. Every firmware mode set still uses the 120 Hz timing, so the known DCP crash path stays closed. Other machines: dcppacedrates() is false, so the only change is an untaken branch.

Areas: area:display, area:gpu

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

Hardware rows at head 76de6e29 (this commit cherry-picked onto each Mac's running kernel, appledrm built as a module, one-shot boot, then back to the default):

  • 76de6e29 K114s (M5 Pro 14", firmware 27): PASS. Six eDP modes (120 / 60 / 59.94 / 50 / 48 / 47.95), EDID range 24-121, Mutter lists all six plus Variable. Measured flip rate per mode, client flipping as fast as events come, 349 flips each: 120.024 / 60.001 / 59.957 / 50.004 / 48.001 / 47.946 Hz. VRR still variable. Live Mutter switches across all six: 0 firmware mode sets, 0 DCP crashes.
  • 76de6e29 J616s (M4 Pro 16", firmware 26.6, on top of drm/apple: report a firmware 27 ProMotion panel as VRR capable #3616 since its kernel predates it): PASS, inert. Same modes, Mutter list and vrr_capable as stock. Measured 120.001 / 60.000 / 59.940 / 49.998 / 48.000 / 47.953 Hz, matching stock (120.022 / 60.011 / 59.951 / 50.009 / 48.009 / 47.952).

@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 76de6e29

Blockers:

  • Hosted CI is still queued at 76de6e29 (kunit, apple-build, host-tests, and 17 KUnit suites queued; pr-text and readiness passed).

Checked:

  • All 11 changed files (apple_drv.c, dcp-display-metadata.{c,h}, dcp-internal.h, dcp.c, iomfb.c, iomfb_template.c, parser-test.c, dcpext26-queue-tests.py, desktop.py, rate.py).
  • Verified dcp_paced_rates() strictly scopes pacing to firmware 27 T6050 internal ProMotion panels running the 120 Hz boot timing (only_120hz_modes && fw_compat == DCP_FIRMWARE_V_27_0 && (!boot || boot == 120) && dcp_has_panel(dcp)), leaving M1–M4, T8142 Air 60 Hz, external displays, and 60 Hz iBoot panels untouched.
  • Verified dcp_find_mode() -> dcp_paced_base() keeps every firmware call and dcp_mode_settable() on the 120 Hz timing, apple_connector_rate_fastset() avoids firmware mode sets across same-size paced rates, dcp_pace_ns() disables pacing on 120 Hz and VRR_ENABLED without u64/u32 overflow, and iomfb_queue_stop() teardown ordering (stopped = true under iomfb.lock -> hrtimer_cancel(&pace_timer) -> cancel_work_sync(&work)) is race-free.
  • Verified exact-head 76de6e29 hardware rows on K114s (all 6 rates measured within ~0.02 Hz, VRR variable, 0 firmware mode sets, 0 DCP crashes) and J616s (inert regression pass).
Evidence
  • Non-blocking ordering nit: in drivers/gpu/drm/apple/iomfb_template.c, dcp_report_swap_complete() writes dcp->iomfb.last_complete after iomfb_present_complete_h17p(dcp) clears present_state_h17p.pending and wakes iomfb.work. On the first swap after an idle gap, a racing iomfb_pace_hold() on another CPU could read the previous last_complete and send that single swap immediately before resynchronizing on the next swap (harmless, never stalls or crashes).
  • Ready to approve once hosted build, KUnit, and host-tests checks complete green at 76de6e29.

@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.

Adversarial review at 76de6e2 (non-author, KREVIEW, K-board split).

Verdict: MERGE at 76de6e2. Hosted CI is still queued on the shared runners. I ran the two suites it would run locally; readiness gates on the hosted jobs separately.

Checked:

  • Read the whole diff, plus the queue, atomic-check, mode-lookup and teardown code around it.
  • Reproduced locally at this head on the buildbox:
    • kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/gpu/drm/apple/tests/display.kunitconfig (the apple-drm-kunit.yml command): 181 run, 180 pass, 1 skip. parser_internal_v27_only_120hz and parser_panel_identity pass. The one skip is apple_g17_rx_util_min_test (needs CONFIG_UCLAMP_TASK), not this PR.
    • tools/asahi/run-host-tests.py: 846/846.
  • Crash path stays closed: dcp_find_mode() maps a paced rate to the same-size 120 Hz catalog entry only while dcp_paced_rates() holds (fw 27, only_120hz_modes, panel, boot rate 0/120). dcp_mode_settable() now judges the entry the DCP would run, so every firmware mode set still carries the 120 Hz timing. A size with no 120 Hz entry falls back to its own entry and is still refused. When iBoot left the panel at 60 Hz, pacing is off and the old single-timing rule applies (KUnit covers both).
  • Fastset: apple_connector_rate_fastset() runs after the notch fastset and before the colorspace/EOTF/bpc checks, so a commit that also needs a real mode set for those still gets one. The crtc-check VRR re-modeset (dcp.c ~2499) runs later and excludes fw 27 panels anyway. a == b compares pointers into one dcp_modes_snapshot(). If the catalog is replaced between the two lookups, the comparison fails safe to a full mode set.
  • Pacing: iomfb_pace_hold() runs under iomfb.lock at the queue head only and touches only presentation transactions. 120 Hz and VRR swaps reset the schedule. A held swap blocks non-presentation work behind it for at most one period (<= 20.9 ms), against the 10 s queue timeout, which only arms on active.
    • pace_ns tops out at ~41.7 ms and fits u32.
    • Stale pace_next/last_complete after a stop/restart or iomfb_reset_transport() self-heal: the late branch re-anchors, and an anchor in the past sends at once.
    • Teardown: iomfb_queue_stop() sets stopped under the mutex before hrtimer_cancel(). A racing work item therefore bails before it can re-arm, and cancel_work_sync() follows. Every remove/unbind/fail-stop path I found calls iomfb_queue_stop().
  • Scope: only T6050 internal panels can make dcp_paced_rates() true. The J616s row (fw 26.6) shows the untaken branch: same modes and rates as stock.

Non-blocking:

  1. On a fastset, drm_atomic_helper_update_legacy_modeset_state() skips the CRTC (mode_changed false). So legacy crtc->mode (GETCRTC) keeps reporting the previous rate. The atomic MODE_ID blob is right. Same as the notch fastset; worth one comment line.
  2. dcp_panel_paced_min() returns the last match, not the minimum. All matches return 24 today, so the result is the same; min_not_zero() would make the name true.
  3. With VRR_ENABLED on a paced mode, pacing is off and the panel runs at swap pace up to 120 Hz. "60 Hz Variable" therefore behaves like "120 Hz Variable". That's harmless for Mutter, whose frame clock follows the mode, but say so in the commit message.
  4. 59.957 Hz measured against 59.94 nominal sits inside one 240 Hz tick of sampling error over 349 flips (~5.8 s). A ~3000-flip run at 59.94 would show whether there is any long-run drift for video playback.
  5. K116c/K116s (same T6050 panel path) aren't rowed. The code path is identical, so I'm not holding for it, but an owner row would be welcome.

@RyanTheTide
RyanTheTide marked this pull request as draft November 30, 2026 09:20
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

On hold (draft): macOS puts this panel on its real 60 Hz timing, and the M4 Pro (firmware 26) takes real mode sets to the same timings, so pacing is not what macOS does. A real 120 -> 60 Hz mode set from Linux crashes the firmware 27 DCP today (DPTX FIFO error, hot and cold), so the next step is to find what macOS sends for that switch and fix the real mode set. Pacing stays here only as a fallback.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Superseded by #4059 (rebased on main at 13dc5a7, no force push).

@RyanTheTide RyanTheTide closed this Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Two notes from working on the M3 Pro side (#4058, which sets only_120hz_modes on T6030):

On the real mode set: every T6050 crash I found is a K114 board. I found no record of a 120 -> 60 Hz mode set on a mini-LED T6050 (J714s, J716c); the J716c took the same-timing full mode set in #3399. We have an instrumented J714s run ready that separates "any full mode set" from "a timing change".

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) area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants