Skip to content

drm/apple: let a preferred timing with unsafe SDR elements be the default - #3002

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
satchlj/dcp-unsafe-preferred-default-20261123
Nov 23, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
satchlj/dcp-unsafe-preferred-default-20261123

Conversation

@satchlj

@satchlj satchlj commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf (updated 2026-11-23 by Claude Fable 5.2 for head d51708aa).

drm/apple: an external display's default mode can now be a timing that the firmware marks IsPreferred even when all its SDR color elements are listed unsafe. Without this, a 4K display behind a USB-C→HDMI converter comes up at 1080p.

The problem

  • Symptom: on lobata (J775c, Mac Studio M5 Max), a Dell S2725QS on a USB-C→HDMI cable (a Parade PS176 converter, DP alt mode on dcpext0) comes up at 1920×1080 @ 120 Hz. macOS drives the same display and cable at 3840×2160 @ 60 Hz (DPTimingModeId 50, HBR2 ×4).
  • Firmware state: the firmware's TimingElements mark 3840×2160 @ 60 IsPreferred, with the highest score. They also list every color element of that timing in UnsafeColorElementIDs. The unsafe ones are the timings above the 340 MHz of the EDID's HDMI 1.4 block (4K60 at 594 MHz, 1440p120 at 498 MHz); the EDID's HDMI 2.x block takes 600 MHz. macOS reads the same list from the same firmware and still drives 4K60.
  • What Linux did: dcp_external_default() skips any timing without a safe SDR element (!sdr_usable), so the native-resolution pick fell to 1080p120.

Change

  • parser.c records sdr_unsafe for an SDR element that is unsafe but doesn't need DSC.
  • dcp_mode_default_candidate(): a timing is a default candidate if it has a usable SDR element, or if its SDR elements are only unsafe and the firmware marks it IsPreferred.
  • dcp_external_default(): a usable preferred timing beats an unsafe one. If the firmware prefers any timing of the native resolution that has a usable SDR element, the unsafe-only timings are left out of the ranking, and the usable ones rank exactly as before this PR. An unsafe timing is the default only when the firmware prefers no usable timing of that resolution (the Dell: its only usable 4K timing is the non-preferred 30 Hz one).
  • Unchanged:
    • a timing only DSC can carry never qualifies;
    • an unsafe timing the firmware doesn't prefer never qualifies;
    • the T8140 (J700) external path, whose only unsafe elements come under its 1080p180 policy.

History

  • Written 2026-11-05 and carried in lobata's own kernel since then, but never sent as a PR. That's why lobata's newer candidates, built on integration/aurora, regressed to 1080p on this display (2026-11-23).
  • 4a63a421: the same patch, rebased onto integration/aurora 377060f3. The rebase dropped a closing brace in parser-test.c, which broke the KUnit build.
  • d51708aa (current head): brace restored, the usable-over-unsafe rule added, three KUnit cases added.

Testing

  • KUnit, on this head's source: kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/gpu/drm/apple/tests/display.kunitconfig (the Apple DRM KUnit workflow's command, clang, arm64 QEMU): 143 tests, 142 passed, 0 failed, 1 skipped (apple_g17_rx_util_min_test, which needs CONFIG_UCLAMP_TASK; unrelated). The four cases for this change pass:
    • parser_unsafe_preferred_default: the Dell catalog picks 4K60; with 4K60 not preferred it picks 1080p120.
    • parser_unsafe_preferred_dsc: a preferred timing whose SDR element is in DSCRequiredColorElementIDs keeps sdr_unsafe == false and is not a candidate, whether or not the element is also listed unsafe.
    • parser_unsafe_external_sdr: on the external_sdr == true path sdr_unsafe stays false.
    • parser_unsafe_preferred_usable_wins: usable preferred 4K30 beats unsafe preferred 4K60; the Dell shape still picks 4K60.
  • Negative control: with the usable-over-unsafe rule disabled, parser_unsafe_preferred_usable_wins fails and the rest pass.
  • checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.
  • On hardware, earlier versions of this patch only (same display and cable, J775c):
    • 2026-11-05: the old default kernel with the patch drove the display at 3840×2160 @ 60.
    • 2026-11-23: a candidate without it came up at 1080p120; the same candidate with 4a63a421's change cherry-picked came up at 3840×2160 @ 60 (row).

Not tested

  • No boot of this exact head (d51708aa). Still owed, and lobata will post it here: a J775c row on this head with the full tuple (0 SELinux denials, 0 failed units, 0 new kernel errors against a baseline).
  • No second, unaffected display. Also owed from lobata: a no-regression check on a display whose native timing is safe.
  • No second Mac.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)
