Skip to content

usb: typec: tipd: fix coalesced HPD drop recovery on dcp-fabric ports - #3439

Merged
RyanTheTide merged 2 commits into
mainfrom
fix/tipd-hpd-pulse-replay
Dec 1, 2026
Merged

RyanTheTide merged 2 commits into
mainfrom
fix/tipd-hpd-pulse-replay

Conversation

@sithglan

@sithglan sithglan commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What:
Fix two issues preventing external DisplayPort monitors that wake from standby with a short HPD drop (e.g. EIZO FlexScan EV2780 dropping HPD for ~248 ms ~3 s after plug) from lighting up on Apple Silicon dcp-fabric ports:

  1. usb: typec: tipd: only set connector_fwnode when displayport property exists

    • Commit d769aaf5b389 added an else connector_fwnode = fwnode_handle_get(fwnode) fallback in cd321x_register_port(). On dcp-fabric platforms no DRM connector registers with the USB-C connector fwnode, so making connector_fwnode unconditionally non-NULL silently broke the !(IS_REACHABLE(CONFIG_DRM) && cd321x->connector_fwnode) guard in cd321x_typec_update_mode().
    • Restore the "displayport"-only lookup, move tps->h17_display initialization from tipd_resume() into tipd_init() so T8140/T8142 have it set from boot, and update the apple-dcp host selftest mocks (pm.py, transaction.py).
  2. usb: typec: tipd: replay HPD low before high on coalesced HPD drops

    • Replay HPD=0 then HPD=1 (CD321X_DP_SEND_EDGE) to the Type-C mux instead of synthesizing DP_STATUS_IRQ_HPD (which DCP firmware 27.2.1 short-circuits when the timing/color ID is already active).
    • Gate hpd_pulse on cd321x->state_valid && cd321x->state.alt == cd321x->port_altmode_dp and clear dp_status / dp_conf after TYPEC_STATE_SAFE succeeds in cd321x_update_work() so a fresh plug-in after unplug cannot emit a spurious HPD=0 edge.

Tested:

  • Local host checks at head a590df619dd7:
    • tools/testing/selftests/drivers/gpu/apple-dcp/run.py --group lifecycle: 35/35 passed (including typec-probe, probe-mux-pm-dispatch, probe-transaction-rollback, physical-disconnect, fast-replug-bounce).
    • tools/testing/selftests/drivers/gpu/apple-dcp/run.py --group quiesce: 19/19 passed.
    • scripts/checkpatch.pl --strict --git origin/main..HEAD: 0 errors, 0 warnings, 0 checks on both commits.
  • Combined hardware verification at head a590df619dd7 + #3523 (a5af61d67c3e, approved):
    • MacBook Air M1 (J313, T8103, macOS 27.2.1 firmware, EIZO FlexScan EV2780 2560x1440@60 Hz, default cmdline, 0 failed units, 0 new kernel errors): unplug -> monitor standby -> replug replayed HPD=0 -> HPD=1 without wedging the active external display pipe and restored picture + USB cleanly in 569 ms; deep sleep (rtcwake -d rtc1 -m mem -s 8) resumed display and USB hub/HID cleanly.
    • MacBook Air M5 (J813, T8142, SN201202x, second-family no-regression row): combined build passed live USB-C DP replug and both DPMS off/on cycles cleanly with 0 failed units and 0 new kernel errors.
  • Note: depends on #3523 (fix/dcp-unplug-mode-invalidate, approved) landing first or together so the HPD-low edge invalidates the active mode before any CRTC disable swap.

Risk: two-way · all Macs with tipd USB-C DP ports (CD321x and SN201202x).

