Repository navigation
soc: apple: sleep: add T6000 (M1 Pro / J314s) suspend-to-RAM support (on #3381) - #3534
olivergreg wants to merge 36 commits into
Conversation
For a suspend-to-RAM that goes through firmware, a controller without
the warm sleep sequence is put in IDLE, not shut down:
apple_nvme_suspend() saves the SART's entries, calls
apple_rtkit_idle() and then apple_rtkit_reinit(). The reinit frees
every buffer the firmware was given (syslog, crash log, ioreport,
oslog) with dma_free_coherent() and takes its range out of the SART.
On the wake the reset work calls apple_rtkit_reinit() once more,
writes the saved SART entries back, the freed ranges among them, and
starts ANS.
An idled ANS keeps its state. On T6000 (M1 Pro, J314s), after the
wake it sends HELLO, the kernel logs "RTKit: Initializing (protocol
version 12)", the endpoints are started, and the firmware then sends
syslog records without a buffer request or a SYSLOG_INIT before them:
RTKit: received syslog message but no syslog_msg_buffer
logged at each sleep and each wake. The firmware still writes the
records' text to the buffer it had before the sleep, which the page
allocator has handed to someone else by then, and which the SART
admits again. With an out-of-tree T6000 sleep sequence that freed and
re-admitted the buffers the same way, ANS's syslog text was found in
a process's page tables ("Bad page map"), followed by an oops.
Keep the buffers for as long as the firmware may use them. Add
apple_rtkit_reinit_retaining_buffers(), which resets a session's
handshake state as apple_rtkit_reinit() does and leaves the shared
buffers, their SART ranges and the syslog geometry alone, and use it
for the idle before the sleep and for the restart after it.
Both ways the firmware can come back are then served by the code
that is there:
- a firmware that resumes with its state never asks, keeps writing
to memory that is still its own, and its syslog records are read
and printed again;
- a firmware that starts from scratch asks again. A request of the
same size for an endpoint that has a buffer is answered with that
buffer by apple_rtkit_common_rx_get_buffer(), and a SYSLOG_INIT
replaces the geometry.
Nothing is allocated per sleep. The buffers are released as before
by apple_rtkit_free(), or by the apple_rtkit_reinit() of a
controller reset, which follows a shutdown the firmware
acknowledged.
The path is not specific to T6000: T8103 (M1) takes it as well. The
T8122 warm sequence does not reinitialize and is unchanged.
Fixes: 7dfc208 ("nvme-apple: idle ANS for a firmware sleep and start it cold after the wake")
Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
apple_pcie_hib_port_up() slept 100 ms after each link it retrained, the time PCIe r5.0 section 6.6.1 requires before the first configuration request. No configuration request is sent until every port is up, so one wait after the last retrained link covers them all. On a MacBook Pro 14" (M1 Pro, J314s), where the radio and the card reader ports both come back cold, this takes 100 ms off each wake. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
On conventional Apple PCIe hosts that reinitialize their links after a firmware-driven suspend-to-RAM (apple_pcie_s2r_reinit()), endpoints such as the Wi-Fi/Bluetooth and SD card reader links on T6000 (M1 Pro) can run with ASPM L1, ClockPM and L1.1/L1.2 substates enabled on the default kernel command line. When those endpoints transition to D3hot during suspend, the link can drop CLKREQ# ahead of the sleep commit's APCIe bridge quiesce and hang suspend entry unless pcie_aspm=off is passed. Save and clear ASPM, ClockPM and L1SS on each downstream link of a reinit host in apple_pcie_prepare() for firmware-driven sleeps, and restore them in apple_pcie_complete() after resume or on rollback. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
A firmware sleep (suspend-to-RAM) cuts the power of the SoC, the pin controller and the SPI controller. Keys and the trackpad wake the machine through the SMC there, not through the controller's interrupt. The interrupt armed for wake is still pending when the AIC comes back and is counted as a wakeup event after every wake, so a wake the SMC took for the lid or the charger alone cannot go back to sleep. Arm it only when the suspend does not go through firmware. For a firmware sleep the controller is powered off and booted again on resume, as for a device that may not wake the system. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
A SoC whose commit does not stop SIO has its firmware stopped at the late suspend with apple_rtkit_sleep_stop(). A dry run of the sleep refuses before the commit, so the firmware was stopped for a sleep that never happened. Return before the stop when apple_sleep_dry_run() holds. The busy-channel check and the refusal for a SoC that needs the stop at its commit still run, so the dry run reports what a real sleep would refuse. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Before its sleep notice to the SMC, macOS switches off supplies that are wired to SMC GPIOs and that no driver switches at that point. On the J314s (MacBook Pro 14", M1 Pro) it is GPIO 26, the SD card reader's power enable. Which SMC GPIO powers what is board wiring. apple,sleep-low-pins lists the SMC GPIO numbers to drive low before the sleep notice and high again after the wake. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Add "apple,t6000-sleep" for the M1 Pro, with the 22 register blocks its suspend-to-RAM sequence writes. Its wake sources are armed from apple,wake-enable, which is required. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
A firmware-driven suspend powers the interrupt controller down with the rest of the SoC. AIC2 comes back with its global configuration, its per-interrupt target words and its masks at their reset values. The AIC3 variants already save and restore that state through aic_syscore_ops, selected by .fw_suspend. The saved registers are AIC2's own layout, which AIC3 inherited, so set .fw_suspend for AIC2 as well. Both operations do nothing unless the suspend goes through firmware, so an AIC2 SoC without a sleep driver only allocates the save array. Needed for suspend-to-RAM on T6000 (M1 Pro). Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
apple_rtkit_start_ep() refuses an application endpoint unless the firmware is running. A restart through the full boot handshake has to start the application endpoints before that state is reached. Move the message into apple_rtkit_start_announced_ep(), which checks only that the endpoint map announced the endpoint, and keep the state check in apple_rtkit_start_ep(). No functional change. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
apple_rtkit_sleep_return() restarts a coprocessor parked by apple_rtkit_sleep_stop(). The mailbox is not stopped on that path, so apple_mbox_start() finds it started and writes nothing. Where the mailbox's block lost power in the sleep, its interrupt enables and outbox enable are back at their reset values, the firmware's HELLO raises no interrupt and the handshake times out. That is the case for SIO and the PMP on T6000 (M1 Pro). Call apple_rtkit_mbox_restore() before the run bit is set. It writes the enables apple_mbox_start() wrote at the first start, so a mailbox that kept them is unchanged. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
apple_rtkit_sleep_return() expects a firmware that restarts warm, with its buffers and endpoints kept. On T6000 (M1 Pro) the display coprocessor and the GPU, both on firmware 13.5, boot from scratch after a sleep that took their power: they wait for IOP power state INIT before HELLO, send the endpoint map again and have every application endpoint closed. Treated as a warm restart they never answer. Add apple_rtkit_sleep_return_with_init() for them. It resets the session expecting a new endpoint map, restores the mailbox's enables, sets the run bit, sends IOP power state INIT and waits for the map and the power state acknowledgment as at a first boot. It then starts every application endpoint that was started before the sleep and sets the AP power state on. The restart preparation is shared with apple_rtkit_warm_restart() through apple_rtkit_prepare_restart(); the warm case is unchanged. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
After the sleep request is sent, the enclave's answer is polled for until it arrives, the power word shows DEV_DISABLE, or 5 s pass. The M1 generation never sets DEV_DISABLE: an enclave that is down shows an actual state of 0, which the wait after the poll already accepts through sep_ps_down(). An enclave that gated before its answer was read ran the poll to its timeout, and the request was treated as failed, which is fatal after the send. T6000 (M1 Pro) was brought up with this case accepted. Use sep_ps_down() for the poll as well, and accept a request with no answer read and the domain off. An answer that reports an error still fails, and so does a timeout with the domain on. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
For a system sleep the AOP driver sends each started AFK endpoint a sleep message and, after the wake, a wake message. The T6000 profile left both lists empty, which addresses every endpoint from 0x20 to 0x30. The profiles whose order was traced on macOS (T6041, T8142, T6050) address the twelve endpoints 0x20 to 0x2b and nothing above. Name the same twelve for T6000, in endpoint order both ways. The order has not been traced on this SoC; apple,sleep-endpoints and apple,wake-endpoints can still override it. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The boot loader locks some DARTs before it hands over, and the driver neither saves nor restores a locked DART around system sleep. On T6000 (M1 Pro) suspend-to-RAM powers the DARTs down. A locked DART comes back with every register at its reset value, the lock bit included, while its page tables are still in DRAM. The first DMA of its consumer after the wake faults. Mark the T6000 DART type with sleep_clears_lock. Such a DART has its lock word and stream enables saved at suspend with the TCR and TTBR registers. After a wake through firmware, if the registers no longer hold the saved translations, they are written back, then the stream enables, then the lock word, and the TLBs are flushed. A locked DART whose registers survived, and the other DART types, are left alone as before. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
T6000 (M1 Pro) has a first-generation SMC like T8103: it is told of a suspend-to-RAM last, with interrupts off and one CPU left, which needs the saved command lane the driver uses for T8103 and J813. Enable the lane for "apple,t6000-smc" where the device tree has an enabled T6000 sleep controller, so the T6001 and T6002 machines that share the compatible keep the ordinary transport. Between slpw and slpa macOS writes, in this order: - gP1a = 0, the SMC GPIO that powers the SD card reader on the J314s; - pmVC, the VDD_CIO rail mask, which T8103's SMC does not have; - WKTP = 2, as on T8103. Take the GPIOs from apple,sleep-low-pins. Each is written 0 before the other keys and switched on again after waka, if this sleep lowered it. pmVC is written from the existing apple,sleep-pmvc, before WKTP. T8103 sets neither property and sends what it sent before. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Suspend-to-RAM on T6000 (M1 Pro) powers the display crossbar down. It comes back with its tunable gone and every output unrouted, while the mux core and the driver still hold the selections made before the sleep. A display connected over USB-C before the sleep stays dark. Mark the T6000 crossbar as reset by a firmware sleep. On resume after such a sleep, write the probe-time tunable and run the ordinary selection for each output that has one. Suspend-to-idle, a refused sleep and the other crossbar variants are not affected. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
macOS sends the display firmware the unnamed A500 call before it stops the coprocessor for a sleep. The H17P and 26.6 tables carry it as dcpep_unnamed_500 with iomfb_s2r_500(). The 13.5 firmware, which T6000 (M1 Pro) runs, dispatches the same call under the same tag. Add it to the 13.5 method table with iomfb_s2r_500_v13_3(). The argument is zero, the form the T6000 sleep was brought up with, and the firmware is given 2 s to answer. No caller yet; the T6000 stop that sends it follows. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The internal display coprocessor of T6000 (M1 Pro) runs firmware 13.5, for which the driver has no stop: across a system sleep the firmware is left running with its domains held on. Suspend-to-RAM takes the coprocessor's power regardless, and afterwards the driver waits on a session that no longer exists and the panel stays dark. Give "apple,t6000-dcp" its own match data with hw.sleep_13_5. For a sleep that goes through firmware, the internal processor on 13.5 is: - sent A500, as macOS sends it before the stop; - parked and stopped with apple_rtkit_sleep_stop(); - restarted on resume with apple_rtkit_sleep_return_with_init(), since this firmware boots from scratch after losing power. A dry run of the sleep leaves the firmware running. After a sleep refused with the firmware already parked, apple_rtkit_sleep_return() is used. The later firmwares have their own stop under hw.s2r, and no other SoC on 13.5 sets the flag. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The HDMI port of the 14" and 16" MacBook Pro sits behind a DP-to-HDMI converter whose supply is an SMC GPIO (dp2hdmi-pwren-gpios). The driver switches it on at probe and leaves it on. The SMC keeps its GPIOs through a suspend-to-RAM, so the converter stays powered while the SoC is off and draws several hundred milliwatts, more than the rest of the machine in that state. macOS has it off. Switch the supply off in the suspend path when the sleep goes through firmware, and on again first thing on resume, before the port's hot-plug state is sampled. The converter's draw was first measured by Andreas Fernandez. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Two points of the early-context entry are fixed in the core and differ on T6000 (M1 Pro), whose sequence follows macOS: - SEP is asked to sleep after the display blocks are down. On T6000 macOS asks SEP first, and the display blocks' lowering waits for SEP's power gate. With .enclave_first, SEP's stop runs right after the other cores are held, with ops->before_enclave ahead of it. - apple_sleep_commit() stops the parked cores before ops->commit_regs. T6000's commit stops them in the middle of its own sequence, after PLL0 is off and before the last cluster's target goes to 0. With .commit_stops_cpus the core leaves the stop to commit_regs. No profile sets either yet. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Add the T6000 (M1 Pro) sleep profile to the Apple SoC sleep driver, following the PMGR S2R timer commit path used on Firestorm/Icestorm SoCs (based on the T6000 suspend-to-RAM reference by Andreas Fernandez). The profile: - arms wake sources from the device tree's apple,wake-enable property and reports T6000 wake source names from the ADT wake map; - waits for SEP to power-gate, saves PMGR domain state, quiesces the GPU and display fabric bridges (using the same 4-word bridge handshake as T8103) and drops PMP requests before lowering display and GPU domains; - quiesces the four AMCCs and their DCS channels (RMW low-power gating), the PCIe bridge, CPU complex counters/throttlers/APSC, DCS clock state, cluster targets, SoC clock muxes and PLL0, dcs_* domain words, NCO channels, and the final PMGR, clock, fabric p-state and SIO commit state before arming the PMU RTC SPMI vector, AIC mask and S2R timer; - restores clocks, clusters, AMCC/DCS state, PMGR domains, PMP DAPF and IORVBAR, NCO channels, SEP/SIO/GPIO domains, and all AP pins via the shared apple_sleep_restore_pins() path on wake, and reports any entry step that timed out or was left incomplete. Deep sleep is enabled by default on boards that enable the sleep node. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Add the two calls a Rust driver needs to take its coprocessor through a sleep that cuts its power: apple_rtkit_sleep_stop() and apple_rtkit_sleep_return_with_init(). Both take the mapped CPU control word of the coprocessor's ASC and are unsafe for that reason. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The first-generation driver, which runs the G13 GPUs on firmware 13.5, refuses every sleep that goes through firmware: the sleep takes the GPU's power and the driver could not bring its firmware back. On T6000 (M1 Pro) it can: - at .suspend, submissions still in flight get 500 ms to finish, then the firmware is parked and its CPU stopped with apple_rtkit_sleep_stop(). A submission still pending refuses the sleep; - at .resume it is restarted with apple_rtkit_sleep_return_with_init(). The firmware boots from scratch; the driver keeps the state it had in DRAM and kicks the firmware once it is up. Select this with a new HwConfig field, sleep_restart, set for T6000 alone. The driver keeps the GPU object and its ASC block for the two callbacks. A dry run of the sleep leaves the firmware running. A sleep refused after the park leaves the GPU down until the next sleep that happens, and says so. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Describe the register blocks the T6000 suspend-to-RAM profile writes, and name the internal display coprocessor for the core's display check. The node sits in the die 0 include that T6000, T6001 and T6002 share, since the blocks are the die's. The sequence has only been qualified on T6000 (M1 Pro), so the node is disabled here and a board that sleeps enables it. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Enable the sleep controller on the MacBook Pro 14" with M1 Pro, the board its sequence was brought up on, and describe what the sequence needs from the other devices: - the SMC writes pmVC = 0x100 before its sleep notice and switches SMC GPIO 26, the SD card reader's power enable, off for the sleep; - the PMP's firmware SRAM is kept across the sleep, which takes its power; - the AP pin controller has every pin restored except 114, 115 and 119; - the four USB-C port controllers are told the system power state, S3 before the sleep and S0 after it. The profile is not marked untested in the driver, so deep sleep is the default sleep state on the default kernel command line, with no apple_sleep parameter. The J316s and the T6001 and T6002 machines keep the node disabled. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
With .enclave_first, SEP is asked to sleep right after the other cores are held, and ops->display_off follows. Neither can be taken back, but the coprocessors' last checks, the SMC scope check, the SoC's final check and the pending-wakeup check still came after them. A sleep refused there returned with SEP asleep and, on T6000, with the display and GPU domains down, and the resume that followed hung. Run every other check first. SEP's request is then the last refusal, as it is without .enclave_first, and ops->display_off runs past it, where a failure can no longer be returned. On J314s a sleep refused at the last check hung the machine before this, and returns to a running system with it. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
T6000 matched the generic data, so its firmware was idled and stopped in the late suspend. A firmware-driven sleep can still be refused after that, and an idled firmware does not come back with its power kept: the sleep engine has no reset for it on T6000 (-ENODEV), so it stayed stopped until a sleep that happened. Give "apple,t6000-sio" the generic words with .stop_at_commit. Where the board has a sleep controller the firmware then runs until the sleep's commit idles it, past the last refusal, as on T6041 and T8140. T6001 and T6002 share the compatible and have no firmware-driven sleep, so nothing changes for them. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The legacy GPU's .suspend parked the firmware and stopped its CPU. A
firmware-driven sleep can still be refused after the devices have
suspended, and a parked firmware only comes back through a sleep that
takes its power. After a refused sleep the GPU stayed down, and every
later sleep failed in .suspend, which tried to park it again ("AP idle
not acknowledged: -62"), so it never came back.
Leave the stop to the sleep's commit instead. .suspend drains what is
in flight and registers a first-pass stop with the sleep core, which
runs it with interrupts off once nothing can refuse any more:
apple_rtkit_sleep_idle_polled(), the mailbox's receive off, and the run
bit cleared twice, as apple_rtkit_sleep_stop() does. The firmware runs
until then, so the GPU's domain is held up across the noirq phase as it
is across a suspend-to-idle.
On an .enclave_first SoC ops->display_off now runs after the first-pass
stops: T6000's takes the GPU's domain down with the display's.
.resume restarts a firmware the commit parked after a sleep that
happened. After a sleep refused before the commit there is nothing to
do: the firmware never stopped. One parked by a commit whose sleep did
not happen stays parked, and the next sleep neither parks it again nor
refuses, and restarts it at its wake.
Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The late commit waited 2 ms after two power-state writes, 2 ms after the fabric's sleep state, 100 us after the clock muxes went off, and 200 ms before the wake timer was written. None of them waits for anything: the fabric state is already polled for, and J314s sleeps and wakes the same without the others (25 of 25). Drop the two 2 ms waits and the 200 ms one. Poll each clock mux for its busy bit in place of the 100 us, and report one that stays busy with the other incomplete steps. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
After a refused sleep the display coprocessor's firmware has idled with its power kept, and it only starts again from a power loss. The words that take its CPU domain down are in the sleep's entry, and nothing could run them outside a sleep. Add apple_sleep_display_power_cycle() for the coprocessor's driver. On T6000 it lowers the CPU domain's word with the two writes of the entry and raises it to the word it held, in the wake's order. The front end stays on, and the entry is not changed. The coprocessor's request to the PMP is withdrawn around the cycle. A running PMP takes a block whose request it holds as active, the entry withdraws the request before it lowers the word, and the request's power domain, a child of the CPU domain's, keeps that order everywhere else. Nothing in the report's driver raises or reports a domain lowered under a held request, so only the withdrawal keeps the PMP's view true. On J314s, with the front end on, the word read 0x1f0403ff before, 0x0f040100 off and 0x1f0403ff again in under 1 ms, with the PMP's requests at 0x7200 and acknowledged before it. The firmware then started in about 2 ms, 5 of 5 times with the request withdrawn, and in about 3 ms the one time it was held. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Without the queue, a call the firmware never answers stays on its channel. After a restart every later command then goes out on the callback context, and an ack can be paired with a call slot that holds no record: dcpep_handle_ack() derives the record's address from a NULL output pointer and reads it. Seen once on T6000, after a restart that followed calls to a stopped firmware: an Oops in iomfb_recv_message() at 0xfffffffffffffff8, the in_len of a record 12 bytes below NULL. Add iomfb_channels_reset() to empty the call stacks before such a firmware starts again. An ack for an empty slot is ignored with a warning, and one on a call stack deeper than its slots marks the firmware crashed. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
A sleep refused after the T6000 display coprocessor's stop left the panel dark until a reboot. Firmware 13.5 does not start from an idle with its power kept, and after A500 it completes no page flip even if it is never stopped. The resume cleared s2r_fw_down all the same, and the calls that followed timed out against a firmware that was down. Give a panel's firmware the power loss a real sleep gives it: its CPU domain is power-cycled through the sleep driver, and the firmware starts as after a wake, with its call stacks emptied. Its DARTs are not touched. Both kept their lock word, their stream enables and all 16 translation register pairs across the cycle, and the display subsystem, which maps through them, resumes after the coprocessor. A firmware that does not start, after a refusal or a real sleep, is left stopped and marked crashed, so that nothing calls it. It stays down for the next suspend, and the next sleep that happens starts it again. On J314s, 4 of 4 refused sleeps, two at each of two points of the entry, came back from the resume with the panel lit: about 1 ms for the cycle, 2 ms for the firmware's start and 0.5 s for the whole resume. After 6 refusals in one boot, 10 deep sleeps passed. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
…nnot follow t6000_domains_restore() raises every PMGR domain that was on before the sleep, waits up to 20 ms for each, and repeats the whole pass up to 30 times while any has not followed. On J314s ten never do, so every wake spent 6.5 s there: - nine are words of the cores and their managers (ecpu0_1, pcpu0_0-2, pcpu1_0-2, pcpm0, pcpm1). They read on with a target of 0: their power is their complex's, not this word's to ask for, and they come back when the cores are started; - one (afnc1_lw1) has AUTO_ENABLE and gates itself as soon as that is written back, which was before the check. The later passes then left it on with AUTO_ENABLE cleared. Skip a domain that was on with no target, and judge whether a domain followed before AUTO_ENABLE goes back. J314s, 25 deep sleeps: the step takes 60 ms (6522 ms before) in one pass with no domain left behind, and the resume ends 0.8 to 1.0 s after the first code that runs at the wake (7.2 to 7.5 s before). Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
main now carries 4f3e0d2 ("PCI: apple: disable L1SS around deep sleep on reinit hosts"), which handles the same links as 1c3375c ("PCI: apple: disable ASPM and L1SS across firmware sleep on reinit hosts"). Conflicts in drivers/pci/controller/pcie-apple.c and tools/asahi/pciec-policy-tests.py: main's version is taken and 1c3375c is dropped. 2f60f7d (one wait after the last retrained link) is kept. Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
|
A row from a second J314s: 16 of 17 deep sleeps woke, 12 of them back to back in one boot. (Edited 30 Nov. This replaces three earlier comments of mine. The first two reported mostly failures, and those runs were invalid: the distribution's Setup — MacBook Pro 14" M1 Pro, J314s, the 8-core chip (2 E + 6 P), 32 GB; iBoot2 iBoot-8422.141.2, OS firmware 13.5.
One boot, twelve sleeps (regular root, nothing masked)
First sleep of a boot, five boots: woke (120 s), reset (60 s), woke, woke, woke (60 s each).
Log lines on each wake
Not yet here: a lid wake, a night for a power figure, external displays (none to test with). |
|
Very interesting, yesterday I changed most of the fixed waits to polls or dropped them entirely (including the 200 ms wait right after I've not had issues with normal sleep myself, but an event triggered right at the last stage of entering sleep (everything is powered down and mailboxes cleared) re-wakes and causes a hang that needs a force reboot. So the only way I can trigger a fault is by plugging/unplugging a charger right as it enters sleep, and the timing has to be very tight to get it to do so. Other than that I've had many working sleeps on that same code over the weekend (with an older DTB + minimal test overlay), measuring about 90-110mW so it's definitely looking promising once we've got these last issues sorted. Setup wise: Mine is also an 8 core, but 16GB not 32GB. Same stage 2 also on I'm going to test putting the post- |
|
Thanks, that helps a lot. Our comments crossed: I rewrote my row a minute before your reply. The early resets were my setup, not your code (the test kernel's modules were being removed between boots). With that fixed, the PR as it is at 305ef36 is at 21 wakes in 22 sleeps here, so I have nothing against the dropped waits. The one reset I can't explain (first sleep of a boot, 60 s alarm, last note 0x7a, nothing incomplete) could well be your late-event case: I can't rule out an event in that window. The PR at 305ef36, ordinary boots, stage 2 aura 26c1a85, stage 1 m1n1 v1.6.1:
All of that in one second. Neither macsmc's "dark wake N" line nor its "SMC was busy for N ms" line was printed, so my guess is that One small thing: I can repeat the charger-under-a-closed-lid run, or plug it in right at the entry, on either build. If there is something you'd like read out after a hang, say so and I'll add it. |
|
@olivergreg We have a J316s (16-inch M1 Pro, T6000) on the lab bench running aura In the meantime, we're queuing an exact-head |
|
J316s (16-inch M1 Pro, T6000) exact-head
No regressions from the shared driver changes on J316s |
|
A follow-up on the charger under a closed lid, now on the PR itself (305ef36, notes on, same loader):
So on the PR the closed-lid port wake dies somewhere after 0x7e, where c02b26e comes back and then refuses the re-entry with -16. That refusal is now 8 in 8 here, the last one with the battery at 15%; the Mac then sat awake under the lid for 13 minutes until I opened it. Totals here: the PR 23 wakes in 26 sleeps, the test branch 26 in 27. |
Conflicts, resolved: - soc: apple: sleep: main's late display power-down (sleep_display_late) and T6000's enclave_first are kept side by side; before_enclave runs as on main, which covers T6000's call. - drm/asahi: main's suspend_noirq_hold(hold_firmware) also honours the T6000 deep hold; the PR's suspend/resume callbacks stay. - PCI: apple: main split the port bring-up into helpers; the single 100 ms wait after the last retrained link is kept, and main's per-port fallback in the noirq path now waits once as its phased path does. - dcp-internal.h, rtkit.c, macsmc.c, apple-display-crossbar.c: both sides added independent fields and functions; all kept. - soc: apple: sleep-test: list apple,t6000-sleep in the profile inventory, in its of_match position. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Forward merge of What conflicted and how I resolved it (8 files):
Checks on
Still owed: exact-head J314s and J316s deep-sleep rows at |
Gate the < 14 internal DCP apple,firmware-compat check in apple_sleep_undescribed() behind a per-SoC display_legacy_no_wake flag enabled only on T8103 and T8112. SoCs with a working 13.x DCP deep-sleep wake path (such as T6000 in aurora-silicon#3534) now keep their deep-sleep default unaffected. Extend the host test suite with a T6000 13.5 case verifying display_legacy_no_wake = false leaves apple_sleep_undescribed() at 0. Signed-off-by: Dmitrii Semenenko <116227467+Sedmio@users.noreply.github.com>
|
J316s (16" M1 Pro, T6000) deep-sleep row at #3534
One difference from the J314s rows here: this J316s runs system firmware 26.2. @olivergreg @CoreyH, what system firmware are your J314s on ( J316s node (our commit 206ff3db on top of 305ef36)The J316s was restored to its saved default afterwards and verified. We won't open the J316s DT PR until a J316s deep row passes. |
Conflicts, resolved: - drm/asahi: main now gives the G15 and T8122 probes their own stats export (raw_dev, raw_stats, stats); the PR's legacy_gpu and legacy_asc stay None there, as on every probe but the first-generation one. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Second forward merge of What conflicted and how I resolved it (1 file):
Checks on
Still owed (unchanged): exact-head J314s and J316s deep-sleep rows, now at |
What: Adds suspend-to-RAM for T6000 (M1 Pro) and enables it on J314s.
sleep-t6000.hprofile fordrivers/soc/apple/sleep.c, likesleep-t8103.h, plus the driver and device tree changes the sleep and wake need.mainStage 2, default kernel command line.Tested: J314s (MacBook Pro 14" M1 Pro) at
305ef36c, default command line: 25/25 deep sleeps on one boot.O_DIRECTwrite reads back intact.mainwas merged in, at6c8d7e7c: an 8 s RTC sleep takes 10.0 s end to end, and a sleep refused at.enterreturns to a running system with the panel back, 8 of 8.energy_nowdropped 0.67 Wh (15.73 -> 15.06 Wh, 89 mW) andcharge_nowdropped 60–70 mAh (90–105 mW at 11.4 V; s2idle measured 1.8 W).event-log source 19report (see Not yet).Risk: one-way (adds DT bindings; deep becomes the default sleep state on J314s) · M1 Pro J314s.
Not yet:
event-log source 19report. It comes from the clock mux switch before sleep and needs a fix in the EDAC driver.Unable to change power state from D3hot to D0, device inaccessiblelines.mmc0: Card is consuming too much power!with no card in the reader.Details
Stack
main's newerrtkit.csortkit-oslog-tests.pypasses.mainis merged in and its L1SS handling inpcie-apple.creplaces my commit1c3375c2. It leaves ClockPM and ASPM L1 on across the sleep, where mine cleared them. Sleep entry did not hang in 46 sleeps.Needs aura Stage 2 from
mainat3526be04or later. The1.0.0~b17release hangs on every wake.What changes
sleep-t6000.h,sleep.c, bindings,t600x-die0.dtsi,t6000-j314s.dts): the T6000 profile, a hook that lets a profile order SEP's sleep and the CPU stop, and the sleep controller node, disabled in the SoC file and enabled on J314s only. Pins are saved and restored throughapple,pinctrl.pcie-apple.c): one 100 ms wait after the last retrained link on resume (PCIe r5.0, 6.6.1).apple_rtkit_sleep_return_with_init()and its Rust wrapper.irq-apple-aic.c: keep AIC2's configuration across a firmware suspend.apple-dart.c: restore a locked DART after a firmware sleep.pm_shim.c: accept a power-gated SEP as a taken sleep request.DEV_DISABLEstays fatal.macsmc.c: the sleep notice, with the GPIOs to lower taken from the newapple,sleep-low-pins.spi-hid-apple,apple-sio,aop.rs: small sleep fixes.Chip checks: the profile is selected by the
apple,t6000-sleepcompatible, as for T8103.macsmc.cenables the saved command lane forapple,t6000-smconly where the device tree enables that sleep controller, so T6001 and T6002 keep the ordinary transport.Evidence
J314s, kernel
7.3.0-t6000-s2r28at593a4c61plus a test-only DT overlay, one boot, default command line (mem_sleep: s2idle [deep])rtcwake -d rtc1 -m mem -s 8boot object resumes 0 -> 25, wake sourceNUB.SPMISw3IRQ25 -> 28, wake sourceSMC.OutboxNotEmpty28 -> 29; the charge counter moves too little at this draw to give a figureAfter the 29th wake:
suspend_statssuccess=31 fail=0,193 of 252 AP pins changed by the sleep, all put back, Wi-Fi up, Bluetooth powered, audio cards present, Borealis enumerates the GPU, NVMe healthy.Overnight power check (J314s,
7.3.0-t6000-s2r46, default command line)boot object resumes 3 -> 4, wake sourceSMC.OutboxNotEmpty, 0 unexpected wakes):energy_now15.732 -> 15.059 Wh(89 mW),charge_now1381 -> 1321 mAhimmediate /1381 -> 1311 mAh3-sample median (90–105 mW at 11.4 V).Build and host tests at
305ef36c, withmain37a9d681merged incheckpatch.pl: 0 errors over the series' commitstools/asahi/run-host-tests.py: 756 jobs pass. 8 did not run: they read old commits that my shallow clone does not have.