Repository navigation
usb: typec: tipd: CD321x DisplayPort hotplug fixes (HPD pulse, level change, pin change) - #355
Merged
Merged
Conversation
cd321x_update_work() decides inline whether a cable update first reports the external display as disconnected, and whether it reports the display as connected once the mux is set. The conditions mix Type-C session state with the DisplayPort HPD and pin assignment bits of DATA_STATUS, and so far they could only be exercised with real cables. Move them into cd321x-dp.h as pure functions of the update's DATA_STATUS, the bits that changed since the previous update and whether a display route was up, and add KUnit tests that pin down the current behaviour. No functional change. [ryan: rebased onto aurora-wip 0daed2d + ATC PIPE park v3. Kconfig and Makefile: the tests' help text and objects follow those of the interrupt (#338) and held-mux (PIPE park v3) tests. core.c: cd321x_dp_notify() follows v3's cd321x_retry_held_mux() and cd321x_update_done(), and the connected event is sent before v3's cd321x_update_done(). No other change.] Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
A CD321x cable update can tell the display connector that its sink has gone, or that it is present again. The data status trace shows each register read, but not the debounced update that produced the event, so a display that drops out after a plug cannot be traced back to the HPD or pin assignment transition that caused it. Add a cd321x_dp_hotplug tracepoint where the event is sent. It records the connector status, whether a display route was up, the HPD level, the pin assignment and the DATA_STATUS bits that changed since the previous update. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
A CD321x cable update reports the external display as disconnected and then as connected again whenever the HPD level changed since the previous update. Updates run CD321X_DEBOUNCE_DELAY_MS after the last interrupt and accumulate the DATA_STATUS bits that changed in between, so a sink that drops HPD for less than the debounce and raises it again looks the same to this check as a sink that was unplugged. The display connector then tears down the pipeline and rebuilds it, and the picture drops although the sink never left. The DisplayPort Alt Mode driver (altmodes/displayport.c) forwards the HPD level as it is reported and handles IRQ_HPD as a separate attention event; it never reports a disconnect while HPD is high. Do the same. When the partner, the alternate mode and the pin assignment are unchanged and HPD was high before the update and is high after it, keep the sink and report connector_status_unknown, which asks the connector to recheck and retrain its existing link. Handle a newly set HPD_IRQ with HPD held high the same way. "HPD was high" has to mean that the connector was told about the sink. The cached mux status cannot answer that: an update that reported the sink gone and then failed with -EAGAIN keeps the route marked up and the old status, and its retry would retrain a link the connector no longer has. Record the last event sent to the connector instead. C and D, and E and F, differ only in USB3_CONNECTION, and a change between them changes the DisplayPort lane count. A pulse that comes with such a change still reconnects the display. Every other case is unchanged. An unplug, flip, new partner, DisplayPort exit, pin assignment change or HPD low still tears the display down, and HPD rising after a reported low still announces it. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The DisplayPort pin assignment that cd321x_typec_update_mode() programs into the mux is decoded from two DATA_STATUS fields: the two-bit DP_PIN_ASSIGNMENT field selects A, B, C/D or E/F, and USB3_CONNECTION picks D over C and F over E. The cable update only looks at DP_CONNECTION and DP_PIN_ASSIGNMENT to decide whether the DisplayPort lanes change. A partner that moves from D to C, or from F to E, while HPD stays high changes USB3_CONNECTION alone. The update then neither reports the display as disconnected nor drops the USB role before the mux is reprogrammed, and the lanes are reallocated from two to four (or back) under a running display stream. Treat USB3_CONNECTION as part of the pin assignment while DisplayPort is connected, in both decisions. Without DisplayPort it remains a plain USB change and still leaves the role alone. The check came with the CD321x DisplayPort hotplug support in the initial import of this tree. Fixes: 38c14f6 ("drm: apple: support ProMotion variable refresh rate") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Commit bd00b3c0aa40 ("usb: typec: tipd: Retrain the display link on an
HPD pulse") keeps the external display connected when HPD was high
before a debounced cable update and is high after it, with the same
partner and pin assignment. It asks the connector to retrain instead.
The accumulated DATA_STATUS change mask records only that the HPD level
changed, not for how long it was low. A monitor unplugged behind a
dock and another one plugged in, or a KVM switching sinks, within
CD321X_DEBOUNCE_DELAY_MS looks exactly the same. A retrain does not
retire the old sink's EDID, so the connector can go on offering the old
sink's modes for the new one.
DisplayPort Alt Mode already separates the two cases. The partner
reports the sink's short IRQ_HPD pulse as an attention with IRQ_HPD set
and HPD_State still high, and the CD321x reflects that in HPD_IRQ while
HPD_LEVEL stays high. HPD_State goes low only for a long low, which
DisplayPort treats as an unplug. The DisplayPort Alt Mode driver
(altmodes/displayport.c) likewise forwards every HPD level change it
receives and counts IRQ_HPD separately.
So report any sampled HPD level change as a disconnect followed by a
connect again, as before that commit. Ask for a retrain only for an
IRQ_HPD on a sink whose HPD level stayed high. When retraining, first
report the sink as connected, as every other update with HPD high does.
A connector that already has the sink ignores that, and one that lost
it in the meantime connects it again rather than dropping the retrain.
Fixes: bd00b3c0aa40 ("usb: typec: tipd: Retrain the display link on an HPD pulse")
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
A debounced cable update takes the DATA_STATUS bits that changed since
the previous update and clears them before it programs the mux and the
USB role. If either of those fails, the update is retried from a fresh
read; with -EAGAIN, for instance while the PHY's USB consumer is not
ready yet, the retry keeps the session and does not tear the display
down. The fresh read then shows the same DATA_STATUS as before, with no
changed bits, so an IRQ_HPD that the failed pass was about to deliver
turns into a plain connected event and the retrain it asked for is lost.
Moreover, IRQ_HPD is taken from the change mask across the debounced
update, so an attention that sets HPD_IRQ and clears it again within
CD321X_DEBOUNCE_DELAY_MS is missed.
Track the attention on every interrupt instead. TI documents the HPD
IRQ bit of DATA_STATUS as sticky, and the partner's DisplayPort status
keeps IRQ_HPD until its next status message, so either becoming set
while HPD is high is a new IRQ_HPD. Keep it pending until an update
has been applied and its event sent. A connect overtakes it, and HPD
going low or the partner leaving drops it.
Fixes: bd00b3c0aa40 ("usb: typec: tipd: Retrain the display link on an HPD pulse")
[ryan: rebased onto aurora-wip 0daed2d + ATC PIPE park v3. A
disconnected plug now ends the update with v3's cd321x_update_done()
instead of cd321x_pm_complete(); the pending IRQ_HPD is dropped before
it, as reviewed. A change that a held mux retries keeps the IRQ_HPD
pending, as the bounded retries do.]
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
The cd321x_dp_hotplug tracepoint records the HPD level and the
DATA_STATUS bits that changed, but not why the Type-C session was
reset. A plug removed and inserted again within the debounce, a flip,
a different partner or a forced reconnect after a failed update can end
with the same DATA_STATUS as before. Those updates correctly report the
display as gone, but their trace shows HPD high and nothing relevant
changed, which looks like a spurious disconnect. The tracepoint does
not identify the controller either, so events of the two ports of a
machine cannot be told apart.
Record the reasons for a session reset as flags in the update instead
of a single bool, and trace them together with the device name and
whether an IRQ_HPD is pending. The reset decision itself is unchanged:
the flags are set from the same conditions that set was_disconnected,
plus the partner leaving.
Fixes: 33af24cea854 ("usb: typec: tipd: Trace the CD321x DisplayPort hotplug events")
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
The cd321x-dp tests check one debounced update at a time. The display bugs fixed recently needed several interrupts and updates to show: samples that are folded into one update, an IRQ_HPD that has to outlive a deferred update, and a lane change that only one sample reveals. Add a second suite that models a port the way cd321x_queue_status() and cd321x_update_work() drive it. Interrupts add samples through cd321x_dp_irq_hpd() and the change masks, and debounced updates make the display decisions around a mux update that can fail and be retried through the cd321x-pm helpers. Each case checks the exact order of connector events it sends. The cases cover a Type-C replug, a monitor replaced behind a dock, IRQ_HPD from either source, an IRQ_HPD across a deferred update, HPD low, a C/D change with and without an HPD bounce, and a dock removed while an IRQ_HPD is pending. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
…helpers The physical-disconnect fixture, which fast-replug-bounce and dropped-swap-teardown build on, extracts cd321x_update_work(). The hotplug decisions it takes are now the inline helpers in cd321x-dp.h, reported through cd321x_dp_notify(), and the port keeps a pending IRQ_HPD and whether a sink was reported. When cd321x-dp.h is present, inline it (without its kernel includes) and extract cd321x_dp_notify() with the update work. Give the fixture's port the two new flags, turn its connector status values into the enum the helpers name (same values: the OOB mock still tears the display down on disconnected only, and an unknown status is a retrain, not a teardown), and supply DP_STATUS_IRQ_HPD and a no-op trace point. The fixtures keep their assertions; all 55 host tests pass. [ryan: rebased onto aurora-wip 0daed2d + ATC PIPE park v3, whose commit "usb: typec: tipd: Keep applying a Type-C state that a busy mux holds up" changed this fixture too: it extracts v3's held-mux helpers, adds the mux handle and its shims, and gives the stubbed cd321x_typec_update_mode() its held out-parameter. Kept all of that; cd321x-dp.h is inlined and cd321x_dp_notify() extracted as reviewed, the two port flags join v3's struct, and the source takes the header after v3's shim.] 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 #7 assembly, stacked on top-up #6a 40a2ec8 so that it is a fast-forward of that publish head. The second parent is that canonical assembly; the tree is identical to it. Ported from aurora-wip, each commit with cherry-pick -x and its original author: - #306: aurora_j700_defconfig, regenerated for 7.2.10 with savedefconfig from the published 7.2.10 J700 configuration (900-config-tooling); - #354 (j700/clamshell-mic-v4), 3 commits: the LPAI pointer published after its frames, the spin_lock_irqsave() Rust helpers, and the mics reported unplugged with the lid closed (070-audio); - #355 (j700/tipd-hpd-pulse-v2), 9 commits: the CD321x DisplayPort hotplug decisions, their trace events and KUnit tests (170-usb), and the apple-dcp selftests that compile them (200-dcp); - #356 (fix/rust-dmabuf-xarray-20261018): the dma_buf stub gated on built-in DRM and the xarray KUnit values allocated before xa_lock (210-gpu, with the Fixes: tags of the 7.2.10 base); its dma-resv backport is already in asahi-wip; - #357 (fix/sep-followups-20261018), 7 commits: dma_wmb()/dma_rmb() for Rust, the SEP shared buffers ordered against the mailbox, the hwrng and sleep glue and its tests, and the trusted-keys built-in source fixes (100-sep). Our own 7.2-native commits, not on aurora-wip (100-sep): the Rust system_dfl_wq wrapper, and the SEP, Asahi DRM and binder work moved off the deprecated system_wq. Their AOP change is not carried: the 070-audio AOP driver already registers its services on its own ordered queue. Adaptations, each with a [ryan: ...] note in its commit: - the AOP lid tests go after the parser tests, where 7.2.10 has the name tests (context only); - trusted_key_core_done goes next to 7.2.10's trusted_key_source_migratable (context only); - the defconfig is regenerated, not picked; its note lists the 62 lines that differ from the 7.1 file, none of them a J700 setting. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
added a commit
that referenced
this pull request
Oct 18, 2026
A mux that holds a change up is retried until it goes through, and a PHY that stays stuck is given up after 16 retries, said to be some two minutes. That holds only while nothing else happens. A controller event during the backoff brings the retry forward to the usual debounce, and that retry counted against the 16 too, without making the hold-up any shorter. With an event in every backoff, as a partner that keeps renegotiating raises, the retries come about a second apart and the port gave up after some 16.5 s. If the PHY then let go after the last event, nothing applied the state again until a later event. Limit a series by time instead: note when its first failure was, and give up at the first failure two minutes or more after it. The start is noted whenever a failure finds no series under way, so a series that ended in any way, each of which clears its backoff, never lends its start to the next. The state machine keeps to milliseconds, as for its delays, and the driver passes jiffies_to_msecs(jiffies); the difference is taken so that the clock may wrap. Keep the count only as a bound on the warnings of a series. Ordinary controller events bring retries about a second apart, debouncing both the read and the update. Tunnel notifications skip the read debounce, but the 500 ms update debounce alone keeps the limit of 240 from ending a series before two minutes. Counting only the retries that the timer runs would bound nothing that the time limit does not. The warning now gives the retries and the time. Correct the texts that promised about two minutes for a count. Also make typec_mux_timeout_transient()'s kernel-doc say that it describes the last request that failed with -ETIMEDOUT: one that fails with -EBUSY before it owns the providers leaves the answer as it was. A consumer asks only right after -ETIMEDOUT, so say so rather than change the core. The query keeps its form, a flag on the handle; upstream would rather have typec_mux_set() return the answer. The new tests inject an event into every backoff while the PHY holds the change up, and expect the port to give up only two minutes after the first refusal, after some 120 retries rather than 16. With an event every 1.5 s for well over a minute, after which the PHY lets go, the next retry of the backoff must apply the safe and USB states with no further event. The fixture runs works before their delay, so it makes a series as old on the driver's clock as it is in the time of the tests. The state machine tests cover the limit, a clock that wraps, retries a second apart, the count and the fresh start after an event, and the backoff test reads the backoff rather than the time left on its timer. The apple-dcp host selftests pass the time of each failure and check that retries a second apart do not end a series sooner. Repair two existing test races exposed while qualifying this change on ed289aa. The IRQ test joins the immediate resume read and checks that retries attempt acknowledgment, rather than requiring work to stay pending. The host teardown fixture ends its observation at the lock that fences the selected removal: direct xHCI teardown may proceed once the host mutex is dropped, while the controller mutex is still held. Force that interleaving and check that the PHY and root accesses have finished before removal can proceed. [ryan: rebased onto #355 — kept HPD v2 and #349 test changes; combined the ceiling retry race checks, clock shims and new cases.] [ryan: split by topic: only the tipd, Type-C mux and ATC PHY part; the apple-dcp selftests part is in 200-dcp] Fixes: 70f7c21 ("phy: apple: atc: Route the PIPE from the Type-C mux on a fixed-hub port") (cherry picked from commit 6f715d4 ("usb: typec: tipd: Limit the retries of a held mux by time, not count")) Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
added a commit
that referenced
this pull request
Oct 18, 2026
A mux that holds a change up is retried until it goes through, and a PHY that stays stuck is given up after 16 retries, said to be some two minutes. That holds only while nothing else happens. A controller event during the backoff brings the retry forward to the usual debounce, and that retry counted against the 16 too, without making the hold-up any shorter. With an event in every backoff, as a partner that keeps renegotiating raises, the retries come about a second apart and the port gave up after some 16.5 s. If the PHY then let go after the last event, nothing applied the state again until a later event. Limit a series by time instead: note when its first failure was, and give up at the first failure two minutes or more after it. The start is noted whenever a failure finds no series under way, so a series that ended in any way, each of which clears its backoff, never lends its start to the next. The state machine keeps to milliseconds, as for its delays, and the driver passes jiffies_to_msecs(jiffies); the difference is taken so that the clock may wrap. Keep the count only as a bound on the warnings of a series. Ordinary controller events bring retries about a second apart, debouncing both the read and the update. Tunnel notifications skip the read debounce, but the 500 ms update debounce alone keeps the limit of 240 from ending a series before two minutes. Counting only the retries that the timer runs would bound nothing that the time limit does not. The warning now gives the retries and the time. Correct the texts that promised about two minutes for a count. Also make typec_mux_timeout_transient()'s kernel-doc say that it describes the last request that failed with -ETIMEDOUT: one that fails with -EBUSY before it owns the providers leaves the answer as it was. A consumer asks only right after -ETIMEDOUT, so say so rather than change the core. The query keeps its form, a flag on the handle; upstream would rather have typec_mux_set() return the answer. The new tests inject an event into every backoff while the PHY holds the change up, and expect the port to give up only two minutes after the first refusal, after some 120 retries rather than 16. With an event every 1.5 s for well over a minute, after which the PHY lets go, the next retry of the backoff must apply the safe and USB states with no further event. The fixture runs works before their delay, so it makes a series as old on the driver's clock as it is in the time of the tests. The state machine tests cover the limit, a clock that wraps, retries a second apart, the count and the fresh start after an event, and the backoff test reads the backoff rather than the time left on its timer. The apple-dcp host selftests pass the time of each failure and check that retries a second apart do not end a series sooner. Repair two existing test races exposed while qualifying this change on ed289aa. The IRQ test joins the immediate resume read and checks that retries attempt acknowledgment, rather than requiring work to stay pending. The host teardown fixture ends its observation at the lock that fences the selected removal: direct xHCI teardown may proceed once the host mutex is dropped, while the controller mutex is still held. Force that interleaving and check that the PHY and root accesses have finished before removal can proceed. [ryan: rebased onto #355 — kept HPD v2 and #349 test changes; combined the ceiling retry race checks, clock shims and new cases.] [ryan: split by topic: only the apple-dcp selftests part; the tipd, Type-C mux and ATC PHY part is in 170-usb] Fixes: 70f7c21 ("phy: apple: atc: Route the PIPE from the Type-C mux on a fixed-hub port") (cherry picked from commit 6f715d4 ("usb: typec: tipd: Limit the retries of a held mux by time, not count")) Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This series fixes how tipd handles DisplayPort hotplug on CD321x ports, used by the MacBook Neo and by M1/M2 Type-C displays. Three cases went wrong:
Commits (9)
Fixes:).Testing
f001934351ed, after J700: keep rear SuperSpeed through a PD re-election (ATC PIPE park + USB3 handover v3) #353 (PIPE park v3). The changes are placement only, next to v3's helpers; v3's held-mux path is kept intact.cd321x_dp*HPD cases; the atc, usb-dart-atc-lockdep and DCP hotplug lanes have 0 failures; W=1 gives 0 warnings.run.py55/55.displayportreference, socd321x_dp_notify()returns early, and the DCP's own HPD path drives the external display (0cd321x_dp_hotplugevents). The behaviour change applies to CD321x ports whose connector links a DisplayPort node.displayportlink is a separate DT decision.🤖 Generated with Claude Code