Assisted-by: LLM (Anthropic:Claude Fable 5.2)

@satchlj

satchlj commented Nov 23, 2026 •

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

J775c row: 3840×2160 @ 60 with this patch, 1920×1080 @ 120 without it. Same display and cable (Dell S2725QS on a USB-C→HDMI cable, Parade PS176, DP alt mode on dcpext0), attached before boot, 2026-11-23.

Kernel External default (first modeset) 4K modes offered
lobata candidate (integration/aurora base + J775c stack + #2664), without this patch, boot 83920b43 1920×1080 @ 120, 297 MHz not read
the same candidate with this patch cherry-picked, boot fcc351e5, Image 3b0e79c2 3840×2160 @ 60, 594 MHz 7
lobata's old default kernel (carries the 2026-11-05 version of this patch), boot 415e34c1 3840×2160 @ 60, 594 MHz 7
  • Health: 0 failed units on the trial boot. The kernel error lines were the board's usual DCP notices.
  • Mode list: identical in both runs: seven 3840×2160 timings, two 2560×1440, then 1080p and below.
  • Caveat: the trial isn't this PR's exact head (it's the patch on lobata's candidate stack), and KUnit wasn't built into that kernel, so parser_unsafe_preferred_default is compile-checked only.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@satchlj
satchlj marked this pull request as ready for review November 23, 2026 16:52

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Formal Pre-PR Checklist Review (§1–§6) — REQUEST_CHANGES

Reviewed commit 4a63a421848760a9e103e41e61c1bd6e14040680 (satchlj/dcp-unsafe-preferred-default-20261123 → aurora-silicon/linux:integration/aurora).


Blockers

  1. CI failure — Apple DRM KUnit (kunit) fails to compile:

    • In drivers/gpu/drm/apple/parser-test.c:2072, the closing } of parser_internal_v27_only_120hz() was dropped during the rebase conflict resolution, nesting struct parser_unsafe_timing, blob_unsafe_timing(), parser_default_mode(), and parser_unsafe_preferred_default() inside parser_internal_v27_only_120hz() and producing 5 clang errors in Apple DRM KUnit (parser-test.o is gated on CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST, separate from parser_test.o/parser_mode_test.o).
    • Fix: Restore the closing } after dcp_modes_release(dcp); at line 2072 and verify the full Apple DRM KUnit CI workflow passes.
  2. Safe vs. unsafe ranking at the same native resolution & modeset-failure risk (drivers/gpu/drm/apple/parser.c:1225-1267):

    • dcp_external_default() filters both loops with dcp_mode_default_candidate(m) (m->sdr_usable || (m->sdr_unsafe && m->firmware_preferred)), and its second loop selects among timings of the chosen native resolution via dcp_mode_default_above(), which ranks strictly by refresh > firmware_preferred > score and ignores sdr_usable vs. sdr_unsafe.
    • If an external monitor marks two timings at its native resolution IsPreferred — e.g. a higher-refresh timing whose SDR elements are all in UnsafeColorElementIDs (genuinely exceeding link/cable capability) alongside a lower-refresh sdr_usable timing — this change promotes the unsafe higher-refresh timing to DRM_MODE_TYPE_PREFERRED over the safe one. Because drm/apple has no automatic driver-level downgrade to a safe timing if the default modeset fails or drops link, that creates a black-screen regression risk on bandwidth-limited cables/adapters.
    • Fix / clarification: In the second loop (or via a tie-breaker when selecting at the native resolution), either prefer sdr_usable over sdr_unsafe when both are firmware_preferred at the same native resolution (still letting the Dell S2725QS's IsPreferred unsafe 4K60 beat non-preferred safe 4K30 and 1080p120), or explain/prove why firmware never emits both a safe preferred timing and an unsafe higher-Hz preferred timing at the same resolution.
  3. KUnit test coverage gaps (once parser-test.c builds):

    • parser_unsafe_preferred_default currently checks preferred=true, unsafe=true (picks 4K60) and preferred=false, unsafe=true (falls back to 1080p120), but does not assert the other invariants claimed by the commit message:
      • a firmware_preferred timing whose SDR element is in DSCRequiredColorElementIDs must keep sdr_unsafe == false and must not become the default candidate;
      • the external_sdr = true (H17P / T8140) path must keep sdr_unsafe == false even when a preferred timing lists unsafe SDR elements;
      • same-resolution sdr_usable + firmware_preferred vs. sdr_unsafe + firmware_preferred policy.
  4. §5 Evidence incomplete:

    • Not tested on this exact PR head (4a63a421848760a9e103e41e61c1bd6e14040680): as noted in the J775c comment, the trial booted a cherry-pick on lobata's candidate stack rather than this PR head, and KUnit was not run (and currently does not build).
    • Incomplete §5 regression tuple: the J775c row reports 0 failed units, but omits SELinux denials (0 SELinux denials) and an explicit 0 new kernel errors count (baseline vs. PR).
    • Single-Mac / single-display coverage (§1/§5): please post a confirming run on the updated exact PR head with the full §5 regression tuple (0 SELinux denials, 0 failed units, 0 new kernel errors) plus a no-regression check on at least one unaffected external display (e.g. direct DP/HDMI sink) or second Mac.

Non-blocking note

  • In parse_color_modes() (drivers/gpu/drm/apple/parser.c:729-791), the !external_sdr branch does not filter DSCRequiredColorElementIDs out of out->sdr_rgb. If a firmware_preferred timing ever combines a higher-scored DSC-required SDR element with a lower-scored unsafe non-DSC SDR element, sdr_unsafe will be set while color_mode_id still picks the DSC-required element (pre-existing behavior for sdr_usable as well, worth keeping in mind).

Pre-PR Checklist Summary (§1–§6)

  • §1 No model gating: PASS — operates purely on firmware-reported IsPreferred, UnsafeColorElementIDs, and DSCRequiredColorElementIDs; internal panels (internal == true) and H17P external (external_sdr == true) are untouched.
  • §2 Production-ready, no hacks: FAIL — production logic has no new cmdline/module params or hacks, but parser-test.c has a broken rebase and fails Apple DRM KUnit CI.
  • §3 Safety: CONCERN — see Blocker #2 regarding promoting an sdr_unsafe preferred timing over a sdr_usable preferred timing at the same native resolution without modeset fallback.
  • §4 Clean-room & attribution: PASS — commit 4a63a421848760a9e103e41e61c1bd6e14040680 has human author/committer (Satya Benson) and human Signed-off-by: only, zero AI trailers in commit, Assisted-by: disclosed in PR body.
  • §5 Evidence: FAIL — not tested on exact PR head, KUnit failed to build/run, and §5 regression tuple is incomplete.
  • §6 Naming: PASS.

Assisted-by: LLM (Gemini 4 Neon)

…ault

A Dell S2725QS on a USB-C to HDMI cable (a Parade PS176 converter) came
up at 1920x1080 120 Hz on a Mac Studio (M5 Max, dcpext0) instead of its
native 3840x2160 60 Hz. The firmware marks 3840x2160 60 Hz IsPreferred
and scores it highest, but lists every one of its color elements in
UnsafeColorElementIDs, and the external default has skipped any timing
without a safe SDR element since it was introduced. Of the timings the
firmware prefers that left 1920x1080 120 Hz.

The unsafe elements are those of the timings above 340 MHz (3840x2160
60 Hz at 594 MHz, 2560x1440 120 Hz at 498 MHz), the clock in the EDID's
HDMI 1.4 block; its HDMI 2.x block takes 600 MHz. macOS reads the same
list from the same firmware (its TimingElements match, unsafe lists
included) and drives the 60 Hz timing, DPTimingModeId 50, over an HBR2
x4 link. Linux sets it too when asked: the firmware programs it and
keeps the link up, with no IRQ_HPD or unplug.

Let a timing stay a default candidate when its SDR elements are only
unsafe and the firmware marks it IsPreferred. A timing only DSC can
carry still never is, nor is an unsafe timing the firmware does not
prefer. The T8140 external path (J700), which never offers unsafe
elements outside its 1080p180 policy, is unchanged.

Nothing falls back to another timing when the default fails to light
up, so an unsafe timing is the default only when the firmware prefers no
usable timing of the native resolution. When it prefers one, the unsafe
timings are left out and the usable ones rank as they did before. On the
Dell the only usable 3840x2160 timing is the 30 Hz one, which the
firmware does not prefer, so 60 Hz is still the default.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj force-pushed the satchlj/dcp-unsafe-preferred-default-20261123 branch from 4a63a42 to d51708a Compare November 23, 2026 18:32
@satchlj

satchlj commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Claude Fable 5.2 on @satchlj's behalf.

@DjDeveloperr thanks for the review. New head: d51708aa33c203e1950a51a28efeed62f07f3ad3 (one commit, amended; human author, committer and sign-off only).

Blockers 1–3 are fixed. Blocker 4 is still open: no hardware has booted this head yet.

  1. KUnit build — fixed. The closing } of parser_internal_v27_only_120hz() is back. Run locally with the workflow's own command (kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/gpu/drm/apple/tests/display.kunitconfig, clang, arm64 QEMU): 143 tests, 142 passed, 0 failed, 1 skipped. The skip is apple_g17_rx_util_min_test (needs CONFIG_UCLAMP_TASK), unrelated.

  2. Safe vs. unsafe at the native resolution — fixed, your first option. I can't prove the firmware never prefers both, so the code no longer depends on it.

    • Rule: if the firmware prefers any timing of the native resolution that has a usable SDR element, dcp_external_default() leaves the unsafe-only timings out of the ranking. The usable ones then rank exactly as before this PR.
    • Dell S2725QS: unchanged. Its only usable 4K timing is the 30 Hz one, which the firmware doesn't prefer, so the unsafe preferred 4K60 still beats it and 1080p120.
    • Why not a comparison inside dcp_mode_default_above(): "usable beats unsafe only when both are preferred" is not transitive next to the refresh-rate rule, so the pick could depend on catalog order. Excluding the unsafe timings up front has no such case.
  3. KUnit coverage — added. All four cases pass:

    Case Checks
    parser_unsafe_preferred_default Dell catalog → 4K60; 4K60 not preferred → 1080p120
    parser_unsafe_preferred_dsc preferred timing whose SDR element is in DSCRequiredColorElementIDs: sdr_unsafe == false, not a candidate, default stays 1080p120 (also with the element listed unsafe as well)
    parser_unsafe_external_sdr external_sdr == true: sdr_unsafe stays false. An unsafe-only timing is dropped there as before; one with a safe second element is plain sdr_usable
    parser_unsafe_preferred_usable_wins usable preferred 4K30 beats unsafe preferred 4K60; the Dell shape still gives 4K60; with only a 24 Hz usable timing preferred, the unsafe one is out and 4K30 wins on refresh rate

    Negative control: with the new rule disabled, parser_unsafe_preferred_usable_wins fails and everything else passes.

  4. Evidence — still owed. Nothing has booted d51708aa. lobata will post here:

    • a J775c row on this exact head with the full tuple: 0 SELinux denials, 0 failed units, 0 new kernel errors against a baseline;
    • a no-regression check on a second, unaffected display.

