Skip to content

M1/M2 regression fixes on the Type-C hotplug base (tipd SAFE order, atc mux requests, optional legacy EDID service) - #332

Merged
RyanTheTide merged 8 commits into
aurora-wipfrom
fix/m1m2-regressions
Oct 16, 2026
Merged

RyanTheTide merged 8 commits into
aurora-wipfrom
fix/m1m2-regressions

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Fixes for regressions that our aurora-wip kernel showed on the M1 Pro (t6000) and M2 (t8112) compared with stock Fedora Asahi, plus the Type-C hotplug series they build on.

Commits

Type-C hotplug base (5, phy: apple: atc). Needed: the fixes do not apply without them.

  • 7156d4c0a7b6 Look up the Type-C target mode before the mux update
  • b0dee3d08c1a Don't wait for USB enumeration when the mux keeps its mode
  • 39bb6d308b70 Add KUnit tests for the Type-C mux decisions
  • 64ef3b3a84f0 Split the mux and switch callbacks from their PHY work
  • 0aeb0acde3e1 Test that a mux update keeping its mode skips the USB3 root hub

M1/M2 regression fixes (3).

  • 672846413c59 drm/apple: Treat a missing legacy EDID service as optional. The old DCPAVSERV -110 warning becomes a debug line, as on stock.
  • 4b36583930a5 usb: typec: tipd: Apply SAFE after ordinary USB role shutdown. This uses the provider-informed SAFE order, so a refused DR swap plus rebind no longer warns in atc (on stock it warns on the first attempt).
  • 2757f43e143e phy: apple: atc: Remember mux requests that keep the lane mode. It returns -EBUSY instead of a WARN against a live PIPE.

Testing

Ref Macs, 2026-10-16/17. We tested this branch merged into aurora-wip a837bd5f (--no-ff, clean). Kernels 7.1.12-aurora-ref-{m1p,m2}-N1-g06cdf1b90+ use each Mac's stock config with USB4_APPLE_SOC=m and apple_sep blacklisted. Each was booted with the aurora DTB and then with the stock DTB.

Check M1 Pro M2
Full-boot scan with the aurora DTB (10 Type-C cycles, refused DR swap + rebind, 3× pm_test, runtime-PM check) 0 WARNING / BUG / Oops / late-IOMMU 0
tcycle 10/10, with partner, AC and PD back each time 10/10
tipd all 4 controllers bound; no deferred devices; the USB4 router bound all 3 bound
pm_test=platform 3/3, 0 DART faults 3/3, 0 DART faults, eDP relit ×3
DCPAVSERV only the debug "no legacy EDID service within 1 s" line same
Wi-Fi, BT, NVMe, Vulkan, audio cards, battery OK OK
KUnit on the merge 78/78

Stock-DTB boots of the same kernel: the M2 shows 0 WARN; the M1 Pro shows 1 WARN, the inherited apple-sio late-IOMMU race, which also appears on true stock. Not covered: USB devices, external displays and cable orientations, because nothing was attached.

MacBook Neo (J700).

  • The five typec-hotplug commits have been on every Neo test kernel of the last two days, including tonight's attended DCP v5 replug run (14/14 fast replugs, slow ×5, cold plug).
  • 4b36583930a5 and 2757f43e143e also touch Neo code (tipd, atc). They get a Neo smoke boot of the exact merge before this PR is merged.

The earlier stock-DTB qualification of the fixes is in reports/refmacs-20261015.md ("v2 qualification"), and the hand-off is reports/codex-impl-20261015/m1m2-regressions.md.

🤖 Generated with Claude Code

atcphy_mux_set() takes the USB3 root hub of a port behind a fixed hub
before atcphy_mux_set_locked() works out which PHY mode the new Type-C
state needs. Move that lookup into atcphy_typec_target_mode() and do it
first, under the PHY lock, so that the mux update can look at the
target before it decides what else it needs. atcphy_mux_set_locked()
now takes the PHY and the target mode.

The lookup keeps its error messages and still maps the off state of a
fixed-hub port to USB2. No functional change.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
…s mode

On a port behind a fixed hub, atcphy_mux_set() takes the device locks of
the USB3 root hub and of the device on its port before it looks at the
new Type-C state. hub_wq holds the root hub's lock for a whole hub
event, and a SuperSpeed enumeration that keeps failing holds it for its
full set of retries, each with 5 s command timeouts.

The CD321x driver also calls the mux for DisplayPort HPD and status
updates that keep the pin assignment. Such an update touches neither the
lanes nor the PIPE, but it still waits for hub_wq, and the HPD event it
carries reaches the display only afterwards. On a J700 with a USB-C dock
(DisplayPort plus USB3), the display came back 27 s after a cable flip,
right after hub_wq gave up on the dock's SuperSpeed hub:

  22:06:46 usb 2-1: new SuperSpeed Plus Gen 2x1 USB device number 20 using xhci-hcd
  22:06:46 usb 2-1: device descriptor read/8, error -71
  22:06:51 xhci-hcd xhci-hcd.0.auto: Timeout while waiting for setup device command
  ...
  22:07:08 usb usb2-port1: unable to enumerate USB device
  22:07:08 phy-apple-atc 40b000000.phy: Pipehandler lock not acked.
  22:07:11 apple-dcp 416e00000.dcp: dcp_hotplug() connected:1 ...

