Skip to content

drm/apple: don't latch ->crashed when the poweroff clear swap times out - #5

Closed
Chromatischer wants to merge 1 commit into
aurora-silicon:aurora-wipfrom
Chromatischer:fix/dcp-clear-swap-timeout
Closed

Chromatischer wants to merge 1 commit into
aurora-silicon:aurora-wipfrom
Chromatischer:fix/dcp-clear-swap-timeout

Conversation

@Chromatischer

Copy link
Copy Markdown

Unplugging a Type-C display once kills that output until reboot. This is the -EINVAL-after-replug that the stale DPTX link PR describes on J416c and leaves unexplained. It is not possible_crtcs.

The chain

iomfb_poweroff() submits a clear swap and waits 50 ms. On unplug the display is already gone, so the firmware swallows it:

IOMFB: swap_submit_dcp: swallowed swap ID 1348 as fControllerPowerState is 0 for External Display

The completion misses its window and iomfb_template.c:939 sets dcp->crashed = true — silently. dcp_crtc_atomic_check() then returns -EINVAL for every later commit on that CRTC.

The replug looks healthy the whole way down:

apple-display-crossbar 50304c000.mux: Switched dpphy to dispext0,0
apple-dcp 271c00000.dcp: allocated Type-C DPTX PHY 1
apple-dcp 271c00000.dcp: dcp_dptx_connect(port=0) target=0:1 typec=1 route=borrowed conn_type=20 connected=0
apple-dcp 271c00000.dcp: dcp_hotplug() connected:1 valid_mode:0 nr_modes:31

status reads connected, EDID is 256 bytes, 31 modes are listed, the compositor names the monitor — and then every atomic commit is rejected. 141 in one session, walking the mode list down to 640x480 before giving up. Routing is fine; drm.debug=0x14 shows the connector picking the right encoder and CRTC:

[drm:drm_atomic_helper_check_modeset] [CONNECTOR:63:USB-2] using [ENCODER:65:TMDS-65] on [CRTC:59:crtc-1]
[drm:drm_atomic_helper_check_planes]  [CRTC:59:crtc-1] atomic driver check failed
[drm:drm_atomic_check_only]           atomic driver check for ... failed: -22

Hard to find because nothing is logged. The other assignment, dcp_rtk_crashed(), prints "DCP has crashed"; this one prints nothing.

The fix

Warn instead of latching the flag. A real firmware crash still arrives through dcp_rtk_crashed().

What was tried and rejected

Carrying on into iomfb_abort_swaps_dcp() and setPowerState(0) rather than returning early leaves less state behind, and matches what the setPowerState(0) wait further down the same function already does on its own timeout. It was built and tested — it is worse. For a display that is already gone the dptx HPD deassert then fails:

apple-dcp 271c00000.dcp: failed to deassert Type-C DPTX HPD: -110

and the next plug borrows the route and reports connected=0 without ever asserting HPD. The display does not come back at all; 20 s later the connector was still disconnected. The early return is load-bearing, and the commit message says so.

Tested

J313 (M1 MacBook Air, t8103) on aurora-wip @ 673d2a6, Type-C to HDMI adapter, LG 4K at 3840x2160@30.

before after
plug on cold boot works works
unplug clean disconnect clean disconnect
replug enumerated, 141 rejected commits, dark connected / enabled / dpms=On, image on screen
suspend/resume with display attached n/a comes back on its own

Rejected atomic commits went from 141 to 0. The one remaining failed to commit in the compositor log is an EBUSY page flip that predates this bug and is unrelated. No unexpected busy command channel and no failed to deassert in any run.

Note for anyone reproducing this on M1

Two device-tree things had to be sorted out first, neither of them part of this PR:

  1. t8103-jxxx.dtsi declares usb4-0-acio / usb4-0-nhi / usb4-0-pcie / usb4-0-pcie-adapter, but m1n1 v1.6.1 looks up usb4_%d_rc / usb4_%d_nhi / usb4_%d_pcie / usb4_%d_pcie_adapter (strings on the shipped binary). Every lookup misses, no apple,tunable-* reaches the cio node, thunderbolt-apple-acio fails probe on Unable to load rc tunable, and because cd321x_probe() waits on a Thunderbolt switch that is only registered past that point, both PD controllers sit in devices_deferred forever. With no Type-C ports at all, plugging a display does nothing. t8112-jxxx.dtsi, t600x-j314-j316.dtsi and t600x-j375.dtsi carry the same hyphen-only aliases.
  2. PCIe-C tunnel disabled: m1n1 handoff is not initialized on both ports, which cannot be worked around from the device tree. Dock testing was not attempted.

Happy to raise either separately.

iomfb_poweroff() submits a clear swap and waits 50 ms for it. When the
display is a Type-C output that has already been unplugged, the firmware
has nothing left to swap to and swallows the request:

  IOMFB: swap_submit_dcp: swallowed swap ID 1348 as
  fControllerPowerState is 0 for External Display

The completion misses its window, the wait times out, and ->crashed is
set with nothing logged. dcp_crtc_atomic_check() then returns -EINVAL
for every commit on that CRTC, so the next plug trains the link, reads a
256-byte EDID and a full mode list, and reports the connector as
connected -- while the screen stays dark. The compositor walks every
mode down to 640x480, has each one rejected, and gives up. Only a reboot
clears it.

One unplug is enough to reach that state. The DCP has not crashed: a
real firmware crash arrives through dcp_rtk_crashed(), which sets the
same flag and says so. A swallowed clear swap on the way down is the
ordinary unplug.

Warn instead, and keep the early return. Carrying on into
iomfb_abort_swaps_dcp() and setPowerState(0) leaves less state behind
and matches what the setPowerState(0) wait further down already does on
its own timeout, so it was tried first -- but for a display that is
already gone it is worse. The dptx HPD deassert then fails:

  apple-dcp 271c00000.dcp: failed to deassert Type-C DPTX HPD: -110

and the next plug borrows the route and reports connected=0 without ever
asserting HPD, so the display does not come back at all. The early
return is load-bearing.

Tested on J313 (M1 MacBook Air, t8103) with a Type-C to HDMI adapter.
Plug, unplug, replug and suspend/resume all bring the display back;
before, one unplug left it enumerated but unusable for the rest of the
boot.

Signed-off-by: Chromatischer <[email protected]>
Assisted-by: Claude:claude-opus-5
cb2206 pushed a commit to cb2206/linux that referenced this pull request Oct 5, 2026
…mailbox-hardening

soc: apple: rtkit/mailbox hardening from aurora-wip
RyanTheTide added a commit that referenced this pull request Oct 17, 2026
Bring the 7.2.10 assembly to the tree of the canonical top-up #5
assembly 1c824ed, stacked on top-up #4 5043778 so that it is
a fast-forward of the published branch. The second parent is that
canonical assembly; the tree is identical to it.

Ported from aurora-wip, each with cherry-pick -x and its original
author:
- #338 tipd lost IRQ (5): never leave CD321x interrupt events
  unacknowledged, recover from a failed partner identity read, keep
  SN201202x events unhandled while it sleeps and wake it when suspend
  fails, and the KUnit race fix of the IRQ test (170-usb).
- #339 Touch ID verify retry (2): say why the sensor status after
  registration was unusable, and retry a failed sensor bring-up before
  a verify (100-sep).
- #340 USB and Bluetooth wake v4.1 (30): AIC wake (010-soc); xHCI,
  DWC3 and hub suspend-to-idle wake with their KUnit tests (170-usb);
  MT7932 Bluetooth wake and MSI wake for Apple PCIe (080-radio); the
  apple-dcp DWC3 wake model (200-dcp); the tools/aurora-wake regression
  tools (900-config-tooling).
- #341 apple-dcp selftests for the tipd lost-IRQ helpers (200-dcp).
- batch1 backlog: rust-clippy (4; 070-audio, 210-gpu), boot-warnings
  (3; 200-dcp), and the 4 harden-all commits not yet carried (010-soc
  qspi resume, 070-audio AOP wrapped-entry test, 200-dcp start
  completion). kunit-parsers, spi-apple-cs and the other 34 harden-all
  commits were already in the topics, including the AOP ring fix that
  top-up #4 brought; it is not duplicated.

Not ported: 3132675, superseded on 7.2.10 by b69728b
("selftests: apple-dcp: Follow the 7.2.10 driver boundaries").

Adaptations, each with a [ryan: ...] note in its commit:
- the new tipd KUnit tests take the CD321x and SN201202x data from
  the exported tipd_hw_variants[] table of 7.2.10;
- the #341 lifecycle.py import also keeps ATC_POST_TUNABLE;
- drm/asahi statistics style without the driver.rs part, which 7.2.10
  already has;
- the Rust doc example refresh only for KVec and Drain: iosys_map.rs,
  the old IoMem example and declare_flags_type!() are gone in 7.2.10;
- "Do not arm the core interrupt for wakeup" split between 170-usb and
  200-dcp.

New: 11e0ce6 ("usb: typec: tipd: cd321x: Don't race the resume
read in the sleep retry test").

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide added a commit that referenced this pull request Oct 17, 2026
Bring the 7.2.10 assembly to the tree of the canonical top-up #6
assembly, stacked on top-up #5 f34b5ae so that it is a
fast-forward of the published branch. The second parent is that
canonical assembly; the tree is identical to it.

Ported from aurora-wip, each with cherry-pick -x and its original
author:
- #347 KUNIT_ALL_TESTS=m modpost (3): the xHCI platform tests call the
  interrupt handler through the HC driver (170-usb), and module
  descriptions for the CD321x PM tests (170-usb) and the drm/apple
  KUnit test modules (200-dcp).
- #349 the CD321x IRQ test waits for the resume read before checking
  its retry (170-usb).
- #350 trusted keys keep a source that registers before
  init_trusted() (100-sep). Its test commit is already carried as
  76d70cc and is not duplicated.
- #351 SEP hwrng: recover the entropy exchange after a request times
  out, and hold entropy requests while the system sleeps (100-sep).
- #352 SEP SBIO: take a reply header only once it has landed, and
  poison it again once read and before each host send (100-sep).

Adaptations, each with a [ryan: ...] note in its commit:
- trusted-type.h: context only, the declaration goes above the
  7.2.10 CONFIG_TRUSTED_KEYS_DEBUG block;
- the CD321x IRQ test takes its data from tipd_hw_variants[], and its
  retry loop replaces the 7.2.10-only fix of the same race in
  11e0ce6.

The Co-Authored-By lines of the three #347 commits are dropped.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
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