Skip to content

drm/apple: dcp: leave the piodma DART alone at shutdown after DPMS off - #3595

Merged
DjDeveloperr merged 1 commit into
mainfrom
fix/dcp-unbind-stopped-fw
Dec 1, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
fix/dcp-unbind-stopped-fw

Conversation

@satchlj

@satchlj satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

What: fixes a restart that hangs in device_shutdown() once DPMS off has powered the internal display down.

The hang:

  • At shutdown, drm_atomic_helper_shutdown() turns an S2R-capable internal panel off the way DPMS off does: it stops the firmware and lowers the display domains, display DART included.
  • dcp_comp_unbind() then destroys the piodma device. That detaches it from a DART that no longer answers, and the restart hangs until a watchdog resets the machine.

Changes:

  • At shutdown (system_state > SYSTEM_RUNNING), when dpms_powered_off && s2r_fw_down, the piodma device is left as it is.
  • When the firmware is already stopped, unbind completes each AFK endpoint's stopped instead of sending shutdowns that RTKit refuses, each of which waited 1 s.
  • Adds the missing \n on afk_shutdown()'s timeout message, which kept it in the printk continuation buffer.
  • Logs an unbind: <step> line for each step during shutdown.

How it was found:

  • J413 (M2 Air, DCP 27.2) with T8112 deep sleep (#3371): every reboot after a deep sleep hung for 2 min until the watchdog reset it.
  • Netconsole traces with step logging showed DPMS off finishing at shutdown. The internal DCP's unbind then stopped at piodma.

Tested: Current head 459960dc47ad is the same code rebased onto main (from 7c5e39b2).

  • J413, on a trial tree: rjianwei/feat/t8112-s2r plus the T8112 S2R fixes from T8112 (Apple M2 / J413) suspend-to-RAM support: coordination before opening a PR #3371 and this change. That tree is not this PR's head, which is main 871400a8 plus one commit, aa2e0f7e.
  • Before (2026-11-29): the reboot after a 10 s deep sleep, with the GPU and desktop live, hung in the internal DCP unbind at piodma until the 2-min watchdog reset.
    • A netconsole step log shows DPMS off finishing at shutdown: quiesce, mailbox off, CPU stop, DART streams off, DART dark, PMC off, domains off.
    • The external DCP's unbind then completed every step. The internal DCP's stopped after piodma.
  • After (same tree plus this change): unbind logs display powered off, piodma DART left for the restart, and shutdown continues through apple-dcp shutdown, PMGR and DARTs. The next kernel booted 10 s after the reboot.
  • At this head: dcp.o and afk.o build with LLVM=1 W=1 and no new warnings, and checkpatch.pl --strict gives 0 errors, 0 warnings, 0 checks.
  • 459960dc on J613 (M3 Air), PASS (tested as 7c5e39b2, the same patch before the rebase onto main 45d7f828; git patch-id identical): with DPMS off (eDP-1 dpms reading Off), the reboot reached the next kernel in 17 s with no device_shutdown() hang, both at this head and at this head + drm/asahi: m3: support firmware-driven deep sleep on T8122 #3504 after one mem/deep through the commit (boot object resumes 0 -> 1). At this head alone the GPU refuses deep sleep (drm/asahi: m3: support firmware-driven deep sleep on T8122 #3504 is needed on T8122). The piodma DART left line prints after journald stops and the machine has no serial console, so it isn't captured. drm/apple: dcp: leave the piodma DART alone at shutdown after DPMS off #3595 (comment)

Risk: two-way door. Shutdown only, and only after DPMS off has powered the display off. At runtime unbind and on other shutdowns nothing changes, except the endpoint shutdowns for firmware already stopped, which used to time out.

@satchlj

satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

Exact-head row on MacBook Air M3 13" (J613 / T8122): PASS on both shutdown paths.

Kernel: 7.3.0-1-rubracand2-ARCH, which is main 694a5fb3 + this PR at aa2e0f7e (merged cleanly) + linux #3590, #2163, #3504, #3505 and #1490; trimmed localmodconfig. Chain: stage 2 Aura 1.0.0b17-gc0af820e + U-Boot 944606df; apple_sleep.deep=1.

Row Before the reboot systemctl reboot → next kernel start
Display on one deep sleep (boot object resumes 0 -> 1), then reboot with the panel on 33 s, the same as an ordinary reboot of the test J613; no hang
DPMS off hl.dsp.dpms({ action = "disable" }) → dpmsStatus: false; DCP logs IOMFB: power on -> off, power_down_M3: disabling M3, shutdown_link_gated … ioav i/f is now closed, did_power_off. Then reboot. 29 s; no device_shutdown() hang

Not shown: the unbind: display powered off, piodma DART left for the restart line itself. It prints in device_shutdown(), after journald has stopped, and the test J613 has no serial console, so I can't capture it. The display was powered off at DPMS (logged above), so that path was taken.

Unrelated, for the record: in the DPMS-off row the deep sleep before the reboot was refused (PM: Some devices failed to suspend, or early wake event detected, right after the GPU and both DCPs stopped; no device named). The two other deep sleeps on the same kernel succeeded.

@satchlj
satchlj marked this pull request as ready for review November 29, 2026 19:40
@satchlj
satchlj requested review from a team as code owners November 29, 2026 19:40
@satchlj
satchlj requested review from Acelogic and malik-na November 29, 2026 19:40

@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: MERGE at aa2e0f7e

Blockers: None (note that the red host-tests run 46222705579 failed on g17-compute-owed-stamp-tests from the 871400a8 base, and the four failed KUnit matrix jobs in 46222705608 hit an Ubuntu apt mirror timeout; apple-build, KUnit dcp-fabric, KUnit dcp-topology, and pr-text all passed).

Checked:

  • Verified dcp_comp_unbind() in drivers/gpu/drm/apple/dcp.c (:7746-7970):
    • system_state > SYSTEM_RUNNING && dcp->dpms_powered_off && READ_ONCE(dcp->s2r_fw_down) tightly scopes the dcp_release_piodma_iommu_dev(dcp) skip to shutdown after DPMS off has already stopped firmware and powered down the display domains and display DART. Runtime unbind (SYSTEM_RUNNING) and active-display shutdowns retain the full piodma / fbdma teardown path unchanged.
    • dcp_unbind_stopped_fw(dcp) runs when READ_ONCE(dcp->s2r_fw_down) is true and calls complete_all(&eps[i]->stopped) on non-error, non-null avep, dptx_controller_ep, ibootep, systemep, and dcpavservep. Verified against afk_shutdown() (drivers/gpu/drm/apple/afk.c:196-218): wait_for_completion_timeout(&afkep->stopped, ...) returns immediately without waiting out 1 s timeouts per endpoint, while afkep->stopping = true, afk_quiesce(afkep), and rx_scratch cleanup still run normally.
    • dcp_unbind_step() only logs when system_state > SYSTEM_RUNNING, avoiding runtime log noise.
  • Verified afk_shutdown() timeout dev_err() gains the missing \n (drivers/gpu/drm/apple/afk.c:206).
  • Verified hardware rows: J413 (M2 Air, DCP 27.2) before/after netconsole trace confirming the 2-minute watchdog hang at piodma is eliminated (next kernel boots in 10 s), plus exact-head J613 (M3 Air, T8122) PASS on both display-on (33 s) and DPMS-off (IOMFB: power on -> off, 29 s) reboot paths.
  • Verified LLVM=1 W=1 build clean, checkpatch.pl --strict 0/0/0, DCO sign-off, and two-way Risk description.
Evidence
  • drivers/gpu/drm/apple/dcp.c:7751-7764 (dcp_unbind_stopped_fw, dcp_unbind_step), :7889-7953 (dcp_comp_unbind), :5966-5985 (dcp_release_piodma_iommu_dev).
  • drivers/gpu/drm/apple/afk.c:196-218 (afk_shutdown).
  • CI verification on aa2e0f7e: apple-build PASS, KUnit dcp-fabric PASS, KUnit dcp-topology PASS; host-tests run 46222705579 failed only in g17-compute-owed-stamp-tests; KUnit run 46222705608 (asahi/spi-hid-apple/avd/ave) failed in apt-get update (Could not wait for server fd, exit 100).
  • Minor non-blocking note: dcp_unbind_stopped_fw() covers the five primary endpoints (avep, dptx_controller_ep, ibootep, systemep, dcpavservep); if an external/desktop DCP ever enters dcp_comp_unbind() with s2r_fw_down set, dcp->dptxep and dcp->desktop->graph[] could be included there in a future follow-up.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (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 29, 2026
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Merge readiness at f3fb6f3f: not ready yet

Check Detail
CI at head running running: apple-build, KUnit plan
Review ok approved by DjDeveloperr, RyanTheTide
Requested changes ok none
Hardware row at head no no line with the head SHA f3fb6f3f, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · . Shutdown only, and only after DPMS off has powered the display off. At runtime unbind and on other shutdowns nothing changes, except the endpoint shutdowns for firmware already stopped, which used to time out.

Areas: area:display

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@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 aa2e0f7e for CI disposition.

I independently checked the shutdown predicate. The PIODMA release is skipped only during system shutdown, after DPMS has powered the display off and firmware is marked down. Runtime unbind and display-on shutdown retain the release. The stopped endpoint completions avoid timeout waits while AFK cleanup still runs. The J413 and J613 results cover the reported hang and both shutdown paths.

The existing code approval stands. Resolve or rerun the red and pending hosted checks before landing, then take this ahead of #3647.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 29, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

The owed-stamp failure is present on the base. I matched all seven harness and source inputs between the PR job checkout 4d7bc26f and the PR parent 871400a8. Running the isolated harness at the parent produces the same Rust E0061 error at note_retired. An isolated run at current base 3ba0883f also produces it.

The DCP code review stands. The train still needs to resolve the base CI failure and the remaining hosted checks before landing.

https://github.com/aurora-silicon/linux/actions/runs/46222705579/job/141220789968

@satchlj
satchlj force-pushed the fix/dcp-unbind-stopped-fw branch from aa2e0f7 to 7c5e39b Compare November 29, 2026 22:17
@satchlj

satchlj commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Rebased onto current main (af1413ddc1c7) to pick up the host-test fix that landed there; the G17 failure came from the old base. Conflict-free, same patch-id.

Old head aa2e0f7e7c4c, new head 7c5e39b2add1. The J613 row will be rerun at the new head.

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

Superseded 12-01: not a hold under the merge bar (no shown failure). Head moved (same patch-id); follow-ups: new hosted run, J613 rerun

The stable patch ID matches the previously reviewed shutdown-only DART change. The updated base is intended to pick up the owed-stamp fixture fix. Please keep landing on hold until the new hosted run and the promised J613 rerun pass.

@satchlj

satchlj commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Hardware row at this head on J613 (MacBook Air 13" M3, T8122): PASS. No device_shutdown() hang after DPMS off, including after a deep sleep. Each reboot reached the next kernel in 17 s.

Setup: Stage 2 Aura 1.0.0b17-gc0af820e + U-Boot 944606df. Daily command line plus apple_sleep.deep=1 apple_sleep.untested_commit=1. In each row, DPMS was turned off in the logged-in Hyprland session with hl.dsp.dpms({ action = "disable" }), and the row went on only after /sys/class/drm/card1-eDP-1/dpms read Off. Then came one mem/deep attempt with a 15 s RTC wake, then systemctl reboot.

Kernel Deep sleep systemctl reboot → next kernel
This head, 7c5e39b2 (main af1413dd + this commit) refused at prepare, aurora 292400000.gpu: genpd_prepare returns -16 (this base cannot deep-sleep on T8122 without #3504) 17 s, no hang
This head + #3504 (8e6a5b81), merged 1/1 through the commit: boot object resumes 0 -> 1, woke on NUB.SPMI0.SW3 17 s, no hang

In both rows the journal runs to Unmounting /home 6 s after the reboot, and the next kernel prints Booting Linux 11 s later.

Not captured: the piodma DART left line and the unbind: steps print after journald stops, and the machine has no serial console. So this row shows the reboot completing, but not which branch the unbind took.

@satchlj
satchlj force-pushed the fix/dcp-unbind-stopped-fw branch from 7c5e39b to 459960d Compare November 30, 2026 03:00
@satchlj

satchlj commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Rebased onto current main (45d7f828e08a), which contains #3672 (the apple-dcp host-test fix). Conflict-free; the commit keeps its patch-id.

Old head 7c5e39b2add1, new head 459960dc47ad. The J613 rerun requested at 7c5e39b2add1 tests the same code.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 30, 2026
@satchlj

satchlj commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

J413 (M2 Air) at 459960dc47ad, applied with #3647 c5a423774421, #3659 7cee228f4ea1 and #3668 2d286282dd51 (same patch-ids as built): PASS. After 3 deep sleeps plus one 1200 s deep sleep, a normal reboot reached the next boot in 10 s, from the journal stopping at 03:33:30 to the kernel starting at 03:33:40, with no watchdog. Without this PR, the same J413 reboot after a deep sleep hung in device_shutdown() until the 2-minute watchdog.

DjDeveloperr
DjDeveloperr previously approved these changes Dec 1, 2026

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

The change is narrow: the piodma DART is kept only at shutdown, after DPMS off, with the firmware already stopped. Endpoints of stopped firmware no longer wait out their timeouts, and the step breadcrumbs print only during shutdown. The J613 row (same patch ID) and the J413 run cover two generations.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026
With an S2R-capable internal panel, drm_atomic_helper_shutdown() turns
the display off as DPMS off does: the firmware is stopped and the display
power domains, display DART included, are lowered. The component unbind
that follows then destroys the piodma device, which detaches it from
that DART. Its registers no longer answer, and the restart hangs in
device_shutdown() until a watchdog resets the machine.

On a J413 (M2 Air, firmware 27.2) this hung every reboot after a
deep sleep for 2 minutes, until the hardware watchdog reset it.

At shutdown, once DPMS off has powered the display down, leave the
piodma device as it is: the system is going down.

The unbind also asked every AFK endpoint of the stopped firmware to shut
down. RTKit refuses each message to a stopped coprocessor, so each
shutdown only waited out its timeout. Complete their stopped completions
instead. afk_shutdown() timeout message gains its missing newline, which
kept it in the printk continuation buffer. During shutdown the unbind
logs each step, so a hang names the step it is in.

Signed-off-by: Satya Benson <[email protected]>
@satchlj

satchlj commented Dec 1, 2026 •

Copy link
Copy Markdown
Member Author

Conflict-only rebase onto current main (a171afd2123f), resolving the adjacent forward declarations added above dcp_comp_unbind() by 6aefc6058db0.

Old head: 459960dc47ad
New head: f3fb6f3ffad1
Delta: unchanged (+44/-2); patch-id shifted (4aaad4074ed5 -> 2320cbd3553d) only due to the new context lines above dcp_unbind_stopped_fw().

@satchlj
satchlj force-pushed the fix/dcp-unbind-stopped-fw branch from 459960d to f3fb6f3 Compare December 1, 2026 06:58
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) and removed ci-failing A check failed at the PR head (bot) labels Dec 1, 2026

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

Reviewed the rebase at f3fb6f3. The PIODMA bypass still applies only during system shutdown after DPMS off and firmware teardown. The surrounding declarations moved, and runtime unbind still takes the normal teardown. The DCP checks on the rebased head and an updated DPMS-off restart row remain the landing checks.

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

Compared the rebased patch with 459960d. The forward declarations remain in place and the rebase preserves the DCP unbind logic, including the shutdown-only PIODMA exception.

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) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants