Skip to content

soc: apple: suspend-to-RAM on the M4 Max (T6041, J616c) - #1664

Merged
DjDeveloperr merged 26 commits into
aurora-silicon:mainfrom
AxxzyWasTaken:t6041-s2r
Nov 25, 2026
Merged

DjDeveloperr merged 26 commits into
aurora-silicon:mainfrom
AxxzyWasTaken:t6041-s2r

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What: Real suspend-to-RAM (deep) on the MacBook Pro 14"/16" M4 Max (T6041, J614c/J616c) at EL2 via a DT-driven T6041 sleep platform driver (t6041-sleep.c), integrating with the shared Apple sleep core, AOP/PMP/SPMI/SMC/PCIe/GPU suspend-resume hooks, and Kahn topological ordering of DT power-domain shutdown/restore lists (ensuring amcc23/amcc19 restore before dcs_23/dcs_19 and apcie_phy_sw -> apcie_sys_* -> ans -> apcie_* on entry).
Tested: J616C M4 Max 16" (32-core T6041, 26.6.2 firmware, default cmdline, 7.3.0-s2r1664+) exact-head PASS at 8e43db29ae7d (rebased onto main 38ffa67c1ec0, 26 commits):

  • 5/5 consecutive real deep S2R cycles (rtc1 +15s x 5, 18s each, rc=0, identical boot_id, 0 GPU faults, 0 failed systemd units, Wi-Fi recovered, post-soak gpubench-vk render.deferred crc=2cfe9a54 & compute.conv2d crc=2d55a14d valid=true, max-health.sh PASS) on Aura 1.0.0b16-g07ea3332-dirty.
  • 3/3 consecutive real deep S2R cycles (rtc1 +15s x 3, 17s each, rc=0, identical boot_id, 0 GPU faults, 0 failed units) on unmodified stock Aura 1.0.0b15-g4a6a093d — confirming no Stage 2 Aura change is required on J616C.
  • DTB topological sort check on t6041-j616c.dtb: ps_off 73 nodes (0 DT-edge violations), ps_restore 227 nodes (0 DT-edge violations, 22 AMCC/DCS pairs checked, 0 inversions). ARM64 LLVM=1 build clean (checkpatch.pl 0 C errors/warnings).
    Risk: one-way · T6041 Macs (M4 Max J614c/J616c) when entering deep S2R, plus shared spmi-apple-controller, macsmc, pmp.rs, and pcie-apple suspend/resume hooks (gated to firmware-driven sleep / T6041 DT properties so non-T6041 s2idle/sleep paths stay unchanged).
    Not yet: 40-core T6041 (J614c / J616d) and macOS 27.2 firmware (pmp.rs sram_backup / apple,sram-keep) live S2R verification; non-T6041 regression check on T8140 / M5.
Details
  • Reworked from the earlier 45-commit v1 bring-up stack into a clean 26-commit DT-driven v2 series (9c39bb0ec33a..8e43db29ae7d) rebased onto main (38ffa67c1ec0).
  • Root-caused and fixed the 5.0 s WD2 reset during wake restore (8e43db29ae7d): static DT order restored dcs_23/dcs_19 before amcc23/amcc19, and ps_off required strict child-before-parent ordering (apcie_phy_sw -> apcie_sys_* -> ans -> apcie_*). Kahn topological sorting over DT power-domains eliminates all 22 AMCC/DCS inversions and preserves exact shutdown/restore invariants.
  • Preserved upstream macsmc has_wktp / dark-wake handling and pmp.rs config fields cleanly across the rebase.

@joske

joske commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Tried this on a J614c (MacBook Pro 14" M4 Max, 40-core GPU), os-fw 26.6.2, EL2 through aura main d5e180ba. The kernel was integration/aurora 9219565 with this PR merged on top, plus an apple,t6041-sleep node in t6041-j614c.dts (the J614c's ADT has the same pmgr and apcie0 as the J616c's, so the driver's tables should fit). It probes: "T6041 deep sleep at EL2 through aura's S2R mailbox", and mem_sleep offers deep.

GPU: the 40-core part runs CONFIG_25G83 in hw/t6041.rs, which has no sleep_restart, so the first try was refused ("no firmware restart on this chip, refusing sleep"). Setting sleep_restart: true there, as t6041_25g83::CONFIG has, got past that.

Then it hangs:

  • dry=1 + rtcwake -m mem -s 20: never comes back; only a forced power-off helps.
  • pm_test=devices: comes back fine.
  • pm_test=platform: hangs. So it's in a late or noirq callback, before .enter.

PMU notes (diag=1, read after the forced reset from /sys/bus/nvmem/devices/spmi_nvmem0/nvmem at 0xa200; the 0x8308 mark is 0x10 both times):

  • With everything bound: last device 0000:01:00.0 (brcmfmac), callback count 0x195.
  • With 0000:01:00.0 and 0000:01:00.1 removed from the bus: last device 404c80000.iommu (the SEP's DART), count 0x18b.

The count drops by 10, the two removed devices' callbacks, so the hang comes at the same point in the sequence. The noted device looks like whatever is next, not the cause. My guess: something is already stuck by then, possibly around the SEP going to sleep at device suspend.

One more J614c data point, from #1477's hibernation dry runs on this machine: at every pm_test level from platform up, apple-pmgr-pwrstate ...power-controller@c00: PS sep: Failed to reach power state 0xf (requested 0xf, now: 0x1000030f) on the way back. I can run more tests or provide a different log if it helps.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Thanks for trying it on the J614c, this helps a lot.

I think the hang is the SEP's DART. On my J616c the bring-up device tree gives iommu@404c80000 three sleep lists (apple,sleep-prepare, apple,sleep-restore, apple,sleep-restore-late), and the in-tree t604x.dtsi has none. On T6041 the SEP is told to sleep at device suspend, and the SEP driver saves its DART with those lists first, after which the DART's own callbacks leave it alone. Without them nothing is saved, the enclave sleeps, its power domain drops (your 0x1000030f), and then the DART's noirq suspend reads its registers and the bus hangs. That fits both your runs: the hang is at the same point in the order, and the noted device is just whatever started last.

I've pushed four commits for it:

  • the lists on &sep_dart in t6041.dtsi, and the apple,t6041-sleep node in t6041-j614c-j616c.dtsi, so the in-tree tree should be enough now
  • the SEP refuses the sleep with a message, instead of hanging, when its DART has no lists
  • sleep_restart: true for CONFIG_25G83, as you did
  • the driver doesn't bind without aura's mailbox

To try it on your current build, this in your DTS should be enough:

&sep_dart {
	apple,sleep-prepare = <0x80 0xa102>, <0x704 0xffffffff>;
	apple,sleep-restore = <0x210 0x0>, <0x20c 0x800005f5>,
			      <0x220 0xf0f0f>, <0x224 0x80808>,
			      <0x300 0x1>, <0x318 0x1>;
	apple,sleep-restore-late = <0x80 0x8000>, <0x228 0x3f3f3f3f>,
				   <0x22c 0x1010101>;
};

dry=1 only stops at .enter, so it can't catch anything earlier. If it gets further and then resets or hangs, the 0x8308 mark after the forced reset says how far it got (6: it reached the commit, 0x67: Linux got all the way back), and the notes at 0xa200 work as before. The new commits are only build-tested; my J616c already slept with the lists, so nothing changes on it.

@joske

joske commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Thanks, the SEP DART lists were it: the hang at pm_test=platform is gone on the J614c. A real sleep now gets to the commit, but the Mac resets instead of waking.

Same J614c (MacBook Pro 14" M4 Max, 40-core GPU), os-fw 26.6.2, aura 1.0.0b12 + aura#166 + a local dcpext3 entry. Kernels: integration/aurora fa59399 + #1667/#1684 and a few J614c DT patches, with this PR merged at two points:

  • 35.7: PR head 128743e, no local sleep patches. The in-tree apple,t6041-sleep node probes ("T6041 deep sleep at EL2 through aura's S2R mailbox") and mem_sleep defaults to deep.
  • 35.6: PR at fe530fa, to still have diag and the PMU marks.

pm_test=platform (35.7): comes back. The PMP refuses ("firmware never stopped"), and so do the SIO and the GPU. The SEP logs "the enclave stays asleep until the next real sleep or a reboot". Two problems after it:

  • The internal panel stays black. The system is fine over SSH and GNOME is running, but apple-panel-bl reads brightness 54 and actual_brightness 0. Writing a new brightness, or display power-save off and on through Mutter, gets no reaction from the driver (nothing in the log). On the way down, dcp@402e00000 logged Endpoint 0x37 is not running, cannot send message, iomfb_poweroff_v26_6_desktop: clear swap timed out and setPowerState(0) timeout 1000 ms.
  • The next reboot hangs after SSH is gone; only a forced power-off helped.

Real sleep, rtcwake -m mem -s 20: the Mac resets (35.7, and 35.6 with diag=1). The journal ends at "PM: suspend entry (deep)".

PMU scratch after the 35.6 reset (diag=1; the 0x8308 mark was 0x10 before the run):

  • 0x8308 = 0x06: it reached the commit, but not 0x60, so Linux never ran again.
  • Bit 11 counts all 0: 0x8314, 0x831c-0x831f and 0x8311; 0x8316-0x8318 and 0x8384+ are 0xff.
  • 0x830a = 0x10, 0x830b = 0x0f, 0x830c = 0x4d.
  • 0x830d = 0x80: no USB-C port domains left on.
  • 0x830f = 0x18, 0x8312 = 0x98, 0x8315 = 0x80.
  • 0x8310 = 0xc0: all 64 keep-alive words.
  • 0x8319 = 0x80, 0x831a/b = 0x4f/0xff.
  • 0x8342/3 = 0x06/0x03, 0x8344/5 = 0/0.
  • SEP: 0x8346/7 = 0x07/0x07, 0x8359/5a = 0x3f/0x00, 0x835b = 2 ms.
  • 0x8348 = 0x80, 0x8349/4a = 0xff/0x81, 0x834b/c = 0x4f/0x01.
  • 0x8350/1 = 3 non-PS and 52 PS rows differing from macOS. The PS bytes from 0x83a2: ff, 13 × 4f, 15 × 00, 14 × 4f, 0f ff ff ff 00 00 ff 00 00.
  • 0xa200 note: 500700000.pmp, count bytes ba 02.

So the commit looks clean from here: nothing busy, the SEP asleep, the USB-C domains down. The failure is after it: the RTC wake doesn't come, or the wake path resets before it reaches Linux.

One more thing: with Wi-Fi WoWLAN enabled (iw phy phy0 wowlan enable magic-packet, or whatever re-enabled it at boot here), brcmfmac refuses deep with -95 (brcmf_pcie_pm_enter_D3), so the suspend is aborted. That's by design, WoWLAN being s2idle only, but it may be worth a hint when deep is the default.

I'm happy to run more: a different wake source, a debug build, or other PMU offsets.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Thanks, that's a big step: the commit really is clean now. Your 35.6 record matches the commit record of my J616c when it wakes fine almost byte for byte: 3 non-PS and 52 PS rows differing from macOS, the same 0x8342-0x834c, the same PS bytes, nothing busy, the SEP asleep, the USB-C domains down. Only the first differing PS row differs: ff on yours, 0f on mine.

My best guess for the reset: your kernel has #1667, #1684 and a local dcpext3 entry, so it runs more external DCPs than mine. The display stop before the sleep kept one "already stopped" slot per external DCP by name: dcp@3a2e00000 got one, and every other external DCP shared the second. So with three or four external DCPs, the second one stopped took that slot and the rest were skipped, their firmware still running at the commit. Only the first two chains' DARTs were made dark, too. I've pushed drm/apple: T6041 S2R: every external DCP, not only the first two, which keeps the mark in each DCP and makes the DARTs of every enabled apple,t6041-dcpext node dark.

Two things that would tell us more:

The pm_test=platform black panel is a real gap: the display stop assumes a real sleep follows. Under pm_test the firmware is stopped but never power-cycled, and the restart path expects a power cycle. So pm_test=platform with the display isn't supported yet. I'll put that in the PR text, along with your WoWLAN note (brcmfmac refuses deep with -95 while WoWLAN is enabled).

@joske

joske commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Thanks! The raw PMU scratch 0x8300-0x83ff from that 35.6 run (diag=1) is below; it was already read before the next boot. Decoded with fe530fa's t6041_macos_regs, the bitmap at 0x8352 puts the ff on row 9, fab3_soc (0x502280118): macOS has 0x4f there at the commit, this J614c 0xff, your J616c 0x0f. The non-PS diff that's still readable is dcs_perf (0x8666, macOS 0x7666). The rest of that area is overwritten by the 0x8384+ busy rows.

Correction to my last comment: 0x8359/5a fall inside the bitmap, which is written after them, so the 3f 00 there is bitmap and not the SEP state. 0x8346/7 (0x07/0x07) still say the SEP is asleep.

8300: 9c 41 a5 ce 48 84 92 14 06 60 10 0f 4d 80 18 18
8310: c0 00 98 0c 00 80 ff ff ff 80 4f ff 00 00 00 00
8320: d8 29 7e 42 88 12 43 3c 78 a5 98 88 ca 07 15 8d
8330: 18 22 30 66 72 47 51 69 c3 28 27 e4 5a 32 1f 0d
8340: 5f 5f 06 03 00 00 07 07 80 ff 81 4f 01 0f 00 00
8350: 03 34 10 02 00 00 00 00 fc 3f 00 02 00 f0 de 57
8360: 00 80 54 d5 d5 00 00 01 42 08 00 00 40 01 00 00
8370: 40 08 24 02 00 00 00 00 00 00 00 00 00 00 04 00
8380: 66 86 00 00 ff ff ff ff ff ff ff ff ff ff ff ff
8390: 69 63 5f 72 75 6e 74 69 6d 65 5f 73 75 73 70 65
83a0: 6e 64 ff 4f 4f 4f 4f 4f 4f 4f 4f 4f 4f 4f 4f 4f
83b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4f
83c0: 4f 4f 4f 4f 4f 4f 4f 4f 4f 4f 4f 4f 4f 0f ff ff
83d0: ff 00 00 ff 00 00 72 71 7c 64 70 6d 5f 72 75 6e
83e0: 5f 63 61 6c 6c 62 61 63 6b 7c 64 65 76 69 63 7c
83f0: 1b 00 00 00 1b 00 00 00 1b 00 00 00 1b 00 00 00

fac697f: still resets. Built as fac697f with fe530fa's t6041-sleep.c, sleep.c and sleep.h put back for the marks, all four external DCPs enabled (dcpext0-3), WoWLAN off, diag=1, rtcwake -m mem -s 20. The record is the same as before: mark 0x06, nothing busy, the same bytes at 0x8308-0x834c, fab3_soc still 0xff. The one difference is a 53rd PS row, nub_spmi4 (macOS 0x4f, here 0xff):

8350: 03 35 10 02 00 00 00 00 fc 3f 00 02 00 f0 de 57
8370: 40 08 26 02 00 00 00 00 00 00 00 00 00 00 04 00
83d0: ff 00 00 ff ff 00 00 71 7c 64 70 6d 5f 72 75 6e

(the other lines are as above.)

Next I'll try your other suggestion, only dcpext0/1 enabled, by booting an aura without the dcpext2/3 fill so the gate leaves those chains off.

@joske

joske commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Only dcpext0/1: still resets. Same 35.8 kernel (fac697f + fe530fa's sleep files for the marks), with an aura from main just before #166, so t6041_exts has only dcpext0/1. The gate enabled /dcp@3a2e00000 and /dcp@602e00000 and left /dcp@606e00000 and /dcp@306e00000 off ("no firmware memory"). No external displays, WoWLAN off, diag=1, rtcwake -m mem -s 20.

The record is the same again: mark 0x06, nothing busy, the same 0x8308-0x834c, and fab3_soc 0xff. The 53rd PS row is now dcs_10 (macOS 0x4f, here 0xff) instead of nub_spmi4, so that row seems to vary between runs.

8360: 00 80 54 f5 d5 00 00 01 42 08 00 00 40 01 00 00
8370: 40 08 24 02 00 00 00 00 00 00 00 00 00 00 04 00
83c0: 4f 4f 4f 4f 4f 4f ff 4f 4f 4f 4f 4f 4f 4f 0f ff
83d0: ff ff 00 00 ff 00 00 71 7c 64 70 6d 5f 72 75 6e

So with the same external DCPs as your J616c it still resets, and across the three runs fab3_soc at 0xff is the only difference from your record that stays. Is there anything on fab3 that the J614c has and the J616c doesn't, or that I could take out to test?

@joske

joske commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Your exact branch: still resets. Built fac697f as it is (base integration/aurora 9219565), with only fe530fa's t6041-sleep.c, sleep.c and sleep.h on top for the marks, and aura main 5ebc72f (1.0.0b13-7). No J614c patches of mine: only dcpext0/1 enabled, no external displays, and no WoWLAN on this base. diag=1, rtcwake -m mem -s 20.

The record is byte for byte the one from my first 35.6 run: mark 0x06, nothing busy, 3 non-PS and 52 PS rows differing from macOS with the same bitmap and bytes, fab3_soc 0xff.

So on the J614c it resets in every configuration I tried (4 or 2 external DCPs, my tree or yours) with the same clean commit record, and fab3_soc is the one row that differs from your J616c every time. Happy to try a patch that does something to fab3 before the commit, or to read anything else after the reset.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Thanks for running all of those. Same record in every configuration, with fab3_soc on, rules out the external DCPs.

One difference between our setups I can name: your kernel boots the in-tree device tree, mine boots my bring-up one, and they describe fab3_soc's children differently (in-tree: sio, ans, sep; mine: sio, ans, apcie_sys_st1, apcie_sys_gp). That only changes Linux's genpd bookkeeping, not what the hardware has on at the commit. Something under fab3 still reads on there, and the macOS table that 0x8350.. is checked against doesn't have it.

So, to see which domain it is, a small patch on top of fe530fa's t6041-sleep.c (the build you have for the marks). Right after MARK 6 it writes a bitmap of every PS word that reads on (ACTUAL != 0) to PMU SRAM: 0xa300 main PMGR (0x502800000, +0x000..+0x4f8, 20 bytes), 0xa314 East (0x502280000, +0x000..+0x3f8, 16 bytes), 0xa324 AON (0x508300000, +0x000..+0x178, 6 bytes), and 0x50 at 0xa32a once it's done. Bit n of byte n/8 is the word at +8n.

diff --git a/drivers/soc/apple/t6041-sleep.c b/drivers/soc/apple/t6041-sleep.c
index 15130a0..bd61e84 100644
--- a/drivers/soc/apple/t6041-sleep.c
+++ b/drivers/soc/apple/t6041-sleep.c
@@ -404,6 +404,32 @@ static int t6041_ps_match_all(void)
  * 0x837e..0x83a1 the first 6 non-PS diffs as u16 index + u32 value;
  * 0x83a2..0x83ff each differing PS row's [7:0] (actual, target), in row order, 94 of them.
  */
+/*
+ * DIAG: every PS word that reads on (ACTUAL != 0) at the commit, as bitmaps in PMU SRAM, bit n
+ * of byte n / 8 = the word at +8 n: 0xa300 the main PMGR (0x502800000, +0x000..+0x4f8, 20
+ * bytes), 0xa314 East (0x502280000, +0x000..+0x3f8, 16 bytes), 0xa324 AON (0x508300000,
+ * +0x000..+0x178, 6 bytes); 0xa32a = 0x50 when done.
+ */
+static void t6041_ps_on_map(struct t6041_sleep *s)
+{
+	static const struct { u16 at, words; } blk[3] = { { 0xa300, 160 }, { 0xa314, 128 }, { 0xa324, 48 } };
+	void __iomem *base[3] = { s->ps, s->east, s->ps_aon };
+	unsigned int b, i;
+
+	for (b = 0; b < 3; b++) {
+		for (i = 0; i < blk[b].words; i += 8) {
+			u8 byte = 0;
+			unsigned int j;
+
+			for (j = 0; j < 8; j++)
+				if (FIELD_GET(PS_ACTUAL, readl(base[b] + 8 * (i + j))))
+					byte |= BIT(j);
+			t6041_pmu_write(s, blk[b].at + i / 8, byte);
+		}
+	}
+	t6041_pmu_write(s, 0xa32a, 0x50);
+}
+
 static void t6041_reg_diff(struct t6041_sleep *s)
 {
 	unsigned int i, n[2] = { 0, 0 };
@@ -1210,6 +1236,7 @@ static int t6041_sleep_commit(unsigned long unused)
 		    busy_n < ARRAY_SIZE(busy_rows))
 			busy_rows[busy_n++] = i;
 	MARK(s, 6);
+	t6041_ps_on_map(s);
 	t6041_commit_t = read_sysreg(cntpct_el0);
 	for (i = 0; i < ARRAY_SIZE(t6041_macos_regs); i++)
 		t6041_reg_now[i] = readl(t6041_reg_map[i]);

After the reset: dd if=/sys/bus/nvmem/devices/spmi_nvmem*/nvmem bs=1 skip=$((0xa300)) count=48 2>/dev/null | xxd (the spmi_nvmem whose parent is 0-0b). I'll take the same map on my J616c, and the words on yours that aren't on mine are the candidates.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

For comparison, the same map from my J616c: one RTC deep sleep (20 s) at the greeter on a kernel with fe530fa's sleep files plus the patch above. It woke normally (0x8308 = 0x67).

a300: 10 00 02 00 7f 80 fb ff ff 01 02 00 00 00 84 10 0e 07 00 00   main  0x502800000 +0x000..+0x4f8
a314: 00 00 00 00 50 00 78 c0 3f f0 ff f0 ff 00 00 00               East  0x502280000 +0x000..+0x3f8
a324: 01 f8 06 e1 05 00                                             AON   0x508300000 +0x000..+0x178
a32a: 50

Bit n of byte n/8 is the word at +8n. fab3_soc is East +0x118 (byte 4, bit 3): off here, as the 0x0f in the PS rows says. Any bit that is set in your map and clear in mine is a domain still on at your commit, and the likely holder of fab3. This run's 0x8350/1 read 03 35 (53 PS rows), so the 53rd row varies on mine too.

@joske

joske commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

The map from the J614c, same build as my exact-branch run (fac697f + fe530fa's sleep files) plus your patch, rtcwake -m mem -s 20, reset as before. 0xa32a = 0x50, so it's complete:

a300: 10 00 02 00 7f 80 fb ff ff 7f 03 00 00 00 84 10 0e 07 00 00   main
a314: 00 00 00 00 58 00 78 c0 3f f0 ff ff ff 0f 00 00               East
a324: 01 f8 06 e1 05 00                                             AON
a32a: 50

Nothing is on in yours that's off in mine. On here and off on your J616c, named from the J614c ADT's pmgr devices:

Block Offsets Domains
main +0x248..+0x280 AMCC24, DCS_24, AMCC25, DCS_25, AMCC26, DCS_26, AMCC27
East +0x118 FAB3_SOC
East +0x2c0..+0x2d8 AMCC28..AMCC31
East +0x340..+0x358 DCS_28..DCS_31

So at the commit this machine has all 32 memory controllers on (AMCC0-31), and yours has 24 (AMCC0-23). This one is the full M4 Max (16 CPU cores, 64 GB, 512-bit). Going by the 24, I guess yours is the binned one (14 cores, 36 GB, 384-bit)? AMCC28-31 and DCS_28-31 sit in the East block with FAB3_SOC, so fab3 looks like the fabric for that last quarter of DRAM. If that's right, it isn't a leaked domain but the extra channels, and whatever the sleep path does per memory channel (or the macOS table it's checked against) only covers 24 of them.

If you have a macOS table or sequence from a 512-bit M4 Max, or want me to try something per channel for AMCC24-31, I can run it. One aside: this boot came from the J614c's aura build with the dcpext3 entry rather than stock main (update-m1n1 didn't switch it), but the gate still only enabled dcpext0/1, as in the exact-branch run, and the commit record is the same as before (mark 0x06, nothing busy, 3 non-PS and 52 PS diffs, fab3_soc 0xff).

🤖 Generated with Claude Code

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

That's it, thanks. Yes, mine is the binned one: 14 cores, 36 GB, 384-bit. On it, the words you list read target and actual 0 live (amcc24 +0x248 = 0x0f000300, amcc28 East +0x2c0 = 0x0f000300), so those channels are fused off.

The sleep path is written for 24 channels throughout, not only the macOS table:

  • the AMCC error-enable quiesce runs on 24 planes;
  • the cache flush and allocation-off (t6041_mcc_macos) and the way restore after the wake run on 6 AMCCs;
  • DCS dynamic power gating runs on 24 DCS blocks;
  • the table matched against macOS comes from my J616c, so it has no words for AMCC24-31 or DCS_24-31.

So on yours, the last eight channels are never flushed, and their PS words stay forced on. That holds fab3_soc at ff.

I've pushed soc: apple: t6041-sleep: the full part's 32 memory channels:

  • At probe, the driver counts 32 channels when amcc24's and amcc28's words aren't both zero; it logs t6041-sleep ...: 32 memory channels.
  • It quiesces, flushes and power-gates all eight AMCCs and 32 DCS blocks, and puts the 15 extra words on AUTO as macOS has their twins (an AMCC slice 0x1000030f, a DCS channel 0x1400034f). They're saved first and put back on wake, before the cache restore.

One check before you run it: the AMCC and DCS addresses for groups 6 and 7 are extrapolated from the first six: AMCC block 0x22c000000 and 0x22e000000, DCS 0x22c200000 + 0x200000 * c and 0x22e200000 + 0x200000 * c. Could you confirm them against your ADT's mcc reg list (reg 12+ the AMCC blocks, reg 20+ the DCS channels)? If they differ, it would fault on the first sleep.

If it still resets, the same map with the new commit would show whether fab3_soc came down.

@joske

joske commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

f3fcc17: still resets. The addresses match the J614c ADT first: arm-io ranges maps 0 to 0x200000000, and mcc has amcc-count = 8, dcs-count-per-amcc = 4. Reg 18/19 are 0x2c000000/0x2e000000 (0x200000 each), so 0x22c000000/0x22e000000. Reg 44-47 are 0x2c200000-0x2c800000 and reg 48-51 are 0x2e200000-0x2e800000 (0x8000 each), so 0x22c/0x22e200000 + 0x200000 * c. The error words (+0x25000 + 0x40000 * p) and the all-planes window (+0x1c0000) fall inside those blocks.

  • f3fcc17 as it is (on fac697f, base 9219565, dcpext0/1 only): the probe logs t6041-sleep t6041-sleep: 32 memory channels, then rtcwake -m mem -s 20 resets as before.
  • The same + your map, with the call placed just before t6041_spin_s(20) (after t6041_atc_commons_on()), so the SPMI-quiet gap stays as it is. 0xa300..0xa32f was zeroed before the run. After the reset it reads:
a300: 10 00 02 00 7f 80 fb ff ff 7f 03 00 00 00 84 10 0e 07 00 00   main
a314: 00 00 00 00 58 00 78 c0 3f f0 ff ff ff 0f 00 00               East
a324: 01 f8 06 e1 05 00                                             AON
a32a: 50

So it's fresh, and it's bit for bit the map from before the change: AMCC24-27, DCS_24-26 (main +0x248..+0x280), AMCC28-31 and DCS_28-31 (East +0x2c0..+0x2d8, +0x340..+0x358), and FAB3_SOC (East +0x118) still read on at that point. Note that on your J616c map AMCC0-23 read on at the commit too, so on AMCC/DCS words seem expected there. What's still different is fab3_soc, which stays on here alongside the extra channels even with them on AUTO.

If it helps, I can dump the raw words (target, AUTO, flags, actual) of those 15 plus fab3_soc at the same point, or try whatever you'd like done to fab3 or the extra channels before the commit.

🤖 Generated with Claude Code

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Thanks for checking the addresses and for the run. Agreed: AMCC/DCS reading on at that point is expected, because their AUTO state only drops them once the commit has gone quiet. fab3_soc is the one real difference.

Yes, the raw words would help most. Could you dump these 16 at two points: where the map runs now, and right after t6041_ps_match_all() (the last PS writes before the commit)?

  • amcc24-27 (main +0x248, +0x258, +0x268, +0x280)
  • dcs_24-26 (main +0x250, +0x260, +0x270)
  • amcc28-31 (East +0x2c0..+0x2d8)
  • dcs_28-31 (East +0x340..+0x358)
  • fab3_soc (East +0x118)

Writing them as 32-bit words from 0xa340 (16 x 4 bytes, then the second set from 0xa380) keeps them clear of the map.

Those words would tell us three things:

  • whether the AUTO bits and auto states took (bits 28 and 27:24);
  • whether a target was left at f;
  • whether fab3_soc's own word still has a target of f, or AUTO 4 with a child keeping it up.

If fab3_soc is at AUTO 4 with the extra channels on AUTO, then the next suspect is the fab3 child the J614c has and mine doesn't. In your bring-up DTB, fab3's children are sio, ans, apcie_sys_st1 and apcie_sys_gp.

@joske

joske commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

The raw words, f3fcc17 + your map + a dump of the 16 words at both points (u32 LE, in your order: amcc24-27, dcs_24-26, amcc28-31, dcs_28-31, fab3_soc). 0xa300..0xa3bf was zeroed first; after the reset the done marks 0xa32a/b/c read 50 51 52, so all three sets are from this run. It reset as before.

a300: 10 00 02 00 7f 80 fb ff ff 7f 03 00 00 00 84 10 0e 07 00 00   map (unchanged)
a314: 00 00 00 00 58 00 78 c0 3f f0 ff ff ff 0f 00 00
a324: 01 f8 06 e1 05 00 50 51 52
Word right after t6041_ps_match_all() (0xa380) where the map runs (0xa340)
amcc24 0x1f0002ff 0x1400024f
amcc25-27, dcs_24-26, amcc28-31, dcs_28-31 0x1400024f (all 14) 0x1400024f (all 14)
fab3_soc 0x1f0000ff 0x1f0000ff
  • AUTO took on all 15 (bit 28). amcc24 hadn't settled yet right after the match (auto state f, actual f), and by the map point it's like the others.
  • The auto states: all 15 end at auto state 4, actual 4, target f. That's macOS's DCS value (0x1400034f, apart from bit 8), but for the eight AMCC words macOS has auto state 0 and actual 0 (0x1000030f). The AMCC ones read 4 here, so either the 0 didn't take or the field reads back the state it's at.
  • fab3_soc is on its own word: 0x1f0000ff at both points, AUTO 1, auto state f, actual f, target f. So not AUTO 4 with a child holding it up.

Raw dump of 0xa340..0xa3bf for reference:

a340: 4f 02 00 14 4f 02 00 14 4f 02 00 14 4f 02 00 14   (x3 lines)
a370: 4f 02 00 14 4f 02 00 14 4f 02 00 14 ff 00 00 1f
a380: ff 02 00 1f 4f 02 00 14 4f 02 00 14 4f 02 00 14
a390: 4f 02 00 14 4f 02 00 14 4f 02 00 14 4f 02 00 14   (x2 lines)
a3b0: 4f 02 00 14 4f 02 00 14 4f 02 00 14 ff 00 00 1f

🤖 Generated with Claude Code

@joske

joske commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

One more thought on those words, and a question.

t6041_ps_match_all() already writes fab3_soc with your table's 0x1400034f (AUTO, auto state 4), and the word reads 0x1f0000ff right after. The AMCC words were written with auto state 0 and read 4, and amcc24 went from f to 4 between the two dumps. So [27:24] looks like the level the hardware grants rather than the one we write: at least what we ask for, more if something downstream needs it. On this J614c something needs fab3 at f.

The children both machines have (sio, ans, sep) read the same in both maps. The only difference is the eight extra channels, and AMCC28-31/DCS_28-31 sit in the East block with fab3. On your binned part they're fused off and fab3 goes to 0. So I suspect fab3 is the fabric for that last quarter of DRAM, and with those channels at auto state 4 (which macOS allows for the DCS words too), fab3 has to stay up on a full part. If so, fab3 at f is expected here, and the reset comes from something a binned-J616c reference can't show.

So, how did you capture the macOS commit state on your J616c? If it's something I can run on this J614c under macOS (26.6.2), a full-part table would show what macOS really does with fab3_soc and AMCC24-31 at the commit, and what else differs. I'd rather get that than guess at memory fabric power before the commit.

If you'd like the theory confirmed first, I can do one more run that rewrites fab3_soc to auto state 4 and the extra AMCCs to 0 at the map point, waits, and dumps the words again.

🤖 Generated with Claude Code

@joske

joske commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Same result on the new head (7288144, with the integration/aurora merge) plus the same two diag commits: 32 memory channels, rtcwake -m mem -s 20, reset. The dump is fresh (0xa300..0xa3bf zeroed first, marks 50 51 52) and the map is byte for byte the same. The words too: the 14 channel words at 0x1400024f and fab3_soc at 0x1f0000ff at both points. The only change is that amcc24 had already settled by the t6041_ps_match_all() point this time (0x1400024f instead of 0x1f0002ff), which looks like timing.

🤖 Generated with Claude Code

@joske

joske commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

I tried one more idea on the J614c, from the M5 Max sleep in #2119. There the commit dropped all the CPU clusters together, the P cluster's power-down queued behind the boot cluster's and never finished, and the engine's watchdog reset the chip 5 s after the commit. The fix was to take the secondary clusters down first and poll until they're done. Our symptom is the same, so I checked whether it applies here.

Diag on 7288144: the cluster block (0x502820000, +0x00..+0x38) dumped to PMU SRAM at three points in t6041_sleep_commit(). The boot CPU is 0x10100, so P0 is the boot cluster.

E +0x0 P0 +0x4 (boot) P1 +0x8 AVE +0xc/+0x10 +0x14..+0x38
before writel(0, cluster + 0x0) 0xf 0xf 0xf 0 0
right after writel(0, cluster + 0x8) 0x10 0xf 0x10 0 0
after t6041_atc_commons_on(), before the quiet gap 0 0x10 0 0 0

E and P1 change at once and read 0 by the last point, the same as the AVE complexes. Only the boot cluster is still at 0x10. That is the order #2119 needed, so I don't think this is our reset. T6041 has no T6050-style sequencer status words at +0x18/+0x1c (everything past the AVE words reads 0), so this is based on the cluster words only. Same reset as before.

So I'm back to the AMCC words. Your comment in t6041_mcc_macos() says macOS has every slice power-gated (0x1000030f) at its commit, while here they're only clock-gated (0x1400024f). I'm happy to run a dump of all 32 AMCC/DCS words at the commit, or anything else that would help. And the earlier question still stands: how did you capture the macOS trace? If I can take the same trace on the full part, we can compare it word for word with yours.

🤖 Generated with Claude Code

@joske

joske commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Found it: on the full T6041 the reset is dcs_27, and with one line added the J614c sleeps and wakes.

A diag kernel on 7288144 dumped the PS words of all 32 AMCC slices and all 32 DCS channels right after t6041_atc_commons_on(). 63 of the 64 read 0x1400024f (AUTO, auto state 4). The one exception is dcs_27, main +0x530 (DCS_27 in the J614c's ADT pmgr:devices), which reads 0x0f0002ff: forced on, no AUTO. t6041_full_ps leaves it out ("dcs_27 isn't among the words the J614c has on there"), but that conclusion came from my PS-on map, which only covered main +0x000..+0x4f8. 0x530 is past its end, so the map couldn't show it, sorry about that. dcs_27 is the only memory channel outside the main DCS range, and it only exists on the full part, which fits the binned/full split. It also matches what #1910 says for T6040: the engine expects every DCS to gate itself and waits for good if one isn't in automatic mode.

The fix, with the value your table has for the other DCS words:

 	{ 0, 0x280, 0x1000030f },	/* amcc27 */
+	{ 0, 0x530, 0x1400034f },	/* dcs_27 */
 	{ 1, 0x2c0, 0x1000030f },	/* amcc28 */

(and t6041_full_ps[15] → [16], plus the comment above it).

On 7288144 plus that line, J614c (16/40, 32 channels, os-fw 26.6.2), one boot:

  • 3 deep sleeps with rtcwake -m mem -s 20, each back after about 22 s: panel, Wi-Fi with my SSH session still up, Bluetooth (rebinds itself after "power lost in the sleep"), SEP, ANE.
  • Then a lid close of about 4.5 minutes and a lid open: back the same way. suspend_stats: 4 ok.

Still open on the J614c:

  • SD reader: after the first wake, sdhci-pci 0000:02:00.0 fails its resume (mmc0: enable PCI MSI failed, error=-22, pci_pm_resume returns -22). Then mmc0 times out a command every 10 s, which keeps a workqueue busy, so the next suspend fails at freeze after 20 s (wq_busy=1, last_failed_dev 0000:02:00.0). With sdhci_pci unloaded, the later sleeps were fine. No card inserted.
  • EDAC: apple_soc_edac event-log-handler: hardware error: event-log source 9 (IRQ 249) (AIC 476) at the first wake, a few times after it, and not at the later ones. Nothing visibly broken.
  • Bluetooth logs failed to destroy transfer ring 6 / reprobe after command timeout failed at the wakes, but is powered and works after.

🤖 Generated with Claude Code

@joske

joske commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Two more things from the J614c, one bad and one good.

Merged with a newer integration/aurora, the wake hangs. I merged 7288144 (plus the dcs_27 line) into integration/aurora c0a2a75 (15 Nov) for my daily kernel. Five conflicts, all resolved by keeping both sides: macsmc.c/macsmc.h, pcie-apple.c, soc/apple/sleep.c, g17/sleep.c. On that kernel the J614c never comes back from a deep sleep, with a lid close or rtcwake -m mem -s 20. The screen stays black, there's no watchdog reset 5 s later, and only a forced power-off gets it back. The journal ends at PM: suspend entry (deep), so I can't say whether it dies before the commit or in the wake. The same tree without my one PCIe change below hangs the same way.

The same set of extra commits cherry-picked onto your branch instead (7288144 + dcs_27) wakes every time. So it's something in integration between your base (fc05050) and c0a2a75. That range is 19 PRs, and the one that touches the sleep path is #1963 (T6050 S2R: sleep.c +1258, plus macsmc.c, pcie-apple.c, spmi-apple-controller.c and RTKit). I haven't bisected it, so #1963 is my guess, not a result. Worth knowing before your next rebase.

The SD reader after a wake. I found the cause of the enable PCI MSI failed, error=-22 from my last comment. After a real sleep, the PCI core's noirq power-up of the functions runs while the ports are still down (Unable to change power state from D3hot to D0, device inaccessible), so current_state stays at D3. apple_pcie_resume() then retrains the port and restores the saved config, but the function is still marked D3. The GL9755 driver's resume frees and re-allocates its MSI vector, and __pci_enable_msi_range() refuses a device that isn't in D0 (drivers/pci/msi/msi.c, -EINVAL). There's no interrupt after that, every command times out, and the busy MMC workqueue fails the next suspend at freeze. The fix is to record D0 before the restore:

@@ static int apple_pcie_resume(struct device *dev)
 		if (!port || !port->hib_cold)
 			continue;
+		/*
+		 * The PCI core's noirq power-up ran with the link down and left the function
+		 * marked D3: the reset brought it up in D0, so record that before the
+		 * restore, or its driver's resume can't enable MSI again (-EINVAL).
+		 */
+		pci_set_power_state(fn->pdev, PCI_D0);
 		if (pci_load_saved_state(fn->pdev, fn->state))

With it, on 7288144 + dcs_27: two rtcwake sleeps in a row with the reader bound, no MSI error, no mmc0 timeouts, the reader in D0 after each wake. Before, the second sleep always failed. Wi-Fi and Bluetooth hit the same failed power-up but recover through their own restart.

Still open here: apple_soc_edac event-log-handler: hardware error: event-log source 9 (AIC 476), a few times around each wake. Nothing visibly breaks.

🤖 Generated with Claude Code

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Rebuilt the series without the merge commit: the 37 commits now sit directly on fc05050, the merge's integration/aurora side. The four files the merge resolved got the same resolutions, and the final tree is identical to the previous head 7288144.

It still conflicts with current integration/aurora, in drivers/soc/apple/sleep.c, drivers/gpu/drm/asahi/g17/sleep.c, drivers/pci/controller/pcie-apple.c, drivers/mfd/macsmc.c and include/linux/mfd/macsmc.h. Upstream changed those a lot since (about 10k lines in sleep.c alone). dt-checks still fails: /t6041-sleep (apple,t6041-sleep) has no binding schema. Both need a proper rebase and a binding, which I'll do separately.

Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested on my M4 Max as described.

@joske

joske commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

An overnight result from the J614c (16/40), on 7288144 + dcs_27 + the SD fix and a few unrelated cherry-picks, now my daily kernel.

Battery: one lid-closed deep sleep of 9 h 30 min, unplugged. charge_now went from 5825 to 5807 mAh (−18 mAh, −205 mWh by energy_now), and capacity stayed at 99%. That figure also covers about 17 s awake before the suspend and about 1.5 min awake after the wake, so the sleep itself was well under 2 mA on average. That's in line with your ~7 mAh in 8.5 h, and better than macOS's "under 1% a night" on this machine.

After that wake: panel, Wi-Fi (I'm typing this over it), speakers, Bluetooth and the camera all work. The camera also worked after earlier wakes, so the description's note that the ISP doesn't come back is out of date, at least for T6041. No EDAC event-log source 9 at this wake.

Brightness after a lid wake: two parts.

  • Before, the panel came back at 5 to 7 nits whatever the level, and only a DPMS on (lock/unlock) fixed it. dcp_backlight_s2r_restore() asks for a fade (dcp_bl_request()), but after the S2R restart nothing ever runs it: no fade_start, no fade work. Its first present can also reach the firmware before the backlight is enabled (Received brightness update when backlight is disabled). In my test change, the restore now:

    • jumps straight to the target (dcp_bl_jump());
    • clears a dpms_off left from the lid close, since the mode set has lit the panel;
    • sends the level once more 1.5 s later.

    With that, the level is right after a lid wake (S2R brightness restore: bd 153 target 153 level 153 actual 153 ...).

  • Still open: even at the right level, the picture looks clearly dimmer (about half) than the same level after a lock/unlock, and a lock/unlock still brings it back. So something besides the brightness value isn't restored by the S2R re-commit. My guess is color/gamma or another panel setting that the DPMS-on path sends and the S2R path doesn't, but I haven't found it yet. The rtcwake sleeps don't show this; only lid sleeps do.

I can push the brightness change somewhere if it's useful, but it's a workaround for the level, not the whole fix.

🤖 Generated with Claude Code

Clear any stale pending edge/level latch after unmasking a level GPIO
interrupt during resume so unmasked level lines (such as speaker amplifier
fault/interrupt lines after a firmware sleep) do not trigger an interrupt
storm on wake.

Signed-off-by: AxxzyWasTaken <[email protected]>
After a firmware-driven sleep on a conventional PCIe host, the BCM4377
Bluetooth controller loses power and must be rebound after resume so its
firmware and rings are cleanly reinitialized. Update the bcm4377 resume
host test fixture accordingly.

Signed-off-by: AxxzyWasTaken <[email protected]>
A conventional Apple PCIe host (internal Wi-Fi, Bluetooth, and SD card
reader ports) loses power across a firmware-driven deep sleep, leaving
endpoints unpowered or in reset behind down links.

Unconditionally save conventional port state in suspend_noirq, snapshot
endpoint saved state before PCI core noirq resume spends it on a down
link, retrain cold ports (PWREN, PERST#, link-up, 100 ms PCIe r5.0 6.6.1
settle, RID-to-SID map, and interrupt mask) in resume(), and restore
endpoint configuration. Enable async suspend/resume on the host so link
retraining runs in parallel with NVMe and display resume.

Signed-off-by: AxxzyWasTaken <[email protected]>
…p-pmvc

Describe the apple,sleep-wake-type boolean property (write WKTP sleep/wake
state around firmware sleep commit) and the apple,sleep-pmvc u32 property
(VDD_CIO rail mask written to the SMC pmVC key before sleep commit).

Signed-off-by: AxxzyWasTaken <[email protected]>
Drive SMC WKTP and pmVC sleep-commit writes from the apple,sleep-wake-type
and apple,sleep-pmvc DT properties rather than machine-compatible checks:

- When apple,sleep-wake-type is set, write WKTP = 2 before slpa at sleep
  commit and restore WKTP = 0 on a full wake (or in .complete if sleep was
  refused), preventing the SMC from remaining in power-nap fan/thermal
  policy after wake.
- When apple,sleep-pmvc is set, log the boot pmVC at debug level and write
  the DT-specified VDD_CIO rail mask (bit 8 plus bit n keeping port n's
  CIO rail powered across sleep) before slpa, refusing sleep if either
  WKTP or pmVC fails.
- Gate apple_smc_suspend_noirq()/resume_noirq() on pm_suspend_via_firmware()
  so s2idle does not enter the firmware-sleep path.

Signed-off-by: AxxzyWasTaken <[email protected]>
Look up T6041's GPU power domain from PMP report entries in g17/sleep.c
and enable sleep_restart on both the 32-core (t6041_25g83::CONFIG) and
40-core (CONFIG_25G83, tested on J614c by joske) T6041 profiles so the
GPU stops cleanly before deep sleep and warm-restarts on wake.

Signed-off-by: AxxzyWasTaken <[email protected]>
Add apple_dart_display_keep() so the display driver can preserve and
restore T6041 display/DCP DART stream translation state across host-driven
display power-down and warm restart during suspend-to-RAM.

Signed-off-by: AxxzyWasTaken <[email protected]>
… domains

When a device tree describes external display chains referencing disabled
DISPEXT power domains, drop the dangling power-domains property on gated
chain nodes so their devices do not wait on unavailable domain providers
and defer-timeout the display subsystem. Trees without DISPEXT power
domains are unaffected.

Signed-off-by: AxxzyWasTaken <[email protected]>
Add apple,sleep-host-stop and apple,display-power to apple,dcp.yaml and
extend apple,t8140-display-power.yaml with the apple,t6041-display-power
binding describing the PMC, power-gate, GAPF, AXI2AF register windows and
per-chain PMGR power-domain phandles used during T6041 display S2R.

Signed-off-by: AxxzyWasTaken <[email protected]>
Implement host-driven display stop and warm restart for T6041
suspend-to-RAM, driven strictly from the apple,sleep-host-stop and
apple,display-power DT properties without hardcoded addresses or unbacked
fixed delays:

- Parse the apple,display-power node's register windows (pmc-dcp, pwrgate,
  pwrgate-aux, gapf, axi2af) and per-chain PMGR power-domain phandles
  from DT at probe, failing sleep cleanly if required resources are
  missing.
- Handle every enabled external DCP and mark all external chain DARTs dark
  by DT node before lowering their power words so post-wake framebuffer
  unmaps never flush a DART behind a powered-off block.
- On 26.6 desktop firmware, route D572 through dcp_s2r_dart_power() and
  complete s2r_dart_done only on 0 ("done with display"), track in-flight
  dcp_ack() replies in iomfb_channels_idle(), send A500, idle RTKit, and
  poll hardware COPROC, GAPF, and PMGR PS_ACTUAL/PARENT_OFF status with
  bounded timeouts and error unwind.
- On wake, raise the internal display domains, restore DART streams,
  warm-restart DCP firmware, wait for D575 hotplug completion and channel
  idle, recommit the active CRTC mode, restore backlight (with
  dcp_backlight_s2r_restore() declared in dcp_backlight.h), and restore
  boot power-word state. Propagate errors in apple_platform_suspend/resume.

Signed-off-by: AxxzyWasTaken <[email protected]>
Allow the T6041 shared APCIe storage/PHY register windows (axi2af,
cio3pll, clkgen, phy-block, phy-ip) and bootloader-provided apple,tunable-*
properties on apple,t6041-pcie so the sleep driver can reinitialize the
storage PCIe link after deep sleep strictly from DT.

Signed-off-by: AxxzyWasTaken <[email protected]>
Add the DT binding schema for apple,t6041-sleep describing its register
windows (ps-aop, cluster, pwrgate, cpu-start, wdt, aon-misc, commit,
clk-mux, ka-pmgr, ka-east, pmc, ptd, perf, wake, AMCC/DCS banks, and
AXI2AF bridges), pinctrl/SPMI/ATC-PHY/APCIe phandles, wake source IDs,
and PMGR power-domain phandle lists (including apple,atc-off-domains).

Signed-off-by: AxxzyWasTaken <[email protected]>
Add the EL2 suspend-to-RAM platform driver for Apple T6041 (M4 Max),
committing sleep and returning to cpu_resume through aura's S2R mailbox:

- Bind only when aura publishes the S2R mailbox and bootloader-provided
  APCIe tunables (apple,tunable-* via <linux/soc/apple/tunable.h>) are
  present in DT; otherwise fail probe with -ENODEV so the machine stays
  on s2idle.
- Map all MMIO windows from DT reg-names and resolve all PMGR power-state
  words from DT phandle lists, topologically sorting sleep-off and restore
  lists from DT power-domains edges with cycle detection. Uniformly skip
  fused-off channel words across 24-channel (binned J616c) and 32-channel
  (full J614c, including dcs_27 at main +0x530 found by joske) parts.
- Advertise commit-time enclave/coprocessor stops, hold parked CPUs via
  spin_table_hold_parked() before stopping them, check coprocessors and
  pm_wakeup_pending() before the refusal boundary, and stop SEP and
  coprocessors at commit so aborted suspends do not strand Touch ID or SIO.
- Use pure arch_timer_read_counter() + cpu_relax() polls in the commit
  path (avoiding arm64 WFIT/WFET early power-gating) to poll ATC, sleep,
  DCS/SoC perf, secondary CPU/CPM, and SPMI hardware states with wake-time
  timeout reporting, retaining only the two hardware-documented fixed
  spins (5 ms PTD SOC-DEV-PS-REQ pulse and 3 ms commit-to-WFI gap) and
  the 1 us PHY refclk settle on wake.

Signed-off-by: AxxzyWasTaken <[email protected]>
…splay-power

Wire suspend-to-RAM in the T6041 SoC and J614c/J616c board device trees:

- Add pmgr_disp, t6041-sleep-pmgr.dtsi (keeping newly added firmware-owned
  power-state nodes disabled), SEP DART sleep-prepare/restore lists, and
  the ps_venc1_sys -> ps_fab0_soc parent link in t6041.dtsi.
- Add the t6041_sleep node in t6041.dtsi (disabled at SoC level so boards
  without qualified deep sleep such as J575c remain on s2idle) with all
  DT reg windows, wake sources, and PMGR domain phandle lists (including
  apple,atc-off-domains).
- On t6041-j614c-j616c.dtsi, add the dcp_power node, wire apple,sleep-host-stop
  and apple,display-power on &dcp, apple,sleep-wake-type and
  apple,sleep-pmvc = <0x101> (VDD_CIO bit 8 + port 0 bit 0) on &smc, the
  shared APCIe storage/PHY reg windows on &pcie0, and enable &t6041_sleep.

Signed-off-by: AxxzyWasTaken <[email protected]>
…PS skip scope

Fix three suspend-to-RAM commit regressions in the DT-driven T6041 sleep
driver:

1. Replace the DFS-and-reverse topological sort in t6041_topo_sort() with
   a stable (input-order-preserving) Kahn's topological sort (forward for
   child-first shutdown, reversed-index child-first reversed back for
   parent-first restore so edge-free auto-managed DCS nodes stay after
   their AMCCs), add the missing ps_apcie_sys_gp parent edge on
   ps_apcie_phy_sw, and order ps_ans before ps_apcie_st1/st0/gp in
   apple,sleep-off-domains. This ensures ps_apcie_phy_sw lowers before
   ps_apcie_sys_gp/sys_st*/ans and ps_apcie_st*/gp lower after sys_*/ans,
   avoiding PARENT_OFF bit 11 latches.
2. Match all three CPM power-state words (ecpm, pcpm0, pcpm1) in
   t6041_cpu_ps_match() instead of stopping at index 2, clear
   PS_AUTO_STATE alongside PS_TARGET/PS_AUTO_ENABLE, and clear any stray
   target/auto bits on absent/fused-off CPU words without raising them.
3. Restrict fused-off channel skipping in t6041_ps_match_all() strictly
   to AMCC/DCS memory channel slices (amcc*/dcs_*) so idle non-channel
   domains such as fab6_soc still enter hardware AUTO, and restore the
   20 ms SPMI quiet window before clearing the keep-alive tables.

Signed-off-by: AxxzyWasTaken <[email protected]>
@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 25, 2026

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gemini 4 Neon on @satchlj's behalf

Audited the new top commit fc4c0a683b15 (soc: apple: t6041-sleep: fix APCIe topo order, pcpm1 match, and auto-PS skip scope) and its CI on main post-#3111:

  • Stable Kahn's topological sort (drivers/soc/apple/t6041-sleep.c:1509-1656): t6041_topo_add_ancestors() correctly deduplicates child -> parent edges via !__test_and_set_bit, handles transitive ancestors not in the target list, catches self-cycles and general cycles (!found -> -EINVAL), and frees all temporary allocations on every exit path. Running forward for child_first and reverse-index reversed for parent-first restore preserves input order for edge-free nodes (keeping auto-managed DCS nodes after AMCCs), and adding <&ps_apcie_sys_gp> to ps_apcie_phy_sw + ordering ps_ans before ps_apcie_st1/st0/gp aligns shutdown ordering cleanly.
  • Scoped fused-channel skip & CPM/CPU matching (t6041_ps_match_list, t6041_cpu_ps_match): Restricting the !(PS_TARGET | PS_ACTUAL) skip to amcc*/dcs_* via devm_bitmap_zalloc ensures non-channel idle domains like fab6_soc still enter hardware AUTO. Looping all T6041_CPM_COUNT words fixes the missed pcpm1 word, and absent/fused-off CPUs have stray PS_TARGET | PS_AUTO_ENABLE | PS_AUTO_STATE bits cleared without raising PS_TARGET. The 20 ms SPMI quiet window before clearing keep-alive tables is clean.
  • CI (fc4c0a683b15): All checks (kunit including SEP source checks / kunit, dt-checks, host-tests, rust-build, source, DWC3/ATC, readiness, pr-text) still pending (DWC3/ATC builtin-no-atc=queued/-, DWC3/ATC builtin-modular-atc=queued/-, kunit=in_progress/-, dt-checks=in_progress/-, rust-build=in_progress/-, kunit=in_progress/-, host-tests=in_progress/-, kunit=in_progress/-). Code looks solid — holding formal APPROVE strictly until remaining CI checks finish green.

@RyanTheTide

Copy link
Copy Markdown
Contributor

fc4c0a683b15 J316s (M1 Pro, T6000, boot d4802554) + J413 (M2 Air, T8112, boot 71a1e7b5) non-T6041 shared-code regression PASS (7.3.0-aurora-pr1664, CONFIG_APPLE_SOC_SLEEP=y, default cmdline): t6041-sleep INACTIVE (drv=1 bound=0 dmesg=0, mem_sleep=[s2idle]), apple-pmgr-pwrstate (189 / 146 bound), macsmc, apple_aop, apple_pmp (J316s), apple_sep all clean (subsys_err=0), s2idle 3/3 via rtc1 (suspend_success=3 fail=0 on both; J316s logged benign dwc3-apple genpd_prepare returns -11 on active USB-C tether ports without blocking suspend), Borealis VK probe OK (gpu_faults=0), Enforcing, 0 failed, 0 AVC, 0 new kernel errors; both Macs restored to saved 7.3.0-aurora-fleet89 (88c78a93 / 84f0492e).

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

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gemini 4 Neon on @satchlj's behalf:

Re-checked exact head fc4c0a683b15 now that the transient actions/checkout network timeout in DWC3/ATC builtin-no-atc has been re-run and all 14/14 CI checks are green:

  • The prior CHANGES_REQUESTED finding (duplicate apple_adp_phy_remove() unregistration / lifetime bug) remains cleanly resolved on fc4c0a683b15.
  • No remaining code or CI blockers; flipping to APPROVE.

Assisted-by: LLM (Google:Gemini 4 Neon)

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr All three blockers from the review at b4b8db1b1736 are resolved on the current head fc4c0a683b15 (rebased onto main 2943fffab7db, 14/14 CI checks green):

  1. Missing prototype (-Wmissing-prototypes): dcp_backlight_s2r_restore(struct apple_dcp *dcp) is now declared in the shared header drivers/gpu/drm/apple/dcp_backlight.h:410 (clean arm64 LLVM build).
  2. Deep-sleep soak (10+ cycles on J616C): On this exact v2 DT-driven stack (identical 26-commit range-diff to fc4c0a683b15 except the pmgr-pwrstate-test.c KUnit test-driver name fix and conflict-free rebase onto main), J616C (M4 Max, T6041) completed 14/14 consecutive real deep S2R cycles with 0 hangs, 0 GPU faults, and 0 failed units:
    • 2a75c8f8be0d: 6/6 consecutive deep S2R cycles PASS (rtc1 wake)
    • 8e43db29ae7d (rebased atop main): 5/5 consecutive deep S2R cycles PASS (18 s each, post-soak render.deferred & compute.conv2d CRCs valid) + 3/3 consecutive deep S2R cycles PASS on unmodified stock production Aura (1.0.0b15-g4a6a093d, 17 s each, confirming no Stage 2 Aura PR is required).
  3. Conflicts & cross-generation regression: Cleanly rebased onto 2943fffab7db (MERGEABLE, 14/14 CI green). Exact-head fc4c0a683b15 also passed non-T6041 shared-code regression + 3/3 s2idle on J316s (M1 Pro) and J413 (M2 Air) above (with t6041-sleep inactive), and satchlj approved fc4c0a683b15.

Ready for re-review whenever convenient.

@DjDeveloperr
DjDeveloperr merged commit efed1ae into aurora-silicon:main Nov 25, 2026
20 of 21 checks passed
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Post-merge verification note for merge efed1ae377ba: checking #issuecomment-7151927704, the 14 J616C deep S2R cycles ran on 2a75c8f8 (6) and 8e43db29 (8) prior to the manual macsmc.c conflict resolution on the rebase to fc4c0a683b15, while the J316s and J413 s2idle regression rows ran at fc4c0a683b15. Keeping the queued J616C deep S2R run on fc4c0a683b15 / efed1ae377ba as a required post-merge check; please post its result here (we will revert immediately if it fails).

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Post-merge J616C (T6041 M4 Max 16") deep S2R verification row on merged main commit efed1ae377ba9093e9c05ae0220bdb6d2914d46a (7.3.0-main-efed1ae3+):

  • Build & Boot: exact efed1ae377ba kernel + DTB (with apple,max-brightness patched 600 -> 1000 for panel safety), Aura stage2 1.0.0b16-g07ea3332-dirty, default cmdline (root=... arm64.nosme user4k=on no_console_suspend brcmfmac.roamoff=1 panic=10), mem_sleep: s2idle [deep], t6041-sleep 508304000.sleep-controller: 24 memory channels / T6041 deep sleep at EL2 through aura's S2R mailbox.
  • Soak (5/5 PASS): 5 consecutive rtc1 +15s echo mem > /sys/power/state cycles (04:09:04Z–04:10:42Z), all rc=0, elapsed=18s, boot_same=YES (boot_id preserved across all 5 cycles).
  • Post-soak hardware & GPU health:
    • 0 failed systemd units, 0 GPU faults in dmesg (before and after GPU bench), backlight=150/1000, SLC enabled, speakerguardd-v2 active.
    • Wi-Fi (wlan0) up with IPv4 lease, Bluetooth (hci0) cleanly rebound on wake, PCIe CLKREQ# ASPM L1.1/L1.2 (PCI-PM_L1.2+ PCI-PM_L1.1+ ASPM_L1.2+ ASPM_L1.1+) intact on both root ports before and after soak.
    • Post-soak gpubench-vk (/opt/aurora-mesa ec791567c7d0):
      • render.deferred depth 1: 215.89 us (4632 fps), CRC 2cfe9a54 valid
      • render.deferred depth 2: 109.22 us (9156 fps), CRC 2cfe9a54 valid
      • compute.conv2d depth 1: 267.67 us (7746.97 Mpix/s), CRC 2d55a14d valid
      • compute.conv2d depth 4: 162.34 us (12773.38 Mpix/s), CRC 2d55a14d valid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:bringup Area from CODEOWNERS (bot) area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) area:power Area from CODEOWNERS (bot) area:rust Area from CODEOWNERS (bot) area:wireless Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) changes-requested A reviewer requested changes (bot) door:one-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.

6 participants