Repository navigation
phy: apple: t6040: Count the coprocessor hard recoveries in debugfs - #2410
Conversation
A PHY coprocessor that does not acknowledge Power Down on detach, does not stop cleanly or does not tune the PHY on attach has its common_dp and phymxwrap domains power-cycled, and the USB3 or CIO bring-up is tried once more. Each step is logged, but the retry turns a wedged coprocessor into a working port, so how often it happens can only be told by reading back through the kernel log, and why the coprocessor wedges is not known yet. Keep the recovery and the single retry, and count them: hard recoveries started, bring-ups tried again and bring-ups that failed with no retry left, read-only in the PHY's existing debugfs directory next to drop_next_power_down_ack. Document why the retry is there and link the issue that tracks the cause: #2315. Signed-off-by: Ryan Murray <[email protected]>
|
Blockers: 1.
Otherwise sound. I checked that every counter write happens under Not this PR: HW row: J616s on this head. Run the KUnit suite Assisted-by: LLM (Claude:Opus 5.5) |
The recovery counters only saw a failed bring-up when the firmware tune failed with no retry left. A hard recovery that itself fails (phymxwrap does not power off, the RTKit transport does not restart, common_dp does not resume) and a wake that fails both leave the bring-up before t6040_recovery_retry() is reached, so hard_recoveries went up and nothing else did. Those are the cases that leave the port without USB3 or CIO, and in debugfs they looked the same as a recovery that worked. Count every bring-up that ends in "USB3 PHY bring-up failed" or "CIO PHY bring-up failed" at the two labels all those paths reach, and show it as bringup_failures next to the other counters. bringup_retries_exhausted keeps its meaning and is the part of the failures that had used the retry. Cover a failed power cycle in the KUnit suite: it counts as a failure, not as a retry or an exhausted one, and the next bring-up still power-cycles. Link: #2315 Signed-off-by: Ryan Murray <[email protected]>
|
Review blocker fixed in 15782d9: every bring-up that ends in "USB3 PHY bring-up failed" or "CIO PHY bring-up failed" (failed hard recovery, failed wake via Testing: t6040-usb2.c compiles warning-free with the KUnit test enabled; the recovery state machine + KUnit cases run on the host via a shim: 4/4 ok, and a mutant without the count fails 2/4; |
Signed-off-by: Ryan Murray <[email protected]>
There was a problem hiding this comment.
Verdict: FINISH at 62cf9b5
- The four
debugfs_create_u32()readers int6040_debugfs_init()use the generic plain load withouttphy->lock, while recovery writers update the same fields under that mutex. A read during recovery races with the write. Use synchronized access on both sides, such as read-only getters that take the PHY mutex or atomic counters. bringup_failuresis documented instruct t6040_recovery_stateas counting all failed bring-ups. Int6040_cio_up_locked(),pm_runtime_resume_and_get()can fail after orientation and mode checks, yet it returns before the counter. Count that failure without dropping an unacquired PM reference, or document and test the narrower lifetime of the count.
I traced the USB3 and CIO retry, exhaustion, and early return paths. The DTS and bindings are unchanged. The J616s zero-count row covers idle exposure. Please run the recovery suite and confirm a nonzero readback in the next validation.
…d resume The four recovery counts were plain u32s exposed with debugfs_create_u32(), whose reader loads them without tphy->lock while a recovery updates them under it. Make them atomic_t and expose them with debugfs_create_atomic_t(). bringup_failures is documented as every failed bring-up, but t6040_cio_up_locked() returned before counting when pm_runtime_resume_and_get() failed. Count that failure too. No runtime reference was taken, so nothing is put. The recovery KUnit cases now read the counts with atomic_read(). Reported by the aurora-silicon review of #2410. Signed-off-by: Ryan Murray <[email protected]>
|
Fixed in 571f175, per the review at 62cf9b5:
|
There was a problem hiding this comment.
Verdict: MERGE at 571f175 after hosted checks and nonzero hardware readback.
Checked: all four debugfs files now read atomics, and every update uses atomic_inc(). Failed CIO runtime resume increments the failure counter and returns before the reference-release path. Reviewed the retry and exhaustion assertions, the posted recovery KUnit results, and the prior J616s zero-count boot. DT sources and bindings are unchanged.
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
What: Count the T6040/T6041 USB2 PHY coprocessor hard recoveries (started, bring-ups retried, bring-ups failed with no retry left) and show them read-only in debugfs. The recovery itself is unchanged.
Tested: J616s (M4 Pro, T6040) at 15782d9 in the combined one-shot kernel 7.3.0-aurora-dsw2 (main 2a173ca + 15 drafts; this PR's files byte-identical to head 62cf9b5 = 15782d9 + a clean merge of main):
hard_recoveries= 0 on all three T6040 PHYs (t6040-atcphy-382a90000/38aa90000/392a90000.phy), USB root hubs up, 0 error-level lines, 0 WARN/BUG, s2idle rc 0 (only the baseline dwc3genpd_prepare -11lines the fleet kernel's own s2idle shows too), 0 failed units. M1 Pro, J473 and J713 (no T6040 PHY) boot the same kernel unchanged.Risk: two-way · T6040, T6041 (debugfs counters only)
Not yet: a boot where a recovery actually runs (non-zero counter); none happened in this row
Evidence
grub2-reboot, no Stage 2, DTB or boot.bin change (boot.bin 3fe02289 before and after). The J616s went back to the saved fleet89, the test kernel was removed, and production state was verified: next_entry empty, Enforcing, 0 failed units.Original description
Problem
drivers/phy/apple/t6040-usb2.c(T6040/T6041) recovers a PHY coprocessor that did not acknowledge Power Down on detach, did not stop cleanly, or did not tune the PHY on attach. It power-cycles thecommon_dpandphymxwrapdomains and tries the USB3 or CIO bring-up once more (T6040_RECOVERY_RETRIES, from 249746e, "phy: apple: t6040: hard-recover a wedged coprocessor"). Each step is logged. But the retry turns a wedged coprocessor into a working port, so the only way to tell how often this happens is to read back through the kernel log. Why the coprocessor wedges is not known (#2315).Change
The recovery and its single retry stay as they are, and are now counted.
struct t6040_recovery_statecounts hard recoveries started, bring-ups tried again, and bring-ups that failed with no retry left. These appear read-only ashard_recoveries,bringup_retriesandbringup_retries_exhaustedin the PHY's existing debugfs directory (/sys/kernel/debug/t6040-atcphy-<dev>/), next todrop_next_power_down_ack. A comment atT6040_RECOVERY_RETRIESsays why the retry is there and links #2315.The counters are updated under the PHY lock on paths that already run, so there is no behaviour change on any port. The driver binds only on T6040/T6041.
The PHY driver is the work of Jonathan Goyvaerts, František Balázsy, CJ Damsleth, Jos Dehaes and AxxzyWasTaken, and the recovery is from 249746e.
Testing
t6040-usb2.o(with the KUnit tests compiled in), release config: 0 warnings. checkpatch --strict is clean.phy-apple-t6040-recoveryextended (compiled, not run, see below): the retry and exhaustion counts, and that they outlive the bring-up they were taken in.KUnit and build
Objects built against an O= dir prepared from base 0abc2f3 with the release config (
CONFIG_PHY_APPLE_T6040_USB2=m,CONFIG_PHY_APPLE_T6040_KUNIT_TEST=y, so the tests are compiled intot6040-usb2.o):make ARCH=arm64 LLVM=1 W=1 t6040-usb2.o: rc 0, 0 warnings. checkpatch --strict: 0 errors, 0 warnings, 0 checks.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_T6040_USB2=y --kconfig_add CONFIG_PHY_APPLE_T6040_KUNIT_TEST=y phy-apple-t6040-recovery(or loadphy-apple-t6040-usb2.koon any arm64 kernel with KUnit and read/sys/kernel/debug/kunit/*/results).Still to run
phy-apple-t6040-recoveryon arm64 (command below).On J616s (T6040):
cat /sys/kernel/debug/t6040-atcphy-*/{hard_recoveries,bringup_retries,bringup_retries_exhausted}reads0 0 0with no missed acknowledgement in the log.echo 1 > /sys/kernel/debug/t6040-atcphy-<dev>/drop_next_power_down_ack, then unplug and replug a USB3 device (or, without a person at the machine, unbind and bind the port's dwc3-apple controller, which powers the USB3 PHY off and on):hard_recoveriesreads 1, the device comes back at 5000M (lsusb -t), and the log shows "completed hard recovery".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: J616s: hard_recoveries / bringup_retries / bringup_retries_exhausted read 0/0/0 on all three PHYs after boot and after 2 s2idle cycles.