Skip to content

soc: apple: t6041-sleep: restore GP PCIe ports 2/3 and display clusters - #3421

Merged
RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
7robertodantas:t6041-sleep-gp-ports-disp-clusters
Dec 1, 2026
Merged

RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
7robertodantas:t6041-sleep-gp-ports-disp-clusters

Conversation

@7robertodantas

@7robertodantas 7robertodantas commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What: Update drivers/soc/apple/t6041-sleep.c to save and restore optional GP PCIe ports 2/3 (when described and set up) and display cluster registers +0x0c (DISP_INT) and +0x10 (DISP_EXT, backing DISPEXT_RAIL_V) across T6041 deep sleep.

Tested: J575c (Mac Studio M4 Max, T6041) at 3cfb4d073b7c: standalone boot of 7.3.0-1-132-ARCH with unmodified head DTB, default Arch cmdline, and stock aura (HDMI-A-1 and DP-2 active at 2560x1440, 0 failed units, 0 new kernel warnings/errors, s2idle 1/1 via rtc0 with unchanged boot_id); checkpatch --strict 0/0/0, LLVM=1 W=1 t6041-sleep.o 0 warnings.

Risk: two-way door · T6041 (J575c, J614c, J616c). Boards without port2/port3 in DT keep gp_port[2..3] NULL and restore only active ports 0/1; display cluster restore only writes non-zero pre-sleep low nibbles back to +0x0c/+0x10.

Not yet: a J614c/J616c peer deep-sleep run; live hardware deep-sleep commit/wake on J575c at this standalone commit (unmodified t6041-j575c.dts does not yet wire &t6041_sleep — deep-sleep DT enablement is a separate follow-up PR; the same t6041-sleep.c changes were previously exercised across 6/6 J575c deep-sleep cycles in a combined development tree).

Details
  • GP PCIe ports 2/3: T6041 desktops (J575c) expose GP PCIe ports 2 and 3 in apple,apcie in addition to ports 0 and 1. Expand gp_port[]/gp_phy[] and saved state arrays from 2 to T6041_GP_PORTS (4), map optional port2/port3 and phy2/phy3 silently via t6041_apcie_block() while keeping port0/port1 and phy0/phy1 required for apcie_ready, track active ports (gp_phy_pre[i] & BIT(0)) in gp_up during t6041_save(), and restore clocks in t6041_gp_pcie_clk() only for ports set in gp_up.
  • Display cluster wake restore: T6041 sleep commit powers down s->cluster + 0x0c (DISP_INT) and +0x10 (DISP_EXT, backing DISPEXT_RAIL_V), while t6041_sleep_return() previously restored only CPU clusters +0x0, +0x4, and +0x8. Save +0x0c and +0x10 into pre_disp_cluster[2] in t6041_save() and restore their low nibble when non-zero in t6041_sleep_return().
Evidence
Check Scope / head Result
scripts/checkpatch.pl --strict --no-tree 3cfb4d073b7c PASS (0 errors, 0 warnings, 0 checks)
LLVM=1 W=1 drivers/soc/apple/t6041-sleep.o 3cfb4d073b7c PASS (0 warnings)
Full arm64 Image + modules + dtbs (7.3.0-1-132-ARCH) 3cfb4d073b7c PASS (43 warnings = baseline)
Standalone boot on J575c (7.3.0-1-132-ARCH, unmodified head DTB, default Arch cmdline, stock aura) 3cfb4d073b7c PASS (HDMI-A-1 + DP-2 active 2560x1440, 0 failed units, 0 new warnings/errors, s2idle 1/1 via rtc0 same boot_id)

T6041 desktops (J575c) expose GP PCIe ports 2 and 3 in addition to ports
0 and 1, and T6041 sleep commit powers down cluster +0x0c (DISP_INT) and
+0x10 (DISP_EXT, backing DISPEXT_RAIL_V).

Map optional port2/port3 and phy2/phy3 windows from apple,apcie while
keeping ports 0/1 required, track which mapped GP ports had refclk
requested (BIT(0)) before sleep, and restore clocks only for those active
ports on wake.

Save cluster +0x0c and +0x10 in t6041_save() and restore their low nibble
on wake in t6041_sleep_return() when non-zero before sleep.

Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
@7robertodantas
7robertodantas requested review from a team as code owners November 27, 2026 17:59
@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at 12de58f8: not ready yet

Check Detail
CI at head no failing: apple-build, KUnit ane-boot, rust-build, KUnit ane-pm, KUnit dcp-fabric, KUnit dcp-topology
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 12de58f8
Conflicts ok none
PR text ok Risk: two-way · T6041 (J575c, J614c, J616c). Boards without port2/port3 in DT keep gpport[2..3] NULL and restore only active ports 0/1; display cluster restore only writes non-zero pre-sleep low nibbles back to +0x0c/+0x10.

Areas: area:platform

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks right at 3cfb4d07. One hardware row is still needed before merge, on a Mac that runs this driver. Thanks for working on this.

Missing row: t6041-sleep is enabled only on the M4 Max MacBook Pros: &t6041_sleep { status = "okay"; } is in t6041-j614c-j616c.dtsi. t6041-j575c.dts doesn't enable it, so the J575c s2idle run doesn't execute any changed line. On those laptops pcie0 already lists port2/port3 and phy2/phy3 in reg-names, so both changes run there:

  • the driver now maps ports 2 and 3;
  • gp_up decides which ports get their clocks back;
  • the +0x0c/+0x10 cluster words are written on wake.

What's needed is one deep-sleep cycle (commit and wake) on a J614c or J616c at this head, with 0 SErrors/DART faults and PCIe (Wi-Fi, SD reader) back after wake. If you have one of those, that settles it. If not, we'll ask for it from a Mac that has one, so it isn't on you.

Nit, not blocking: the comment on t6041_ave_off() calls +0xc and +0x10 "the two AVE complexes", while the new comment in t6041_sleep_return() calls them DISP_INT and DISP_EXT (DISPEXT_RAIL_V). Whichever is right, it would help if the two comments agreed.

What I checked
  • Ports 0/1: they stay required for apcie_ready and gp_saved. Missing port2/port3 stay NULL silently: t6041_map_name() returns an error pointer that t6041_apcie_block() turns into NULL.
  • Which ports are restored: gp_up comes from the pre-sleep PHY REFCLK0REQ bit. pcie-apple sets it only on ports it sets up, and on the laptops that is ports 0 and 1, so their restore is unchanged there.
  • Cluster words: t6041_save() runs before t6041_ave_off() in t6041_sleep_commit(), so pre_disp_cluster[] holds the boot-time state. The restore writes back only non-zero low nibbles and keeps the upper bits it reads.
  • Base: nothing on main since cec0503a touches t6041-sleep.c.

@7robertodantas

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing @DjDeveloperr.

I only have the J575c Studio (no J614c or J616c), so I can't run the laptop S2R row here — routing that to a J614c/J616c tester would be appreciated.

On the comment nit: in the J575c ADT (soc-clusters / pmgr), cluster slots 3 and 4 at +0x0c and +0x10 are DISP_INT and DISP_EXT (backing DISPEXT_RAIL_V), so t6041_ave_off()'s existing comment looks outdated. Happy to leave it for a follow-up to avoid churning 3cfb4d07, or amend t6041_ave_off()'s comment here if you'd prefer it aligned in this PR.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train review at 3cfb4d07: Verdict: merge after CI + the J575c row at this head. Checked: ports 0/1 stay required for gp_saved, and ports 2/3 are mapped and restored only when the apple,apcie node describes them. The restore now runs only for ports whose PHY refclk bit was set before the sleep (gp_up). This also stops the unconditional clock restore of a port 0/1 that was never brought up, which is correct but is a behaviour change on the J575c, so the row should cover a wake with port 0/1 both up and idle. The DISP_INT/DISP_EXT cluster restore writes back only a non-zero saved low nibble and keeps the other bits. It's T6041-only, with no gates. No blocking finding.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 3cfb4d07 pending a deep-sleep row with the changed driver bound.

Blockers: Keep Dj's J614c or J616c request. Confirm deep-sleep commit and wake, resumed Wi-Fi and SD reader, and zero new SError or DART faults. The author has a J575c, so the requested row remains with a laptop tester.

Checked: The head is unchanged since Dj's source review. GP ports 0 and 1 stay required; newly mapped ports 2 and 3 remain conditional on the DT, and restoration is gated by the saved refclk state. The J575c s2idle result exercises a separate path because its DT leaves this driver disabled.

Evidence

Existing exact-head review: #3421 (review)

@RyanTheTide

Copy link
Copy Markdown
Contributor

