Skip to content

phy: apple: atc: serve a T8132 device role on USB2 - #2434

Merged
RyanTheTide merged 3 commits into
mainfrom
djdev/t8132-device-role-usb2
Nov 26, 2026
Merged

RyanTheTide merged 3 commits into
mainfrom
djdev/t8132-device-role-usb2

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

On a T8132 port whose lanes run USB3, a device role failed. atcphy_usb3_set_mode() refused PHY_MODE_USB_DEVICE with -EOPNOTSUPP, then:

  • dwc3-apple failed the role with USB3 PHY setup failed, err=-95;
  • the SN201202x gave up with 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:

  • When the controller asks for the device role on a calibrated T8132 port, USB3 and pin-D USB3_DP move to USB2. Four-lane DisplayPort (pin C/E) keeps USB2 on its own wires and is unchanged.
  • t8132_device is set only after atcphy_mux_switch() and atcphy_usb3_route() succeed, and is cleared on controller role exit (atcphy_usb3_power_off() or switching to PHY_MODE_USB_HOST) rather than on SAFE/OFF mux bounces.
  • typec_mode preserves the partner's un-downgraded SuperSpeed mode so a direct device-to-host data role swap restores SuperSpeed lanes before host_active blocks T8132 lane reconfiguration.
  • Driver, KUnit (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:

  • Before: dwc3-apple 40a280000.usb: USB3 PHY setup failed, err=-95 (×3), then sn201202x 1-0a: cable revalidation failed after 3 attempts.
  • After: phy-apple-atc 40aa90000.phy: USB device role: SuperSpeed device mode not supported by driver, using USB2 (log message updated from earlier wording). No -95 and no revalidation failure; dwc3 enters device mode with run/stop set and a configfs ACM gadget binds to UDC 40a280000.usb.
  • Host-role ports, including the front fixed hub with the keyboard, are unchanged.

Assisted-by: LLM (Gemini:4 Neon)

RyanTheTide added a commit that referenced this pull request Nov 19, 2026
…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]>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Host-tests fix pushed in de20ca2.

The failures were mine. atc-usb3-tests and the apple-dcp units around the mux, the PIPE, the role exit and the dwc3 teardown compile the real atcphy functions against their own struct apple_atcphy. They didn't know the new t8132_device field, the atcphy_t8132_device_mode() helper, dev_info(), or the call to atcphy_mux_switch() from atcphy_usb3_set_mode().

What the commit changes:

  • The field goes into every mock.
  • The helper is emitted with the target-mode mapping.
  • Units that place the mux after atcphy_usb3_set_mode() get prototypes ahead of it.
  • dev_info() gets stubbed where it was missing.
  • atc-usb3-tests gains a T8132 device-role case: USB3 goes to USB2, a later USB3 request stays USB2, and both the safe state and the host role lift it. It also gains three mutations; all are killed.

Local results, through tools/asahi/run-host-tests.py in a 2 GiB scope, base 0abc2f3:

  • atc-cio-sleep-tests, atc-usb3-tests and atc-usb3-tests --mutations pass, with 58/58 mutations killed.
  • apple-dcp passes 88/88.