Not yet: nothing (#3523 is now on main).

@sithglan
sithglan requested review from a team as code owners November 27, 2026 21:22

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

Verdict: FINISH, then merge at bc4852dd7098

The direction is right: restoring the "displayport"-only lookup in cd321x_register_port() fixes the regression from d769aaf5b389 that disabled hpd_pulse on every dcp-fabric port, and replaying HPD low before HPD high for a coalesced >2 ms HPD drop matches the DisplayPort spec, cd321x_dp_teardown(), and cd321x_dp_sid_replay(). Three items need to be fixed before merge.

Blockers:

  1. drivers/usb/typec/tipd/core.c:926-936 and drivers/usb/typec/tipd/core.c:1346-1362: cd321x_update_work() does not clear cd321x->dp_status when placing the mux in TYPEC_STATE_SAFE (on unplug it returns at :1376 without calling cd321x_typec_update_mode()). On CD321x (where cd321x_dp_release_first() does not run), unplugging a DP monitor leaves cd321x->dp_status & DP_STATUS_HPD_STATE set. On the next plug-in, st->data_status_changed & CD321X_DATA_STATUS_HPD_LEVEL and dp_data.status & DP_STATUS_HPD_STATE are both set, so hpd_pulse becomes true even though cd321x->state.alt is NULL (just came from SAFE). With the updated else branch at :936, that sends CD321X_DP_SEND_EDGE (HPD=0 first). If another port holds the only external display pipeline (e.g., M1/M2 Air), dcp_typec_route_apply() (drivers/gpu/drm/apple/dcp-fabric.c:2190,2241) records port->dp_hpd = false and returns -ENOSPC; core.c:956-959 sets *display_busy = true and skips the HPD=1 call, and :1453 does not retry. Because port->dp_hpd stays false, dcp_typec_route_waiting() (dcp-fabric.c:1629) skips the port when the first display is later unplugged, so the waiting display never lights up on its own. Fix: gate hpd_pulse on cd321x->state_valid && cd321x->state.alt == cd321x->port_altmode_dp, and clear cd321x->dp_status = 0 and cd321x->dp_conf = 0 after TYPEC_STATE_SAFE succeeds in cd321x_update_work() at :1361.
  2. drivers/usb/typec/tipd/core.c:926,4032,4382: tps->h17_display is only initialized in tipd_resume() (:4382), never in tipd_init() (:4032), so it stays false from boot until the first suspend/resume. Previously, the unconditional connector_fwnode fallback masked this on T8140/T8142 by keeping !(IS_REACHABLE(CONFIG_DRM) && cd321x->connector_fwnode) false. Removing that fallback exposes T8140 (J700) to hpd_pulse firing before the first suspend/resume and tearing down the retained H17P external pipeline via dcp_dptx_disconnect_oob() -> dcp_external_disconnect(dcp, true). Fix: initialize tps->h17_display in tipd_init() (moving the existing assignment out of tipd_resume(), or setting it in both).
  3. PR body format and hardware rows:
    • The PR body uses ## Summary / ## Testing and is missing the required **Tested:** and **Risk:** lines (pr-text will fail on both). Add **What:**, **Tested:** (naming the Mac, head SHA, and regression check result: 0 SELinux denials, 0 failed units, 0 new kernel errors, default cmdline), **Risk:** (two-way door · all Macs with tipd USB-C DP ports), and **Not yet:**.
    • Re-run the J313 hardware row at the updated head SHA after fixing blockers 1 and 2. Because drivers/usb/typec/tipd/core.c is shared across Mac generations (CD321x and SN201202x), also add a no-regression row on one other Mac generation with a USB-C DP display (or request one via a regression request), and wait for CI (host-tests, pr-text, readiness) to turn green.

Checked: no Apple material, no AI attribution, no new model/chip/board/firmware gates, no new cmdline/module parameters or sleeps, human author and Signed-off-by on both commits, Fixes: SHAs verified against main, diff traced across tipd, phy-apple-atc, dcp-fabric, apple_drv, and t8152_typec.

Evidence
  • Verified all callers of cd321x->connector_fwnode in drivers/usb/typec/tipd/core.c (:927, :1132, :1466, :3027, :3075, :3106) and confirmed drivers/gpu/drm/apple/apple_drv.c only attaches dcp->dev.fwnode in apple_connector_create() (:1347), never the USB-C connector fwnode (apple_probe_typec_ports(), :1679-1744).
  • Traced CD321X_DP_SEND_EDGE (HPD=0 -> HPD=1) through atcphy_mux_set() (drivers/phy/apple/atc.c:6326, ignores DP_STATUS_HPD_STATE, no-op), dcp_typec_route_apply() (drivers/gpu/drm/apple/dcp-fabric.c:2079,2251, runs dcp_dptx_disconnect_oob() then dcp_dptx_connect_oob()), cd321x_dp_sid_replay() (core.c:1015-1038, real IRQ_HPD on SN201202x still replays cleanly), and t8152_typec_set() (drivers/gpu/drm/apple/t8152_typec.c:74-101).
  • Checked interaction with #2879: complementary (#2879 forwards true IRQ_HPD with HPD high to dcp_dptx_sink_irq(); this PR handles coalesced >2 ms HPD level drops as HPD low -> high).
  • Checked pr-text.sh against the current PR body structure: fails for missing Tested: and Risk: fields. GitHub CI runs (host-tests, pr-text, readiness) were still queued at review time.
  • Non-blocking nit: drivers/gpu/drm/apple/dcp-fabric.c:2054-2056 still comments that cd321x_dp_send() clears IRQ_HPD first for a repeated IRQ_HPD; that comment can be updated here or in a follow-up.

@github-actions github-actions Bot added area:usb Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) ci-failing A check failed at the PR head (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at a590df61: ready to merge

Check Detail
CI at head ok 4 checks passed
Review ok approved by DjDeveloperr, erikwb
Requested changes ok none
Hardware row at head ok comment at a590df61
Conflicts ok none
PR text ok Risk: two-way · all Macs with tipd USB-C DP ports (CD321x and SN201202x).

Areas: area:usb
Merge: gh pr merge 3439 --merge (Owners and Core through the bypass: add --admin).

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

… exists

Commit d769aaf ("usb: typec: tipd: reconcile firmware-entered J616s
DP mode") added a fallback in cd321x_register_port() that sets
cd321x->connector_fwnode to the USB-C connector fwnode itself whenever no
"displayport" reference property is present in the device tree.

On Apple Silicon systems using dcp-fabric, no DRM connector registers with
the USB-C connector fwnode (apple_connector_create() only attaches
dcp->dev.fwnode for non-fabric external pipelines). Consequently,
drm_connector_oob_hotplug_event() with the fallback fwnode silently matches
no connector, while making cd321x->connector_fwnode unconditionally
non-NULL breaks the !(IS_REACHABLE(CONFIG_DRM) && cd321x->connector_fwnode)
guard in cd321x_typec_update_mode(). That disabled coalesced HPD pulse
handling on every dcp-fabric port.

Restore the original lookup so cd321x->connector_fwnode is only set when a
"displayport" reference actually exists, and remove the now-unused
fwnode_property_present()/fwnode_handle_get() stubs from the apple-dcp
host selftest.

Also move tps->h17_display initialization from tipd_resume() into
tipd_init() so T8140/T8142 have h17_display set from boot rather than
staying false until the first suspend/resume once the connector_fwnode
fallback no longer masks it.

Fixes: d769aaf ("usb: typec: tipd: reconcile firmware-entered J616s DP mode")
Signed-off-by: Thomas Glanzmann <[email protected]>
When a DisplayPort sink drops HPD and raises it again within the 500 ms
debounce window of cd321x_update_work() — for example an EIZO EV2780
waking from standby and dropping HPD for ~248 ms about 3 s after plug —
cd321x_typec_update_mode() previously synthesized DP_STATUS_IRQ_HPD.

On a dcp-fabric port, DP_STATUS_IRQ_HPD routes to dcp_retrain_oob(), which
only requests a modeset for the active mode without toggling DPTX HPD. On
DCP firmware 27.2.1 (M1 MacBook Air J313), the firmware still considers
the link up for that timing/color ID and short-circuits the modeset as a
no-op, skipping DisplayPort link training so the monitor reports "No
Signal" and returns to standby.

A >2 ms HPD drop is a hot-unplug/hot-plug event rather than an IRQ_HPD.
Replay HPD low first and then HPD high to the Type-C mux on a coalesced
HPD drop/rise, matching what cd321x_dp_sid_replay() already does on
SN201202x and what an uncoalesced (>500 ms) HPD drop produces. Gate
hpd_pulse on the port already being in DP altmode (state_valid &&
state.alt == port_altmode_dp) and clear dp_status/dp_conf after placing
the mux in TYPEC_STATE_SAFE on disconnect so a fresh plug-in after unplug
cannot trigger a spurious HPD=0 edge. Update cd321x_dp_send() and its
KUnit test accordingly.

Fixes: 836f05b ("usb: typec: tipd: report a coalesced sink HPD pulse as IRQ_HPD")
Fixes: b905751 ("usb: typec: tipd: send each IRQ_HPD request to the display route once")
Signed-off-by: Thomas Glanzmann <[email protected]>
@sithglan
sithglan force-pushed the fix/tipd-hpd-pulse-replay branch from bc4852d to a590df6 Compare November 27, 2026 23:28
@sithglan

Copy link
Copy Markdown
Contributor Author

@erikwb Thanks for the thorough review! Addressed all code/CI items at a590df619dd7:

  1. Blocker 1 (stale dp_status / hpd_pulse after SAFE): Gated hpd_pulse on cd321x->state_valid && cd321x->state.alt == cd321x->port_altmode_dp and cleared cd321x->dp_status = 0 / cd321x->dp_conf = 0 after TYPEC_STATE_SAFE succeeds in cd321x_update_work().
  2. Blocker 2 (tps->h17_display uninitialized before first resume): Moved tps->h17_display initialization from tipd_resume() into tipd_init() in Commit 1 (and added h17_display to transaction.py's struct tps6598x mock).
  3. host-tests (apple-dcp) & pr-text: Removed the now-unused fwnode_property_present / fwnode_handle_get stubs in tools/testing/selftests/drivers/gpu/apple-dcp/pm.py (lifecycle 35/35 and quiesce 19/19 now pass locally; checkpatch.pl --strict is 0/0/0) and updated the PR body to the What / Tested / Risk / Not yet format.

Fresh USB-C DP monitor hardware rows at a590df619dd7 (J313 + a second Mac generation) are still pending physical monitor attach and noted under Not yet.

@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) and removed needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 28, 2026

@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: FINISH, then merge at a590df61

Blockers:

  1. Missing exact-head a590df61 J313 USB-C DP hotplug/replug row (and a second-generation no-regression USB-C DP hotplug row), as listed under Not yet:.
  2. Re-run the cancelled readiness check (3/3 build/host/pr-text checks are green).

Checked:

  • drivers/usb/typec/tipd/core.c, cd321x-pm.h, cd321x-pm-test.c: a590df61 cleanly resolves the prior review blockers by gating hpd_pulse on cd321x->state_valid && cd321x->state.alt == cd321x->port_altmode_dp, clearing dp_status / dp_conf on TYPEC_STATE_SAFE, and replaying HPD low before HPD high (CD321X_DP_SEND_EDGE) on coalesced drops with updated KUnit coverage.
  • Checked for Apple material, tool attribution, private serials, and board gating: clean; MERGEABLE on main.
Evidence
  • Head: a590df619dd7 (base: main, mergeable: MERGEABLE, +26/-30 across 5 files).

@sithglan

Copy link
Copy Markdown
Contributor Author

Hardware verification at exact head a590df619dd7 across two Mac generations (note: live testing also uncovered a separate pre-existing apple-dcp unplug regression from #3157 on main, now fixed in #3523 — #3523 should merge before or alongside this PR because #3439's HPD=0 replay exercises disconnected_hpd_event() while a firmware-27 external CRTC is active):

  1. MacBook Air M5 (J813 / T8142, SN201202x, macOS 27.2 firmware) at exact head a590df619dd7:

  2. MacBook Air M1 (J313 / T8103, CD321x, macOS 27.2.1 firmware) at exact head a590df619dd7:

@erikwb Both prior review items are addressed at a590df619dd7 (host-tests and pr-text green) and hardware-verified on J313 + J813 (with #3523 identified as a companion fix for #3157's disconnected_hpd_event() crash). Ready for re-review!

@sithglan
sithglan requested a review from erikwb November 28, 2026 12:45
@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 28, 2026

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

Verdict: FINISH, then merge at a590df619dd7

Blockers:

  1. drivers/usb/typec/tipd/core.c:948: the J313 run at this head shows that replaying HPD low on the EIZO's standby pulse can wedge the active external display pipe. The low edge reaches disconnected_hpd_event() before the mode is invalidated, and a CRTC disable during that window submits a clear swap that never completes. Land #3523 first or together with this change and record the combined result in the Tested section.

Checked: The earlier code and PR text fixes are in. Host tests, PR text and readiness passed, and the branch has no conflicts. J313 and J813 hardware results are in the comments. The clean hotplug results on both machines include #3523.

Evidence

Earlier review at bc4852dd7098:

  1. Fixed in a590df619dd7. The replay requires a valid DP altmode state. A successful transition to SAFE clears both cached DP fields.
  2. Fixed in 68c8317cc5fb. The existing H17 display exception is initialized at probe, before the first hotplug or resume.
  3. The PR format is fixed in the description. 68c8317cc5fb updates the host test fixtures. The current-head hardware runs report the display failure above, and the combined J313 run restored picture and USB in 569 ms. On J813 the combined build passed live replug and both DPMS cycles.

@sithglan

Copy link
Copy Markdown
Contributor Author

Updated the Tested: section to record the combined J313 (569 ms restore, no wedged pipe) and J813 (live replug + DPMS cycles) hardware results at a590df619dd7 with #3523 (a5af61d67c3e). #3523 is approved and ready to land first (or together with this PR).

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

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: - drivers/usb/typec/tipd/core.c, cd321x-pm.h, cd321x-pm-test.c: a590df61 cleanly resolves the prior review blockers by gating hpd_pulse on cd321x->state_valid && cd321x->state.alt == cd321x->port_altmode_dp, clearing dp_status / dp_conf on TYPEC_STATE_SAFE, and replaying HPD low before HPD high (CD321X_DP_SEND_EDGE) on coalesced drops with updated KUnit coverage.

  • Checked for Apple material, tool attribution, private serials, and board gating: clean; MERGEABLE on main.

Follow-ups (not blocking): J313 USB-C DP hotplug row, rerun readiness

@RyanTheTide

Copy link
Copy Markdown
Contributor

@erikwb your blocker at a590df6 was to land #3523 first. #3523 is now on main (merged), and you noted the J313 and J813 hotplug runs that included it were clean. Can you clear your review if that settles it? It's the only thing this PR is waiting on; it goes into the next merge train once you do.

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

Verdict: MERGE at a590df619dd7

Blockers: none. My earlier blocker was to land #3523 first; it is merged on main (b32acf0b7844) at a5af61d67c3e, the same commit used for the combined J313 and J813 runs.

Checked: the combined J313 (picture and USB back in 569 ms, no wedged pipe) and J813 (live replug, both DPMS cycles) results at this head with #3523 are in the Tested section; host tests, PR text and readiness pass at this head; no conflicts.

Evidence
  • Nit: the Not yet: line still says to land #3523 first; it can say nothing now.

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

Verified that coalesced HPD drops replay low then high on an active DP route, that a successful SAFE transition clears the cached DP state, and that H17 starts with the right display path before resume. Host tests passed at this head, and the J313 and J813 results cover the display path with the companion DCP fix now on main.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at a590df619dd7 (B2 merge train, 12-01 merge bar). Approval at this head: DjDeveloperr,aurora-silicon-review[bot],erikwb. Row: J313 + J813 hotplug rows at a590df6 with #3523 (now on main), in the Tested section. CI: linux train L10 = main + #3439: Apple driver compile + drivers/usb/typec/tipd compile pass (the one tipd warning is already on main); hosted host-tests green at this head. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 4566db5 into main Dec 1, 2026
10 of 16 checks passed
@RyanTheTide
RyanTheTide deleted the fix/tipd-hpd-pulse-replay branch December 1, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:usb Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants