Skip to content

drm/apple: gate T6020 DCP S2R layouts on apple,sleep-tested and drop s2r_untested - #4243

Draft
DjDeveloperr wants to merge 2 commits into
mainfrom
fix/t6020-dcp-s2r-sleep-tested
Draft

DjDeveloperr wants to merge 2 commits into
mainfrom
fix/t6020-dcp-s2r-sleep-tested

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

What

Follow-up to #3999 removing the appledrm.s2r_untested runtime module parameter and tying T6020's DCP S2R layouts to the board's per-board apple,sleep-tested DT state, matching how sleep.c gates t6020_sleep_soc.untested.

Confirmed on main (a0e5cf151159): appledrm.s2r_untested defaulted to true, enabling T6020 internal DCP firmware stop/domain drop on DPMS off and external USB-C dcpext s2r_ext/ext-idle (including on s2idle) across all T602x boards on firmware 27.x even when &sleep lacked apple,sleep-tested (J416s, J474s, T6021, T6022).

Changes:

  • Add apple_sleep_tested(const char *compat) to include/linux/soc/apple/sleep.h (sibling of apple_t6050_sleep_property() / apple_sleep_smc_policy_described()).
  • Replace hw.s2r_untested and the appledrm.s2r_untested module parameter with hw.s2r_v27_only (T6020 + T8142) and hw.s2r_sleep_tested_compat = "apple,t6020-sleep" (T6020 internal + external DCP), checked via dcp_s2r_static_layout_allowed() at both internal DCP probe and dcp_s2r_ext_capable() (which also gates dcp_ext_idle_capable()).
  • Add KUnit test dcp_s2r_t6020_gated_by_sleep_tested in drivers/gpu/drm/apple/dcp_s2r_test.c covering untested T6020 (internal, external S2R, and ext-idle all off), sleep-tested T6020 on fw 27.x (all on), non-v27 firmware (off), and T8142 (v27-only unchanged).

Tested

  • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.
  • make ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/apple/dcp.o with CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST=n: 0 warnings.
  • make ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/apple/dcp.o with CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST=y (includes dcp_s2r_test.c and dcp-firmware-test.c): 0 warnings.
  • KUnit suite dcp-display runs in GitHub Actions (apple-build-kunit.yml).
  • Companion J414s s2idle + DPMS PEER arm harness prepared offline (work/peer-j414s-dcp-s2r-gate-20261203, --check 2/2 ok, judge.py selftest 7/7).

Risk