Your non-blocking note (a DSC-required SDR element can still become color_mode_id outside the external SDR path): agreed, and it predates this PR. I left it alone here.

checkpatch.pl --strict is clean. The PR body now matches this head.

Assisted-by: LLM (Anthropic:Claude Fable 5.2)

@satchlj

satchlj commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

Hardware row for head d51708aa33c2 on lobata (Mac Studio M5 Max, J775c, T6050): one one-shot boot per arm, 2026-11-23, default command line plus our trial helper's arm64.nomte, carry DTB 0442bec2.

Baseline: cand-16b + #2664 Head: cand-16b + #2664 + d51708aa
Boot 5dfa5ed2 000f555b
build-id 9d9f1097e3d2… 1b2580769c84…
HDMI-A-1 (GLKVM, unaffected display) connected, 2560x1440@60, 241500 kHz same
DCP modeset (392e00000.dcp) color:72 timing:40, 8-bit RGB, ×2 same
Mode list / EDID 18 modes, EDID sha256 b00dc0c2797d… identical
Greeter (Hyprland) HDMI-A-1 2560x1440@59.951, scale 1, 1 window same
SELinux AVC denials 0 0
Failed units 0 0
Kernel err lines 3 the same 3: no new kernel errors

The three error lines are pre-existing and identical in both boots:

  • DCP "requested undeclared provider clock index"
  • DCP set_active_lane_count "unexpected lane count"
  • macaudio "can't assure safety on this model, disabling speakers"

