Skip to content

usb: typec: tipd: enable DP_SID_UPDATE and replay coalesced HPD drops on polled T8142 - #3649

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

RyanTheTide merged 2 commits into
mainfrom
fix/tipd-t8142-dp-sid-hpd-replay

Conversation

@sithglan

@sithglan sithglan commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What: Enable SN201202X_INT_DP_SID_UPDATE on apple,t8142 in cd321x_uses_dp_sid() and replay coalesced HPD-low pulses on polled SN201202x ports (!tps->irq) via cd321x_dp_sid_coalesced_hpd_low(), with KUnit coverage (cd321x_dp_sid_coalesced_hpd_low_test) and apple-dcp selftest shim updates.
Tested: MacBook Air 13-inch (M5, J813 / apple,t8142) at 4747d512bd54 — PASS (cold boot + active-Sway physical unplug/standby/replug with EIZO EV2780 USB 2.0 -> USB 3.0 hub wake HPD bounce: 635 ms end-to-end recovery, 0 swallowed swaps, 0 kernel errors, 0 failed units); Mac mini (M6, J873g / apple,t8152, IRQ-driven SN201202x second-generation peer check) at 4747d512bd54 — PASS (see comment below); KUnit cd321x* 122/122 passed; apple-dcp selftests lifecycle 35/35 + quiesce 19/19 passed; checkpatch.pl --strict 0 errors/warnings/checks.
Risk: two-way · T8142 (M5) polled SN201202x ports (a plain revert undoes it). IRQ-driven SN201202x ports (tps->irq != 0) and apple,t8140 are unchanged. Merge #3523 before or alongside this PR.
Not yet: T8142 J815 confirmation.

Details
  • Enable SN201202X_INT_DP_SID_UPDATE on apple,t8142 in cd321x_uses_dp_sid() (keeping apple,t8140 excluded for J700's retained external H17P display pipe). On T8142, dcp_is_retained_external() is false for dcp_t8142_ext(), so the external DCP tears down and retrains cleanly on HPD replay.
  • Add cd321x_dp_sid_coalesced_hpd_low() in cd321x-pm.h and call it from cd321x_dp_sid_event(): on polled SN201202x ports (!tps->irq, 500 ms poll interval on T8142 nub_spmi_a0), a short sink HPD-low pulse (~250 ms when an EIZO EV2780 wakes from standby and switches its internal hub from USB 2.0 to USB 3.0) latches SN201202X_INT_DP_SID_UPDATE while DP_SID_STATUS.status_rx has already returned to the previously applied HPD-high status by the next poll. Treat that unchanged HPD-high status update (without DP_STATUS_IRQ_HPD) on an already-active DP route as a coalesced HPD drop so cd321x_dp_sid_replay() tears down and retrains the link instead of dropping the event.
  • Add cd321x_dp_sid_coalesced_hpd_low_test to cd321x-pm-test.c covering all positive and negative cases, and add DP_STATUS_HPD_STATE plus the unused-helper shim in tools/testing/selftests/drivers/gpu/apple-dcp/common.py.
  • Merge order with #3523: Like #3439, replaying HPD=0 on an active firmware-27 external CRTC requires #3523 (drm/apple: invalidate mode state on disconnected HPD event) so the compositor does not submit a swallowed swap during teardown (#3157).
Evidence
  • Live hardware (J813 / MacBook Air 13-inch M5, apple,t8142) with EIZO EV2780 USB-C display (2560x1440@60, USB 2.0 -> USB 3.0 hub wake switch) on aurora/main + #3523 + #3439 + #3567 + 4747d512bd54:
    • Cold boot with EIZO attached: card1-DP-2: connected at t=2.4 s, real 256-byte EDID (ENC 0x2811), 18 modes, 2560x1440@60, USB 2 + USB 3 hubs + EIZO HID + Billboard all enumerated cleanly.
    • Active-Sway physical unplug -> EIZO standby (~15 s) -> physical replug (t=73.12 s) -> 3.86 s later EIZO dropped HPD (~260 ms): sn201202x 1-0a: DP partner reported its display gone and back: HPD low, then high (t=77.218 s) -> DCPDPService re-admitted on channel 9 -> set_digital_out_mode finished:2060 (t=77.853 s, 635 ms end-to-end recovery inside Sway, 0 swallowed swaps, 0 timeouts, 0 DART/DCP/kernel errors, 0 failed units).
  • KUnit (ARCH=um): cd321x* 122/122 passed (cd321x-pm: 50/50 including cd321x_dp_sid_coalesced_hpd_low_test, cd321x-tbt: 10/10, cd321x-irq: 11/11, cd321x-mux: 21/21, cd321x-dp: 20/20, cd321x-dp-sequence: 10/10).
  • apple-dcp host selftests: lifecycle 35/35 passed, quiesce 19/19 passed.
  • Compile & style: ARCH=arm64 LLVM=-19 clean build of drivers/usb/typec/tipd/; ./scripts/checkpatch.pl --strict --git HEAD~1..HEAD 0 errors, 0 warnings, 0 checks.

… on polled T8142

On Apple T8142 (M5) systems, the SN201202x Type-C controllers on
nub_spmi_a0 run in polled mode (500 ms poll interval). Two issues combine
to drop short sink HPD low pulses such as an EIZO EV2780 waking from
standby (~250 ms HPD low while switching its internal hub from USB 2.0 to
USB 3.0):

1. cd321x_uses_dp_sid() excluded apple,t8142 alongside apple,t8140,
   masking out SN201202X_INT_DP_SID_UPDATE. Unlike T8140 (J700), T8142
   external DCP is not a retained display pipe (dcp_is_retained_external()
   is false for dcp_t8142_ext()) and tears down and retrains cleanly on
   HPD replay.
2. When a sink drops HPD and raises it again between two 500 ms polls,
   SN201202X_INT_DP_SID_UPDATE latches, but DP_SID_STATUS.status_rx has
   already returned to the previously applied HPD-high status by the time
   the poll reads it.

Enable DP_SID_UPDATE on apple,t8142 (keeping apple,t8140 excluded) and
add cd321x_dp_sid_coalesced_hpd_low() so that a polled SN201202x seeing
an unchanged HPD-high DP_SID_UPDATE without IRQ_HPD on an already-active
DP route replays HPD low via cd321x_dp_sid_replay().

Update the cd321x-pm KUnit suite and the apple-dcp host selftest header
shim accordingly.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan
sithglan requested review from a team as code owners November 29, 2026 18:48
@github-actions github-actions Bot added area:usb Area from CODEOWNERS (bot) blast:neo Macs affected, 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) needs-template PR body lacks Tested or Risk (bot) labels Nov 29, 2026
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Merge readiness at 768a654e: not ready yet

Check Detail
CI at head ok 3 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 768a654e
Conflicts ok none
PR text ok Risk: two-way · T8142 (M5) polled SN201202x ports (a plain revert undoes it). IRQ-driven SN201202x ports (tps->irq != 0) and apple,t8140 are unchanged. Merge #3523 before or alongside this PR.

Areas: area:usb

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 4747d512bd54

Blockers:

  • Merge dependency on #3523: #3523 (drm/apple: invalidate mode state on disconnected HPD event) is still open; as noted in the PR's Risk section, #3523 must land before or alongside this PR to avoid swallowed swaps during firmware-27 external HPD teardown (#3157).
  • Hosted CI & PR metadata: Hosted CI at 4747d512bd54 is still queued (1 passed, 0 failed, 3 queued); also add one-way or two-way to ### Risk so pr-text passes.
  • No-regression hardware row: Awaiting the second-generation SN201202x no-regression check (e.g. IRQ-driven T604x/T8132 port) noted in Not yet.

Checked:

  • Verified drivers/usb/typec/tipd/core.c (cd321x_uses_dp_sid(), cd321x_dp_sid_event()):
    • Re-enables SN201202X_INT_DP_SID_UPDATE on apple,t8142 while keeping apple,t8140 excluded.
    • Both callers of cd321x_dp_sid_event() (cd321x_wake_events() and cd321x_interrupt()) and cd321x_update_work() hold &tps->lock, so reads of dp_sid_valid, state_valid, state.alt, and dp_status are properly serialized.
  • Verified drivers/usb/typec/tipd/cd321x-pm.h (cd321x_dp_sid_coalesced_hpd_low()): tightly gated on polled mode (!tps->irq), valid/active DP state (dp_sid_valid && state_valid && in_dp), HPD high in both applied and rx, no active DP_STATUS_IRQ_HPD, and unchanged non-IRQ status bits, so IRQ-driven ports, initial attach, IRQ_HPD, and non-HPD status changes (e.g. DP_STATUS_PREFER_MULTI_FUNC) are unaffected.
  • Verified KUnit coverage (cd321x_dp_sid_coalesced_hpd_low_test, 122/122 cd321x* passing), tools/testing/selftests/drivers/gpu/apple-dcp/common.py host-header shim (DP_STATUS_HPD_STATE + __attribute__((unused))), checkpatch.pl --strict 0/0/0, DCO sign-off, and J813 live EIZO EV2780 standby-wake HPD recovery (635 ms, 0 swallowed swaps, 0 errors).
Evidence
  • drivers/usb/typec/tipd/core.c: verified lockdep_assert_held(&tps->lock) at L2259, mutex_lock(&tps->lock) at L2295, and guard(mutex)(&tps->lock) in cd321x_update_work() at L1187.
  • drivers/usb/typec/tipd/cd321x-pm.h L410-423 & cd321x-pm-test.c L115-139: positive and negative branches all covered by unit assertions.
  • #3523 status at review time: OPEN (mergedAt: null).

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) and removed needs-template PR body lacks Tested or Risk (bot) labels Nov 29, 2026
@sithglan

Copy link
Copy Markdown
Contributor Author

Second-generation IRQ-driven SN201202x no-regression verification at exact head 4747d512bd54: Mac mini (M6, J873g / apple,t8152) — PASS

  • Build & boot: exact PR head 4747d512bd5401c8482bff76110397cf50c7f535 (Linux mini6 7.3.0-aurora-j873-pr3649+ #1 SMP PREEMPT, built with ARCH=arm64 LLVM=-19, booted via one-shot aura-try).
  • IRQ-driven SN201202x controllers (1-08, 1-0a, 1-0c): all 3 bound cleanly to sn201202x + tps6598x_core with live apple_spmi Edge IRQs (98–106, !tps->irq false so the polled-only coalesced HPD-drop path stays inactive); port0, port1, port2 registered cleanly; zero errors and zero spurious HPD replays in dmesg.
  • Display & system health: card0-DP-1: connected (256B EDID, 29 modes, 2560x1440), 0 failed systemd units, 0 kernel warnings/BUGs/SErrors/DART faults.
  • Cleanup & stock return: removed /boot/efi/aurora/pr3649/, /boot/efi/aura-try, and /lib/modules/7.3.0-aurora-j873-pr3649+; rebooted cleanly back to stock 7.3.0-aurora-j873-main-1127+ #2 (0 failed units, card0-DP-1: connected).

Also added two-way to ### Risk in the PR description to satisfy pr-text.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 29, 2026
Pick up unrelated CI harness fixes on main; no changes to PR files.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 30, 2026
@sithglan

Copy link
Copy Markdown
Contributor Author

Forward-merged main (e6c7b032633c) into this branch at 768a654e1307 (normal merge commit, no force-push) to pick up the unrelated g17-output-fence-tests.py CI fix (08051669fa98) and refresh pr-text.

Hardware row at 768a654e1307: MacBook Air 13-inch (M5, J813 / T8142): PASS and Mac mini (M6, J873g / T8152): PASS (carried from 4747d512bd54; PR diff is unchanged).

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 30, 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: HOLD at 768a654

Blockers: #3523 remains open. Please verify the IRQ-driven peer on the integrated tree, or document why the new probe-time kept-attach replug cannot affect that hardware row.

Checked: Hosted checks completed successfully. The J813 and IRQ-driven J873g results were carried from 4747d51. The PR patch is unchanged, but the landed base adds a replug at probe in the same TIPD core file. The replay remains confined to the polled path.

@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 768a654e1307

Blockers:

  • None.

Checked:

  • Audited the full 4-file diff (drivers/usb/typec/tipd/core.c, cd321x-pm.h, cd321x-pm-test.c, tools/testing/selftests/drivers/gpu/apple-dcp/common.py, +63/-4, MERGEABLE against main):
    • cd321x_uses_dp_sid() enables DP_SID_UPDATE strictly for apple,t8142 (M5), leaving T8140 and every other SoC unchanged.
    • cd321x_dp_sid_coalesced_hpd_low() is strictly gated on !cd321x->tps.irq (polled ports only) plus dp_sid_valid, state_valid, in_dp, unchanged HPD-high status, and clear DP_STATUS_IRQ_HPD, so IRQ-driven ports (J873g/T8152) are provably unaffected.
    • Unit test cd321x_dp_sid_coalesced_hpd_low_test covers polled vs IRQ-driven, initial attach, prior HPD-low, active IRQ_HPD, and non-HPD bit transitions.
  • Hosted CI is completely green at 768a654e1307 (5/5 passed: host-tests, pr-text, readiness).
  • Hardware verified on both J813 (M5 Air T8142, polled path) and J873g (M6 Mac mini T8152, IRQ-driven control), with no runtime delta in the 768a654e main merge.
Evidence
  • Head: 768a654e13078609a9b6268761652936fbc8cb45 (base main, MERGEABLE).
  • Status checks: host-tests SUCCESS, pr-text / pr-text SUCCESS, readiness / readiness SUCCESS.
  • Related #3523 is already approved; #3649 is cleanly MERGEABLE on main and scoped strictly to polled T8142.

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

Reviewed at 768a654. The coalesced-HPD replay only runs on polled ports with a valid DP_SID route already in DP and an unchanged HPD-high status, and the KUnit cases cover each guard. The only change for other code is enabling DP_SID on T8142, which the J813 row covers; J873g (T8152) is the second family. Better than before for T8142 standby-wake, and nothing changes for IRQ-driven ports.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging under the 6-point rule (Ryan 09:29, permanent), at 768a654e. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J813(T8142)+J873g(T8152);App-approved;ours-approved. (5) There's no blocking review. (6) Code-owner approval at this head: RyanTheTide. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit f3fd30f into main Dec 1, 2026
6 of 8 checks passed
@RyanTheTide
RyanTheTide deleted the fix/tipd-t8142-dp-sid-hpd-replay branch December 1, 2026 00:47
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:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants