Repository navigation
usb: typec: tipd: sn201202x: retry waking-controller register select sooner - #3014
Conversation
DjDeveloperr
left a comment
There was a problem hiding this comment.
Adversarial pre-PR checklist (§1–§6) review at 2e4427c52c3f2a2febbfcc1e812dadbcc7a95028: REQUEST_CHANGES (2 blockers; live CI host-tests: FAIL).
Blockers
-
CI failure in
host-tests(apple/sn201202x-transport,tools/testing/selftests/drivers/apple/sn201202x-transport.py:95,157-162)- Live check run
host-testsfailed withAssertionErroratsn201202x-transport.py:162. - Commit
bc4eacb9634dmoved the select-polling implementation (includingerr || val == reg) out ofregmap_sn201202x_select_reg()intosn201202x_select_reg(sdev, reg, timeout_us), leavingregmap_sn201202x_select_reg()as a 1-line wrapper. Becausesn201202x-transport.pystill extracts onlyregmap_sn201202x_select_regand__regmap_sn201202x_read,busy = program.replace("err || val == reg", ...)no longer matches (and the generated C harness also missessn201202x_select_reg,SN201202X_SELECT_TIMEOUT_US,usecs_to_jiffies, andmax). - Fix: Update
tools/testing/selftests/drivers/apple/sn201202x-transport.pyto extractsn201202x_select_regand provide the required stubs/macros sohost-testspasses cleanly.
- Live check run
-
device_enable_async_suspend(&device->dev)breaks DPM ordering assumptions relied on bytipd_usb_wake()andsn201202x_wake_macos()(drivers/usb/typec/tipd/spmi.c:1065,1154-1158,1210-1211)sn201202x_suspend()andsn201202x_resume()explicitly rely on DPM registration order against xHCI without anydevice_linktodwc3-apple/xhci-plat:spmi.c:1210-1211:/* Registered before xHCI, so its root port has suspended by now. */ tipd_usb_wake(tps, true);spmi.c:1154-1158:sn201202x_wake_macos(sn, err);(hands backUSBw 0x80/0x00and restoresSSPS S0) and/* Registered before xHCI, so this is before the root port resumes. */ tipd_usb_wake(tps, false);
- Enabling
device_enable_async_suspend(&device->dev)causesdpm_resume()(drivers/base/power/main.c:1248-1263) to dispatchsn201202x_resume()asynchronously and advance to subsequent devices without waiting forsn201202xto wake the controller, return to S0, and hand back USB2 lines (USBw), and letsdpm_suspend()dispatchsn201202x_suspend()upfront as an async leaf (dpm_leaf_device,main.c:2105). - On firmware-sleep Macs using
apple,usb-remote-wakeorapple,sleep-ssps(sn201202x_wake_macos()), racingUSBwhand-back against xHCI root-port resume risks leaving USB2 devices missing after wake (as documented atspmi.c:1277-1279). - Fix: Establish explicit PM ordering (e.g.,
device_linkto the USB host/root hub) before enabling async suspend, or keep synchronous suspend/resume wheretipd_usb_wake()/macos_sleepordering against xHCI is required.
Checklist audit (§1–§6)
- §1 / §2 / §3 / §4 / §6: No new chip/board/firmware gates; default-cmdline safe; the 5 ms
SN201202X_WAKE_SELECT_TIMEOUT_USshortens the per-attempt select poll timeout within the existing 500 ms wake budget (not a sleep over a race); both commits (bc4eacb9634d,2e4427c52c3f) have human author/committer andSigned-off-by: Satya Benson <satya@benson.earth>only with zero AI commit trailers; PR body includesAssisted-by:. - §5 Evidence (to accompany the fixes above): Current hardware evidence is
pm_test=deviceson a mixed-DTB J775c (no deep sleep, noapple,sleep-ssps/apple,usb-remote-wake). After addressing blockers 1 & 2, please include a real RTCs2idlerow on J775c and a firmware-sleep row on a board exercisingapple,sleep-ssps/apple,usb-remote-wake(e.g., J714s/J713/J700).
Assisted-by: LLM (Gemini 4 Neon)
…sooner While a sleeping SN201202x controller wakes up, a register selection sent before it is ready is never confirmed. sn201202x_wake_poll() called regmap_sn201202x_select_reg(), which waits a full 100 ms per attempt before timing out and letting the wake loop retry; a single early attempt therefore added ~100 ms to every waking controller on resume. Split out sn201202x_select_reg() with an explicit timeout parameter, keep the 100 ms timeout for normal register selections, and use a 5 ms timeout while polling a waking controller so retries happen 20x sooner without changing the overall wake budget. Signed-off-by: Satya Benson <satya@benson.earth>
2e4427c to
430de1f
Compare
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR re-review at 430de1f0096fa8226e5658a43d10643a89fed4d5 (base integration/aurora; live CI host-tests: PASS).
Resolved Since 2e4427c52c3f
- CI
sn201202x-transportfailure: Fixed inf7dc93cbbf5cby updatingtools/testing/selftests/drivers/apple/sn201202x-transport.pyto extractsn201202x_select_regand provide the required macros/stubs. Livehost-testsnow passes, and commit 1 (f7dc93cbbf5c) itself looks clean and well-bounded (bothatomic_us = min(timeout_us, 10ms)andbudget_ms -= 5stay consistent).
Remaining Blockers
-
§2 / §3 Technical Blocker —
device_enable_async_suspend(&device->dev)(drivers/usb/typec/tipd/spmi.c:1065) is unchanged and still breaks DPM ordering against xHCI:sn201202x_suspend()(spmi.c:1185-1186) andsn201202x_resume()(spmi.c:1129-1135) explicitly rely on DPM registration order before xHCI without anydevice_linktodwc3-apple/xhci-plat:spmi.c:1185-1186:/* Registered before xHCI, so its root port has suspended by now. */ tipd_usb_wake(tps, true);spmi.c:1129-1135:sn201202x_wake_macos(sn, err);(hands backUSBw 0x80/0x00and restoresSSPS S0) followed by/* Registered before xHCI, so this is before the root port resumes. */ tipd_usb_wake(tps, false);
- Calling
device_enable_async_suspend(&device->dev)unconditionally breaks both ordering invariants:dpm_suspend()dispatchessn201202x_suspend()upfront as an async leaf (potentially armingtipd_usb_wake(tps, true)before xHCI root ports finish suspending), anddpm_resume()dispatchessn201202x_resume()asynchronously and moves on to xHCI beforesn201202xfinishes waking, restoringS0, and handing back USB2 lines (USBw) — risking missing USB2 devices after wake as documented atspmi.c:1251-1255. - Fix: Establish explicit PM ordering (
device_linkbetween the port controller and its USB host/root hub) before enabling async suspend/resume, or split out / drop commit 2 (430de1f0096f) until explicit PM links are in place.
-
§5 Evidence (to accompany the fix):
- Current hardware evidence is still
pm_test=deviceson a mixed-DTB J775c (and the PR description still cites the old commit SHAsbc4eacb9634d/2e4427c52c3f). Please refresh the PR body SHAs and include a real RTCs2idlerow plus a firmware-sleep row on a board exercisingapple,sleep-ssps/apple,usb-remote-wake(e.g., J714s / J713 / J700) once the async DPM ordering issue is resolved.
- Current hardware evidence is still
§1–§6 Checklist
- §1 No model gating: Pass.
- §2 Production-ready, no hacks / §3 Safety: Request changes — unresolved async DPM ordering race vs xHCI in commit 2 (
430de1f0096f). - §4 Clean-room & attribution: Pass (
f7dc93cbbf5cand430de1f0096fcarry human author/committer andSigned-off-by: Satya Benson <satya@benson.earth>only, zero AI commit trailers; PR body ends withAssisted-by:). - §5 Evidence: Request changes (real
s2idle+ firmware-sleep board row + updated commit SHAs owed). - §6 Naming: Pass.
Assisted-by: LLM (Gemini 4 Neon)
430de1f to
f7dc93c
Compare
|
Gemini 4 Neon on @satchlj's behalf. Addressed the review feedback in
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR re-review at live head f7dc93cbbf5c737b1340c42320a06c92a52b573d (base integration/aurora 5746ef8a5afd, not superseded; MERGEABLE/CLEAN; live CI host-tests PASS).
Resolved Since 430de1f0096f
- Async PM ordering blocker removed: The
device_enable_async_suspend()commit was dropped, leaving only the clean wake-select timeout split (f7dc93cbbf5c). - Code & selftest audit (
drivers/usb/typec/tipd/spmi.c,tools/testing/selftests/drivers/apple/sn201202x-transport.py):sn201202x_select_reg(sdev, reg, timeout_us)cleanly preserves the 100 msSN201202X_SELECT_TIMEOUT_USfor normal regmap reads/writes while givingsn201202x_wake_poll()a 5 msSN201202X_WAKE_SELECT_TIMEOUT_USretry timeout.- Atomic polling clamps via
min_t(unsigned int, timeout_us, SN201202X_ATOMIC_SELECT_MS * 1000)and matchesbudget_ms -= SN201202X_WAKE_SELECT_TIMEOUT_US / 1000; completion waits usemax(1UL, usecs_to_jiffies(timeout_us))(never zero jiffies at anyHZ). - Host transport selftest updated and passing (
6/6 PASS, live CIhost-testsPASS).
- Exact-head §5 hardware verification: PR body refreshed to
f7dc93cbbf5cwithlobata(J775c / T6050,Image.gz5b3848aa..., boot0535fd99, default cmdline): all 4sn201202xcontrollers (0-06,0-08,0-0a,0-0c) bound cleanly and passedpm_test=devicess2idlesuspend/resume (exercisingsn201202x_suspend()/sn201202x_resume()/sn201202x_wake_poll()) with 0 errors, clean health tuple (0 new kernel errors, 0 new failed units, SELinux N/A), and explicit §1 request for full deep-sleep/RTC-wake testing on T6040/T8132/T8142.
§1–§6 Checklist
- §1 No model gating: Pass.
- §2 Production-ready, no hacks: Pass (shortens per-attempt select poll timeout within the existing 500 ms wake budget; default cmdline,
checkpatch --strict0/0/0,W=1clean). - §3 Safety: Pass.
- §4 Clean-room & attribution: Pass (
f7dc93cbbf5ccarries human author/committerSatya Benson <satya@benson.earth>and humanSigned-off-by:only, zero AI commit trailers; PR body ends withAssisted-by:). - §5 Evidence: Pass.
- §6 Naming: Pass.
Assisted-by: LLM (Gemini 4 Neon)
|
f7dc93c J616s (M4 Pro T6040, macOS 26.6.2 fw) PASS: guarded one-shot 7.3.0-aurora-pr2905+ (exact f7dc93c in drivers/usb/typec/tipd/spmi.c, 0-line diff, combined with exact #2905 aa132a2, default cmdline, boot_id=eba6163a, boot-ctxr.bin untouched); all 4 SPMI sn201202x controllers (1-08, 1-0a, 1-0c, 2-0c) bound cleanly; connected USB-C/USB4 peer (thunderbolt 0-1, 20.0 Gb/s x 2 lanes) and port0..port3 Type-C roles intact before and after 2x real rtc1 s2idle wakes (suspend_stats success=2 fail=0); tipd_errs=0; eDP-1 connected, Borealis gpubench-vk + gpubench-gl (render.postfx 1080p 2080 fps, crc=2133faaa valid=true) ok; 0 GPU faults, 0 failed units, Enforcing + 0 AVC; restored and verified 7.3.0-aurora-fleet89. |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Summary
While a sleeping SN201202x USB-PD controller is waking up, a register selection sent before it is awake is never confirmed.
sn201202x_wake_poll()calledregmap_sn201202x_select_reg(), which waited a full 100 ms per attempt before timing out and letting the wake loop retry.Split out
sn201202x_select_reg()with an explicittimeout_usparameter:SN201202X_SELECT_TIMEOUT_US(100 ms) timeout viaregmap_sn201202x_select_reg().sn201202x_wake_poll()passesSN201202X_WAKE_SELECT_TIMEOUT_US(5 ms), clamps atomic polled selects withmin_t(unsigned int, timeout_us, SN201202X_ATOMIC_SELECT_MS * 1000), usesmax(1UL, usecs_to_jiffies(timeout_us))for completion waits, and accountsbudget_ms -= SN201202X_WAKE_SELECT_TIMEOUT_US / 1000.tools/testing/selftests/drivers/apple/sn201202x-transport.pyto match the split helper.(Note: the earlier async PM commit was dropped per review because
device_enable_async_suspend()without explicitdevice_link/ dependency audit risks racing Type-C consumers.)Verification
scripts/checkpatch.pl --strict --git origin/integration/aurora..HEAD— 0 errors, 0 warnings, 0 checks;W=1arm64 build (drivers/usb/typec/tipd/spmi.o) — 0 new warnings.python3 tools/testing/selftests/drivers/apple/sn201202x-transport.py— 6/6 PASS.lobata(Mac Studio M5 Max / J775c / T6050):origin/integration/aurora(160ca431b325) + exact PR headf7dc93cbbf5c,Image.gzSHA-2565b3848aaf84041154d36e3268d904db95a9a176398d78c1a01730a6cd8c9b7dc, paired with J775c DTB0442bec28ef4c650d4e3395589f7001808c7e5b4a3bdd4971fc466d68f9de0ed, default kernel cmdline (rdinit=/init nr_cpus=18 maxcpus=18 root=UUID=3da7492b-6c5e-4e84-9eac-65b89fae44c6 arm64.nomte),boot_id:0535fd99-4dca-412e-b2ca-a4042e37cd4c.0-06,0-08,0-0a,0-0c) bound cleanly (with0-0ccleanly left inDBMadebug mode) and completed a full device-PMs2idlesuspend/resume cycle (pm_test=devices,echo freeze > /sys/power/state,124.395 s -> 132.080 s;/dev/rtc0is unavailable on this mixed DTB becausemacsmc-rtcdefers on baselineapple-spmiGen4-95) with 0sn201202xwarnings or errors.-SELINUX); 0 new failed systemd units (pre-existingac-power-mode.service); 0 newdmesg -l err,crit,alert,emerglines beyond the 4 pre-existing baseline lines (apple-spmi-95,apple_aop-61,apple-dcpx2).