Repository navigation
soc: apple: suspend-to-RAM on the M4 Max (T6041, J616c) - #1664
AxxzyWasTaken wants to merge 39 commits into
Conversation
|
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 GPU: the 40-core part runs Then it hangs:
PMU notes (
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 |
84f27ca to
fe530fa
Compare
|
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 I've pushed four commits for it:
To try it on your current build, this in your DTS should be enough:
|
fe530fa to
3862ef2
Compare
|
Thanks, the SEP DART lists were it: the hang at 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:
Real sleep, PMU scratch after the 35.6 reset (
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 ( I'm happy to run more: a different wake source, a debug build, or other PMU offsets. |
|
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: 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 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 |
|
Thanks! The raw PMU scratch 0x8300-0x83ff from that 35.6 run ( Correction to my last comment: 0x8359/5a fall inside the bitmap, which is written after them, so the fac697f: still resets. Built as fac697f with fe530fa's (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. |
|
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 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. 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? |
|
Your exact branch: still resets. Built fac697f as it is (base integration/aurora 9219565), with only fe530fa's 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. |
|
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: So, to see which domain it is, a small patch on top of fe530fa's 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: |
|
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). 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. |
|
The map from the J614c, same build as my exact-branch run (fac697f + fe530fa's sleep files) plus your patch, Nothing is on in yours that's off in mine. On here and off on your J616c, named from the J614c ADT's pmgr
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 |
|
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:
So on yours, the last eight channels are never flushed, and their PS words stay forced on. That holds fab3_soc at I've pushed
One check before you run it: the AMCC and DCS addresses for groups 6 and 7 are extrapolated from the first six: AMCC block If it still resets, the same map with the new commit would show whether fab3_soc came down. |
|
f3fcc17: still resets. The addresses match the J614c ADT first:
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 |
|
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
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:
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. |
|
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.
Raw dump of 0xa340..0xa3bf for reference: 🤖 Generated with Claude Code |
|
One more thought on those words, and a question.
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 |
5499579 to
7288144
Compare
|
Same result on the new head (7288144, with the integration/aurora merge) plus the same two diag commits: 32 memory channels, 🤖 Generated with Claude Code |
|
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
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 🤖 Generated with Claude Code |
|
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 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 On 7288144 plus that line, J614c (16/40, 32 channels, os-fw 26.6.2), one boot:
Still open on the J614c:
🤖 Generated with Claude Code |
|
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: 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: The SD reader after a wake. I found the cause of the @@ 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 Still open here: 🤖 Generated with Claude Code |
7288144 to
8f34100
Compare
|
Rebuilt the series without the merge commit: the 37 commits now sit directly on fc05050, the merge's It still conflicts with current Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested on my M4 Max as described. |
|
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. 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 Brightness after a lid wake: two parts.
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 |
The probe line and the header comment still said "test, entry only" and "no resume yet". The driver resumes: the commit writes cpu_resume into aura's S2R mailbox, and the wake comes back through it. No code change. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
The spin table only stops a parked CPU that answered a hold first: smp_rvbar_spin_table_cpu_die() leaves the park for the stop only while spin_table_hold_parked() has asked for it. The T6041 commit called spin_table_stop_parked() without the hold, so every other core stayed awake in the park, with its power state still on. The sleep engine then waited for the cores, and the watchdog reset the SoC about 5 s after the commit. Ask for the hold in .enter while the suspend can still be refused, as the sleep core does for T8140, and refuse the sleep if a parked CPU does not answer. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
The driver writes the PMU over the SPMI controller by itself and gave
each command's reply a fixed 50 us before draining the FIFO. A reply
that arrived later stayed there. The controller keeps its power
through the sleep, so after the wake the SPMI driver's next command,
the RTC's acknowledge of the alarm that woke the machine, read that
reply ("unexpected SPMI response 0x8b30"), the RTC marked its I/O as
failed and refused every later suspend.
Poll for the reply for up to 1 ms, then drain the FIFO.
Assisted-by: LLM
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
While Linux is away the queue keeps being used: aura's wake path and
the platform's sleep code write the PMU through it. Every command the
driver sent was answered before the suspend, so a reply still waiting
at the resume is someone else's, and the next command takes it as its
own. On the M4 Max that was the RTC's acknowledge of the alarm that
woke the machine ("unexpected SPMI response 0x8b30"), after which the
RTC refused every later suspend.
Read such replies out at resume_noirq after a firmware-driven suspend.
Assisted-by: LLM
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
aura writes the PMU on the same queue at the wake. Waiting for the first reply after a write could take one of its replies for ours and leave ours behind. Empty the FIFO before the write as well. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
… lists On T6041 the enclave is told to sleep at device suspend. Its DART is saved first with apple_dart_sleep_prepare(), which only saves a DART whose node has apple,sleep-restore, and only such a DART is then left alone by its own callbacks. Without the property nothing was saved, the enclave slept, its power domain went off, and the DART's noirq suspend read its registers: the suspend hung there. This was seen on a J614C booted with the in-tree device tree, which has no lists for that DART. Refuse the sleep at suspend instead when the DART has no list. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
Without the mailbox the driver set its suspend ops anyway and refused every sleep in .enter. Deep sleep is then the default, so a kernel booted at EL2 by another loader could not suspend at all. Don't bind instead. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
The T6041 sleep driver binds to an "apple,t6041-sleep" node, which the J614c and J616c device trees get at their root. The node has no registers and no properties: the driver maps the blocks it writes itself, and finds its way back from a sleep through the boot loader's S2R mailbox in /chosen. The other Apple sleep bindings (apple,t8140-sleep and apple,t6050-sleep) require the registers and the display coprocessors, so this node gets a binding of its own. Without it, CHECK_DTBS reports /t6041-sleep in t6041-j614c.dtb and t6041-j616c.dtb as matching no schema. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
Give the SEP's DART the writes around a sleep that T8140's has, as the J616C's bring-up device tree does: the SEP driver saves the DART with them before the enclave sleeps at suspend, and refuses that sleep without them. Add the apple,t6041-sleep node to the J614C and J616C, so the in-tree device tree is enough to test suspend-to-RAM there. The driver stays out unless aura passes its S2R mailbox. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
The 40-core J614C on 25G83 firmware runs CONFIG_25G83, which had no sleep_restart, so its GPU refused every deep sleep. Set it as the 32-core profile has. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
Remove what was only there to find the sleep's problems on hardware: the dry, diag and serror_go parameters, the progress marks and notes in PMU scratch and SRAM, the register snapshot against the macOS table at the commit, the before and after windows with their S2RDIFF and S2RAMCC lines, the console, die and panic notes, and code nothing called any more (the MCC stop, the AXI2AF teardown, the core snapshot). The writes, delays and polls of the commit and of the wake are the same as before. The AMCC cache words and the display's PMC votes, which the wake puts back, are saved on their own now instead of through the comparison windows. The clkgen write-back that worked from those windows only ran with diag set, and goes with them. What the wake could not bring back is reported at .end. apple_sleep_coprocs_count() had no other user and goes too. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
apple_dart_display_keep() read the whole register block of a display DART before a sleep and printed what differed after the wake, with each stream's TCR and TTBR. That was only there to look for what the wake took. Keep the TCR and TTBR save and write-back, and declare the helper in <linux/soc/apple/dart.h> instead of in its caller. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
The display stop and restart for T6041's deep sleep ran as test steps first: an s2r_stop parameter took them one at a time, and each step wrote progress marks to PMU scratch, logged S2RSTOP, S2RSTART and S2RTIME lines and kept result words. A kmsg dumper put a panic's call trace into PMU scratch, and s2r_bl showed the backlight state. Remove all of that, and the parameters with it. The waits are constants with the values that ran (settle 200 ms, words 100 ms, stop 300 ms, down 100 ms), and each switch keeps the behaviour it had by default: the display power-off without the sleep transition (s2r_hard = 2), bridge 4 left as boot has it, the GAPF word not written back, the backlight and the boot power words restored, the steps run from the display's own suspend and resume. What fails is still reported. The power word step now unmaps what it maps. dcp_sleep() has no caller again and gets its __maybe_unused back. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
…ISPEXT The M4 Max gate enables each external display chain as the in-tree trees describe it: no DISPEXT power domain, the domains are on as iBoot left them. The J616c's bring-up EL2 tree does describe them: the chains' DARTs, mailbox and DCP point at dispextN_fe, which is disabled like the PMP report entries above it. Enabled as they were, those devices waited for power domain providers that never came and failed at the deferred probe timeout (the mailboxes with -110), and the display subsystem never bound: the internal panel stayed on simpledrm. Drop the power-domains property of a chain node whose domain stays disabled, so such a tree ends up as the in-tree ones do. Nothing changes with the in-tree trees. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
The power word step forces both external display chains down, and the display subsystem maps every framebuffer through their display DARTs. Only the DART of an external DCP the stop visited was marked dark, but a DCP whose probe failed (the display subsystem skips it as unusable) is not bound to the DCP driver, and the stop never saw it. After the wake, an sddm restart or a logout unmapped a framebuffer, flushed that DART behind its dead block, and the machine stopped: on the J616c the HDMI chain's display DART at 0x3a2300000. Mark the external chains' display and DCP DARTs dark by device tree node right before their power words go down, while they can still be read, whether or not their DCP bound. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
The display stop for a T6041 sleep kept one "stopped already" slot per external DCP by name: dcp@3a2e00000 got one, every other external DCP shared the second. With more than two external chains enabled (dcpext2, dcpext3) the second external DCP to be stopped marked that slot, and any after it was skipped: its firmware still ran at the commit. The DARTs made dark before the power word step were also only those of the first two chains. Keep the mark in each DCP, and make the display and DCP DARTs of every enabled apple,t6041-dcpext node dark, found through the device tree. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
The full T6041 has eight AMCCs and 32 memory channels, the binned one six and 24. The sleep path only handled 24: the AMCC quiesce, the cache flush and way restore, and DCS dynamic power gating stopped at the sixth AMCC, and the macOS commit table (from a binned J616c) has no words for amcc24-31 or dcs_24-31. On a full J614c those words stayed forced on at the commit, holding fab3_soc on, and the chip reset instead of sleeping. Count the channels at probe from amcc24's and amcc28's PS words, which read target and actual 0 on the binned part. On the full part, run the quiesce, flush and restore on all eight AMCCs. Put the 15 extra words on AUTO as macOS has the same kind of word, save them first, and put them back on the wake before the cache restore. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
The sleep commit writes WKTP = 2 on T6041, but nothing wrote it back.
With the key left at 2 the SMC treats all the time awake after the first
sleep as a power nap: it keeps its own fan policy against a fan request
(on the J616c every fan target write timed out after about 10 s and the
fans stayed at 0 rpm under load), and under thermal load it requests a
sleep once a second ("SMC Thermal pressure requested Sleep during power
nap" in its syslog), slowing the machine down. Only a reboot cleared it.
Write WKTP = 0 after a full wake, and when the sleep ends in a refusal
(apple_smc_complete), as the M4 Pro sleep series in aurora-silicon#1910 does. A dark
wake keeps the key: it sleeps again, and the next commit writes it anyway.
Assisted-by: LLM
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
… EIO again integration/aurora now requires request-path messages in apple_sep to be rate-limited (tools/aurora-sep/tests/test_log_ratelimit.py). Use the rate-limited macros for the T6041 suspend-time sleep path and the mailbox check. On platforms with a sleep core commit, sleep_enter() refused a Lost gate with EBUSY and a message; integration/aurora refuses it with EIO, which sep-suspend-errors-tests checks. Take that back: T6041 never reaches it, it sleeps through the suspend-time path. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
…ests The bcm4377 resume and SEP suspend tests compile extracted driver functions against fixtures. The T6041 S2R code those functions now call is not in the fixtures, so neither test built. bcm4377: dma_window_base, pm_resume_via_firmware() and bcm4377_queue_rebind(). The controls model resumes after s2idle, so pm_resume_via_firmware() is false and the rebind is never reached. SEP: sleep_at_suspend, sleep_enter_at_suspend(), sleep_exit_at_suspend(), mailbox_drains() and pm::platform_commit(). Every platform the test models has a sleep core commit, so platform_commit() is true, the suspend-time path is never taken and the mailbox always drains. All controls and mutations pass, as does the whole run-host-tests.py suite (321/321). Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
8f34100 to
cd59f6b
Compare
|
Rebased onto current Conflicts
Binding Duplicates Tested (compile and checks only)
The rebased series has not been booted. What ran on the J616c is the previous head on fc05050. Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested as described. |
|
I booted the rebased head (cd59f6b on integration 59b02d5) on the J614c, with the dcs_27 line added. It wakes, from On the dim panel after a wake, a correction and a finding. Correction: I wrote that only lid sleeps showed it. On the rebased head the Finding: a DPMS off and on from the compositor fixes it every time, even with only 0.1 s off (GNOME:
In the DCP syslog the bad and the good power-on look the same:
The differences:
So something in the mini-LED path that the first power-on after the restart sets up seems to need either time or the end of the resume. I don't know which yet. A delayed off/on works as a stopgap in my daily, but I don't think it's the right fix for the PR. Still seen on the J614c: 🤖 Generated with Claude Code |
The full T6041 (J614c, 32 channels) reset in the sleep. joske's dump of all 32 AMCC and 32 DCS power words right after t6041_atc_commons_on() found 63 of them on AUTO and one forced on: dcs_27 at main +0x530 (DCS_27 in the J614c's ADT pmgr:devices) read 0x0f0002ff. It isn't next to dcs_26, so the list of the full part's words missed it. Add it to t6041_full_ps with the value the other DCS words get, 0x1400034f. With this line the J614c sleeps and wakes (rtcwake and lid, on the previous head and on this one rebased; joske). The list is only used on the full part (eight AMCC groups); on the binned J616c dcs_27 is fused off and reads 0x0f000300. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
|
@joske thanks for all of this, and sorry for the slow answer. dcs_27 is in a new commit at the head, "soc: apple: t6041-sleep: dcs_27 to AUTO at the commit on the full part". It is your line, Camera: thanks. The description now says the camera works after a wake on the J614c, and drops the old note. Dim panel after a wake: I don't know the cause yet, and I haven't looked for it on my J616c. From your findings, the first power-on after the restart differs in two ways: it loads the LED M3, and it runs inside the resume. A later off and on fixes the picture. These are the checks I'd run next, in this order:
I agree that the delayed off and on shouldn't go into this PR as the fix. If none of the checks above finds the cause, it could go in as a separate commit marked as a workaround, so it's easy to drop later. Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested as described. |
Real suspend-to-RAM on the MacBook Pro 16" M4 Max (T6041, J616c) under Linux at EL2: entry, wake and a full resume of the running system, from the lid or
systemctl suspend. It uses the sleep core from #1445; the T6041 side has its own platform driver (t6041-sleep.c), because the M4 Max commits through aura's S2R mailbox rather than the T8140 path.Draft: the sleep works on my machine and the bring-up diagnostics are gone; see "Not working" for what is left.
Tested on
One machine: J616c, 26.6.2 firmware, booted at EL2 through aura.
This series, on #1445 as it was on 11 Nov (
b8f5b1e7f750), 12 Nov:integration/aurora(9219565939723cd5) for this PR; it rebased without conflicts, and two new AOP configs (T8152, T8142) needed the newed0pfield. With the J614C fixes and the cleanup below, 12 Nov evening: 3 deep sleeps in a row (RTC alarm, 20 s each), each one back on its own: Wi-Fi with the SSH session up, NVMe, Bluetooth,suspend_stats3 ok and 0 failed. With the display gate fix below as well: the internal panel on appledrm from boot, then a lid close and open, deep sleep, and the picture back after the wake.The same T6041 code on my older bring-up tree (7.3 daily kernel, 10 to 12 Nov):
Found while porting onto #1445
spin_table_hold_parked()first. The T6041 commit calledspin_table_stop_parked()without the hold, so the other cores stayed on and the watchdog reset the SoC 5 s after the commit. The T6041 enter now asks for the hold while it can still refuse.spmi-apple-controllernow drops replies left over at a firmware-driven resume, and the T6041 driver drains the FIFO around its own PMU writes. The SPMI change applies to any firmware-driven suspend, so T8140 too; it would be good to check it there.Found on a J614C (joske's test, 12 Nov)
apple,sleep-restore; the J616C's bring-up tree has the lists, the in-tree one didn't. Without them the DART's noirq suspend read its registers after the SEP's domain went off.t6041.dtsinow has the lists (the same writes as T8140's), and the SEP refuses that sleep with a message instead of hanging when they're missing.CONFIG_25G83inhw/t6041.rshad nosleep_restart, so the GPU refused every sleep there; it has it now.apple,t6041-sleepnode, and the driver doesn't bind without aura's S2R mailbox (before, it set its suspend ops and refused every sleep).Found on a J614C (joske, 17 Nov)
soc: apple: t6041-sleep: dcs_27 to AUTO at the commit on the full partputs it on AUTO with the others. With that line, the rebased head (cd59f6bf5donintegration/aurora59b02d5) wakes on the J614c fromrtcwake -m mem -s 20and from a lid close: panel, Wi-Fi, speakers and the SD reader are back. An earlier head with the same line slept 9 h 30 min unplugged for -18 mAh. The commit itself is build-tested only.apple_soc_edac event-log-handler: hardware error: event-log source 9a few times around each wake on the J614c. Nothing visibly breaks.Found on the J616C with integration/aurora
power-domains = <&dispextN_fe>, disabled like the PMP report entries above it; the in-tree trees describe no DISPEXT domain. The M4 Max gate enabled the chain nodes only, so they waited for domain providers that never came, failed at the deferred probe timeout (the mailboxes with-110), and the display subsystem never bound: the panel stayed on simpledrm.soc: apple: display-gate: M4 Max: chains from a tree that describes DISPEXTdrops the property where the domain stays disabled; nothing changes with the in-tree trees.iommu@3a2300000, the HDMI chain's display DART. That chain's DCP fails its probe here, so it is not bound to the DCP driver and the sleep's stop never marked its DART dark, while the power word step powers the chain off.drm/apple: T6041 S2R: the external chains' DARTs dark by nodemarks both external chains' display and DCP DARTs dark by node before their power words go down. After it: 2 deep sleeps, each followed by an sddm restart, in one boot, with the machine and the panel fine. Then on my daily build of this series (latestintegration/aurora+ this PR + clpc/g17: busy-share memory floor from the DT + light effort on every G17 #1369), a lid close and open followed by a desktop logout: fine.dcp_platform_suspend()warns twice (workqueue.c:4409,flush_workandcancel_delayed_work_syncon work that was never set up), apparently for the external DCP that is skipped as unusable. Harmless. That code isn't from this series, the gate fix only makes it reachable here; I left it alone.Not working / not tested
External displays: I have no external monitor to test with. The current code shuts the external display controllers down at the first sleep and they stay down until a reboot (as J616s (M4 Pro) at EL2: hibernation and suspend-to-RAM #1477 does).
@astaff, you are the other person doing M4 Max work: if you have a display and want to try or fix this part, that would be very welcome.
Touch ID after a wake, bring-up tree: works (a lid close and open, then a fingerprint unlock at the lock screen). A deep sleep is refused, cleanly, while the enclave is not confirmed asleep (
soc: apple: sep: refuse a deep sleep at once over a stuck enclave).Speakers after a wake: the amplifiers keep their configuration and report no fault; playback not checked by ear.
Camera: works after a wake on the J614c, including after a 9.5 h sleep (joske). Not checked on the J616c.
Panel dim after a wake (J614c): the brightness level is right, but the picture is at about half brightness until a DPMS off and on from the compositor; the same cycle inside the resume doesn't fix it (joske, 17 Nov). Cause not found yet.
Touch ID after a wake on this tree: works (a lid close and open, then an unlock at the lock screen). One earlier try failed 5 times and locked Touch ID; the integration driver keeps that lockout across restarts until
SEP_BIO_REARMgets the password, which nothing on my install calls yet.pm_test=platformand the display: the display stop assumes a real sleep follows. Underpm_testthe firmware is stopped but never power-cycled, the restart expects a power cycle, and the internal panel stays dark (joske, J614c). Not supported yet.Wi-Fi WoWLAN: with WoWLAN enabled, brcmfmac refuses
deepwith -95 (brcmf_pcie_pm_enter_D3) and the suspend is aborted; WoWLAN is s2idle only. Withdeepas the default, that is worth knowing (joske).More than two external DCPs: the display stop used to handle only the first two external DCPs;
drm/apple: T6041 S2R: every external DCP, not only the first twohandles every enabledapple,t6041-dcpext. Build-tested only.Notes for review
apple,t6041-sleepnode and the SEP DART lists; I have only slept with the bring-up EL2 DTB on the J616C so far.sep_pm_platform_commit()picks the path.spmi: apple: drop replies left by firmware at a firmware-driven resume(above),pinctrl: apple: ack a level interrupt again after unmasking it(all Apple SoCs; it stopped an interrupt storm from the speaker amps after a wake here),PCI: apple, nvme-apple: resume asynchronously, and the coprocessor stop helpers insleep.c.t6041-sleep.c(thedry,diagandserror_goparameters, PMU scratch marks and notes, register snapshots), the DCP driver (thes2r_*parameters, the step-by-step test hook, S2RSTOP/S2RSTART prints, the panic dumper) andapple_dart_display_keep()(its register dump). The commit and wake do the same hardware writes, delays and polls as before; the defaults the parameters had are now fixed. They are separate commits so the change is easy to review, and can be folded into the commits they clean up. The 4 BRING-UP ONLY commits are dropped.