Repository navigation
Conversation
A DCP's system suspend settles its IOMFB queue first and refuses the sleep
when that times out ("display updates still pending, refusing sleep"). The
refusal does not say what the queue is waiting for: an active transaction,
queued ones, a present the firmware has not finished, or a call or an ACK
still outstanding on one of the channels.
Report that state, rate-limited, from the settle's last pass when it
times out. The queue state is read under the IOMFB lock. The channel
depths, ACK count and callback count change outside that lock, so the
report labels them as samples.
Signed-off-by: Erik Bourget <[email protected]>
On the J313 (M1, firmware 27.2.1 DCP), deep sleep with a lit external display on a USB4 dock is refused every time. The display then stays dark until a reboot: dcpext: setPowerState(0) timeout 1000 ms dcpext: display updates still pending, refusing sleep dcpext: PM: failed to suspend: error -16 ... dcpext: IOMFB transaction timed out: ... present=1 accepted=1 The dock's port is torn down at PM_SUSPEND_PREPARE, while userspace is still running. The firmware acts on the display's unplug by powering the external pipe off, then reports the unplug through its hotplug callback. The compositor then turns the CRTC off, with the mode still valid. The power-off sends the clear swap. The firmware accepts it but never completes it on a pipe it has powered off. The present stays in flight, because the CRTC-off path cancelled the swap watchdog. The IOMFB queue holds the abort_swaps and setPowerState(0) calls behind it, and they never reach the firmware. setPowerState(0) times out, the DCP's suspend cannot settle the queue and refuses the sleep, and ten seconds later the queue's timeout declares the coprocessor crashed. Record the firmware's own reports of a Type-C display, after the reports that are not display changes have been filtered out. One word holds the number of unplugs reported and whether the last report had a display, so it is always read whole. The CRTC notes that number, with the mux's count, wherever it claims its display: at its power-on, and at a mode set that succeeds with the CRTC kept on. The display of the CRTC's session is gone, and its pipe with it, once both of these have happened since the claim: the Type-C mux has announced the unplug, and the firmware has reported one. They come in either order. The USB4 port's teardown at the sleep takes the display away, and the firmware reports it, before the mux announces it. A display's unplug that the firmware never reported does not stand in for the next display's. The desktop hears of the unplug from the mux. When the CRTC of such a display turns off before the firmware's report, the power-off waits for the report, bounded by a named limit; firmware without the queue does not wait. Without the report it powers the pipe off as before. On firmware with the queue, the swap watchdog now also watches the clear swap, so one the pipe swallows is retired a second later rather than holding the power-off until the queue's timeout declares the coprocessor crashed. That covers any panel-less output, such as a fixed HDMI port whose display drops off at DPMS off, with the watchdog's usual retrain. An unplug report also has the watchdog retire a present the pipe had accepted, should the CRTC not turn off. Once the firmware has reported the unplug, on firmware with the IOMFB queue, the departing session's present ends. A reply still on its way lands first: a reply now wakes the channel waiters once its callback has run. A present the firmware accepted for a display that went is retired, as the swap watchdog would retire it, with its framebuffers kept until a later present completes, and only its own commit's flip is finished as failed. Each present notes the firmware's unplug count when it is begun, on the same receive path as the reports, so a present begun before the last unplug report is the departed display's, while one begun for a display reported on the pipe since is left to complete. Presents still queued are not sent: the connector is disconnected. The pipe is then sent nothing, since no scanout of ours is left to stop. Two cases still get the full power-off, which the old present no longer holds up: a display the firmware reported on the pipe since, and a pair, which stops through its own sequence. A present that cannot be retired leaves the swap watchdog armed, and nothing is sent behind it unless another display needs its power-off. A system sleep can come before the compositor turns the CRTC off. Its suspend cancels the watchdog too, so it ends the unplugged session the same way before settling the queue, waiting first for the firmware's report of an unplug the mux has announced, as the power-off does. The decision is passed to the power-off as an argument. Firmware without the IOMFB queue powers the pipe off as before. Signed-off-by: Erik Bourget <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: MERGE at 4261e69d
Blockers: None (wait for the queued hosted CI checks at 4261e69d — apple-build, host-tests, readiness, and KUnit matrix jobs — to finish green; kunit and pr-text have already passed).
Checked:
- Audited both commits (
b934f2d0and4261e69d, DCO present on both) across all 5 files (dcp-internal.h,dcp.c,iomfb.c,iomfb_template.c,dcp_dropped_swap_test.c):iomfb_queue_report_locked()(iomfb.c:912-924): assertsdcp->iomfb.lock, rate-limits reporting to the final expired pass ofiomfb_queue_settle(), and reads lockless channel/ACK/callback counters withREAD_ONCE()/atomic_read().dcp_typec_fw_hotplug()/dcp_typec_claim()/dcp_typec_fw_display()(dcp.c:137-188,iomfb_template.c:3281): packs the 31-bit unplug counter and connected bit into a singleu32written only on the RTKit receive path after filtering out non-display-change hotplug callbacks (typec_crtc_off,t6040_relinking,dcp_typec_relink). Bothdcp_poweron()anddcp_crtc_atomic_modeset()claim the session; either mux-first or firmware-first unplug order is handled without leaking an unreported unplug across sessions.iomfb_end_unplugged_session_h17p()(iomfb.c:1092-1172): waits up toIOMFB_UNPLUG_REPLY_MS(500 ms) onchannels_idle_wq(now woken after callback execution indcpep_handle_ack()), re-verifies!iomfb_present_unanswered(dcp)underdcp->iomfb.lock, distinguishes departed vs replacement presents viapresent_fw_unplugs(recorded on the same RX path indcp_present_begin()), retires accepted presents via sharediomfb_retire_present_locked()while retaining framebuffers, cancelsswap_watchdog_wqwithout_syncunderiomfb.lockbeforeiomfb_queue_advance(), and finishesdcp_drm_crtc_flip_lost()+drm_crtc_commit_put()outside the lock (no ref leak or lock inversion). Paired DCPs (peer_frames.active) and replaced displays (DCP_TYPEC_FW_REPLACED) still perform full pipe power-off.dcp_swap_cleared()(iomfb_template.c:2446-2454):else ifattaches cleanly toif (status)so an accepted clear swap (status == 0) on queued H17P/V27 firmware armsdcp_swap_watchdog_arm(dcp).dcp_s2r_ext_suspend()(dcp.c:10389): invokesdcp_typec_end_unplugged_for_sleep(dcp)after pausing presentation and beforeiomfb_queue_settle().
- Verified hardware evidence across three generations: exact-head J313 (M1, T8103, DCP 27.2.1, TS5 dock) before/after (
1/1baseline refused ->6/6deep sleeps + awake unplug/replug PASS,0failed units), plus J713 (M4, T8132) and J716c (M5 Max, T6050 paired DCPs) regression rows; arm64 QEMU KUnit340/340(apple-dcp-dropped-swap28/28, 15 new cases, 6/6 mutations killed) andcheckpatch.pl --strictclean.
Evidence
drivers/gpu/drm/apple/dcp.c:5777-5889(dcp_typec_fw_*,dcp_typec_end_unplugged_for_sleep),:5961-5972(dcp_poweroff),:10389(dcp_s2r_ext_suspend).drivers/gpu/drm/apple/iomfb.c:912-949(iomfb_queue_report_locked,iomfb_queue_settle),:2359-2363(dcpep_handle_ack),:4506-4564(iomfb_retire_present_locked),:4766-4917(iomfb_end_unplugged_session_h17p,iomfb_watch_unplugged_present_h17p).drivers/gpu/drm/apple/iomfb_template.c:2319-2332(dcp_present_begin),:2434-2454(dcp_swap_cleared),:3250-3282(dcpep_cb_hotplug).drivers/gpu/drm/apple/dcp_dropped_swap_test.c: 15 new KUnit cases covering all unplug/replace/sleep/late-report/held-present/unqueued branches.
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
|
The two patches worked together on the J313 (T8103) daily build
The combined run supports carrying both fixes in the J313 daily. |
…g tracking Tracking firmware Type-C unplug reports updated dcpep_cb_hotplug(), dcp_poweron(), dcp_poweroff(), and dcp_crtc_atomic_modeset() to call dcp_typec_fw_hotplug(), dcp_typec_claim(), and dcp_typec_fw_unplug_wait(), added the pipe_unplugged argument to _dcp_poweroff(), and placed iomfb_end_unplugged_session_h17p() ahead of iomfb_queue_atomic(). Update the four host-test harnesses that extract those functions: - rate.py (publication-hpd): stub dcp_typec_fw_hotplug(). - lifecycle.py (stale-crtc-poweroff): verify dcp_typec_claim() via dcp_crtc_atomic_modeset(), stub dcp_typec_fw_unplug_wait(), and accept pipe_unplugged in _dcp_poweroff(). - dcpext26-queue-tests.py: end the iomfb.c slice at iomfb_atomic_release() and append iomfb_queue_atomic() explicitly. - backlight-coldboot-tests.py: stub dcp_typec_claim(). Signed-off-by: Erik Bourget <[email protected]>
Signed-off-by: Erik Bourget <[email protected]>
|
Fixed the Changes (
Forward merge of Checks at
Hardware rows / PR body: Scrubbed internal build names from the PR description and updated |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed both unplug notification orders, replacement-display handling, and retiring a stale present while retaining its framebuffers. The refreshed docked J313 sleep/reconnect row and hosted Apple build and DCP KUnit are still needed.
|
The merge with |
|
This needs a merge of |
What: On firmware-27 external display processors, a Type-C display unplugged under a lit CRTC is left powered off by the firmware. The power-off therefore no longer sends the clear swap and teardown, which the firmware swallows. On the M1 MacBook Air that swallowed clear swap held the IOMFB queue: every docked deep sleep with a lit external display was refused, and the dcpext was declared crashed, dark until a reboot. A second commit reports what an unsettled IOMFB queue is still waiting for.
Tested: At
5ce4ffaeb3fe(forward merge oforigin/main19ee1b5bc9d5overbe574d3b3b94, updatingdcp_t6041_stop_one()'s non-v27 fallback to_dcp_poweroff(dcp, false)):make O=_build_w1 ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/apple/(0errors,0warnings), KUnit (topology.kunitconfig231/232with1skipped andapple-dcp-dropped-swap28/28,display.kunitconfig188/189with1skipped,tests/.kunitconfig117/117),dcpext26-queue-tests(+--drop-v27-closenegative control) 2/2,backlight-coldboot-tests(+--negative-controls) 2/2, andapple-dcp(publication-hpd,stale-crtc-poweroff,connected-irq-hpd-to-firmware,dcp-sink-irq-fallbackpass; 87/101apple-dcpunits pass on Clang 23.1.5, 14 unrelated fixtures hit Clang 23-Wunused-but-set-global). J313 M1 Air at4261e69d1e9a(same driver code prior to the19ee1b5bc9d5mainmerge): docked deep sleep with a lit 4K120 display 3/3, docked with the display DPMS-off, DPMS off/on, unplug while awake, undocked deep sleep, and replug while awake then a docked sleep. All pass (6/6 sleeps in one boot), with 0 failed units and no new kernel errors. The control atmaind02c84abc8derefuses the docked sleep and the dcpext crashes. On each Mac's daily plus these two commits (4261e69d1e9a): J713 M4 Air (two docked 4K60 displays) passed 3 of 4 docked deep sleeps plus DPMS; one sleep reset the Mac 17 s after boot and did not reproduce at 16 s, while the daily alone passed 2/2. J716c M5 Max (two docked 4K240 paired displays) passed DPMS, docked s2idle and unplug while awake, the same as its default. Details in Evidence.Risk: two-way door · Macs whose external DCP uses the firmware-27 / H17P IOMFB queue (M1 on firmware 27, M4 and M5 dcpexts); others unchanged
Not yet: Refreshed J313 row at
5ce4ffaeb3fe(driver logic unchanged since4261e69d1e9a, prior to the19ee1b5bc9d5mainmerge); M4 and M5 rows onmainitself (maincannot drive the M4's dock without #3273, and the M5 rows ran on its daily, which carries open DCP PRs; deep sleep on the M5 resets on every kernel, including the default).Details
The failure. At
PM_SUSPEND_PREPAREthe USB4 port is torn down while userspace still runs. The firmware loses the DisplayPort sink, powers the external pipe off and reports the unplug. The Type-C mux announces the unplug too (dcp_dptx_disconnect_oob()), and the compositor turns the CRTC off with the mode still valid. The power-off sends the clear swap. The firmware accepts it but never completes it on a pipe it has powered off. The swap watchdog had been cancelled by the CRTC-off path, so the present stays in flight.abort_swapsandsetPowerState(0)wait behind it in the queue,setPowerState(0)times out, the DCP suspend cannot settle the queue and refuses the sleep, and ten seconds later the queue timeout declares the coprocessor crashed.The change.
dcpep_cb_hotplug(). The CRTC notes the count, with the mux's count, wherever it claims its display: at its power-on, and at a mode set that succeeds with the CRTC kept on (dcp_typec_claim()).DCP_TYPEC_FW_UNPLUG_MS. Without it, the power-off runs as before.iomfb_end_unplugged_session_h17p()sends nothing:dcp_drm_crtc_flip_lost().iomfb_atomic_start()).Known limits.
Overlap with #3273. #3273 (T8132 firmware-27 dock displays) also retires a present whose display went: it keys each present to the Type-C attachment it was begun for and lets the swap watchdog retire it. This PR retires such a present at once, from the power-off and the sleep paths, through the same retirement bookkeeping (
iomfb_retire_present_locked(), shared with the watchdog). They touch the same functions. Whichever lands second folds the two into one mechanism. The M4 row below merges both and runs them together.Diagnostic commit. When a queue settle times out, the IOMFB queue's state is reported, rate-limited: the active transaction, queued ones, the present in flight, plus channel depths, ACKs and callbacks sampled outside the lock. This names the cause of a refused sleep.
Host-test harness fix (
be574d3b3b94). Updates the four host-test extractors that pulldcpep_cb_hotplug(),dcp_poweron(),dcp_poweroff(),dcp_crtc_atomic_modeset(), andiomfb_queue_atomic()out of the driver: stubsdcp_typec_fw_hotplug()inrate.py(publication-hpd), checksdcp_typec_claim()viadcp_crtc_atomic_modeset()and stubsdcp_typec_fw_unplug_wait()/_dcp_poweroff(..., pipe_unplugged)inlifecycle.py(stale-crtc-poweroff), stops theiomfb.cslice atiomfb_atomic_release()and appendsiomfb_queue_atomic()indcpext26-queue-tests.py, and stubsdcp_typec_claim()inbacklight-coldboot-tests.py.Evidence
J313 (M1 Air, T8103), DCP firmware 27.2.1, CalDigit TS5, external 3840x2160@120 on dcpext 271c00000. Kernel config: the J313 daily config. Default command line;
rtcwake -d rtc1 -m mem -s 30in a systemd unit.271c00000.dcp-16, thenIOMFB transaction timed out ... present=1 accepted=1, connector brokenThen a replug while awake on
4261e69d1e9a: DP-2 back at 3840x2160, followed by one more docked deep sleep on the new path, for 6/6 sleeps in that boot.On
4261e69d1e9a, each docked sleep logs the new path, with the power-off message enabled through dynamic debug for the run:Kernel errors on that boot are the same Wi-Fi/Bluetooth resume lines (
Unable to change power state from D3hot to D0) and PCIeof_irq_parse_pcilines that the J313 daily shows. None come from apple-dcp beyond theDCPDP2XService admission failed: -19seen on main. No SELinux on this install.J713 (M4 Air, T8132), at
4261e69d1e9amerged into its daily (main219311530ef0+ #3273 and other open PRs; the conflicts were in the shared retirement helper and the older base's lack ofchannels_idle_wq). Two lit 3840x2160@60 displays on the TS5, with the dcpexts 286e00000 / 48ae00000 on firmware 27:Type-C DPTX reconnect failed after 1 retries: -116)The trial boot has no kernel error lines that the J713 daily boot lacks. The one reset left nothing in the journal past the test marker. The displays not returning after a docked wake on the J713 daily is separate from this change.
J716c (M5 Max, T6050), at
4261e69d1e9amerged into its daily (basea812cfe477e2). That daily carries a third retirement variant,iomfb_retire_stalled_present_h17p(), which the merge keeps. Two lit 3840x2160@240 displays on the TS5, each on a paired DCP. The trial was one boot of a chained trial Stage 2 under the watchdog dead-man:a812cfe477e2)DP tunnel clock N stopped30 s laterNo kernel error lines that the default boot lacks. Deep sleep can't be judged on this M5: it resets about 6 s in on every kernel, and an RTC alarm doesn't wake it from s2idle on either kernel.
KUnit at
5ce4ffaeb3fe(qemu arm64,LLVM=1,drivers/gpu/drm/apple/tests):topology.kunitconfig231 passed / 1 skipped (apple_g17_rx_util_min_test, needsCONFIG_UCLAMP_TASK,232total;apple-dcp-dropped-swap28/28 passed),display.kunitconfig188 passed / 1 skipped (189total),tests/.kunitconfig117/117 passed. Prior KUnit at4261e69d1e9a(343run,340pass,3skipped) covered the 28apple-dcp-dropped-swapcases:Mutations each fail at least one case: ignoring the firmware report, not retiring, not waiting for the report, not arming on the report, not watching the clear swap, and dropping the per-present display check.
Host builds & tests at
5ce4ffaeb3fe:make O=_build_w1 ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/apple/(defconfig+asahi.config,CONFIG_RUST=n,CONFIG_DRM_FBDEV_EMULATION=y): 0 errors, 0 warnings.dcpext26-queue-testsanddcpext26-queue-tests --drop-v27-close(negative control killed): 2/2 pass.backlight-coldboot-testsandbacklight-coldboot-tests --negative-controls: 2/2 pass.apple-dcp(publication-hpd,stale-crtc-poweroff,connected-irq-hpd-to-firmware,dcp-sink-irq-fallbackpass; in the fullapple-dcprun on Clang 23.1.5 with-Wno-unused-but-set-globalhost CC, 87/101 units pass; 14 unrelated fixtures hit Clang 23-Wunused-but-set-globalunder-Wall -Werror).checkpatch.pl --strict(d02c84abc8de..be574d3b3b94):4261e69d1e9aandbe574d3b3b94clean (0 errors, 0 warnings);b934f2d087bbhas 1 line-length warning (102 cols on thedev_info_ratelimitedarguments).git diff --check origin/main...5ce4ffaeb3feclean.