A Comet capture of the HDMI output during each boot shows the greeter at 2560x1440, sharp, with its password field.

Head tree: the row's parser.h and parser-test.c are byte-identical to d51708aa. parser.c differs only in two lines that integration/aurora had already changed before this PR (a brace style in an unrelated block). The base is cand-16b, our integration/aurora-based J775c stack, because integration/aurora alone, with its stub J775c DTB, does not boot this Mac.

Not covered by this row:

  • The USB-C→HDMI Dell (the display this PR is for) was not attached, so the unsafe-preferred-timing path was not exercised here. The earlier row on the previous head showed 3840x2160@60 there.
  • KUnit: this kernel config has CONFIG_KUNIT unset (so no CONFIG_DRM_APPLE_KUNIT_TEST); the parser cases did not run on hardware.

Both boots handed back to lobata's default kernel: known-good, both ESPs fsck-clean, 0 failed units, journal verifies clean.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Formal Pre-PR Checklist Re-Review (§1–§6) — APPROVE

Re-reviewed commit d51708aa33c203e1950a51a28efeed62f07f3ad3 (interdiff 4a63a4218487..d51708aa33c2) against all four Wave 85 blockers.


Resolution of Wave 85 Blockers

  1. Apple DRM KUnit compile fix (drivers/gpu/drm/apple/parser-test.c) — RESOLVED:

    • The missing closing } of parser_internal_v27_only_120hz() is restored at line 2073.
    • Live CI on d51708aa33c203e1950a51a28efeed62f07f3ad3 is green: Apple DRM KUnit (45239566548, 143 tests: 142 passed, 0 failed, 1 unrelated skip apple_g17_rx_util_min_test) and Host tests (45239566512) both passed.
  2. Safe vs. unsafe preferred timing ranking at the same native resolution (drivers/gpu/drm/apple/parser.c:1249-1287) — RESOLVED:

    • dcp_external_default() now checks whether any default candidate of the chosen native resolution is both sdr_usable and firmware_preferred (usable_preferred), and if so excludes !m->sdr_usable timings up front before ranking with dcp_mode_default_above().
    • This is order-independent, preserves pre-PR ranking whenever a usable preferred timing exists at native resolution, and still picks 4K60 on the Dell S2725QS (where 4K30 is not IsPreferred).
    • Verified parse_color_modes() (parser.c:729-736) only sets out->sdr_unsafe = true when limits_known && !external_sdr && cmode.eotf == DCP_EOTF_SDR_GAMMA && unsafe && !dsc_required.
  3. KUnit coverage (drivers/gpu/drm/apple/parser-test.c) — RESOLVED:

    • All four cases (parser_unsafe_preferred_default, parser_unsafe_preferred_dsc, parser_unsafe_external_sdr, parser_unsafe_preferred_usable_wins) are present and verified passing in live Apple DRM KUnit CI, covering DSCRequiredColorElementIDs (with and without unsafe), external_sdr == true, and safe-vs-unsafe same-resolution ranking.
  4. §5 Evidence & regression tuple — RESOLVED:

    • J775c A/B run on d51708aa (cand-16b + #2664 baseline 5dfa5ed2 vs. head 000f555b) verified an unaffected HDMI display (HDMI-A-1, 2560×1440@60, Comet visual capture, identical EDID/18 modes/modeset) with the complete §5 regression tuple: 0 SELinux denials, 0 failed units, 0 new kernel errors (the same 3 pre-existing errors in both boots).
    • Combined with the earlier J775c A/B on the affected Dell S2725QS + Parade PS176 USB-C→HDMI cable (1920×1080@120 → 3840×2160@60) and full KUnit proof of the deterministic usable_preferred delta in dcp_external_default(), §5 evidence is sufficient.

Non-blocking note

  • The PR body's "Not tested" section still reflects pre-comment #issuecomment-7110664110 status; updating it (and optionally re-confirming with the Dell S2725QS attached on d51708aa post-merge) is welcome but non-blocking.

Pre-PR Checklist Summary (§1–§6)

  • §1 No model gating: PASS — driven purely by firmware IsPreferred, UnsafeColorElementIDs, and DSCRequiredColorElementIDs.
  • §2 Production-ready, no hacks: PASS — default command line, no hacks, live CI green (Apple DRM KUnit + Host tests).
  • §3 Safety: PASS — usable preferred timing always beats unsafe preferred timing; DSC-only and non-preferred unsafe timings remain excluded.
  • §4 Clean-room & attribution: PASS — commit d51708aa33c203e1950a51a28efeed62f07f3ad3 carries human author/committer (Satya Benson) and human Signed-off-by: only, zero AI trailers in commit, Assisted-by: disclosed in PR body.
  • §5 Evidence: PASS — affected J775c + Dell S2725QS A/B + exact-head J775c unaffected-display A/B with 0 SELinux denials, 0 failed units, 0 new kernel errors + live Apple DRM KUnit and Host tests passing.
  • §6 Naming: PASS.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide
RyanTheTide merged commit 880a97a into integration/aurora Nov 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants