Repository navigation
phy: apple: atc: Retry only an owed SuperSpeed port power-on, warn on a failed post-sleep mode - #2409
RyanTheTide wants to merge 2 commits into
Conversation
…owed atcphy_mux_update_to() hands every USB-side failure to atcphy_usb3_port_retry(), also a failure to look up the root hub or to take the port down. When no port was held off, nothing is owed: the retry work only takes the controller, xHCI and root hub locks five times over about three seconds, which waits for any enumeration in progress, and if the lookup keeps failing it ends in "SuperSpeed port left off" for a port that was never off. The same happens for a port held off once its host or root hub is gone (-ENODEV, -ESHUTDOWN): no retry can bring that port back, and the next host powers the ports of its root hubs itself as it starts, where atcphy_usb3_set_mode() drops the debt. Schedule a retry only for a port that is still held off, and not for a host that is gone. What is left is the case the retry was added for: a power-on request to a running root hub that failed for want of memory, a failed runtime resume, or a controller or hub driver not bound yet. Nothing signals when such a request would succeed, so the bounded backoff stays, and each failed power-on is still logged as it happens. Document what is retried and why. Fixes: 5f5dc5f ("phy: apple: atc: Retry a SuperSpeed port power-on that a mux update owes") Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
When atcphy_common_restore() cannot set a USB3 mode up again after a sleep in place, it falls back to USB2 and warns "USB2 for now", saying that the mux update after the wake tries the mode again. That second attempt is atcphy_sleep_ss_up(), which logs its result at debug level only: if it fails too, the port stays at USB2 until the next Type-C event, and the log has nothing beyond the first warning to say so. Warn when atcphy_sleep_ss_up() fails, and say in the fallback's comment and message which path applies the mode again, and that after a power cycle outside a sleep in place only the next Type-C event does. Why the set-up can fail after the sleep is not known yet; that is tracked in #2314. The sleep path is Diljit Singh's, from commit d9b438c ("arm64: apple: support coordinated suspend-to-RAM on T8140"). Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Looks good; approve once the KUnit suite has run and the J700 rear-port row is done. I checked the following and found no blocker.
There are no gates, no new parameters and no register changes. The commits carry a human Signed-off-by with no agent trailers. The body ends with the Assisted-by line. CI host-tests pass. The PR merges cleanly with the current base and with #2403. The combined-kernel row (0 "SuperSpeed port left off" on four Macs) is a regression check only. No Mac in it had a device on the J700 rear port, so the changed paths were not exercised. The new HW row: on this head, run KUnit Assisted-by: LLM (Claude:Opus 5.5) |
|
Folded into #2457, which now carries this PR's commits unchanged (merge commit); review continues there. |
Problem
drivers/phy/apple/atc.cretries the power-on of a fixed-hub controller's SuperSpeed root port that a Type-C mux update still owes (atcphy_usb3_port_retry(), added in 5f5dc5f, "phy: apple: atc: Retry a SuperSpeed port power-on that a mux update owes"). It is reached only on a fixed-hub PHY with the T8140 DisplayPort path, which is the J700 rear port today.atcphy_mux_update_to()hands every USB-side failure to the retry, also a failure to look up the root hub or to take the port down. When no port was held off there is nothing to power on: the retry work still takes the controller, xHCI and root hub locks up to five times over about three seconds, which waits for any enumeration in progress, and if the lookup keeps failing it warns "SuperSpeed port left off" about a port that was never off. The same happens for a port held off once its host or root hub is gone (-ENODEV,-ESHUTDOWN). No retry can bring that port back. The next host powers its root hub ports itself as it starts, andatcphy_usb3_set_mode()drops the debt then.After a sleep in place,
atcphy_common_restore()falls back to USB2 when it cannot set a USB3 mode up again, and warns "USB2 for now". The second attempt that this message promises isatcphy_sleep_ss_up(), which logged its result at debug level only. If that attempt failed as well, the port stayed at USB2 until the next Type-C event, and the log said nothing beyond the first warning.Change
atcphy_usb3_port_retry()now schedules a retry only for a port that is still held off (usb3_port_off), and not after-ENODEVor-ESHUTDOWN. The case the retry was added for is unchanged: a power-on request to a running root hub that failed for want of memory, after a failed runtime resume, or while a controller or hub driver was not bound yet. Nothing signals when such a request would succeed, so the bounded backoff (100 ms doubling, five tries, about 3 s, then a warning) stays. Each failed power-on is still logged byatcphy_usb3_port_on()as it happens. The comment now says what is retried and why.atcphy_sleep_ss_up()warns when applying the mode again fails. The fallback's comment and message name the path that applies the mode again, and say that after a power cycle outside a sleep in place only the next Type-C event does. Why the set-up can fail after a sleep is not known yet. That is tracked in phy: apple: atc: USB3 mode not set up again after a sleep falls back to USB2, cause unknown #2314.Both changes only affect the error paths of the fixed-hub T8140 PHY. On every other ATC PHY
atcphy_usb3_pm_get()returns 0 without a root hub,usb3_port_offis never set, and the retry was not reachable before either. The sleep-in-place path exists only on fixed-hub T8140. No register access changes.The sleep path is Diljit Singh's, from d9b438c ("arm64: apple: support coordinated suspend-to-RAM on T8140").
Testing
atc.o(with the KUnit tests compiled in) at both commits, release config: 0 warnings. checkpatch --strict is clean.atcphy_test_update_port_unowed. With no port held off, a root hub that is not bound yet leaves no retry queued. A held-off port behind such a hub is retried, until the host is gone (-ENODEV). A dead controller that fails the power-on with-ESHUTDOWNqueues no retry. The existing retry cases (-ENOMEMpower-on retried, given up after five tries, host gone) are unchanged.KUnit and build
Objects built against an O= dir prepared from base 0abc2f3 with the release config (
CONFIG_PHY_APPLE_ATC=m,CONFIG_PHY_APPLE_ATC_KUNIT_TEST=y, so the tests are compiled intoatc.o):make ARCH=arm64 LLVM=1 W=1 atc.o, run at each of the two commits. Both builds: rc 0, 0 warnings. checkpatch --strict: 0 errors, 0 warnings, 0 checks on both patches.The KUnit suite was compiled but not run. Running it needs a full arm64 kernel and modules for QEMU, which was not built for this change. Run with:
./tools/testing/kunit/kunit.py run --arch=arm64 --kconfig_add CONFIG_PHY_APPLE_ATC=y --kconfig_add CONFIG_PHY_APPLE_ATC_KUNIT_TEST=y 'phy-apple-atc*'(or loadphy-apple-atc.koon any arm64 kernel with KUnit and read/sys/kernel/debug/kunit/*/results).Still to run
phy-apple-atcon arm64 (command below).On J700 (T8140), with a USB3 device on the rear port:
lsusb -t: the device is at 5000M, anddmesg | grep -c 'SuperSpeed port left off'is 0. It was also expected to be 0 before this change, so the row checks for regressions.rtcwake -m freeze -s 15, then the deep sleep path): after resumelsusb -tshows 5000M again, and the log has neither "not set up again after the sleep" nor "not applied again after the sleep". If either line shows up, it goes to phy: apple: atc: USB3 mode not set up again after a sleep falls back to USB2, cause unknown #2314 with the error code.Hardware rows (combined test kernel, 2026-11-20)
This change was booted in a combined test kernel: integration/aurora 0abc2f3 plus the open gate-sweep drafts plus this and the related drafts (7.3.0-aurora-hk2/pwr1/hk3). It ran once on each lab Mac (M1 Pro J316s, M2 J413, J616s, Neo J700) and was compared against the production kernel on the same Mac, using the same silent row script:
M1 Pro, M2 and J616s matched production on every row, apart from the new counters and lines the drafts add. The Neo row found the old-DTB display regression that #2358's follow-up commit fixes.
This PR: "SuperSpeed port left off" and "not set up again after the sleep": 0 on all four Macs, including after 2 s2idle cycles on J616s, M1 Pro and M2.