@7robertodantas: the DT half you mentioned as a follow-up is up as #3626. It turns the T6041 sleep node on at the SoC (no more "not qualified" board gate) and gives the J575c apple,apcie = <&pcie0> + apple,atc-phys = atcphy0..3, like the J614c/J616c. It's meant to land after this PR.

If you have time on your J575c, could you run a deep-sleep row with this PR + #3626 together (e.g. #3626's commit 09a077c on top of 3cfb4d0)?

  • one-shot boot, then cat /sys/power/mem_sleep (expect [deep])
  • deep s2r x3 with RTC wake (rtcwake -m mem -s 30)
  • after each wake: HDMI + a USB-C display, Ethernet (port 2) link, SD reader / ASM3142 (port 3) devices, Wi-Fi/BT, USB
  • dmesg refusals/errors, if any

If your combined 6/6 tree wired anything else into &t6041_sleep on the J575c (or needed the SEP from #3276), please say so and I'll add it to #3626. Neither PR merges before your row.

@7robertodantas

Copy link
Copy Markdown
Contributor Author

@RyanTheTide here is the J575c row with #3421 + #3626 together, on current main.

Tested: Mac Studio J575c (M4 Max). Tree = main 498d53fd + 3cfb4d07 (#3421) + 09a077c3 (#3626), both applied cleanly. Kernel 7.3.0-1-134-ARCH and its unmodified J575c DTB, aura 1.0.0b17-g1f77cab4 (aura main), default cmdline, one-shot boot.

Result: no deep sleep, by design of the driver. The J575c stays on s2idle, and s2idle still works.

  • The DTB has the sleep node enabled with apple,apcie = <&pcie0> and the four atcphys. But the J575c &pcie0 only has config, rc, port0-3, phy0-3, so the probe stops at t6041_map_apcie():
    t6041-sleep 508304000.sleep-controller: 32 memory channels
    t6041-sleep 508304000.sleep-controller: no PCIe tunables for ANS: no deep sleep
    
  • cat /sys/power/mem_sleep gives [s2idle] (no deep); echo deep > /sys/power/mem_sleep gives EINVAL.
  • rtcwake -m mem -s 30 x3: PM: suspend entry (s2idle) / PM: suspend exit each time, suspend_stats 3/0. After each wake: the HDMI and USB-C DRM connectors still connected (not checked by eye), Ethernet (port 2) link up, lspci unchanged (9 entries: BCM4388 Wi-Fi + BT, GL9755 SD reader, AQC113, ASM3142 and the bridges), hci0 and phy0 present, 12 USB devices. 0 refusals, 0 WARNs, 0 SErrors, 0 DART faults. soc: apple: t6041-sleep: restore GP PCIe ports 2/3 and display clusters #3421's code doesn't run, since the driver doesn't bind.
  • Side note for the command: on this kernel rtc0 is macsmc-rtc (no alarm) and the PMU RTC is rtc1, so a plain rtcwake -m mem fails with "rtc0 not enabled for wakeup events". I used -d rtc1.

So #3626 is safe to land on the J575c as it is (no regression, s2idle unchanged), but it doesn't turn deep sleep on. To answer your question: yes, the 6/6 tree wired more than &t6041_sleep. Against main 498d53fd, the J575c still needs:

DT:

  • &pcie0: the axi2af, cio3pll, clkgen, phy-block and phy-ip windows, same addresses as the J614c/J616c. This is what the probe above is missing.
  • &smc: apple,sleep-pmvc = <0x101>, without apple,sleep-wake-type. The J575c SMC has no WKTP key: PM_TEST=core failed with Failed to write WKTP = 2: -5 until I dropped it.
  • apple,sleep-ssps on hpm0-hpm3 (the J575c version of arm64: dts: apple: t6041-j616c: system power state for the port controllers #2174).
  • dcp_power (apple,t6041-display-power, chains ext3/ext2/ext1/ext0/main), and on &dcp: apple,sleep-host-stop, apple,display-power = <&dcp_power>, clocks = <&clk_disp0>. The J575c has no panel, and aura#546 hands the internal DCP over as the sleep host when the property is there.
  • The SEP (arm64: dts: apple: t6041-j575c: enable the SEP, without Touch ID #3276). This one is required. With no enclave registered, apple_sleep_enclave_stop_all() returns 0 and the commit goes ahead with the SEP awake: my first runs without it hung the Mac in the commit.

Driver (not on main):

One thing on ordering: please don't add the &pcie0 windows to #3626 on their own. They are what turns deep sleep on for the J575c, and without the SEP and the DCP sleep host a suspend is either refused (the displays are still up) or commits with the SEP awake, which hung my first runs. As it is, #3626 is a no-op on the J575c and can land after #3421 whenever you like. I'll send the rest as J575c PRs: the DCP sleep host + external restart stacked on #3421, then one DT PR with the windows, sleep-pmvc, sleep-ssps, dcp_power and the &dcp properties, depending on #3276. That last PR gets the full deep-sleep x3 row at its exact head.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@7robertodantas: thank you, that's a thorough row and exactly the information that was missing.

  • Agreed on ordering. arm64: dts: apple: t6041: enable deep sleep on every board, J575c too #3626 stays as it is: a no-op on the J575c (the driver doesn't bind, s2idle unchanged), landing after this PR. I won't add the &pcie0 windows or anything else J575c-specific to it. Your follow-ups (DCP sleep host + external restart on this PR, then the DT PR on arm64: dts: apple: t6041-j575c: enable the SEP, without Touch ID #3276 with the full deep x3 row at its exact head) own deep sleep on the Studio. I've updated arm64: dts: apple: t6041: enable deep sleep on every board, J575c too #3626's body to say so.
  • Your SEP finding is a real hazard worth closing in the driver too, not only by DT ordering. If an enabled SEP node never registers its enclave, apple_sleep_enclave_stop_all() returns 0 and t6041-sleep commits with the enclave awake (your hang). T8132's path refuses that case (refused: SEP has no prepared irreversible sleep request). Would you add the same refusal to t6041-sleep in your sleep-host PR? That is: refuse at prepare when the DT has an available apple,sep node but no enclave is registered. Then a board whose SEP DT lands late, or whose SEP probe fails, can't commit and hang. If you'd rather keep your PR focused, say so and I'll send it as a small separate PR.
  • Thanks for the rtcwake -d rtc1 note; my request should have said it.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@7robertodantas: we picked up your j575c-deep-sleep branch so the Studio's deep sleep can land as one series: #3666 (head 4d830b9). It carries your 11 commits unchanged, with your authorship and sign-off, on top of this PR, #3276 and #3626. One commit of ours is added last: t6041-sleep now refuses deep sleep when no SEP has registered its sleep request, so the "commit with the SEP awake" hang you hit becomes a clean refusal. Builds (W=1), DTB checks and dcpext26-retrain-tests.py all pass. The tree is byte-identical to your branch merged with the three PRs, plus the guard.

If you have time, could you run the deep-sleep row at #3666's exact head? Deep x3 with rtcwake -d rtc1 -m mem -s 30, and after each wake HDMI + a USB-C display, Ethernet, SD, ASM3142, Wi-Fi/BT and USB. A one-line check of the guard would also help: one deep attempt with apple_sep unloaded or blacklisted should now print refused: no SEP has a sleep request ready and stay up. Results on #3666 please. If you'd rather open your own PRs instead, tell us and we'll close #3666 in their favour. Thanks for all of this.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 30, 2026
The T6041 sleep commit powers down the GP PCIe domains (apcie_phy_sw,
apcie_sys_gp, apcie_gp) with the active links still up: no L2 entry and
no PERST# before the power goes. The wake's GPIO restore then releases
PERST# before the refclk is back. An endpoint that keeps its own power
across the sleep sees both, like the J575c's 10 GbE controller on
port 2, which pcie-apple notes is sensitive to PERST# released without
its clock.

Stop each active GP port in the commit path right after t6041_save(),
in sleep-t6040.h's order: link interrupt masked, PME_Turn_Off to L2,
PERST# asserted at its pin, 1 ms hold, PORT_PERST cleared under its
guard bit, PHY and application clocks off. Record the asserted PERST#
in gpio_pre so that the wake's t6041_gpio_restore() keeps the endpoint
in reset until pcie-apple has set up its refclk and releases it, and
leave refclk gating bit 31 clear on stopped ports in
t6041_gp_pcie_clk().

On the J575c the controller on port 2 was lost on 4 of about 55 deep
sleep wakes before, and on 2 of about 130 with this; it still happens
and needs a restart (tracked separately).

Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
@7robertodantas

Copy link
Copy Markdown
Contributor Author

New commit 12de58f865e5: the T6041 commit now stops each active GP port before the power goes (PME_Turn_Off to L2, PERST# asserted at its pin, PORT_PERST cleared, PHY and app clocks off), in sleep-t6040.h's order, and the wake's pin restore keeps PERST# asserted until pcie-apple has the refclk back. On the J575c, the 10 GbE controller on port 2 was lost on 4 of ~55 deep-sleep wakes without it and 2 of ~130 with it; the rest is tracked in #3694. Row with #3653 at this head: deep x3 pass (see #3653). Standalone row at this head: next.

@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Nov 30, 2026
@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 30, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 12de58f8

Blockers:

  • Hosted pull_request CI workflows (Apple build and KUnit, Host tests, SEP source checks, pr-text) are all action_required awaiting maintainer workflow approval for this fork PR.
  • Standalone hardware boot row at head 12de58f8 on J575c is pending (noted as next in the latest comment; the PR body's standalone row is still from 3cfb4d07).

Checked:

  • GP PCIe port stop (t6041_gp_ports_stop()): follows the sleep-t6040.h sequence (mask/clear link interrupts, disable appclk CG, APCIE_PORT_L2_ENTER poll, assert endpoint PERST# GPIO and save asserted level into gpio_pre when not skipped so wake's GPIO restore never deasserts PERST# ahead of refclk, clear APCIE_PHY_LINK, hold 1 ms, clear APCIE_PORT_PERST under PERST_GUARD, drop PHY enables/reset/clocks and port appclk).
  • GPIO bounds & wake clock restore (t6041_map_apcie(), t6041_gp_pcie_clk()): gp_perst[] initializes to -1 and is populated only when args.np == pin_np and args.args[0] < s->npins, guaranteeing s->gpio and s->gpio_pre bounds. Wake restore handles active ports 0..3 via gp_up and skips setting APCIE_PHY_LINK when gp_perst[i] >= 0 so pcie-apple brings the link back cleanly after PERST# release.
  • Display cluster restore (pre_disp_cluster[2]): saves +0x0c (DISP_INT) and +0x10 (DISP_EXT) and restores only non-zero low nibbles on wake.
  • Combined-tree validation: deep x3 pass on J575c with #3653 at 12de58f8, and 10 GbE wake-loss rate dropped from 4/~55 to 2/~130.
Evidence
  • Diff scope: +180/-17 in drivers/soc/apple/t6041-sleep.c only; no defects found in the new 12de58f8 port-stop logic.
  • Ready condition: Upgradeable to APPROVE once hosted fork CI runs green and the standalone 12de58f8 boot row is posted.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 12de58f865e5

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: - GP PCIe port stop (t6041_gp_ports_stop()): follows the sleep-t6040.h sequence (mask/clear link interrupts, disable appclk CG, APCIE_PORT_L2_ENTER poll, assert endpoint PERST# GPIO and save asserted level into gpio_pre when not skipped so wake's GPIO restore never deasserts PERST# ahead of refclk, clear APCIE_PHY_LINK, hold 1 ms, clear APCIE_PORT_PERST under PERST_GUARD, drop PHY enables/reset/clocks and port appclk).

  • GPIO bounds & wake clock restore (t6041_map_apcie(), t6041_gp_pcie_clk()): gp_perst[] initializes to -1 and is populated only when args.np == pin_np and args.args[0] < s->npins, guaranteeing s->gpio and s->gpio_pre bounds. Wake restore handles active ports 0..3 via gp_up and skips setting APCIE_PHY_LINK when gp_perst[i] >= 0 so pcie-apple brings the link back cleanly after PERST# release.
  • Display cluster restore (pre_disp_cluster[2]): saves +0x0c (DISP_INT) and +0x10 (DISP_EXT) and restores only non-zero low nibbles on wake.
  • Combined-tree validation: deep x3 pass on J575c with #3653 at 12de58f8, and 10 GbE wake-loss rate dropped from 4/~55 to 2/~130.

Follow-ups (not blocking): fork CI approval; standalone J575c boot row

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 1, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 12de58f865e5 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: the hardware row at 12de58f that the readiness check found (PR body or comment). CI: linux train L4 = main (after L3) + 34 approved PRs (#3419 dropped: conflicts): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit ane-boot/clpc/ane-pm/dcp-fabric/dcp-topology/dcp-display/macaudio/asahi/sep all pass, host tests apple-dcp + apple-scaler-recovery pass (the red host-tests on some heads were base failures since fixed on main). The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 825af81 into aurora-silicon:main Dec 1, 2026
11 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants