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

Hi everyone! This moves omacom/linux-aurora#509 over here, now that kernel work has moved to this repository. It is a small one for the Type-C PHY, found while chasing idle power on my M1 Pro (J314s), and it picked cleanly onto the current integration/aurora (3710668).

The AXI2AF bridge in front of each ATC PHY only gets its apple,tunable-axi2af values on the first cable event. Until a port has seen a cable its bridge sits at its reset values, and that keeps the fabric branch behind the ports (afnc1_lw1) from clock gating. After a boot with nothing plugged in the machine idled at 1.21 W with the screen off. With the same values written to the unused bridges it dropped to 1.02 W, so about 0.2 W is lost just because a port was never used.

The patch writes the AXI2AF tunables at probe, right after the PHY has been reset to its off state, and again on resume. It only does this on the T8103 generation, which the T600x PHYs fall back to, and it 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 as it is.

I want to be upfront about the testing, which is why this is a draft. I have not booted a kernel built from this commit. On this base it builds (kernel and modules on 3710668 with the 7.3.0 edge config, W=1 on drivers/phy/apple with no new warnings) and tools/asahi/run-host-tests.py gives the same result as on the base. The atc-t8132-usb3 selftest compiles atcphy_resume() on its own, so the patch adds a stub for the new helper there. What has run on real hardware is the identical set of register writes done from userspace: my J314s has done them at every boot since the 18th of November, on a local 7.3 kernel, through suspend and resume and through the first plug of a dock and two USB-C displays on ports that had never seen a cable. Everything came up (36 USB devices, both displays, Ethernet, charging and DP audio). That suspend was an out-of-tree suspend-to-RAM setup with a resume hook writing the values again, so I don't know whether s2idle resets the bridges, and the resume call is cheap insurance. Base M1, M2 and the Max chips take the same code path and are untested.

I'm happy to boot this on the J314s and report back before taking it out of draft. Any feedback is very welcome, and thanks for all the work on the ATC driver!

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.

Assisted-by: LLM
@RyanTheTide

Copy link
Copy Markdown

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

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)

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