Repository navigation
phy: apple: atc: serve a T8132 device role on USB2 - #2434
Conversation
…ce mode A USB3 PHY that cannot run a SuperSpeed device answers the device request with -EOPNOTSUPP and leaves the PIPE alone. The glue already offers the gadget at high speed for that (T6040), but on T8132 and T6050 the check for failed host handoffs ran first and failed the role instead. Its reason is xHCI: a failed BIST or PIPE handoff must not start the host. That does not apply to a gadget whose USB2 PHY already runs as a device. The T8132 ATC PHY refuses the device role while its lanes run USB3, so a T8132 port with a USB3 calibration and a host on the other end lost its USB (seen on the J773g, linux#2434). Take the high-speed path for a device-role -EOPNOTSUPP on every SoC, before that check; other USB3 PHY errors are handled as before. T6050 never gets here, its USB2 PHY has no device mode. The ATC PHYs that answer -EOPNOTSUPP for another reason (a T8103 port whose lanes are all DisplayPort or that has no SuperSpeed tunables) cannot carry a SuperSpeed device either, so the high-speed gadget fits them too; they already took this path. The T8132 selftest now expects the high-speed gadget. This is the generic form of the T8132 fallback in linux#2420 by techmore, whose J773g row (a USB 3 host lists the gadget at 480 Mb/s where the role failed before) is the hardware evidence for it. DjDeveloperr reported the failure and serves the T8132 device role from the PHY side in linux#2434; both changes can land. Link: #2420 Link: #2434 Signed-off-by: Ryan Murray <[email protected]>
|
Host-tests fix pushed in de20ca2. The failures were mine. What the commit changes:
Local results, through
My host's clang 23 adds 🤖 Generated with Claude Code |
|
This commit is now carried unchanged in #2334 (161cf31, your authorship), as the merge train asked: one head for the device-role work. On top of it, #2334:
The host-tests failure on this PR came from the ATC USB3 harness and the apple-dcp models, which compile atc.c against their own structs. A Still owed: a J773g row at #2334's head ( |
|
Merge-train adversarial review (MERGETRAIN-LINUX2) at de20ca2: NO BLOCKERS. Code read only, nothing built here. Before the merge it still needs Dj's verdict at this head; the missing rows are listed below. Full review#2434 phy: apple: atc: serve a T8132 device role on USB2 @de20ca29VERDICT: NO BLOCKERS in the code. The PR does not prove its feature yet: no host has enumerated the gadget. Treat that as a merge gate. Shared-code check: the new behaviour is reached only through Nits / risks:
Missing rows:
|
On a T8132 port whose SuperSpeed banks are calibrated, a USB device role previously failed in atcphy_usb3_set_mode() with -EOPNOTSUPP, causing dwc3-apple to fail setup and the Type-C port controller to give up after cable revalidation retries. SuperSpeed device mode is not supported by this driver on T8132, so serve a T8132 device role on USB2 instead: - Map APPLE_ATCPHY_MODE_USB3 and pin-D APPLE_ATCPHY_MODE_USB3_DP to APPLE_ATCPHY_MODE_USB2 while the device role is active, keeping four-lane APPLE_ATCPHY_MODE_DP (pin C/E, where USB2 uses its own wires) unchanged. - Set t8132_device only after atcphy_mux_switch() and atcphy_usb3_route() succeed, and clear it on controller role exit (atcphy_usb3_power_off() or PHY_MODE_USB_HOST) rather than on mux SAFE/OFF transitions. - Preserve the partner's un-downgraded mode in typec_mode so a direct device-to-host data role swap restores SuperSpeed lanes before host_active blocks T8132 lane reconfiguration, and subsequent atcphy_usb2_init() calls respect t8132_device. - Update the KUnit test and host selftest fixtures in the same commit so host test builds remain bisectable. Signed-off-by: Diljit Singh <[email protected]>
de20ca2 to
025e7ea
Compare
|
Updated and force-pushed as a single squashed commit (
Verification:
Assisted-by: LLM (Gemini:4 Neon) |
|
Merge-train re-review (MERGETRAIN-LINUX2) at 025e7ea: NO BLOCKERS. The earlier points 1-4 are resolved. Point 5 is still open: KUnit has not been run at this head. Still needed before the merge: a host-side enumeration row (J773g at 480M) and a KUnit run at this head. Full re-review#2434 phy: apple: atc: serve a T8132 device role on USB2 @025e7ea2VERDICT: NO BLOCKERS I read the code only; nothing was built or run. Head 025e7ea is one commit on integration/aurora 24dc422. GitHub reports it MERGEABLE. Line numbers below are atc.c at 025e7ea. The merge gate from the earlier review still stands: no host has enumerated the gadget. The only evidence is still that the -95 error is gone. See the missing rows. Earlier points (review-B.md, @de20ca29)
BlockersNone. New problems / nits
Missing rows
|
|
Re-review at 025e7ea (code read only). Earlier points:
New:
Still missing, at this head:
Assisted-by: LLM (Claude:Opus 5.5) |
|
KUnit at 025e7ea: I ran the ATC KUnit suites under qemu arm64 (
At 025e7ea the ATC host tests also pass: atc-usb3-tests (plain and So the KUnit item is closed. The hardware row is still owed: a real host has to enumerate the gadget at 480M, then a swap or replug as host has to come back at 5000M. Assisted-by: LLM (Claude:Opus 5.5) |
|
Hardware half of the row at 025e7ea: the J713 (13-inch M4 Air) in device role on USB2, enumerated by a real host. The kernel is 7.3.0-aurora-fleet81, the J713's default. It is integration/aurora eb6d9ec plus open heads, including this PR at 025e7ea. It ran on the default command line with no reboot. Port0 was in device role with an NCM gadget from configfs. The host was an M4 Pro MacBook Pro running Linux, on the same cable.
Still to run: the same port back in host role at 5000M. That needs a USB3 device on port0 or a physical swap, and nobody was at the Mac. Assisted-by: LLM (Claude:Opus 5.5) |
|
I replayed With that test-only resolution, the actual merged ATC driver passed all 39 host cases and all 63 mutation controls were rejected. Please forward-merge using that resolution. The previous J713 result remains tied to Assisted-by: LLM (Codex) |
Signed-off-by: Ryan Murray <[email protected]>
|
Forward-merged Linux The exact tree passed 39/39 ATCPHY host cases, rejected all 63 mutation controls, and passed 93/93 Apple DCP/PHY/DWC3 host cases. The physical gate remains the exact J713 USB2 device-to-host transition, with normal host USB3 and display and a same-block peer check. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge, at cde842ce4844 (code is fine; it needs a device-role row at this head)
Blockers: none in the code
Checked: I traced the role sequences through the PHY and dwc3-apple, read the KUnit case, and confirmed host-tests CI is green. The fallback is keyed on t8132_ss, which probe sets only when the optional SuperSpeed banks are present in the DT. So the selector is a hardware property: no new chip or board gate, and no cmdline or module knob. I traced these paths:
- Device role.
atcphy_usb3_set_mode(DEVICE)switches USB3 or USB3_DP to USB2, then restorestypec_modeto the partner's mode, routes, and only then setst8132_device. - Mode changes while in the device role.
atcphy_mux_switch(),atcphy_mux_in_mode()andatcphy_mux_update_to()all map throughatcphy_t8132_device_mode(), so a repeated USB3 request is a no-op on USB2. DP pin C/E is unaffected. - Role exit. dwc3-apple always runs
dwc3_apple_core_stop(), which callsphy_power_off()on the USB3 PHY. That clearst8132_deviceand configures OFF, and the nextatcphy_usb2_init()brings back the un-downgradedtypec_mode. A device-to-host swap through dwc3-apple therefore gets SuperSpeed back. - Error paths. A failed device route leaves the port on USB2 without the flag. dwc3-apple then fails the role for
apple,t8132-dwc3and itscore_stopturns the port OFF, so nothing is left stuck.
Non-blocking:
atcphy_usb3_set_mode(), DEVICE branch:host_active = falseis set afteratcphy_mux_switch(). A direct host-to-deviceset_modewith no power-off in between would hit-EBUSYfrom the T8132 lane check (t8132_common_owned && host_active, orpipe_state != DUMMY). dwc3-apple never does this today, because it always powers off between roles. The HOST branch comment, though, describes direct swaps. Either note that the DEVICE path relies on the power-off, or clearhost_activebefore the switch.- The KUnit case covers the mode helper and target mapping, but not the
set_moderollbacks: the restore oftypec_modeafter a failed device switch, and the re-set oft8132_deviceafter a failed host restore. Both are small enough to add toatc-test.c.
Row still needed: the J773g measurement in the body is from 2026-11-19 on 7.3.0-m4drv8, before the merge commit that is now the head. Per the merge policy it needs one row at cde842ce4844 on a T8132 port:
- device role on a calibrated port: no
err=-95, the gadget binds, plus a host-role regression on the same port; - on the J773g, or on our J713, which has the same ATC block (M4 Air).
Evidence
- Read at head
cde842ce4844:drivers/phy/apple/atc.c(set_mode, usb3_power_off, usb2_init, mux_switch/in_mode/update_to, the T8132 lane check around line 4040, thet8132_ssprobe around line 6627) anddrivers/usb/dwc3/dwc3-apple.c(core_stop, core_start, set_role). - CI:
host-testspass.
|
Row: cde842c J713 pass, USB2 device role on port0, merged onto main 70e700c with no other change to atc.c or dwc3-apple (kernel 7.3.0-aurora-airs89a, default cmdline, one boot).
The branch conflicts with main again, but only in |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict at cdf35323: no blockers. Merge once CI at head is green (3/3 now).
Blockers: none
Checked
cdf35323= your025e7ea2plus a normal merge of main (f3bfe50). The only conflict was the import line intools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py, resolved as the union of both sides (atc_set_mode_prototypes+atc_cfg_helpers). No force push; your commit is unchanged.- Device role on the T8132 ATC PHY: USB3 and pin-D USB3+DP drop to USB2 instead of
-EOPNOTSUPP.typec_modeis kept, so the host role restores the partner's SuperSpeed mode.t8132_deviceclears on USB3 power-off and on the host switch, andatcphy_mux_in_mode()compares against the fallback mode, so Type-C events don't fight it. Four-lane DP (pin C/E) is unchanged. - Gates: selection uses the PHY block's existing generation and SuperSpeed-bank data (
t8132_ss). No new chip, board or firmware check. - Host tests on the merged tree: apple-dcp 1/1, ATC set 13/13.
Row: cdf35323 J713 (M4 Air), default cmdline, one boot: port0 device role, UDC configured at high-speed; J616s host sees 1d6b:0104 cdc_ncm at 480M, ping 10/10 (1.88 ms avg); clean disconnect, 0 atc/dwc3 errors, 0 AVC, 0 failed units.
Evidence
- J713 kernel 7.3.0-aurora-airs89m built from
cdf35323(fleet89 config), non-default one-shot, saved fleet85 restored afterwards. - The J713's GPU stays deferred on main because its internal DCP needs the open display stack; that is main's state and not from this PR.
- Nit, follow-up only: if
atcphy_usb3_route()fails after the USB2 mux switch,t8132_devicestays false while the mux is in USB2. The next Type-C event reconfigures it anyway.
Main merged #2434 in its reviewed form (atcphy->t8132_device and atcphy_t8132_device_mode()): the partner's mode stays in typec_mode, the USB2 mapping is applied in atcphy_mux_switch(), atcphy_mux_in_mode(), the mux update's mode check and atcphy_usb2_init(), and a host role restores the SuperSpeed lanes itself. Keep that mechanism and key it on the PHY's capability, as this branch does: the flag is usb2_device, set for a device role when hw->no_ss_device (T8132's match data) instead of t8132_ss, and the helper is atcphy_usb2_device_mode(). This branch's own mapping in atcphy_typec_target_mode() and its clear on a mux switch to off are dropped in favour of main's: the target mode keeps the partner's request and the role is cleared on USB3 power-off or a host selection. Pin-D USB3+DP runs USB2 in the device role, as on main. Port the KUnit case and the ATC USB3, apple-dcp PHY, quiesce and dwc3 host fixtures to the renamed field and helper, keep this branch's .validate and main's T8132 CIO KUnit cases, and add a mutation that fails if the device role ignores hw->no_ss_device. Signed-off-by: Ryan Murray <[email protected]>
…ce mode A USB3 PHY that cannot run a SuperSpeed device answers the device request with -EOPNOTSUPP and leaves the PIPE alone. The glue already offers the gadget at high speed for that (T6040), but on T8132 and T6050 the check for failed host handoffs ran first and failed the role instead. Its reason is xHCI: a failed BIST or PIPE handoff must not start the host. That does not apply to a gadget whose USB2 PHY already runs as a device. The T8132 ATC PHY refuses the device role while its lanes run USB3, so a T8132 port with a USB3 calibration and a host on the other end lost its USB (seen on the J773g, linux#2434). Take the high-speed path for a device-role -EOPNOTSUPP on every SoC, before that check; other USB3 PHY errors are handled as before. T6050 never gets here, its USB2 PHY has no device mode. The ATC PHYs that answer -EOPNOTSUPP for another reason (a T8103 port whose lanes are all DisplayPort or that has no SuperSpeed tunables) cannot carry a SuperSpeed device either, so the high-speed gadget fits them too; they already took this path. The T8132 selftest now expects the high-speed gadget. This is the generic form of the T8132 fallback in linux#2420 by techmore, whose J773g row (a USB 3 host lists the gadget at 480 Mb/s where the role failed before) is the hardware evidence for it. DjDeveloperr reported the failure and serves the T8132 device role from the PHY side in linux#2434; both changes can land. Link: aurora-silicon#2420 Link: aurora-silicon#2434 Signed-off-by: Ryan Murray <[email protected]>
On a T8132 port whose lanes run USB3, a device role failed.
atcphy_usb3_set_mode()refusedPHY_MODE_USB_DEVICEwith-EOPNOTSUPP, then:USB3 PHY setup failed, err=-95;cable revalidation failed after 3 attempts.That started once the boot loader passed the T8132 USB3 calibration (aura#113 24812c55). Before that, these ports ran USB2 only, and the device role worked on them. On the M4 Mac mini (J773g) a rear port with a host on the other end lost its USB.
SuperSpeed device mode is not supported by this driver on T8132, so this serves the device role on USB2 instead:
USB3and pin-DUSB3_DPmove toUSB2. Four-lane DisplayPort (pin C/E) keeps USB2 on its own wires and is unchanged.t8132_deviceis set only afteratcphy_mux_switch()andatcphy_usb3_route()succeed, and is cleared on controller role exit (atcphy_usb3_power_off()or switching toPHY_MODE_USB_HOST) rather than onSAFE/OFFmux bounces.typec_modepreserves the partner's un-downgraded SuperSpeed mode so a direct device-to-host data role swap restores SuperSpeed lanes beforehost_activeblocks T8132 lane reconfiguration.atcphy_test_t8132_device_role_usb2), and host selftest fixture updates are squashed into a single bisectable commit.Measured on the J773g, 2026-11-19, default kernel 7.3.0-m4drv8 with this module:
dwc3-apple 40a280000.usb: USB3 PHY setup failed, err=-95(×3), thensn201202x 1-0a: cable revalidation failed after 3 attempts.phy-apple-atc 40aa90000.phy: USB device role: SuperSpeed device mode not supported by driver, using USB2(log message updated from earlier wording). No-95and no revalidation failure; dwc3 enters device mode with run/stop set and a configfs ACM gadget binds to UDC40a280000.usb.Assisted-by: LLM (Gemini:4 Neon)