Skip to content

usb: typec: tipd: Limit the retries of a held mux by time, not count - #359

Merged
RyanTheTide merged 1 commit into
aurora-wipfrom
fix/tipd-mux-ceiling-time-20261018
Oct 17, 2026
Merged

RyanTheTide merged 1 commit into
aurora-wipfrom
fix/tipd-mux-ceiling-time-20261018

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

A controller event can bring a held Type-C mux retry forward and exhaust the old 16-attempt limit in about 16 seconds. Measure the retry series from its first failure and stop after two minutes instead. Retain the count as a bound on warnings, and reset the time series when the hold ends.

Rebase the reviewed ceiling follow-up onto aurora-wip 23ff1ecffce4. Preserve HPD v2 and #349 coverage, combine the IRQ acknowledgment race checks, and retain the host teardown observation-window repair. Add clock-wrap, dense-event, delayed-release and fresh-series coverage.

Validation on 6f715d4dc5ac: tipd, tipd-spmi, atc and usb-dart-atc-lockdep KUnit each passed 3/3, including all 30 HPD cases and the new ceiling cases; apple-dcp host selftests passed 55/55. W=1 for drivers/usb/typec and drivers/phy/apple produced zero warnings. Checkpatch reported zero errors and one warning for the required Assisted-by trailer. The published-config Neo build completed with zero compiler warnings; artifact hashes verified. No hardware testing was performed.

Qualification

  • Reviews: t-2481, the original commit: PASS 0/0/0 with 1 NIT, which is applied. t-2518, the race-fix delta: PASS 0/0/0/0, with no production change.
  • Gates on this head:
    • KUnit tipd, tipd-spmi, atc and usb-dart-atc-lockdep, 3/3 each, including the 30 HPD v2 cases and 4 new ceiling cases;
    • apple-dcp run.py 55/55;
    • W=1 0 warnings, checkpatch 0 errors.
  • MacBook Neo (7.1.12-aurora-ceiling-r-g6f715d4d, one-shot):

🤖 Generated with Claude Code

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

Fixes: 70f7c21 ("phy: apple: atc: Route the PIPE from the Type-C mux on a fixed-hub port")
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide merged commit de28083 into aurora-wip Oct 17, 2026
@RyanTheTide
RyanTheTide deleted the fix/tipd-mux-ceiling-time-20261018 branch October 17, 2026 21:47
RyanTheTide added a commit that referenced this pull request Oct 18, 2026
…d GPU

Bring the 7.2.10 assembly to the tree of the canonical top-up #7a
assembly, stacked on top-up #7 29ea847 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 with cherry-pick -x and its original author:
- #359 (fix/tipd-mux-ceiling-time-20261018): a held Type-C mux is
  retried for two minutes from its first failure rather than for 16
  retries, with its KUnit tests (170-usb) and the apple-dcp selftests
  that check it (200-dcp), split by topic.

Our own 7.2-native commits, not on aurora-wip: the Rust system_dfl_wq
wrapper in the topics that need it, the T8140 AOP audio jack, mic
array and speaker work moved off the deprecated system_wq (070-audio),
and the Asahi command retirement and G17 background work moved off
the deprecated system_wq and system_unbound_wq (210-gpu). No Rust
driver we carry uses a deprecated system queue any more.

No commit needed an adaptation.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
joshuaswarren added a commit that referenced this pull request Nov 5, 2026
The completion poll stops when the DART error latch is set, but it
returned 1, the same value as a finished request. If the latch cleared
before ane_tm_execute() read it again, no fault was recorded and the
request went on to the completion check and returned success although
the engine never completed. If a drained fault cleared the same way,
the scratch pages were released without a recovery.

Return -EIO from the poll step so the poll reports the fault itself.
Carry the scratch cap and the drain failure into err as well, so a
fault that clears after them ends in the recovery path and keeps the
scratch mappings until a verified reset reclaims them.

This is the poll and error propagation change of omarchy-ane #359
(merge 20629c55). The scratch lifetime part of that change is already
present here in a different form: this driver keeps the scratch pages
in struct ane_device, never releases them on the wedge path, and
releases them in ane_reclaim_preserved() after a verified power cycle.

The host test builds the production poll and execute code against a
simulated latch. The old revision fails four cases: a fault that
clears before the second read returns 0, a fault seen only by the
last poll releases scratch without recovery, a failed drain loses its
error, and a scratch cap followed by a clear latch releases the
scratch without recovery.

Assisted-by: LLM
Signed-off-by: Joshua Warren <[email protected]>
joshuaswarren added a commit that referenced this pull request Nov 5, 2026
The completion poll stops when the DART error latch is set, but it
returned 1, the same value as a finished request. If the latch cleared
before ane_tm_execute() read it again, no fault was recorded and the
request went on to the completion check and returned success although
the engine never completed. If a drained fault cleared the same way,
the scratch pages were released without a recovery.

Return -EIO from the poll step so the poll reports the fault itself.
Carry the scratch cap and the drain failure into err as well, so a
fault that clears after them ends in the recovery path and keeps the
scratch mappings until a verified reset reclaims them.

This is the poll and error propagation change of omarchy-ane #359
(merge 20629c55). The scratch lifetime part of that change is already
present here in a different form: this driver keeps the scratch pages
in struct ane_device, never releases them on the wedge path, and
releases them in ane_reclaim_preserved() after a verified power cycle.

The host test builds the production poll and execute code against a
simulated latch. The old revision fails four cases: a fault that
clears before the second read returns 0, a fault seen only by the
last poll releases scratch without recovery, a failed drain loses its
error, and a scratch cap followed by a clear latch releases the
scratch without recovery.

Assisted-by: LLM

Signed-off-by: Joshua Warren <[email protected]>
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