Return early, before any USB reference is taken, when the target mode is
the current one, no failed transition is pending and the PIPE already
sits on the backend that mode needs. atcphy_mux_set_locked() keeps its
own check for the case where the state changes in between.

A mode change still takes the root hub, as the PIPE has to be handed
over while the controller is quiet.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Test how atcphy_typec_target_mode() maps Type-C states to PHY modes, on
Type-C ports and on ports behind a fixed hub, and when
atcphy_mux_is_noop() lets a mux update skip the lane and PIPE work: a
DisplayPort update with the same pin assignment does, while a new mode,
a failed transition and a PIPE handoff still owed to a running
controller do not.

The tests are built into the driver, so that they can reach its static
functions.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Move the bodies of atcphy_mux_set() and atcphy_sw_set() into
atcphy_mux_update() and atcphy_set_orientation(), which take the PHY
rather than the Type-C mux or switch device. The callbacks only look up
the PHY and call them.

This lets the driver's KUnit tests run a whole mux update and an
orientation change on a PHY without registering Type-C devices. No
functional change.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
…B3 root hub

The existing tests check atcphy_mux_is_noop() on its own, so they still
pass if atcphy_mux_update() stops returning early and takes the USB3 root
hub again for every DisplayPort HPD or status update.

Run whole mux updates on a PHY behind a fixed hub that has no device tree
node. Taking the root hub then fails with -ENODEV at the controller
lookup, before any register access. An update with the same pin
assignment and orientation must return 0. A new pin assignment, a
pending PIPE handoff, a PIPE away from the USB3 backend of a running
host, and a cable flip reported through atcphy_set_orientation() must
all reach the root hub.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Legacy DCP firmware can start the DPAVSERV endpoint without announcing an
EDID service. Stock accepts expiry of the advisory discovery wait, while
Aurora reports an endpoint failure even though the endpoint remains live.

Keep the discovery window so an early announcement can precede get_modes,
and return success when it expires. Only the announcement callback may
publish a service. Log expiry and legacy publication at debug level so a
late announcement can be distinguished from continued absence without a
warning for an optional service. Leave AFK startup errors and H17P's
asynchronous admission unchanged.

Extend the production-function host tests to check expiry and publication
diagnostics as well as optional discovery and genuine startup failures.

Fixes: 014aed9 ("drm/apple: retrieve external H17P EDID through bounded AFKV2 inline calls")

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Ordinary Apple USB ports must stop DWC3 before the mux changes the shared
PHY lanes. Early SAFE during removal or probe rollback instead reaches
ATC with a live PIPE. Prepare display shutdown first and hold the SAFE
transaction across role NONE, applying it after successful role shutdown.

Let mux providers declare this ordering requirement and use one predicate
for disconnect and removal. ATC declares it only for ordinary ports, so a
fixed host still applies SAFE while its backend clock is available, even
if its firmware graph exposes a no-op role switch. Other providers retain
the existing early order. This keeps the fixed-host divergence from Asahi
because its shared PIPE must be parked before the host clock disappears.

An unregistered role switch returns -EOPNOTSUPP after controller teardown;
accept that shutdown result only when it also reports role NONE. Keep
unsupported requests on a live role as errors. On other errors abort
without applying
SAFE and retain recovery ownership. Reject an ordinary-port SAFE against
a live PIPE with -EBUSY so the next probe cannot warn or change live lanes.

The removal transaction remains open until generic disconnect finishes;
the prepared flag prevents an early second application. Cover the ordering,
fixed-host no-op switch, absent switch, errors and re-probe in host tests,
and the live-PIPE guard in KUnit without MMIO.

Fixes: 6f00436 ("usb: typec: serialize display teardown and preserve recovery ownership")

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
USB role shutdown can power the PHY off while its saved Type-C request is
still USB3. A subsequent SAFE request needs no lane work, but both mux
fast paths return without saving it. A later USB2 PHY initialization can
then restore the old USB3 request instead of respecting SAFE.

Record every accepted request whose lanes already match, both before
acquiring USB runtime ownership and in the locked recheck. Preserve the
capability checks, PIPE retries and fixed-hub no-op bypass.

Test SAFE after independent shutdown on both paths and call the real USB2
initializer with a KUnit configuration stub that counts lane requests.
Extend the host role mock through the production PHY power-off, mux recheck
and USB2 init bodies, leaving only MMIO operations mocked. The host cases
now verify that role NONE powers the PHY OFF, SAFE requires no lane work,
and USB2 init cannot restore stale USB3 after SAFE.

Fixes: 48836ec ("phy: apple: atc: Keep USB2 up when the port sits behind a fixed hub")

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Neo gate passed (2026-10-17 09:0x): smoke boot of the exact combined merge a837bd5f ← 2757f43e1 ← DCP v5.1 f2e5e5330 (7.1.12-aurora-stack-g9ee9f3b05) on the MacBook Neo. Clean boot (0 WARN/BUG, 0 tipd/atc/DCP/DART errors), both Type-C ports healthy, a 120 s s2idle cycle with everything resumed, and no new messages vs the default kernel. Ref Macs PASS on both (see the PR body). Merging.

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