My host's clang 23 adds -Wunused-but-set-variable errors in unrelated units, and does so on the base as well. I neutralised those with a wrapper for the local run only; nothing in the tree depends on it.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor

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:

  • turns the T8132 condition into a PHY capability in the match data (no_ss_device), and renames t8132_device to usb2_device;
  • adds a USB3 .validate that refuses the device role on such PHYs, so dwc3-apple sets the core up as a high-speed device (device speed and the GUCTL1 2.0 clock are controller registers the PHY can't set). That's the setup usb: dwc3: apple: keep a T8132 device role on USB2 without SuperSpeed device mode #2420's J773g row used, with a USB 3 host enumerating the gadget at 480 Mb/s;
  • moves the T6040 USB3 PHY onto the same contract.

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 tools: commit in #2334 fixes them, and the full suite passes 427/427. ATC KUnit, including your t8132_device_role_usb2 case, passes 52/52 under qemu arm64.

Still owed: a J773g row at #2334's head (USB device role: no SuperSpeed device mode, using USB2 plus the dwc3 "gadget at high speed" line, host-side enumeration). If you're happy with that shape, this PR can be closed as carried.

@RyanTheTide

Copy link
Copy Markdown
Contributor

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

VERDICT: 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 t8132_ss (set only on the T8132 generation) and the gen == ATCPHY_GENERATION_T8132 block in atcphy_typec_target_mode(). The other hunks only clear the flag (HOST role, mux to OFF). M1/M2/M3/M4 Pro/T8142/Neo are unaffected.

Nits / risks:

  1. atc.c:5955: the flag is cleared on any atcphy_mux_switch(OFF), but dwc3 keeps the device role. This is tied to the mux, not to the role.
    • Scenario 1: device role, then the port controller sends SAFE/OFF (cable revalidation, or alt-mode entry passing through SAFE) without detaching the role. A following USB3 mux update now brings up USB3 lanes under a device-role controller.
    • Scenario 2: with the role still DEVICE, dwc3 does not call set_mode again.
    • That is the configuration the old -EOPNOTSUPP refused. Tie the flag to !host_active + role, or re-apply it in atcphy_typec_target_mode() from the controller role.
  2. atc.c:4759-4764: t8132_device is set before atcphy_mux_switch(). On failure the flag sticks while the role fails.
    • Scenario: host→device DR swap with the PIPE still in the USB3 state. atcphy_configure_t8132() returns -EBUSY at atc.c:4040ff ("pipe_state != DUMMY").
    • Every later mux update is then forced to USB2 until unplug or a host role. Set the flag only on success.
  3. atc.c:4767-4768: DR swap device→host clears the flag, but the lanes stay USB2 (typec_mode was set to USB2 at 5993). They regain USB3 only if the port controller sends another mux update, and the comment assumes one.
    • atc.c:4041 refuses a T8132 mode change while t8132_common_owned && host_active.
    • So a host role on the downgraded port may stay USB2 for the whole session: a silent 480 Mb/s host.
  4. atc.c:3640: in device role, USB3_DP (pin D, 2 DP lanes + USB3) maps to 4-lane MODE_DP when t8132_dp_alt. The partner negotiated pin D, so its SS pair expects USB3, not DP. This is untested, and USB2 (drop DP) or refusing would be the conservative mapping. The device role + DP source combination is rare, so this is a nit.
  5. "T8132 has no SuperSpeed device mode" is stated as a hardware fact in code comments and logs. No evidence is cited; it may only be a driver limitation. Reword it as a driver limitation unless there is proof.
  6. Bisect: commit aa3f0d9 alone breaks the host fixture builds (de20ca2 says so). Tools only; squash or reorder.
  7. PR body ends with the Claude Code footer, not "Assisted-by: LLM (Claude:Opus 5.5)".

Missing rows:

  • Host-side enumeration of the gadget (ACM shows up on a real host) on J773g. The only "after" evidence is the absence of the -95 error. The partner was itself in the device role, so nothing enumerated.
  • J713/J715 (Airs) and J604: device role on a calibrated USB3 port, with a real host on the far end.
  • Unplug/replug in device role, then replug as host on the same port. Does it come back at SuperSpeed?
  • DR swap device→host and host→device, with lsusb speed checked.
  • KUnit atcphy_test_t8132_device_role_usb2: built, never run (arm64 qemu or UML).

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]>
@DjDeveloperr
DjDeveloperr force-pushed the djdev/t8132-device-role-usb2 branch from de20ca2 to 025e7ea Compare November 22, 2026 04:59
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Updated and force-pushed as a single squashed commit (025e7ea2df1b) on integration/aurora, addressing all 7 review points:

  1. Flag tied to role vs mux: Removed clearing t8132_device on APPLE_ATCPHY_MODE_OFF in atcphy_mux_switch(); t8132_device is now cleared on controller role exit (atcphy_usb3_power_off() alongside host_active, and PHY_MODE_USB_HOST in atcphy_usb3_set_mode()) and honored in atcphy_usb2_init(), atcphy_mux_in_mode(), atcphy_mux_switch(), and atcphy_mux_update_to().
  2. Set t8132_device only on success: atcphy_usb3_set_mode(PHY_MODE_USB_DEVICE) now sets t8132_device only after both atcphy_mux_switch() and atcphy_usb3_route() succeed; failed switches leave t8132_device, host_active, and typec_mode intact.
  3. Device-to-host DR swap restores SuperSpeed: typec_mode keeps the partner's un-downgraded mode; PHY_MODE_USB_HOST with t8132_device clears the flag and calls atcphy_mux_switch(atcphy, target) before host_active = true (avoiding the t8132_common_owned && host_active -EBUSY gate) and before routing PIPE to USB3.
  4. Pin D mapping: atcphy_t8132_device_mode() maps both USB3 and pin-D USB3_DP unconditionally to USB2, leaving 4-lane DP (pin C/E) unchanged.
  5. Driver-limitation wording: Reworded comments, log output, commit message, and tests to describe a driver limitation rather than a hardware fact.
  6. Bisectability: Squashed driver, KUnit, and all host selftest fixture updates into one commit.
  7. PR description footer: Updated the PR description and footer.

