Skip to content

usb: typec: tipd: J575c: renegotiate every inherited connection - #2875

Merged
RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
7robertodantas:j575c-reinit-no-attach-gate
Nov 23, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
7robertodantas:j575c-reinit-no-attach-gate

Conversation

@7robertodantas

@7robertodantas 7robertodantas commented Nov 22, 2026 •

Copy link
Copy Markdown

On current integration, a USB 3 device that is attached when a J575c (Mac Studio, M4 Max) boots comes up at USB2 (480M,
usb-storage) instead of 10 Gb/s (uas), until it is replugged. Stock linux-aurora -40 (9125b31) does not have the
problem.

Cause: the 0x7e gate that #1671 added (1a774ee) never really detected an inherited connection. The controller
reports byte 7 = 0x08 for any completed attach, including the one inherited from the boot chain. The 0x04 the gate
relied on was produced by the LDCM command the probe used to send before the gate. 5b5032b (no LDCM to a dry port,
as macOS) removed that command, so the gate now sees 0x08 and skips the renegotiation. 5b5032b itself is fine.
This PR drops the gate, so the J575c renegotiates every inherited connection, as it did before 5b5032b.

Change: drivers/usb/typec/tipd/core.c only (-30/+4): remove check_attach_state, the CD321X_ATTACH_STATE_* defines
and cd321x_attach_state_done(); update the board table comment. No DT or binding change. The J716c row is unchanged.

Tests (J575c, USB 3 drive on typec3 attached through every reboot)

Kernel 7.3.0-1-106 = integration/aurora f5fae3c (tipd sources identical to the current base, 48470aa), package config.

tipd sources DT 0x7e byte 7 at the gate Renegotiated Drive at boot
stock -40 (9125b31) kernel + driver installed not logged (gate passed) 3 ports Gen 2x1, uas
f5fae3c integration + nvram 0x08 no 480M, usb-storage
f5fae3c installed 0x08 no 480M, usb-storage
9125b31 tipd on the f5fae3c kernel, logging installed 0x08 at probe start, 0x04 at the gate (test build used the probe-start value) 480M
f5fae3c with 5b5032b reverted installed 0x04 3 ports Gen 2x1, uas
f5fae3c + this PR installed (no gate) 3 ports Gen 2x1, uas
f5fae3c + this PR integration + nvram (no gate) 3 ports Gen 2x1, uas

With this PR: HDMI and the typec1 DP monitor connected, USB-A keyboard and the USB2 hub on typec OK (the hub's
keyboard needed one descriptor retry, -71, after the renegotiation; same with 5b5032b reverted), no failed units.
With the integration DT (apple,event-irq-in-sleep), the port controllers still sleep while idle after the
renegotiation: typec0, typec2 and typec3 (with the drive) suspended, typec1 (DP monitor) active, as without this PR.

Exact head (0d30880, rebased on integration 48470aa; tipd code unchanged)

Kernel 7.3.0-1-109 built from the head, package config, installed DT, same partners (drive on 1-06, USB2 hub,
DP monitor on 1-0a, HDMI) plus a read-only nofail fstab entry for the drive.

Check Result
Renegotiated 1-06 18.405 s, 1-0a 18.407 s, 1-08 18.411 s (parallel, PROBE_PREFER_ASYNCHRONOUS)
Drive Gen 2x1 uas at 19.55 s, fstab mount at 19.85 s
systemd "Startup finished" 19.85 s (13.5 s on -106 with the gate skipping; 18.1 to 18.3 s on stock -40)
Failed units / AppArmor denials 0 / 0
Kernel warn/err not in the -108 boots (integration without this PR) only the hub keyboard's -71 descriptor retry (stock -40 logs it too)
Unbind 1-06, drive mounted xHCI and drive removed, ext4 shut down within 20 ms, before any renegotiation
Bind 1-06 renegotiated in 5.16 s, drive back at Gen 2x1 uas 1.5 s later (not remounted, as after a replug)

Not tested: a J716c (its row has no gate and is unchanged), a powered dock, a root or /boot disk on USB-C.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

Review at 17fa095.

Thanks, the analysis of where the 0x04 came from is convincing, and dropping a heuristic on an undocumented status bit is the right direction. The change itself looks correct: J716c never set check_attach_state, so its path is byte-for-byte unchanged, and the J575c error handling (best_effort, re-read status) is untouched.

  1. drivers/usb/typec/tipd/core.c:3608-3620: the J575c behaviour is still selected by of_machine_is_compatible("apple,j575c") in cd321x_inherited_boards[], on top of the apple,reset-inherited-usb2-connection property. After this PR the only per-board data left is the LOCK key and best_effort. The key already has a binding (apple,debug-lock-key, which tipd_replug_key() reads), so the table could go: the key would come from the node, and best_effort could be the default, or set by a property. That can be a follow-up, but please don't add rows to the table.
  2. core.c:3646-3655: every connected host-role port on the J575c now gets DISC with a 5 s delay at probe, so VBUS drops for about 5 s on bus-powered partners. tipd is =m. Can you say what happens when the drive on a renegotiated port is already in use at that point (an external root or a /boot disk, or a disk mounted from fstab if tipd loads after root)? A line in the commit message saying it is expected to be safe, or why, would help.
  3. Also with 3 renegotiated ports, each needing at least 5.1 s of msleep, what does probe add to boot time? Please give the dmesg timestamps from your J575c log.

Rows: the J575c rows cover the drive, HDMI, the DP monitor on typec1 and the hub. For no-regression it would help to have one J575c boot with a powered dock (with devices behind it) on a renegotiated port, and one with the boot or root disk on USB-C if that is a supported setup. Nothing else is affected: only the J575c and J716c DTs set the property, and the J716c path does not change.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial pre-PR checklist (§1–§6) review at 17fa0955233cdb014e76e31e82888bbc3f62b2ac (Host tests: success).

Verdict: REQUEST CHANGES — the root-cause analysis of register 0x7e byte 7 (0x08 at probe start vs 0x04 induced by the pre-5b5032b33af3 LDCM command) is convincing and removing the bogus heuristic leaves J716c untouched, but key §2/§3 probe-safety questions and §5 evidence items remain unanswered.

Blockers

  1. §3 Safety — live USB-C storage and runtime driver reprobe (drivers/usb/typec/tipd/core.c:3623-3701):
    • With check_attach_state removed, every connected host-role port carrying apple,reset-inherited-usb2-connection now unconditionally receives DISC with a 5 s VBUS/CC drop inside tps6598x_probe().
    • Because tipd is a loadable module (=m), please confirm and document in the commit message:
      1. What happens at boot if an external root, /boot, or fstab-mounted drive is on a renegotiated USB-C port when tipd probes (is DWC3/xHCI guaranteed not to have mounted it yet via supplier ordering, or is a live disconnect possible?).
      2. What happens on a runtime unbind/bind or rmmod/modprobe of tps6598x? With no 0x7e gate and no boot-once guard, a runtime reprobe will now force a 5 s VBUS drop on every connected host-role port (including already-mounted drives and active DP monitors).
  2. §2 Production-ready — synchronous boot-time probe latency (drivers/usb/typec/tipd/core.c:3651-3664):
    • tps6598x does not set PROBE_PREFER_ASYNCHRONOUS, so probing 3 connected ports on J575c runs msleep(5100) plus polling/command waits sequentially (~15–18 s+ added to probe/boot). Please provide the dmesg timestamps from the J575c boot log showing the exact boot-time impact.
  3. §5 Evidence — exact-head build & regression completeness:
    • The J575c tests were run on f5fae3cbb + patch rather than a build at exact head 17fa0955 (acknowledged that drivers/usb/typec/tipd/ is identical between f5fae3cbb and 110861f43), and the PR body omits the SELinux/AppArmor denial count and new-kernel-error count (0 failed units is noted, plus one -71 descriptor retry on the USB2 hub).
    • Please add the dmesg probe timestamps, full regression counts (0 SELinux/AppArmor denials, 0 failed units, 0 new kernel errors), and a J575c no-regression check with a powered dock (plus external USB-C boot/root disk behavior if supported) at 17fa0955.

