Skip to content

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

Open
7robertodantas wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
7robertodantas:j575c-reinit-no-attach-gate
Open

7robertodantas wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
7robertodantas:j575c-reinit-no-attach-gate

Conversation

@7robertodantas

Copy link
Copy Markdown
Contributor

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 this base, 110861f), 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.

Not tested: a J716c (its row has no gate and is unchanged).

cc @DjDeveloperr (5b5032b)

Assisted-by: LLM (Claude:Opus 5.5)

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.

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.

Fixes: 1a774ee ("usb: typec: tipd: renegotiate inherited J575c connections")
Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor

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.

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.

2 participants