Verification:

  • scripts/checkpatch.pl --strict -g HEAD: 0 errors, 0 warnings, 0 checks
  • tools/asahi/atc-usb3-tests.py --mutations: 39/39 cases passed, 62/62 mutations killed (including 7 T8132 device-role mutations)
  • tools/asahi/atc-cio-sleep-tests.py: 41/41 cases + 11/11 negative controls passed
  • apple-dcp selftests: phy 14/14, quiesce 19/19, lifecycle 35/35 passed

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

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 @025e7ea2

VERDICT: 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)

  1. Flag cleared on mux OFF, not on role change: RESOLVED.

    • The flag is now cleared only in two places: atcphy_usb3_power_off() (4659) and the HOST case of atcphy_usb3_set_mode() (4766).
    • A SAFE/OFF bounce keeps it. A later USB3 request is mapped to USB2 in atcphy_mux_switch() (5979), atcphy_mux_in_mode() (5889) and atcphy_mux_update_to() (6140).
    • Every dwc3-apple role change goes through dwc3_apple_exit() and then dwc3_apple_core_stop(), which calls phy_power_off(usb3) (dwc3-apple.c:778). So the flag follows the controller role.
  2. Flag left set after a failed mux switch: RESOLVED.

    • The flag is set only once both atcphy_mux_switch() and atcphy_usb3_route() have succeeded (4808-4809).
    • On failure, typec_mode is restored (4796).
    • The host→device -EBUSY scenario from the earlier review can't happen with dwc3-apple. Its role exit calls usb3_power_off() first, which clears host_active and parks the PIPE.
  3. Device→host swap staying on USB2: RESOLVED.

    • typec_mode now keeps the partner's requested mode (requested_mode, 5975/5988/6018).
    • With dwc3-apple's ordering, the swap goes power_off (flag cleared, mode OFF), then atcphy_usb2_init() (4575-4580) configures typec_mode, which is USB3.
    • The in-place restore in set_mode HOST (4758-4774) covers a direct set_mode without power-off.
  4. Pin D mapped to 4-lane DP in the device role: RESOLVED, using the conservative mapping.

    • USB3_DP now maps to USB2 (3636-3641).
    • The DP side then refuses cleanly: atcphy_dpphy_set_mode_t8132() returns -EOPNOTSUPP (4891-4906) and validate reports 0 lanes (4938-4949). The display stays dark; nothing crashes.
  5. Hardware-fact wording: RESOLVED. The comments, the log line (4794) and the commit message now describe a driver limitation.

  6. Bisect: RESOLVED. Driver, KUnit and fixtures are squashed into one commit.

  7. PR footer: RESOLVED.

    • The body now ends with "Assisted-by: LLM (Gemini:4 Neon)". No particular model is required.
    • The commit has only Signed-off-by: Diljit Singh. There are no agent trailers, so there is no NIT on this point.
  8. KUnit never run: NOT RESOLVED at this head.

Blockers

None.

New problems / nits

  1. Every device-role start brings USB3 up first, then tears it down (atc.c:4575-4580, 4659).

    • Why: usb3_power_off() clears t8132_device and takes the T8132 lanes to OFF (4699-4702). typec_mode stays USB3. So on the next core start, atcphy_usb2_init() sees mode OFF with the flag clear and runs a full T8132 USB3 configure. Only then does usb3_set_mode(DEVICE) move the lanes to USB2. On first plug the Type-C mux has already set USB3 before the role arrives.
    • Effects:
      • The host on the other end briefly sees SuperSpeed receiver terminations.
      • A USB3 configure failure fails the whole device role, even though USB2 would have worked. Examples: -EBUSY while t8132_suspended, or -EIO after t8132_failed (4031-4036).
      • The USB2 mapping in usb2_init is effectively dead code: the flag is always clear when usb2_init runs from a role start.
    • atcphy_usb2_set_mode(PHY_MODE_USB_DEVICE) runs before the reset is released (dwc3-apple.c:849-855) and is where the role could be recorded instead.
    • Not a regression: before this PR the device role failed outright. It is still a fragile path.
  2. The controller still runs as a SuperSpeed device on a dummy PIPE.

  3. The set_mode HOST restore (4767-4772) fails the whole host role if atcphy_mux_switch(typec_mode) fails. It returns with the flag set back to true.

    • Falling back to a USB2 host with a warning would degrade more gently.
    • With today's dwc3-apple the branch is unreachable: every host start follows a power_off() that already cleared the flag. Either way it is untested.
  4. The behaviour is keyed on the existing t8132_ss field (set from the DT SS banks, 6616), not on a PHY capability such as USB device mode: T6040 USB2 device sequence; device role keyed on the PHYs (host-only and SuperSpeed) #2334's no_ss_device.

  5. Pin D in the device role silently drops DP.

    • Only the generic "using USB2" dev_info appears. The DP alt mode driver still believes pin D is configured.
    • A dev_info naming the dropped DP would help triage.