Non-blocking §1 Note (Follow-up)

  • drivers/usb/typec/tipd/core.c:3608-3621: this PR improves §1 by removing the per-board check_attach_state flag, but cd321x_inherited_boards[] still gates on of_machine_is_compatible("apple,j716c") / "apple,j575c" solely for .key and .best_effort. Since apple,debug-lock-key already exists in Documentation/devicetree/bindings/usb/apple,sn201202x.yaml and tipd_replug_key() (core.c:3734), please track a follow-up to carry apple,debug-lock-key in the J575c/J716c DTs and retire cd321x_inherited_boards[] (respecting the §1 chicken-and-egg transition) rather than adding new rows.

§1–§6 Checklist Summary

  • §1 No model gating: Pass on diff (removes a per-board flag; pre-existing cd321x_inherited_boards[] noted for DT follow-up).
  • §2 Production-ready: Blocked — synchronous msleep(5100) × N connected ports probe-time impact unquantified (dmesg timestamps owed).
  • §3 Safety: Blocked — live-mounted USB-C disk safety (tipd=m) and runtime reprobe VBUS-drop hazard unaddressed.
  • §4 Clean-room & attribution: Pass — commit 17fa0955233c carries human author/committer and human Signed-off-by: only.
  • §5 Evidence: Blocked — Host tests green, but dmesg timestamps, full regression counts (denials / kernel errors), and dock/live-disk coverage at 17fa0955 are owed.
  • §6 Naming: Pass.

Assisted-by: LLM (Gemini 4 Neon)

Since commit 1a774ee ("usb: typec: tipd: renegotiate inherited
J575c connections"), a J575c connection inherited from the boot chain
has been renegotiated only when byte 7 of register 0x7e lacked bit 3.
That bit was taken to mean "the controller has completed an attach with
the OS running", and bit 2 to mean the inherited state. It does not mean
that. Read at the very start of the probe, before any command, byte 7 is
0x08 on every connected port, including a boot-attached USB 3 drive
whose SuperSpeed side is stuck in RxDetect. The 0x04 that the gate saw
came from the probe itself: it used to send each port an LDCM command
before the gate. That command starts a new liquid measurement, and
afterwards the controller reports 0x04.

Since commit 5b5032b ("usb: typec: tipd: sn201202x: Send no LDCM
command to a dry port") a dry port gets no LDCM command. The gate now
sees 0x08 and skips the renegotiation. A USB 3 device attached at boot
then comes up at 480 Mb/s (usb-storage instead of uas) until it is
replugged.

The controller reports nothing else that tells an inherited connection
whose SuperSpeed side is stuck from one that trains. Drop the gate and
renegotiate every inherited J575c connection. That is what the probe
did before the LDCM change: in every J575c boot log we have from before
it, the gate let every connected port through.

The renegotiation drops VBUS and CC for about 5 s, but it cannot take
away a USB device that is in use. dwc3-apple does not start the port's
xHCI before the port controller reports the first connection, and the
probe reports it only after the renegotiation. A drive on a
renegotiated port is first enumerated after it, at boot as well as for
a disk that fstab or the initramfs waits for. Unbinding the port
controller disconnects the partner first (the host role goes to none),
so a later bind renegotiates a port whose devices are already gone.

The ports probe asynchronously (sn201202x sets
PROBE_PREFER_ASYNCHRONOUS), so the renegotiations run at the same
time. With three connected ports the boot takes 5 to 6 s longer, as
with the stock linux-aurora kernel, which renegotiates the same ports:
systemd reports the boot finished at 13.5 s with the gate skipping
them and at 18.6 to 19.9 s with this change (stock: 18.1 to 18.3 s).

Tested on a J575c (Mac Studio, M4 Max) with a USB 3 drive (10 Gb/s)
attached through each reboot on the same port, kernel built from
integration/aurora f5fae3c, whose tipd sources match this base:

  tipd sources               byte 7 at the gate    drive at boot
  f5fae3c                  0x08, skipped         480M usb-storage
  same, LDCM change reverted 0x04, renegotiated    Gen 2x1 uas
  f5fae3c + this change    no gate, renegotiated Gen 2x1 uas

With the tipd sources from before the LDCM change on the same kernel,
byte 7 is 0x08 at the start of the probe and 0x04 at the gate.

A kernel built from this change on integration/aurora 48470aa gives
the same: the three connected ports renegotiated by 18.4 s, the drive
at Gen 2x1 uas, and a read-only fstab mount of it at 19.9 s. Unbinding
the drive's port controller with the drive mounted removed the drive
and shut its filesystem down at once; the bind renegotiated the port in
5.2 s and the drive came back at Gen 2x1.

Fixes: 1a774ee ("usb: typec: tipd: renegotiate inherited J575c connections")
Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
@7robertodantas
7robertodantas force-pushed the j575c-reinit-no-attach-gate branch from 17fa095 to 0d30880 Compare November 23, 2026 11:20
@7robertodantas

Copy link
Copy Markdown
Author

Thanks to you both. The branch is rebased on integration 48470aa (no conflict, drivers/usb/typec/tipd/ unchanged
since 110861f) and the new head 0d30880 changes only the commit message: it now has a paragraph on a drive in use,
one on boot time, and the exact-head run below. The code is the same as 17fa095.

Board table (Ryan 1, DjDeveloperr §1 note). Agreed. This PR adds no row. I'll send the follow-up after this one:
apple,debug-lock-key in the J575c and J716c DTs, then drop cd321x_inherited_boards[], with the DT change landing
first so the driver doesn't depend on it before it is there.

A drive in use on a renegotiated port (Ryan 2, DjDeveloperr blocker 1). It cannot be in use when the
renegotiation starts. dwc3-apple keeps the port's controller off (DWC3_APPLE_PROBE_PENDING) until the port
controller reports the first connection, and tps6598x_probe() reports it only after
cd321x_reset_inherited_connection(). So a root, /boot or fstab disk on such a port shows up about 6 s later than
without the renegotiation, like a slow device. It is never pulled from under a mount. Exact head, drive on 1-06 with a
read-only nofail fstab entry: last renegotiation 18.41 s, Type-C xHCIs 19.08 s, drive Gen 2x1 uas 19.55 s, mounted
19.85 s. I have not tested a root or /boot disk on USB-C.

Runtime unbind/bind: tipd_remove() calls tps6598x_disconnect(), which sets the role to none, so the unbind itself
takes the devices away; that does not depend on this PR. With the drive mounted, unbind of 1-06 removed the xHCI and
the drive and shut ext4 down within 20 ms, before any renegotiation. bind renegotiated the port in 5.16 s (the write
returned then), and the drive came back at Gen 2x1 uas 1.5 s later. It was not remounted, as after any replug.

Boot time (Ryan 3, DjDeveloperr blocker 2). The J575c ports are sn201202x (spmi.c), which sets
PROBE_PREFER_ASYNCHRONOUS (since #1671), so the three renegotiations run in parallel, not one after the other.
J575c, drive, hub, DP monitor on 1-0a, HDMI:

Kernel / tipd probe start renegotiated (1-06 / 1-08 / 1-0a) systemd "Startup finished"
-106 f5fae3c (gate skips), 2 boots 12.69 s none 13.54 s, 13.60 s
-106 with 5b5032b reverted (gate passes) 12.71 s 17.895 / 17.893 / 17.894 s 18.11 s
-106 + this PR, 5 boots not logged 17.90 to 18.92 s 18.59 to 19.88 s
-109 = this head not logged 18.405 / 18.411 / 18.407 s 19.85 s (incl. the fstab mount)
stock -40 (9125b31), 3 boots not logged 17.89 to 17.90 s 18.12 to 18.33 s

So the boot takes 5 to 6 s longer than with the gate skipping, about the same as on the stock kernel, which
renegotiates the same ports.

Evidence (DjDeveloperr blocker 3). Exact head (-109) and the five -106 boots: 0 failed units, 0 AppArmor denials
(AppArmor is in the LSM list, no SELinux). Kernel warnings and errors against boots of the -108 kernel (integration
without this PR): the only new line is one device descriptor read/64, error -71 retry on the hub's keyboard, which
then enumerates. The stock -40 kernel, which renegotiates too, logs the same retry. The PR body has the exact-head
rows now. Not tested: a powered dock, a root or /boot disk on USB-C, a J716c.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formal Pre-PR Checklist Re-Review (§1–§6) — APPROVE

Re-reviewed at verified live head 0d3088096987e69d05fc0fd99b23af0e993da4ee (7robertodantas:j575c-reinit-no-attach-gate → aurora-silicon/linux:integration/aurora). Live CI: Host tests (45164294080) = success; merge state CLEAN.

Verification of Prior Blockers

  1. §3 Safety — live USB-C storage & runtime unbind/bind: Resolved. Confirmed against source (drivers/usb/dwc3/dwc3-apple.c holds DWC3_APPLE_PROBE_PENDING until tipd reports the first connection after cd321x_reset_inherited_connection(); sn201202x_remove() → tipd_remove() → tps6598x_disconnect() disconnects the partner and tears down xHCI before unbind finishes), documented in the commit message, and verified live on J575c at exact head 0d308809 with an fstab-mounted USB 3 drive (renegotiated 18.405 s, Gen 2x1 uas at 19.55 s, mounted 19.85 s; live unbind of 1-06 removes xHCI/drive and shuts ext4 down cleanly within 20 ms before any renegotiation; bind renegotiates in 5.16 s and brings the drive back at Gen 2x1 uas).
  2. §2 Production-ready — boot-time latency: Resolved. Verified sn201202x_driver sets .probe_type = PROBE_PREFER_ASYNCHRONOUS (drivers/usb/typec/tipd/spmi.c:1434), and exact-head J575c dmesg timestamps confirm all three connected ports renegotiate in parallel (1-06 18.405 s, 1-0a 18.407 s, 1-08 18.411 s), giving a total boot time of 18.6–19.9 s matching stock -40 (18.1–18.3 s).
  3. §5 Evidence — exact-head build & regression counts: Resolved. Exact head 0d308809 (rebased on 48470aad, kernel 7.3.0-1-109) built and booted on J575c with the USB 3 drive, fstab mount, DP monitor (1-0a), HDMI, and USB2 hub: restores Gen 2x1 uas (vs 480M usb-storage regression), preserves idle sleep (typec0/2/3 suspended, typec1 DP active), and reports 0 failed units, 0 AppArmor denials, and no new kernel errors beyond the hub keyboard's pre-existing -71 retry (also logged on stock -40). J716c is byte-for-byte unchanged.

Pre-PR Checklist Summary (§1–§6)

  • §1 No model gating: PASS on diff — removes the per-board check_attach_state flag (follow-up noted to move cd321x_inherited_boards[] to DT apple,debug-lock-key).
  • §2 Production-ready, no hacks: PASS — drops the broken 0x7e bit-3 heuristic on default cmdline with verified parallel async probe.
  • §3 Safety: PASS — probe ordering and unbind/bind disconnect behavior verified in code and on hardware with a mounted drive.
  • §4 Clean-room & attribution: PASS — single commit 0d3088096987 has human author/committer (Roberto Dantas), human Signed-off-by: and Fixes: 1a774eeee49a, zero AI trailers in commit.
  • §5 Evidence: PASS — exact-head hardware A/B, live unbind/bind, fstab mount, idle sleep, and regression tuple complete; Host tests green.
  • §6 Naming: PASS.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide
RyanTheTide merged commit 3915250 into aurora-silicon:integration/aurora Nov 23, 2026
1 check passed
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.

3 participants