Skip to content

drm/apple: m4: hold a Thunderbolt display across a deep sleep too - #3958

Draft
themartiano wants to merge 1 commit into
aurora-silicon:mainfrom
themartiano:fix/m4-tb-sleep-tunnel
Draft

themartiano wants to merge 1 commit into
aurora-silicon:mainfrom
themartiano:fix/m4-tb-sleep-tunnel

Conversation

@themartiano

Copy link
Copy Markdown
Contributor

What: Builds on the hold from #2200. #2200 holds a display that the DCP's suspend releases, and replays its mode once the display is connected again. A Thunderbolt display is released earlier: the connection manager takes its tunnel down in the prepare phase, so the DCP's suspend finds nothing to hold. The replay then runs at once, the enable fails with -ENOLINK (-67), the link status goes BAD, and the picture comes back only on the compositor's own modeset. This takes the hold for a display on a tunnel at PM_SUSPEND_PREPARE, while the tunnel is still up. After the wake it waits #2200's 3 s, and up to 10 s from the same start only if the tunnel's cable is back by then.

Tested: Host side at the head, on main 30c1870. arm64 W=1 LLVM 20 build of drivers/gpu/drm/apple/: 0 warnings. checkpatch --strict: clean. The KUnit suites CI picks (dcp-fabric, dcp-topology, dcp-display) pass on arm64 QEMU, with one skip that needs CONFIG_UCLAMP_TASK. apple-dcp host suite: no new failure against main (the same 14 compile errors from this container's newer host compiler). Hardware: measured on a J713 (M4 Air, 26.6.2) with an Apple Studio Display on an earlier tree, before this was redone on #2200: the replay ran 24 ms after the DCP's restart and failed with -67, and the sink was reported 5.9 to 6.0 s after the restart. This commit is in our 7.3.0 next4 test kernel (main ba12094 plus this and other open branches; the files it touches are the same on today's main). A row at this head is not yet run.

Risk: two-way · M4 (T8132) Macs whose external output can be a Thunderbolt tunnel on main: J713 and J715. A Thunderbolt display unplugged during the sleep now costs 3 s at resume, as an alt-mode display whose sink never reports already does. The hold is also taken before an s2idle, since the target state is not known at PREPARE; there the display is still connected at the end, so nothing is waited for (code reading).

Other Macs: The code is in iomfb_m4.c and t8132_ext_drm.c, which only T8132 Macs on firmware 26.6 run. The new part only acts for an output whose route is a tunnel (dcp_is_usb4_output()), and only the J713 and J715 enable USB4 in their trees on main. On the J604, J773g, J623 and J624 the external outputs are direct: they keep #2200's 3 s wait unchanged (same deadline, computed from the same start). Other SoCs do not run this code. On a J715 with a Thunderbolt display it should help the same way, but there are no rows from one.

Not yet: a J713 row at this head with a Thunderbolt display: three deep sleeps with no -67 and the picture back once; DPMS off before the sleep; unplug during the sleep (expect 3 s); an HDMI or alt-mode display alone (unchanged); s2idle if the port allows it. Rows from a J715.

Details
  • iomfb_m4_ext_relink_own() (PM_SUSPEND_PREPARE) now also calls iomfb_m4_ext_relink_expect() for an external output on a tunnel with a sink, and ext_relink_tunnel records that.
  • After the wake, "no cable yet" does not end the wait for a tunnel: its cable comes with the tunnel, from the connection manager's complete on dp_wq. A cable that comes back and then goes does end it.
  • iomfb_m4_ext_relink_wait() takes two deadlines: drm: apple: t8132: keep an external display across a deep sleep #2200's 3 s, then 10 s from the same start if the display is on a tunnel and its Type-C cable is connected again. The 10 s is a bound on an event wait, not a delay. The sink was reported about 6 s after the DCP's restart in both logged sleeps.
  • A reviewer may prefer a flush of dp_wq in apple_nhi_cio_complete() (symmetrical with prepare) to end an unplugged tunnel's wait earlier. Not done: it would touch every CIO sleep.
  • The wait logic has no host test; it was checked by reading.
  • git merge-tree against iommu/apple-dart, drm/apple: t8132: dual-pipe peer bonding for high-pixel-rate external displays #3454 (dual-pipe, also in iomfb_m4.c/iomfb_m4.h): no conflict.
Evidence
  • Head 0878d72, parent 30c1870 (main). Cherry-picked from our branch without conflict; the files it touches are unchanged on main since ba12094, the base of the test kernel.
  • Build: make O=<dir> LLVM=/usr/lib/llvm20/bin/ ARCH=arm64 olddefconfig from our J713 test kernel's config (7.3.0-0.next3), then W=1 drivers/gpu/drm/apple/ (clang 20.1.8). 0 warnings; iomfb_m4.o and t8132_ext_drm.o built.
  • scripts/checkpatch.pl --strict -g main..HEAD: 0 errors, 0 warnings, 0 checks.
  • KUnit, scripts/ci/apple-kunit.py plan picks dcp-fabric dcp-topology dcp-display; run on arm64 QEMU (LLVM=1, clang 23.1.5): dcp-fabric 117/117, dcp-topology 235 passed + 1 skipped of 236, dcp-display 211 passed + 1 skipped of 212. The skip is apple_g17_rx_util_min_test (needs CONFIG_UCLAMP_TASK, which the suites' configs do not set).
  • tools/testing/selftests/drivers/gpu/apple-dcp/run.sh: 87 ok, 14 not ok; main at 30c1870 gives the same 14 (compile errors of this container's newer host compiler, for example -Wunused-but-set-global in pm-ownership). No new failure.
  • git merge-tree with iommu/apple-dart, drm/apple: t8132: dual-pipe peer bonding for high-pixel-rate external displays #3454's head b21a5c5: no conflict.
  • J713 numbers (24 ms, -67, 5.9 to 6.0 s) are from an earlier version of this change on an older tree, before drm: apple: t8132: keep an external display across a deep sleep #2200 merged.

A display released for a deep sleep is held: its connector stays as it
was, and the replay at PM_POST_SUSPEND waits until it is connected again.
A display on a Thunderbolt tunnel gets neither. The connection manager
takes the tunnel down in the prepare phase, so the display is released
before the DCP's suspend, which then finds nothing connected to hold. The
replay runs at once: the enable fails on a link that is not up
(-ENOLINK), the link status goes BAD, and the display comes back on the
compositor's own modeset once the sink is reported.

Take the hold for such a display at PM_SUSPEND_PREPARE, where its tunnel
is still up. After the wake its cable comes with the tunnel, so a cable
that is not there yet does not end the wait; one that comes back and then
goes does. Wait 3 s at most as for any display, and 10 s if its tunnel is
back by then: the sink reports later than on a direct link. A sleep that
leaves the tunnel up, or one refused, finds the display still connected
and waits for nothing.

Measured on a J713 with an Apple Studio Display and an earlier tree: the
replay ran 24 ms after the DCP's restart and failed with -67, and the
sink was reported 5.9 to 6.0 s after the restart.

Signed-off-by: Eduardo <git@martiano.me>

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