Missing rows

  • J773g at this head: a real host enumerates the gadget (lsusb on the host shows the ACM device at 480M). The dmesg should show the "using USB2" line and the dwc3 gadget speed.
  • J713/J715 (Airs) and J604: device role on a calibrated port with a real host on the other end.
  • Unplug or replug in the device role, then replug as host on the same port: lsusb shows 5000M again.
  • DR swap device→host and host→device on one cable, with lsusb speed checked on both sides.
  • Pin D dock or monitor in the device role (DP is expected to stay dark, with no DCP error).
  • KUnit atcphy_test_t8132_device_role_usb2 at this head (arm64 qemu).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review at 025e7ea (code read only).

Earlier points:

  • Flag tied to the role (1): fixed. It is cleared only in atcphy_usb3_power_off() (atc.c:4659) and on HOST (4766), and honoured in usb2_init/mux_in_mode/mux_switch/mux_update_to (4576, 5889, 5979, 6140). SAFE/OFF without a detach keeps it, and a later USB3 update is downgraded and recorded as a noop. Locking is fine: every access is under atcphy->lock.
  • Set on success only (2): fixed (4808-4809). A failed switch restores typec_mode before host_active is touched.
  • Device->host restores SuperSpeed (3): fixed, but by another path than the one the comment describes.
    • dwc3-apple tears the core down on every role change (dwc3-apple.c:1478 -> phy_power_off), so usb3_power_off() clears the flag and configures OFF.
    • atcphy_usb2_init() then rebuilds from typec_mode, which now keeps USB3.
    • The new PHY_MODE_USB_HOST restore branch (4758-4775) is not reached from dwc3-apple, including dwc3_apple_core_reinit(). It is harmless, but please add a host-test case for the real sequence (device, power_off, usb2_init, set_mode(HOST), expect USB3).
  • Pin D (4): fixed (3636-3641). A device role on pin D now drops the partner's two DP lanes without a word. The log line at 4793 could say so.
  • Wording (5), bisect (6), footer (7): fixed.

New:

  • Every device-role start first brings the lanes up in USB3, then drops them to USB2. The flag was cleared in power_off, so atcphy_usb2_init() (4575-4580) configures typec_mode=USB3, and set_mode(DEVICE) then switches to USB2 (4790-4797). That is a full SuperSpeed start and stop on every attach and resume, and a host on the far end may try SuperSpeed link training during it.
    • dwc3-apple already selects PHY_MODE_USB_DEVICE on the USB2 PHY before reset and phy_init (dwc3-apple.c:842-855). Recording the device role in atcphy_usb2_set_mode() would let usb2_init start on USB2 directly.
    • Not a blocker if the row below shows the host settling at 480M promptly.

Still missing, at this head:

  • The device role on a calibrated T8132 USB3 port, with a real host enumerating the gadget (ACM on the host, lsusb -t at 480M). The J773g evidence is from an earlier module and shows only the missing -95 and a bound UDC. J713 or J773g would do.
  • Device->host swap or replug as host on the same port, back at 5000M.
  • A KUnit run of atcphy_test_t8132_device_role_usb2 (arm64 qemu).

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

KUnit at 025e7ea: atcphy_test_t8132_device_role_usb2 passes.

I ran the ATC KUnit suites under qemu arm64 (kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/phy/apple/.kunitconfig.apple-atc 'phy-apple-atc*'):

  • 025e7ea: 40/40 passed, 0 failed. phy-apple-atc-mux 35/35, including the rewritten atcphy_test_t8132_device_role_usb2, and phy-apple-atc-t8132-pm 5/5.
  • Merge-base 24dc422 (integration/aurora), for comparison: 39/39 passed. phy-apple-atc-mux has 34 cases, and the one extra case at this head is the PR's.

At 025e7ea the ATC host tests also pass: atc-usb3-tests (plain and --mutations), atc-cio-sleep-tests and apple/atc-t8132-usb3.

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)

@RyanTheTide

Copy link
Copy Markdown
Contributor

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.

  • UDC: 40a280000.usb reached configured at high-speed.
  • Host side: usb 3-1 enumerated at 480M and cdc_ncm bound.
  • Traffic: link-local ping 10/10 at 1.7 ms; iperf3 from host to J713 ran 8 s at 281 Mbit/s with 0 retransmits.
  • Removal: taking the gadget down gave a clean USB disconnect on the host. The UDC went back to not attached.
  • Counts: there were no atc, dwc3 or -95 lines while the gadget was up or when it was removed. Enforcing, 0 AVC, 0 failed units afterwards.

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)

@RyanTheTide

Copy link
Copy Markdown
Contributor

I replayed 025e7ea2df1b against current integration/aurora a3d477d03f8e. The driver merges automatically. The only conflict is tools/asahi/atc-usb3-tests.py. The integration side now covers CIO retention on USB stop for all applicable generations. Keep those generic mutations and add this PR's seven T8132 device-role mutations, leaving the old T8132-only USB-stop duplicates out of the combined fixture.

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 025e7ea2, and the lab hardware row is queued for the updated head.

Assisted-by: LLM (Codex)

@RyanTheTide

RyanTheTide commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Forward-merged Linux main at d6656a21a059 into the existing PR branch with Dj's approval. The new head is cde842ce4844, pushed normally. The only manual resolution was the ATC host fixture. It retains the current common CIO-stop cases and the seven T8132 device-role controls. The automatically merged driver matched the earlier preview byte for byte.

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.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (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 24, 2026

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

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 restores typec_mode to the partner's mode, routes, and only then sets t8132_device.
  • Mode changes while in the device role. atcphy_mux_switch(), atcphy_mux_in_mode() and atcphy_mux_update_to() all map through atcphy_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 calls phy_power_off() on the USB3 PHY. That clears t8132_device and configures OFF, and the next atcphy_usb2_init() brings back the un-downgraded typec_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-dwc3 and its core_stop turns the port OFF, so nothing is left stuck.

Non-blocking:

  1. atcphy_usb3_set_mode(), DEVICE branch: host_active = false is set after atcphy_mux_switch(). A direct host-to-device set_mode with no power-off in between would hit -EBUSY from the T8132 lane check (t8132_common_owned && host_active, or pipe_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 clear host_active before the switch.
  2. The KUnit case covers the mode helper and target mapping, but not the set_mode rollbacks: the restore of typec_mode after a failed device switch, and the re-set of t8132_device after a failed host restore. Both are small enough to add to atc-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, the t8132_ss probe around line 6627) and drivers/usb/dwc3/dwc3-apple.c (core_stop, core_start, set_role).
  • CI: host-tests pass.

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 24, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

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

  • UDC: 40a280000.usb reached configured at high-speed. The PHY logged USB device role: SuperSpeed device mode not supported by driver, using USB2.
  • Host: an M4 Pro MacBook Pro running Linux, on the same cable, enumerated 1d6b:0104 with cdc_ncm at 480M.
  • Traffic: link-local ping 10/10, 1.9 ms on average.
  • Removal: taking the gadget down gave a clean USB disconnect on the host, and the UDC went back to not attached.
  • Counts: 0 atc, dwc3 or -95 lines. Enforcing, 0 AVC, 0 failed units after the J713 was put back on its normal kernel.

The branch conflicts with main again, but only in tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py's import line: keep both atc_set_mode_prototypes and main's atc_cfg_helpers. Still to run: port0 back in host role at 5000M with a USB3 device.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at cdf35323: not ready yet

Check Detail
CI at head ok 2 checks passed
Review no approved by RyanTheTide, but GitHub does not count it yet (code owner from Core or Omarchy Mac needed, or approval went stale)
Requested changes ok none
Hardware row at head no no line with the head SHA cdf35323, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:gpu, area:usb

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide
RyanTheTide requested review from a team as code owners November 25, 2026 22:56
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026

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

Verdict at cdf35323: no blockers. Merge once CI at head is green (3/3 now).

Blockers: none

Checked

  • cdf35323 = your 025e7ea2 plus a normal merge of main (f3bfe50). The only conflict was the import line in tools/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_mode is kept, so the host role restores the partner's SuperSpeed mode. t8132_device clears on USB3 power-off and on the host switch, and atcphy_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_device stays false while the mux is in USB2. The next Type-C event reconfigures it anyway.

@RyanTheTide
RyanTheTide merged commit bc9b4c0 into main Nov 26, 2026
4 checks passed
@RyanTheTide
RyanTheTide deleted the djdev/t8132-device-role-usb2 branch November 27, 2026 13:21
RyanTheTide added a commit that referenced this pull request Nov 27, 2026
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]>
AxxzyWasTaken pushed a commit to AxxzyWasTaken/linux that referenced this pull request Nov 28, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants