Skip to content

phy: apple: atc: apply the AXI2AF tunables at probe - #2836

Draft
Ante042 wants to merge 1 commit into
aurora-silicon:mainfrom
Ante042:j314s-atc-axi2af-at-probe
Draft

Ante042 wants to merge 1 commit into
aurora-silicon:mainfrom
Ante042:j314s-atc-axi2af-at-probe

Conversation

@Ante042

@Ante042 Ante042 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What: The AXI2AF bridge in front of each ATC PHY only gets its apple,tunable-axi2af values on the first cable event, and until then it keeps the fabric branch behind the ports from clock gating: about 0.2 W at idle after a boot with nothing plugged in. This writes the tunables at probe, after the PHY reset, and again on resume.
Tested: J314s M1 Pro at edb9b70 (candidate 2596602bfaf6 on main 972a566, plus a test-only commit for the HDMI rows): boots, the same failed units as plain main, all four bridges hold the tunable values from the device tree before any cable event.
Risk: two-way door · every Mac whose ATC PHY uses the T8103-generation path (M1, M1 Pro, Max, Ultra; M2 family); only the J314s has run it.
Not yet: the resume write across a real s2idle sleep with a display attached (see #2835 for what happened to the USB-C display after sleep on the candidate; not known whether it is related); the idle power figure on this base.

Details

It is keyed on the PHY's compatible (the T8103 generation, which the T600x PHYs fall back to) and leaves ports behind a fixed hub alone. apple_tunable_apply() skips registers that already hold the right value, so the resume call does nothing on a bridge that kept its values. The existing write on every mode change stays. The atc-t8132-usb3 selftest compiles atcphy_resume() on its own, so the patch adds a stub for the new helper there.

Moved from omacom/linux-aurora#509.

Evidence
  • Bridge registers read on 2596602bfaf6 right after boot (verify/axi2af-show.py): 13 of 13 tunable registers matching the device tree on each of the four PHYs.
  • Idle power, older local 7.3 tree, screen off, nothing plugged in: 1.21 W with the bridges at reset values, 1.02 W with the same values written from user space. That tree did the writes at every boot from 18/11, through sleeps and through the first plug of a dock and two USB-C displays on ports that had never seen a cable.

Thanks for taking a look!

@RyanTheTide

Copy link
Copy Markdown
Contributor

Review at fe1c51d (non-author, draft). No blocker in the code; the booted row is the missing piece, as you say.

  • Locking holds: both call sites run under guard(mutex)(&atcphy->lock) (atcphy_probe_finalize() and atcphy_resume()), which the new helper asserts.
  • At probe the write comes after atcphy_power_off() / atcphy_setup_pipehandler() and before the fixed-hub atcphy_configure(USB2), so it cannot race a mode change, and apple_tunable_apply() leaves matching registers alone, so the later write in atcphy_apply_tunables() on the first cable event is unchanged.
  • On resume it runs only when the PHY is not runtime-suspended (the early return 0 above it), so it never touches a bridge whose domain is off.
  • Merges cleanly on the current integration/aurora tip; the selftest stub keeps atc-t8132-usb3.py building.

Points to consider:

  • The helper limits the write to ATCPHY_GENERATION_T8103. atcphy_apply_tunables() writes the same axi2af tunables on every generation at the first mode change, so a never-used port on M3/M4 is presumably in the same state. If there is a reason the other generations must wait (the M4 common bank is only acquired at USB3 admission, for example), a sentence saying so in the comment would make the check self-explanatory; if not, writing whenever the DT provides apple,tunable-axi2af (and the port is not behind a fixed hub) would cover every Mac with this block.
  • The commit has no Signed-off-by: yet (you mention it); it needs one before it can land.

Assisted-by: LLM (Claude:Opus 5.5)

@mmdisbrow

Copy link
Copy Markdown
Contributor

Tested #2836 (fe1c51dd3cb0) on an M1 MacBook Air (apple,j313, apple,t8103, macOS 13.5 firmware). Both ATC PHYs probed cleanly with apple,tunable-axi2af present in the live DT and stayed clean across boot and 4 s2idle cycles.

Machine and build

  • Hardware. MacBook Air M1 (apple,j313, apple,t8103).
  • Firmware. asahi,os-fw-version: 13.5, asahi,system-fw-version: 26.6.2.
  • Kernel. Local 7.3.0-tier2-j313-ARCH+ build on integration/aurora (377060f3688a) with this PR's exact diff at fe1c51dd3cb0, plus rtc: apple-pmu: enable T8103 (Sera) PMU RTC and 192-vector nub-spmi interrupt #2714 (29e245e97e7c) and arm64: dts: apple: t8103: enable SIO on every board (needs an M1 tester) #1114 (21e911cb4236), booted in multi-user.target (installed Mesa does not yet support the 7.3 aurora GPU driver).
  • DTB. Built from this tree, with DCP/DCPEXT iommus base_hi set to 0x0f (carried over from the installed m1n1 FDT for this machine's 13.5 DCP firmware) instead of the tree's 0x00. No ATC node changed.
  • Host/build checks on this tree: atc-t8132-usb3 13/13 pass, W=1 0 warnings on the modified objects.

Live J313 probe and s2idle receipts

  • Both ATC PHYs bound to phy-apple-atc at boot and remained bound after 4 s2idle cycles:
    • 383000000.phy -> phy-apple-atc (/soc/phy@383000000/apple,tunable-axi2af: 120 bytes in live DT)
    • 503000000.phy -> phy-apple-atc (/soc/phy@503000000/apple,tunable-axi2af: 120 bytes in live DT)
  • Both Type-C ports enumerated (port0, port1; data_role=host [device], power_role=source [sink], partner=no while unplugged).
  • pm_genpd_summary was byte-identical before and after the 4 s2idle cycles; the 14 atc0_*/atc1_* domains kept their state (usb, usb_aon, pcie, common on; cio, cio_usb, cio_pcie off).
  • J313 is ATCPHY_GENERATION_T8103, so both the probe and the resume writes run on this machine. Without a register read-back this does not answer whether s2idle resets the bridges; it only shows the resume path ran 4 times with no ATC/Type-C errors.
  • Boot log: 0 error-level kernel messages at boot and 0 atcphy, dwc3, tps6598x, or typec error/timeout lines across boot and all 4 s2idle cycles. The only failed unit (omarchy-mac-touchid-activate.service) and the per-resume PS fpwm1 line also appear on 7.2.11 (0 new).

Not tested

  • Direct MMIO read-back of the AXI2AF registers themselves (not read without a debugfs/devmem probe), USB-C host/display hotplug or Thunderbolt tunnels, and an idle-power A/B against a kernel without phy: apple: atc: apply the AXI2AF tunables at probe #2836, so this row says nothing about the ~0.2 W saving.

Assisted-by: LLM (Google:Gemini 4 Neon, Anthropic:Claude Opus 5.5, OpenAI:GPT-6.2 Sol)

@Ante042

Ante042 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

There is no technical reason behind the generation check. T8103 is what the J314s falls back to and the only one I could measure, and I did not want to write to a bridge on M3 or M4 before the first mode change without knowing those blocks: the T8132 has separate USB3 and CIO bridge windows, and as you say the M4 common bank is only acquired at USB3 admission, so I can't tell from here that an early write is safe there.

If you'd rather have it apply whenever the DT provides apple,tunable-axi2af and the port is not behind a fixed hub, I'm happy to change it, but someone with an M3 or M4 would need to boot it. Otherwise I'll put that sentence in the comment so the check explains itself.

@mmdisbrow, thanks for running it on the Air! Good to see both PHYs come up clean through s2idle there. I still owe a booted row on the J314s and the sign-off.

@Ante042
Ante042 force-pushed the j314s-atc-axi2af-at-probe branch 3 times, most recently from 20ceeda to 2bd1d9d Compare November 29, 2026 00:38
The AXI2AF bridge in front of each ATC PHY gets its apple,tunable-axi2af
values in atcphy_apply_tunables(), which only runs on a mode change.  A
port that has not seen a cable since boot keeps the bridge's reset
values, and with those the fabric branch behind the ports does not clock
gate.  On a MacBook Pro 14" M1 Pro (J314s) booted with nothing plugged
in, that costs about 0.2 W at idle with the screen off (1.21 W against
1.02 W), until every port has been used once.

Write the tunables at the end of the probe-time reset, and again on
resume in case the bridge lost them in system sleep.
apple_tunable_apply() leaves a register alone that already holds its
value, so the resume call does nothing on a bridge that kept them.  Only
the T8103 generation is touched, which the t600x PHYs fall back to,
since that is where this was measured.  A port behind a fixed hub keeps
its first write for the first SuperSpeed mode change, as before.

Signed-off-by: Andreas Fernandez <[email protected]>
@Ante042
Ante042 force-pushed the j314s-atc-axi2af-at-probe branch from 2bd1d9d to edb9b70 Compare November 29, 2026 21:56

This branch has not been deployed

No deployments
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.

3 participants