Two-way.

  • On J414s (apple,sleep-tested; present on &sleep since #4228) with firmware 27.x: behavior is unchanged (internal DCP firmware stop and external dcpext S2R/ext-idle remain enabled).
  • On untested T602x boards (J416s, J474s, T6021, T6022) with firmware 27.x: internal DPMS stays backlight-only and external dcpext stays out of ext-idle until the board earns apple,sleep-tested;.
  • On T8142 (J813/J815, where t8142_sleep_soc.untested is already false): behavior is unchanged on firmware 27.x and off on 26.x/H17P.
  • Removes the appledrm.s2r_untested kernel module parameter.

Not yet

  • Draft PR — pending CI KUnit (dcp-display) green and a J414s 27.2 s2idle + DPMS peer row (tested and untested-DT arms).

…s2r_untested

On main, appledrm.s2r_untested defaults to true, so T6020's internal DCP
sleep layout (DPMS off stops firmware and powers down display domains)
and external USB-C dcpext layout (s2r_ext and ext-idle on s2idle) are
enabled by default on every T602x board running firmware 27.x, including
boards without apple,sleep-tested (J416s, J474s, T6021, T6022).

Remove the appledrm.s2r_untested module parameter and replace
hw.s2r_untested with two declarative hw_data fields:
- s2r_v27_only: restrict the static layout to firmware 27.x (used by
  T6020 and T8142, keeping T8142 J813/J815 behavior unchanged on 27.x
  and off on 26.x/H17P).
- s2r_sleep_tested_compat: require an available sleep-controller node
  matching this compatible with apple,sleep-tested in the device tree
  (via apple_sleep_tested() in linux/soc/apple/sleep.h), matching
  sleep.c's per-board gate for SoCs with .untested = true.

Set s2r_sleep_tested_compat = "apple,t6020-sleep" on apple_dcp_hw_t6020
and apple_dcp_hw_t6020_dcpext so J414s (which carries apple,sleep-tested)
keeps the layouts on firmware 27.x while untested T602x boards keep
internal DPMS backlight-only and external dcpext out of ext-idle.

Add KUnit coverage in dcp_s2r_test.c verifying internal, external S2R,
and ext-idle gating for tested vs untested T6020 boards, non-v27
firmware, and T8142.

Signed-off-by: DjDeveloperr <hey@djdev.me>
dcp-s2r-primary-ext-tests.py copies dcp_s2r_ext_capable() out of dcp.c
and builds it against a small prelude. That function now calls
dcp_s2r_static_layout_allowed(), and the prelude still declared
s2r_untested, so the host test no longer compiled.

Copy dcp_s2r_sleep_tested() and dcp_s2r_static_layout_allowed() as
well, give the prelude the new hw fields and an apple_sleep_tested()
stub, and add a case for a T6020-style external DCP: no external S2R on
a board without apple,sleep-tested, external S2R on one with it. A new
drop-sleep-tested mutation removes the gate and must fail;
run-host-tests.py runs it with the others.

Signed-off-by: DjDeveloperr <hey@djdev.me>

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review, one round.

Verdict: the change is right. I pushed one fix (e6297d8) for a host test it broke. Merge after the J414s peer row and green CI.

What I checked

  • J414s on firmware 27.x: no change. t6020-j414s.dts enables &sleep with apple,sleep-tested, so apple_sleep_tested("apple,t6020-sleep") is true and both layouts stay on. One caveat: a J414s booted with a DTB from before #4228 (no apple,sleep-tested) now loses the layouts. Our kernels ship with their own DTBs, so this only matters if someone boots this kernel with an old DTB.
  • T8142 (J813/J815): no change. On main the gate was "firmware 27.0", because the parameter defaulted on. s2r_v27_only gives the same answer at probe and in dcp_s2r_ext_capable(), and T8142 sets no sleep compat. The new KUnit case checks both T8142 tables.
  • Other firmware: no change. The static-layout gate still lets only 27.0 through. T6020 never reaches the H17P branch of dcp_s2r_ext_capable(), because only the T8140 and T8142 tables and the T8122 dcpext report H17P.
  • Other SoCs: no change. dcp_s2r_static_layout_allowed() returns true when neither new field is set, so the rewritten probe condition gives the same result for every table that doesn't set them.
  • Boards that lose the layouts: J416s and J474s, plus T6021/T6022, which have no apple,t6020-sleep node at all. They go back to what they had before #3999 landed today: DPMS turns off the backlight only, the dcpext doesn't enter ext-idle, and no S2R PM notifier is registered on the dcpext. None of these boards has run the layouts on hardware, so this is a fix, not a regression.
  • A pre-existing bug this hides (not for this PR): for T6021 dcpext2/3, dcp_s2r_layout() falls back to dcp_s2r_t6020_ext[0], which is dispext0's power words, because hw.s2r_layout is still set. Main turns that on for M2 Max on 27.x today. It has to be fixed before any T6021 board gets apple,sleep-tested.
  • Probe order: no issue. The helper reads the unflattened DT, which exists before any driver probes. It doesn't need the sleep driver to be bound, built in or loaded, and appledrm gets no symbol dependency on it.
  • Org rules: the PR removes a runtime module parameter, which Ryan's rule asks for. The new field is per-SoC data in a per-SoC table, the same table that already holds T6020's power words. The per-board answer comes from the DT, the same way as sleep.c's .untested. I don't see a smaller shape. A phandle from each DCP node to &sleep needs a binding change and edits in t602x-die0/dieX for the same result. Asking the sleep driver adds probe ordering and a module dependency.

Fixed on the branch (e6297d8)

  • host-tests went red at 46245a6 (6 jobs failed). tools/asahi/dcp-s2r-primary-ext-tests.py copies dcp_s2r_ext_capable() out of dcp.c into a small C prelude. The prelude had neither dcp_s2r_static_layout_allowed() nor the new fields, so it stopped compiling. The commit:
    • copies the two helpers as well and updates the prelude;
    • adds a T6020-style dcpext case: off without apple,sleep-tested, on with it;
    • adds a drop-sleep-tested mutation and registers it in run-host-tests.py.

Small things, not blocking

  • On T6020 dcpext, dcp_s2r_ext_capable() now walks the whole DT on every call. dcp_ext_idle_capable() calls it from the HPD, audio and suspend paths. The cost is small and only on those events, but the answer can't change after boot, so latching it at probe would be tidier.
  • apple_sleep_tested() is apple_t6050_sleep_property() with the compat as a parameter. The T6050 helper could call it.
  • The apple,sleep-tested description in apple,t6020-sleep.yaml could add one line saying that the DCP sleep layouts follow it too.

Tested on pc

  • W=1 build of drivers/gpu/drm/apple/ (clang, CONFIG_WERROR=y) over the warm DCP KUnit tree, with KUnit on and with it off: 0 warnings either way.
  • checkpatch --strict: both commits are clean.
  • DCP host-test subset, 250 jobs in the ubuntu2404 container: all pass except 4 --ref control jobs that need git history. My source tree was a git archive, so they had none, and those jobs don't touch this code. --only dcp-s2r: 23/23, including the new mutation.
  • KUnit: CI's KUnit dcp-fabric dcp-topology dcp-display job at e6297d8 passes, including apple-dcp-s2r/dcp_s2r_t6020_gated_by_sleep_tested and apple-dcp-firmware/dcp_ext_idle_audio_dma_pin. I did not get a local UML run: pc's build slot stayed taken for the 40 minutes I allowed.
  • CI at e6297d8: apple-build, host-tests, KUnit, pr-text and readiness all pass. Main has moved 16 commits since a0e5cf1. The only overlap is one added line in the T8122 table in dcp.c, and the PR is still mergeable.

Rows before merge

  • J414s 27.2 peer row, both arms:
    • Head with the shipped DT: DPMS off/on, a USB-C display through ext-idle, s2idle and one deep sleep. Everything should behave as on main.
    • Head with apple,sleep-tested removed from &sleep: DPMS turns off the backlight only, no "firmware stop enabled" line, the dcpext stays out of ext-idle, and there are no DCP errors.
  • Second-gen row for the shared code: one DPMS cycle and one deep sleep at head on one of our own 27.2 Macs (J516s or J773g). Their tables don't set the new fields, so the result should match main.
  • T8142 (J813/J815): the KUnit case covers its truth table, so a peer row is optional.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (M3 Pro, T6030, OS firmware 27.2) second-gen module-only A/B hardware verification for linux#4243 (e6297d8c2203cd83f95934e1995abc1be1aba042 on main a0e5cf1511594d92320a9fb11bd3d0948a2c35ad): VERDICT PASS (Arm A PASS, Arm B PASS; 0 bad lines)

Builds & boots

  • Kernel: 7.3.0-j516s-pr4243 (main a0e5cf151159 on J516s f3822 config) + trial Stage 2 m1n1/pr4243.bin (fecc5a1a…, main t6030-j516s.dtb with apple,t6030-sleep). Only appledrm.ko differs between Arm A and Arm B.
  • Arm A (main appledrm.ko): build-id 8f14e840d7ab7d765db17d4bc33f77daf5970783, s2r_untested module param present, boot 199492e1-5cf9-424e-a866-485816048488.
  • Arm B (#4243 e6297d8c2203cd83f95934e1995abc1be1aba042 appledrm.ko): build-id a10a11c82ed8fbf5a296747ad1915940984acf12, s2r_untested module param absent, boot 0fdb6b8e-5232-470f-a05a-caa9c2707224.

Results (1x DPMS off/on + 1x committed 20 s deep sleep per arm)

  • Arm A (main):
    • Pre-check: eDP-1 connected enabled On, crtc=1, bl=25, Wi-Fi up, NVMe ok, 0 bad lines.
    • DPMS off/on (kscreen-doctor): off (rc=0, 'connected disabled Off', crtc=0, bl=0) -> on (rc=0, 'connected enabled On', crtc=1, bl=25), 0 bad lines.
    • Deep sleep (rtcwake -m mem -s 20): rc=0, 21 s, same boot, PM: suspend entry (deep), apple-sleep: back from sleep, boot object resumes 0 -> 1, DCP v27 stop=+1, wake=+1.
    • Post-wake: eDP-1 connected enabled On, crtc=1, bl=25, Wi-Fi up, NVMe ok, 0 bad lines, taint unchanged.
  • Arm B (#4243 e6297d8c2203cd83f95934e1995abc1be1aba042):
    • Pre-check: eDP-1 connected enabled On, crtc=1, bl=25, Wi-Fi up, NVMe ok, 0 bad lines.
    • DPMS off/on (kscreen-doctor): off (rc=0, 'connected disabled Off', crtc=0, bl=0) -> on (rc=0, 'connected enabled On', crtc=1, bl=25), 0 bad lines.
    • Deep sleep (rtcwake -m mem -s 20): rc=0, 21 s, same boot, PM: suspend entry (deep), apple-sleep: back from sleep, boot object resumes 0 -> 1, DCP v27 stop=+1, wake=+1.
    • Post-wake: eDP-1 connected enabled On, crtc=1, bl=25, Wi-Fi up, NVMe ok, 0 bad lines, taint unchanged.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J414s peer kit for this head (e6297d8c) on main bd3112c5: https://github.com/aurora-silicon/linux/releases/tag/peer-j414s-4243-e6297d8c-20261204

It is a no-regression row: the J414s has apple,sleep-tested, so its display sleep must not change. One main kernel; only appledrm.ko changes between the arms (A = main's, B = this PR's, merged cleanly onto bd3112c5). Each arm does a DPMS off/on of the panel and two committed deep sleeps, and the judge wants B to stop and restart the same display coprocessors as A. About 20 minutes, two one-shot reboots, stock boot.bin untouched, watchdog and dead-man armed.

bash kit.sh --check                                   # CHECK 10/10 ok
sudo bash kit.sh install
sudo bash kit.sh arm a && sudo bash kit.sh go         # then: sudo bash kit.sh run a ./results/arm-a, reboot
sudo bash kit.sh arm b && sudo bash kit.sh go         # then: sudo bash kit.sh run b ./results/arm-b, reboot
bash kit.sh judge ./results/arm-a ./results/arm-b
sudo bash kit.sh rollback

Please post the verdict and a tarball of results/ here.

This branch has not been deployed

No deployments
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.

1 participant