Repository navigation
usb: typec: tipd: cd321x: J714s: SSPS and USBw at a cable change, as macOS does - #2598
Merged
DjDeveloperr merged 2 commits intoNov 20, 2026
Merged
Conversation
This was referenced Nov 20, 2026
Merged
DjDeveloperr
force-pushed
the
djdev/m5-j714s-tipd-macos-cable
branch
from
November 20, 2026 20:14
7070f0e to
600fb72
Compare
…does On the J714s about one deep sleep in ten to fifty, entered some 40 s after a Type-C event on the Dell monitor's port, hung before the commit. Traces of macOS's own sleeps on the J714s show it handles the three port controllers (both USB-C ports and MagSafe) differently at both ends of a sleep. At the entry, before any USB or PHY stop, macOS sends each one: SPMI WAKEUP, a read of SYS_PWR_STATE, DATA1 = 0x03 and 'SSPS', CMD1 read until the command ends (7-12 ms), DATA1 read, and SPMI SLEEP straight after it. No INT_EVENT1 read, no INT_CLEAR1, no LDCM and no LOCK, and nothing more until the wake. At the wake: WAKEUP, INT_EVENT1 read and the same 13 bytes written to INT_CLEAR1 (even when none are set), the status registers read, then SSPS 0x00. Linux sent S3 at the prepare but SLEEP only at the suspend. In between, the 500 ms poll, on system_power_efficient_wq, which the freezer leaves running, kept reading and clearing INT_EVENT1 and reading the status of a controller already in S3; these controllers have no interrupt on the J714s. sn201202x_prepare() also read the liquid detector first and could send LDCM, a command of up to 5 s, which these controllers have been seen to run for over 3 s and then fail with SPMI parity faults and NACKs; right after a replug a measurement can still be running. On the J714s, for a firmware sleep of a polled SN201202x with apple,sleep-ssps and no apple,usb-remote-wake (all three controllers), whose port is last known dry or mitigated (any other enters as before, so its detector reading or mitigation can still refuse the sleep): - prepare: the poll is stopped first (one already running finishes), the prepare neither reads the liquid detector nor sends LDCM, then tipd_prepare() as before (the port's work cancelled, then S3), and SPMI SLEEP right after it under the port lock. A SLEEP that fails is sent again at the suspend, as before; a refused S3 refuses the sleep as before, and the poll is started again. - suspend: nothing more is sent to a controller asleep since the prepare. - resume: WAKEUP as before, then cd321x_wake_events(): INT_EVENT1 read and the same bytes written to INT_CLEAR1, STATUS and DATA_STATUS read; then SSPS S0, which used to wait for the complete. What the poll would have kept of the events is kept (a plug event, a controller found reset, a new DisplayPort status); the resume's revalidation reads the whole port state afresh, as before. - complete: a sleep given up after the prepare, with no resume, wakes the controller there; the poll is started again if no resume did. Linux's own reads around the commands stay (the wake helper's MODE select, the CMD1 busy read before SSPS, the SYS_PWR_STATE check after it, the second WAKEUP of the switch to S0); what goes is the traffic macOS never sends between the entry and the wake. Nothing outside tipd calls into a port controller during a sleep except apple-sleep's debug link cut, which sends its own WAKEUP. A register access that reaches a controller asleep since the prepare all the same is logged with its call stack (the first in a sleep), and the controller is woken for it: before the suspend it then stays awake and the suspend sends SLEEP as before; after the suspend it is put back to sleep after the access. Besides the S3 and S0 commands' own lines, one line per controller at each end of a sleep: sn201202x 1-0a: sleep entry: poll and port work stopped, LDCM skipped (last result 1); S3 at the prepare, 14 ms; SLEEP: 0, 120 us after it; no sleep confirmation on the polled bus sn201202x 1-0a: sleep wake: events 00...00 cleared: 0; status 0x1080b2cd, data status 0x80008571; S0: 0, 12 ms after the WAKEUP; 0 register accesses while asleep /sys/module/sn201202x/parameters/macos_entry (default on, read at each sleep's prepare) switches it; 0 enters and wakes as before. Tested on the J714s (M5 Pro), each sleep a logind deep sleep 40 s after a replug of the Dell's port. Switched in one boot: on, 15 sleeps, 0 hangs; off, 15 sleeps, 1 hang. The hang came once more with this entry on (in the SMC's answer to the AP IDLE message, which a separate RTKit change addresses), so this alone doesn't fix it; it removes the SPMI traffic macOS doesn't send. With the rest of the J714s macOS entry and that change: 22 sleeps, 0 hangs, every device back after each wake. Signed-off-by: Diljit Singh <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
DjDeveloperr
force-pushed
the
djdev/m5-j714s-tipd-macos-cable
branch
from
November 20, 2026 20:28
600fb72 to
07610a4
Compare
…macOS does A trace of macOS on the J714s, while the Dell monitor's port controller (Linux's sn201202x 1-0a) saw its cable go and come back, shows what it sends the controller at a cable change: - 28 ms after the detach: register 0x50 written with 64 bytes, 00 20 and 62 zeros (read back as zeros from 3 ms later; its function is not known); - 60 ms after the detach: SYS_PWR_STATE read (0x00), DATA1 = 0x02 and SSPS; - at the attach, after the events and the status registers: DATA1 = 0x00 and SSPS; - some 530 ms later: SYS_PWR_STATE read twice, DATA1 = 0x00 and USBw. No other 4CC command goes to the controller between the detach and the USBw. Linux sent SSPS only at a sleep's two ends and never USBw on the J714s (no apple,usb-remote-wake), so after a cable change the controller was left as the change left it. On the USB-C ports' SN201202x of the J714s (not MagSafe's, which has no connector and wasn't traced): register 0x50 as macOS writes it, then SSPS 0x02, at a detach while running; SSPS 0x00 at an attach while running, or at the attach after such a detach in any phase but a sleep's or the port's setup and removal (whose own S0 or reset covers it), so a 0x02 is always undone; and USBw 0x00 at the running update after the attach's 500 ms debounce, unless the cable went again before it. Each logs one line. The USBw reads CMD1 with the gaps the sleep's SSPS uses (5 ms): read back to back, a J714s controller's USBw ended late or not within its 1 s limit in one of four attaches. /sys/module/tps6598x_core/parameters/macos_attach (default on) switches it; 0 sends neither, as before. The apple-dcp lifecycle selftests extract cd321x_update_work(); their fixture gets a no-op cd321x_macos_usbw() where the update calls it. Tested on the J714s (M5 Pro) together with the rest of the J714s macOS sleep entry, in 28 logind deep sleeps each entered 40 s after a replug of the Dell's port: every register 0x50 write, SSPS and USBw answered 0. One of those sleeps hung (the SMC's AP IDLE ack, on a tree without the saved lane's log echo) and one woke early; after every other wake every device came back. Signed-off-by: Diljit Singh <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
DjDeveloperr
force-pushed
the
djdev/m5-j714s-tipd-macos-cable
branch
from
November 20, 2026 20:47
07610a4 to
7bfcd5d
Compare
Contributor
|
Thanks, and for listing what changed after the independent review. The same point as on #2597, for this commit's cable-change path. We select behaviour by a hardware property, not by the machines it was tested on. The reason here is the controller's protocol at a cable change, but it is gated on the board:
The controller compatible and the Two smaller things:
We can run no-regression rows on the machines we have once it is keyed on the controller. |
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
J714s (M5 Pro): what macOS sends a port controller at a cable change, from a trace of macOS while the Dell monitor's port saw its cable go and come back.
Depends on #2597. This branch includes its commit; review only the last commit, cd321x: J714s: SSPS and USBw at a cable change.
What changes (every SN201202x on the J714s, only while running, not in a sleep's phases)
00 20+ 62 zeros (as macOS writes it; function unknown), then SSPS 0x02.tipd_usbw_locked(): USBw with CMD1 read at the sleep's SSPS gaps (5 ms). With back-to-back reads a J714s controller's USBw ended late or past its 1 s limit in about one of four attaches.tps6598x_core.macos_attach, default on.Testing (M5 Pro): 28 logind deep sleeps, each 40 s after a replug of the Dell's port. Every register 0x50 write, SSPS and USBw answered 0, and every device came back after each wake.
Review: an independent review found nothing blocking. Fixed from it:
🤖 Generated with Claude Code