Repository navigation
Conversation
A display coprocessor whose power domain is a PMP report entry keeps its firmware running through s2idle and puts itself on the wakeup path for it. Let the entry say so, as apple,sleep-wakeup-path says it for a PMGR power state, so that the entry and the power states above it stay on while the firmware runs. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
genpd keeps a domain on through system sleep for a device on the wakeup path only if the domain is active-wakeup, and only apple,always-on entries were. An entry without it is powered off in the noirq phase although its consumer asked to stay powered: the request is withdrawn and the PMGR states above it go off under a firmware that still runs. Make an entry with apple,sleep-wakeup-path active-wakeup too. Nothing else changes for it: it is not seeded at the PMP start and not requested at probe. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
With APPLE_USE_PMP (J314s, J316s) dcpext1 sits in the pmp-dispext1 report entry, which unlike disp0's and dispext0's is not always-on. Its DCP stays on the wakeup path through s2idle, with its firmware running, but genpd powered the entry and dispext1's power states off in the noirq phase all the same. The firmware lost its power unseen, and the next deep sleep could not park it: link sleep timed out, IOP IDLE failed, and the block went down with it for the rest of the boot. Mark the entry apple,sleep-wakeup-path. dcpext1 then goes through every sleep as dcpext0 does. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
After a deep sleep that cut the GL9755's power, the chip reports an empty slot for most of a second after its resume before Present State shows the card again. The detect the core runs right after resume gets -ENOMEDIUM from the card's re-init and drops a card that never left the slot. The insert interrupt brings it back later as a new card, and a filesystem mounted from it has lost its device. The card state stable bit reads 1 throughout, so it cannot be waited on. When a card sat in the slot before the sleep, wait in the resume hook until the chip reports it, for 1.5 s at most. A resume without a card, or one where the chip kept its power, does not wait. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
Outside compositor pairing order, a direct DP-alt port with no pipeline takes the lowest free one as soon as it enters DP mode, whether or not a display is behind it; only Desktop 26.x, T6041 and T8142 wait for HPD. A USB-C dock without a monitor that enters DP mode before the port of a USB-C display takes the pipeline that display needs, and the display then waits for as long as the dock stays plugged in. Which port enters DP mode first changes from boot to boot. At a wake the port controller applies each port's state again, and the dock's port then takes a pipeline an HDMI display left free. Leave a port that owns no pipeline and has no HPD unrouted on every machine, as those three already do. The port controller reports HPD as a new status when a display appears, and the port is routed then. A port that owns a pipeline behaves as before on an HPD drop, and the compositor-ordered path is unchanged. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
When a display drops and comes back before the host has turned it off, the DCP firmware announces a new DCPAVAudioInterface while the host still holds the previous one open. The firmware keeps that instance, and the display's link with it, until its client closes it: a later release of the link (a DPTX disconnect) is never answered, and the port answers nothing more until the firmware is restarted. The new announcement retired the open instance on the host side as a superseded singleton, so its Close could no longer be sent. Leave an instance its owner still holds open to the owner (a held() callback in the service ops). The work that opens the successor closes it first and retires it then. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
The M1 Pro's sleep controls: the PMGR's AP wake block, its power-state blocks on both sides, the CPU start block, the watchdog, the S2R timer that commits a sleep, the NUB SPMI vector enables, the PMP telemetry block, the SoC clock generator's mux block and the fabric ports of the GPU and of the three display blocks. A sleep keeps the wake sources it names enabled. The node also points at the blocks the sleep reaches through their own nodes: the PMGR's misc block (apple,pmgr-misc), SIO (apple,sio) and the NCO (apple,nco). apple,sleep-late-domains lists the PMGR power-state nodes written right before the S2R timer, each with the word written to it, in the order written. apple,tunable-gfx-fabric, apple,tunable-disp0-fabric, apple,tunable-dispext0-fabric and apple,tunable-dispext1-fabric hold the setup each fabric port gets before its block powers down: whole words, in the order written. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
The T6000 drivers that take part in its firmware-driven sleep need to know whether the device tree describes that sleep. T6001 and T6002 share the T6000 block compatibles (SMC, AIC, DART, NCO) and have no such sleep, so the check looks for an available apple,t6000-sleep node, which only a T6000 machine's tree can carry. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
On the M1 Pro, SIO, the internal DCP and the GPU firmware are idled before a deep sleep and carry on from their saved context once their power comes back. Their shared buffers stay mapped through it, and the restart is the one that was traced for them: INIT, the endpoint map answered as at a boot, the IOP acknowledgment, every app endpoint started again, and only then the AP state. apple_rtkit_reinit() frees the buffers and apple_rtkit_warm_restart() echoes the endpoint map instead, so add the pieces of that restart: apple_rtkit_reinit_keep() and apple_rtkit_detach_keep() around the power cut, apple_rtkit_idle_iop() and apple_rtkit_ap_power_timeout() for the idle and the AP state with its own wait, and apple_rtkit_wake_keep_ap() with apple_rtkit_restart_started_eps() for the way back. Nothing calls them yet. apple_rtkit_reinit_keep() resets the session through the helper apple_rtkit_reinit() uses, keeping the buffers and the endpoints that were started. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
With interrupts off, a caller can already ask for the AP's idle between apple_rtkit_polled_begin() and apple_rtkit_polled_end(). Add the IOP's idle to follow it, for a caller that checks its CPU's state itself afterwards. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
A coprocessor whose power was cut loses its mailbox's control words with it. macOS enables the inbox (bit 0 of the send control word) again before it starts such a coprocessor, if it reads off. Add the setter next to apple_mbox_set_recv_enabled(). It writes only if the bit reads otherwise. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
The deep sleep of the M1 Pro cuts the power of the SIO island, and the SoC only powers down once that island has gated. As macOS does, idle the SIO firmware in the late suspend phase, AP state first with a 2 s wait for its answer, then the IOP state, and stop its CPU with its buffers and context kept. After the power cut start it again from there: the mailbox restarted, the CPU run bit, INIT and the endpoint map, its endpoints started again, then the AP state on. The park needs a running firmware in the late phase, so this SIO stays runtime-active, as one stopped at the sleep's commit does: no runtime stop when idle, and system suspend leaves it alone. Its domain is gated by the sleep itself and not earlier. A firmware that does not idle or does not come back is left alone until a reboot rather than refusing the sleep; nothing is sent to it while it is parked or lost. A firmware parked for a sleep that is then given up stays parked until the next deep sleep cuts the power, through any suspend-to-idle in between. Selected by the apple,t6000-sio compatible; other SoCs keep their path. A dry run of the sleep core, which cuts no power, leaves the firmware running as suspend-to-idle does. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
A T6000 deep sleep resets ANS's AXI2AF block and its storage-lane block (ADT ans reg[4] and reg[5]), and the ANS firmware crashes right after its endpoint discovery without the settings iBoot gave them at cold boot. Allow the two blocks as reg entries on apple,t6000-nvme-ans2, and the ADT's tunables for them (afc-aiu-ans-dual-tunables and storage-lane-common-tunables) as apple,tunable-axi2af and apple,tunable-storage-lane, so the driver can put them back after such a sleep. Other controllers have neither property. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
A T6000 deep sleep resets ANS's AXI2AF and storage-lane blocks, and the ANS firmware crashes right after its endpoint discovery without the settings the boot loader gave them at cold boot. Where the device tree gives both blocks (reg-names "axi2af" and "storage-lane") with their tunables (apple,tunable-axi2af and apple,tunable-storage-lane), map them and put the tunables back after a firmware-driven sleep, before ANS's run bit, together with the SART's power word as the first good start had it. Only words whose bits differ are written. A controller without them is left as before. After such a sleep ANS is started with one apple_rtkit_boot(), bounded by the handshake wait it already has. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
A deep sleep of the M1 Pro takes the PCIe complex's power. Its internal ports, Wi-Fi and Bluetooth and the SD reader, came back in the normal resume phase, the T8103 path, after the PCI core had already restored the functions behind them in the noirq phase: a configuration or BAR access to a port without a link stalls the bus. Match apple,t6000-pcie with the T8103 layout and the sleep's noirq bring-up of the ports that lost their link, before their functions resume. Ports the boot loader has already set up again at the wake keep their link and are left alone. Keep probe's 100 ms after PERST# (PCIe r5.0, 6.6.1) before the PHY's ready bit is polled. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
…leep After a deep sleep of the M1 Pro the internal ports that lost their link are set up again in the noirq resume. When that set-up fails for a port (its GPIOs, its reference clock, or its PHY never getting ready), the functions behind the host would still resume, and Wi-Fi or the SD reader would touch their BARs behind a dead link. Then mark every function of the host disconnected, as after a surprise removal, and stop the DARTs its iommu-map points at from taking commands. A link that is set up but does not train in time is only reported, as before. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
A sleep profile takes some blocks down itself, with interrupts off, after their drivers have suspended: the T6000 display, whose report entry is always on, is one. Let it set or clear one request bit whoever owns it, the T600x AGX vote's bit 9 too, under the report's lock, and poll the acknowledge while the PMP runs, telling the caller whether the bit was set before so that it can put it back when the sleep is given up. The books are left alone: what the owners asked for is what the report hands the PMP again after the sleep. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
… stop Before the M1 Pro's PMP is idled for a sleep, macOS's sleep action takes every request back, not only those of the blocks the report knows, sets the CPU and fabric DVFS entries (SOC-DEV-DVFS 0x108-0x10a and 0x10c) to idle and the report's sleep word to 1. Do the same at the sleep's commit, right before the idle, with interrupts off. At the wake the requests come back from the word kept when the PMP's suspend started, and the DVFS entries from what they read before the idle: left at idle, the PMP keeps the fabric clocks at their idle source. Other SoCs' reports are left as they were. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
…sleep A PMP started again from the SRAM it kept over a sleep may set itself up from the start: it asks for its IOVA table, sets its buffer and registers its ioreg entries again. That was refused as a second table or buffer, which left the firmware without an answer after the wake. Only after such a restart, answer a repeated table request with the table already mapped, take the new buffer, and begin a new ioreg list at the next registration. A firmware that does not ask again sees nothing different. Nothing sets the restart flag yet: the T6000 PMP's power cycle, added later in this series, does. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
A sleep that cuts the PMP's power resets the reset vector iBoot pointed at the firmware SRAM and locked. Let the PMP node name it as an optional third register, "iorvbar", so that the OS can put it back before the firmware starts again. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
Where the DT names the PMP's reset vector, read what iBoot left there at probe, and after a sleep that cut the power write it back before the firmware starts again, unless it still reads locked. Without it the PMP starts from the reset value instead of its SRAM. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
A deep sleep cuts the M1 Pro PMP's power. Name its reset vector (reg[1] of the ADT's pmp node) and keep its whole firmware SRAM, 1 MiB, read after its stop and written back before it starts again. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
The M1 Pro's DARTs have the M1's address filter: 16 entries, 0x40 apart, the same words. A deep sleep clears it just the same. Keep what the loader programmed and write it back after the sleep for a T6000-layout DART that names its filter window, as for a T8020 one. No T6000 DART names one yet. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
Every access of the M1 Pro's PMP passes its DART's address filter (ADT dart-pmp reg[1]), which a deep sleep clears. Name the window, so that the DART driver keeps what the loader programmed and writes it back after the sleep, before the PMP starts again. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
macOS takes the T6000 PMP's own power state and its SRAM's to 0 once the PMP's CPU has stopped, copying the SRAM in between, and the sleep's quiesce steps the memory clock down only once the PMP's power state reads 0: the PMP owns the memory clock while it has power. Leaving the power states up skipped that step on every sleep. At the commit's stop, after the AP and IOP idle, turn the outbox off, wait for the CPU to idle, clear RUN and lower both power states as the PMGR does, with the SRAM copied in between. A CPU that never idles is not powered down. The sleep driver gets no ASC for this PMP, since it would otherwise clear RUN on an unpowered block. At the wake, and after any sleep the stop ran in, bring the SRAM's power up, write the SRAM back, bring the PMP's power up, put the reset vector back and start the firmware cold: RTKit afresh, the outbox on, RUN, the boot, INIT if the firmware does not acknowledge IOP power by itself, and the PMP endpoint. A power state that does not come up ends the start there, with nothing written into its domain. The firmware then sets itself up again, which a restarted session answers. Everything it was given before stays allocated and mapped, as it runs from the kept SRAM and may still point there; each request after the restart gets a new buffer, and the allocation budget counts from the restart, so each sleep keeps one more set of the firmware's setup allocations. The PMP's DART goes down with it, as macOS saves and restores it around the power cut: its interrupt off and its state saved once RUN is clear, and written back, its interrupt on, before the reset vector and RUN. A PMP that does not start again gets its requests back, but not the DVFS entries and the acknowledge wait. Only a PMP whose node has the reset vector register and apple,sram-keep takes this path, and only from a deep sleep's commit; every other PMP keeps the warm restart. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
The enclave's sleep request is staged for the sleep core's commit with a 5 s wait for its answer, and the wait ends early once the power state reads DEV_DISABLE. On T6000 macOS waits up to 15 s for the answer, and only after the answer waits for the power state's actual field to read 0. An idle enclave that still runs can read the same as one that slept, so on T6000 only the answer ends the first wait. Add a sleep profile to the platform profiles: the answer wait and what ends the wait for the domain. Every SoC but T6000 keeps the current values. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
After a deep sleep that cut the SoC's power, the T6000 enclave does not start again on a doorbell. macOS powers its domain on, at its PMGR's wake, with the minimum state raised and DEV_DISABLE cleared, makes the enclave's DART active again, and then lets the SEPROM resume the sepOS still in RAM through the boot endpoint: TZ0 (0x5), and once the ROM reports its status (0xd2), op 8 in place of the firmware, answered by 0x6c. Do the same on the SoCs whose sleep profile asks for it, T6000 only, after a deep sleep whose request the sleep core's commit sent. A control message that reports sepOS active also ends the wait. If the resume fails, the enclave is left as asleep, its receive interrupt held and its DART gated, and the raised minimum is dropped either way. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
The enclave's mailbox loses its control words with the power cut of a deep sleep. When macOS starts the enclave's CPU it enables the inbox if it reads off, then the outbox, and only then lets the SEPROM resume sepOS. Do the same before the resume handshake. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
On the M1 Pro, macOS writes pmVC and WKTP before slpa, and a failed write there gives the sleep up: nothing that cannot be undone has happened yet. Main sends both with slpa, after the point of no return, where a failure can only panic. Add an optional SMC lane step for them and a SoC flag that runs it as a refusal in the entry, right before the enclave's stop, which stays the last step that may refuse: a failed key write then gives the sleep up before the enclave is asked to sleep. The SMC driver's side, which provides the step and leaves the keys it sent out of its notice after the point of no return, follows separately. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
A T6000 enclave that took its sleep request power-gates its own island, and without the SoC's power cut its domain does not come on again. A sleep given up after the request (a device's late or noirq suspend, a refusal in .enter, a pm_test) would leave the enclave unusable until the next deep sleep or a reboot, so the request can only go out once nothing else may refuse. Stage the T6000 request at device suspend, as on the other SoCs, and let the sleep core's commit send it after the last other refusal. The commit path learns what the T6000 profile asks for: - the enclave's DART goes down with the island: it is saved and its commands gated at device suspend, in process context, let go again without a reset when the request was never sent, and reset and put back before the enclave resumes; - an answer whose result is not 0 refuses the sleep with the enclave awake; - with commit_soft_fail, an answer or a gate that does not come within its bound refuses the sleep instead of panicking; the enclave is then left unused, and every later deep sleep refused, until a reboot; - with wake_after_thaw, the enclave is resumed through its SEPROM once the tasks run again, from the PM notifier, so that a SEPROM that does not answer holds up only the enclave's users; a dark wake's next sleep first runs the wake still pending; - with ps_nonposted, the power-state word is mapped non-posted where the PMGR's bus asks for it. The other SoCs set none of these and keep their path as it was. The enclave step's refusal line no longer says the request was not sent, since with a soft failure it was. The enclave's sysfs ABI text says when a T6000 enclave sleeps, and that one that fails its request blocks deep sleep until a reboot. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
Describe ANS's AXI2AF and storage-lane blocks (ADT ans reg[4] and reg[5]) on the T6000's NVMe node, with this SoC's ADT values of afc-aiu-ans-dual-tunables and storage-lane-common-tunables. A deep sleep resets both blocks, and the NVMe driver puts the tunables back before ANS starts again. Only in the T6000 tree: the values were read from a T6000 ADT, and T6001 and T6002 share the compatible. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
Without the enclave's driver bound (main loads it from user space, it has no module alias) the T6000 deep sleep was refused in .enter, by apple_sleep_gate_failed(). By then the AOP was stopped at .prepare and the display coprocessors and the SIO parked in suspend_late, which the refusal then has to undo. Make that refusal, and the one for an unbound internal display coprocessor, in the profile's .begin as well, before any device suspends, where both are already known. .enter keeps them. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
…tree The late power-state image was a table of physical addresses and values in the profile. Describe it instead: the PMGR power words and the values macOS writes to them come from the sleep node's apple,sleep-late-domains, each found through its power-state node, and the steps between them (their waits, the clock generator's words, the PMGR misc block's fabric word, SIO's words and the one NUB word no node describes yet) stay a short list in the profile that names them by kind. SIO's CPU, mailbox, DARTs and power word are reached through apple,sio, the misc block through apple,pmgr-misc; every block is mapped as the sleep node's own, shared and not claimed. The words written, their values and order are the same as before, and so are the waits but one: the memory controllers' power words that the commit puts back to the first sleep's got a fixed 100 us each, for the first eight only, as the traced sequence had it. Each is now waited for until its actual state is its target, bounded as every other power-word wait in the sleep; a word the PMGR manages itself (AUTO_ENABLE) is the PMGR's to move and is not waited for. Words that missed the bound are counted and reported once at the wake. The wake's put-back names a word that did not come back by its step's index instead of its address. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
A T6000 DCP with Type-C outputs stopped its Type-C work in its own .suspend. The USB controllers take the Type-C PHYs down in their suspend, and device suspend sets no order between them and the DCP, so the work could still act on a PHY that is going away. For a deep sleep, stop the work at PM_SUSPEND_PREPARE instead, before any device suspends, and let .suspend skip it then. A sleep that fails before the DCP suspends starts the work again from .complete or PM_POST_SUSPEND. PM_SUSPEND_PREPARE has no target state yet, so a deep sleep is taken to be one where s2idle is not the default; an explicit freeze on such a system also stops the work there, and .complete starts it again. DCPs with hw.s2r_park register for this: T6000's, and T6001's and T6002's, which share the compatible. Those have no deep sleep, so s2idle stays their default and nothing changes for them. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
Add the M1 Pro's sleep controller to the T6000 tree only: T6001 and T6002 share the die's include but have no such sleep. Disabled there, and enabled for J314s, the one T6000 machine whose sleep sequence is described. The wake sources are the ones macOS leaves on: the AOP's, the NUB's (the PMU's RTC alarm among them), the SMC's and the Type-C ports'. The AP pins are put back after a sleep, but for the three the ADT lists as no-restore-gpio-pins. The node names the PMGR's misc block, SIO and the NCO by phandle, lists the PMGR words of the late steps before the S2R timer with the values macOS writes (apple,sleep-late-domains, from our traces of macOS on a J314s), and gives the GPU's and the display blocks' fabric ports with the setup macOS writes before each block powers down (apple,tunable-*-fabric, from the same traces). Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
The park of a T6000 DCP in the late suspend can fail (the IOP does not go idle), and its firmware then keeps running. The sleep went on regardless: the sleep driver checks only the internal DCP's CPU before the commit, so an external DCP left running had its display block taken down under it by the entry. Return the park's result and refuse the deep sleep from the late suspend when it failed, with an error that says so. Nothing is powered down yet at that point, and the resume after the refusal finds the firmware still running, as after a failed park before. A park whose AP comes back ON after the failed IOP idle still refuses: that answer no longer overwrites the park's error. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
A T6000 DCP parked for a deep sleep no longer holds its PHYs, so the sleep takes the HDMI output's ATC PHY and its display crossbar down with their power domain. The PHY sets its mode up again only at its next operation, and the crossbar driver keeps no state across the sleep, while the mux core still counts the HDMI route as selected. A display plugged in after such a sleep then gets no link. Set the fixed HDMI output up again at resume after a sleep that left the PHYs to genpd, with dcp_fabric_hdmi_reinit(), as main does after a deep sleep for an s2r_ext DCP: the converter powered, the PHY taken out of DP and back into it, and the crossbar output selected again. It runs with or without a display attached, and after a sleep given up too, where it only repeats the setup. Only a DCP with a fixed PHY and an HDMI HPD line in the device tree has an output to set up; s2idle and dry runs hold the PHYs and are unchanged. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
A T6000 deep sleep with an HDMI display attached never came back: the SoC reset during the entry. The DCP's suspend kept the display's link up, as for a sleep in which the firmware runs on, and then parked the firmware and let the sleep cut the PHY and the display block under that link, with the DP-to-HDMI converter still powered. For a sleep that parks the DCP, release the link of an attached display while the firmware still runs, report the display gone, and power the converter down, as macOS keeps it in sleep. A release whose answer comes late, after the firmware reported the display unplugged and set the PHY rate to 0, has taken the link down and counts as done. A link the firmware does not release refuses the deep sleep there, before anything is parked, with an error that says so. A release that timed out still goes on in the firmware, so the display is connected again then, as after a wake, and does not stay dark. At resume the converter is powered first, the output is set up again, and the display is connected again with dcp_fixed_hdmi_reconnect(), as main's dcp_s2r_restart_done() does for an s2r_ext DCP; a display unplugged meanwhile is reported gone. That runs from a work, as the T6040 link work does after its wake: the connect of a converter output waits out a link configuration this firmware does not send for it, and the resume does not wait for that. The next suspend lets a running connect finish first. The same runs after a sleep given up in any later step, so the display comes back then too. With no display attached, or for s2idle and dry runs, nothing changes. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
…sleep A T6000 DCP parked for a deep sleep no longer holds its PHYs, so the sleep takes the ATC power domains down, and with them the display crossbar of a Type-C display's route. The crossbar wakes with its output lost while the mux core still holds the selection, and nothing selects it again: the link after the wake has no path to the PHY, the firmware reports link faults and the display does not come back. Take the route's crossbar output down at suspend while it still has power, and select it again at resume before the Type-C work connects the link, with dcp_typec_route_park() and dcp_typec_route_unpark(), as main does for an s2r_ext DCP and for an H17P DCP in s2idle. A sleep given up after the suspend selects it again the same way. Without a Type-C route, or for s2idle and dry runs, which hold the PHYs, nothing changes. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
…given up The T6000 SIO firmware is idled and its CPU stopped in the late suspend phase, and only starts again from reset, which the deep sleep's power cut gives. A sleep given up after that point cuts no power, so the firmware stayed stopped until the next deep sleep, and DisplayPort and HDMI sound with it. On the resume of a sleep given up, pulse the SIO's engine reset, as the runtime resume does, and start the firmware the way the wake does. If the reset fails, the firmware stays parked as before and the log says so. With the sleep controller bound, the engine reset took only power domains in the PMGR block mapped as its "ps", and found none for the T6000 SIO, whose domain is in the east block. Map such a domain through its own PMGR, as the reset already does where no sleep controller is bound. Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Thanks for getting J314s this far. At 72 commits this can't land as one PR, because parts of it change sleep on every Mac. Here is a split that lets each piece get its own rows and merge as soon as they pass.
Already in other PRs: commits 1–6 are #4237 (1–3), #4235 (4), #2835 (5) and #4236 (6). #4237 is approved and waits on one J314s row at its own head 85e09a42 (see the review there). That leaves 66 new commits.
Suggested pieces, in landing order:
| Piece | Commits | Reaches other Macs? | Rows |
|---|---|---|---|
P1 PM core pm_wakeup_hold() |
59 | new API, only T6000 calls it | its own PR (your question 11) |
| P2 RTKit/mailbox API | 9–11 | additive, existing callers unchanged | covered by P3 rows |
P3 sleep core (sleep.c/.h) |
8, 29, 38–40, 42, 53, plus the core parts of 30, 45, 47, 50, 52, 57, 58, 60, 61, 72 | yes | we run J516s, J714s, J773g and J700 (dry run, ≥5 deep sleeps, one refused); T8103/T6020 peer rows for 57/58 |
| P4 drivers | SIO 12/72, ANS 13/14/63, PCIe 15/16, DART 23/33/34/62, AIC 32, pinctrl 44, SPI HID 35, SMC 31/58, Type-C 36/37, AOP 41 | SIO, SMC and AOP yes | audio, dark wake and mics after sleep on our Macs |
| P5 PMP | 17–22, 24, 25 | yes: PMP report runs on T6030, T6050, T8132, T8140 | sleep + PMP perf on all four |
| P6 SEP | 26–28, 30 | yes: shared enclave driver | Touch ID/hwrng after deep sleep |
| P7 DCP | 48, 49, 51, 56, 66, 68–71 | shared driver | displays across s2idle and deep sleep |
| P8 AGX | 55 | behaviour only on T6000 | GPU smoke + one sleep per generation |
| P9 T6000 profile + DT | 7, 43, 45–47, 50, 52, 54, 57, 60, 61, 64, 65, 67 | T6000 only | your J314s rows |
P1 and P2 first, then P3, then P4–P8 in any order, then P9. Commits 30, 45, 47, 50, 52, 57, 58, 60, 61 and 72 mix sleep-core code with T6000 code, so they need splitting before P3 can stand alone.
P3 changes other Macs today:
- Commit 57: on early-context SoCs (T6020/T6030/T6040/T6050/T8103/T8112/T8122), a commit that returns now restarts the Mac through a 5 s watchdog instead of panicking.
- Commit 58: the gen-1 SMC sleep ops gain
.finish, so a secondpm_consume_dark_wake()call also runs on T8103. - Commit 72:
apple_sleep_engine_reset()now maps a domain outside the "ps" block directly instead of skipping it, on every SoC.
To fix when you split:
"apple,t6000-sio"is shared with T6001/T6002. The newpark_keptflag takes the SIO out of runtime PM on J314c, J316c, J375c and J375d too, which have no sleep node.apple_t6000_sleep_described()is a SoC-named check used by DART, AIC, SMC, PCIe and SPI HID, andsleep.c/macsmc.ccheck"apple,t6000-pinctrl"and"apple,t6000-smc"directly. Merged code can't gate on SoC or board; use a per-node DT property instead.- Commit 18 hard-codes the T600x DVFS entries 0x108–0x10a and 0x10c. Those slots are in the ADT (
apple,adt-dvfs); values the ADT carries come from the ADT. - The retries and fixed waits (SMC AP ON sent up to 3 times, a 30 × 10 ms power-word poll, a fixed 200 ms wait, fixed-address mappings, traced PMGR/clock/NUB words in the DT) need a public basis or a wait on a real condition. You already ask about most of these in questions 3–7. Our answer: wait on a condition, and take values from the ADT where it has them.
- Four bindings are new or changed. Please run
dt_binding_checkandCHECK_DTBSand put the results in each piece's Tested line. - Main has since merged #3667, which touches
dcp.c,dcp-fabric.candiomfb_template.c, so P7 and your J314s rows need a rebase and rerun.
No new runtime parameters, good. When J314s is ready to leave .untested, add apple,sleep-tested to t6000-j314s.dts, as #4228 did for J414s.
|
Yes to the split, in your order: P1 ( Commits 30, 45, 47, 50, 52, 57, 58, 60, 61 and 72 (numbers as in your table) get split, so that P3 holds only the sleep-core parts and stands alone. Already in other PRs
P3 changes other Macs today
No question on these. To fix when you split Taken as you wrote them. Each is fixed in the piece it belongs to.
#4239 stays open as the reference for the whole series. I'll mark it draft while the pieces go in. |
What: Deep sleep for the M1 Pro (T6000) in the MacBook Pro 14" (J314s), in main's sleep framework: a T6000 profile, the drivers that have to stop and start their coprocessors around the power cut, and the device tree that describes it. Everything that works before the sleep is meant to work after it: displays (built-in, HDMI, USB-C), GPU, sound (speakers, headphones, DisplayPort and HDMI), camera, Wi-Fi, Bluetooth, storage, SD card, USB and the enclave. The profile stays marked untested, so deep sleep stays off unless
apple_sleep.deep=1andapple_sleep.untested_commit=1are set.Tested: J314s M1 Pro, on main 24970e1. This exact head: dry run, a real sleep, the before/after check, 10 of 10 deep sleeps with all six speaker amp volumes back, and three aborted sleeps with the GPU, the displays and the compositor back, 0 warnings in every boot. The fuller rows below ran on this series plus my own HDMI blink commit on top (see known limit 5): dry run, a real sleep, a before/after check of the devices, 20 of 20 deep sleeps with all six speaker amp volumes kept, three aborted sleeps with the displays, the GPU and the enclave back, sound on four outputs before and after a deep sleep, and six fresh boots with an empty USB-C dock. The hand tests (lid, cables during sleep, headphones) ran on the same series one base earlier (main 5d50604).
Risk: Two-way door. Deep sleep is only offered on J314s (the sleep node is enabled only in its device tree) and only with the two parameters above. This PR sits on four small PRs, whose six commits come first here: #4237 (dcpext1 kept powered through s2idle), #4235 (an SD card kept across a power cut), #2835 (a DP-alt port routed only once its display asserts HPD) and #4236 (an audio instance the firmware replaced is closed). Those run without any parameter and are reviewed there. Only my J314s has run them.
Not yet: The hand tests ran one base earlier only. No row on another Mac for the shared commits. J316s is not enabled. Power draw in deep sleep is not measured.
dt_binding_checkwas not run.Hi! This is the deep sleep port for the M1 Pro. The known limits and my questions are below, the details and the logs are folded under them. Happy to run any extra row you want.
Known limits:
sound/. My speaker rows made that selection by script before they started the daemon. speakerguardd v2 was not run.WARNING ... typec_altmode_update_activefromcd321x_update_work(once in the hand tests, when the monitor was plugged in during a sleep). usb: typec: take the altmode module reference when the mode is already active #3571 deals with it; it is not part of this PR.Questions for maintainers:
.untested = true. How many rows, and on which machines, before it can go?regentries on the sleep node, or new nodes?apple_sleep_check_no_return(), also used by "give up when the last WFI falls through"): after the point of no return the series arms the watchdog for 5 s and restarts instead of callingpanic()like the other profiles. Restart or panic?first_stoppedop in the shared sleep code, used only by T6000. OK, or should T6000 do it inside its own commit hook?pm_consume_dark_wake()call after the SMC's finish. Should this go to the PM maintainers as its own PR first?commit_soft_fail): a failed enclave sleep refuses deep sleep until reboot instead of a panic. Which do you prefer?strict_gate_inventory, the T6000 profile does not. Set it for T6000 too?pm_test,apple_sleep.refuse_late,apple_sep.sleep_refuse_before_send). Are those accepted as evidence for the refusal paths?Related: #4237, #4235, #2835 and #4236 (open; this PR sits on them), #3667 (open; the HDMI standby blink, known limit 5), #3359 (merged; SIO and MCA runtime PM, see question 13), #3846 (merged; dark wake, see question 11), #2880 (merged; speaker volumes), #3811 (open; TAS2764 amps across firmware S2R; not needed for J314s in these rows, the volumes held 20 of 20 without it), #3571 (open; the Type-C warning above), #3760 (merged;
apple,sleep-testedper board, the way the untested flag could later be lifted), #3999 and #3809 (merged; T6020 sleep, and T6030 PCIe and DART, in the same files; resolved in the rebase), #3736 (open; late SMC notice from the DT), #3762 (open; SIO runtime PM on T6041), #3296 (open; enclave xART shutdown barrier, same enclave files).Details
The series has 72 commits on main 24970e1 (63 files, +7186 -139): the six commits of the four small PRs above, then 66 deep sleep commits (58 files, +7026 -128). The deep sleep commits in groups:
The small PRs come first. A PMP report entry can stay on for a consumer on the wakeup path, and dcpext1 uses it, so its firmware keeps its power through s2idle and the next deep sleep can park it. The GL9755 SD reader keeps a card that sat in the slot across the power cut. A DP-alt port is routed only once its display asserts HPD, so an empty dock no longer takes a pipeline. An audio instance the firmware replaced while open is closed, so a later link release is answered.
The sleep is described in the device tree: a binding for the T6000 sleep controller, and
apple_t6000_sleep_described()for the drivers that need to know (T6001 and T6002 share the block compatibles but have no such sleep).Coprocessors that lose their power are idled and started again from their saved context: RTKit gets a restart with buffers kept and a polled IOP idle, the mailbox can enable its inbox again, and the SIO firmware is parked in the late suspend phase.
Storage and PCIe: ANS gets its sleep-reset tunables back from the device tree. The internal PCIe ports (Wi-Fi, Bluetooth, SD reader) come back in the noirq resume, and a host whose port does not come back is cut off.
The PMP withdraws its requests and idles DVFS before the stop, answers a firmware that sets itself up again, gets its reset vector and SRAM back, keeps its DART's address filter, and is power-cycled the way macOS does it.
The enclave takes its answer wait from the SoC profile, resumes through its SEPROM, gets its inbox enabled first, and gets its sleep request only at the commit, past the last refusal.
The SMC hears of the sleep as a gen-1 SMC with pmVC, its last keys can still refuse the sleep, and the wake record is read at the platform finish, after the coprocessors are back.
AICv2, locked DARTs, the AP pins and the port controllers (S3 for the sleep) are kept or set up again. SPI HID arms no wake interrupt, since the keyboard and trackpad wake through the SMC.
The shared sleep code gets optional hooks: at
.prepareand.end, right after the SMC's sleep warning, and right after the first coprocessor stops; and a driver can stop its coprocessor at.prepareand start it again at.finish. The AOP uses that.The T6000 profile follows macOS 13's order: IRQs routed away from cores going offline, the SMC told before its peers stop, the display blocks and the GPU port taken down (the GPU port past the last refusal), one more interrupt check after the quiesce, a clean give-up when the last WFI falls through, a refusal in
.beginwithout the enclave, and wakeup events held from.prepareon. The late steps' words come from the device tree.Displays and GPU: the internal and external DCPs are parked (firmware 13.5 A500 link sleep), disp0 is power-cycled after a refused sleep, a DCP that is not parked refuses the sleep, and the GPU firmware is stopped at the commit and restarted warm. An attached HDMI display is released before the sleep and the HDMI output is set up again after it; a Type-C display's crossbar output is parked and selected again. The SIO is started again after a sleep given up after its park, so DisplayPort and HDMI sound come back. The ISP DART's address filter is named, so the camera starts again.
How to switch it on: T6000 is marked untested, and J314s does not carry
apple,sleep-tested.apple_sleep.deep=1on the command line offers deep in/sys/power/mem_sleep(never the default). Withoutapple_sleep.untested_commit=1(command line, or the module parameter at run time) each sleep is a dry run that stops before the commit. The enclave driver has to be loaded, otherwise the sleep is refused in.begin.In an aborted sleep the enclave never gets its request (
sent=0), by design. It still answers afterwards (hwrng 16 of 16 bytes).Rebase onto 24970e1: one commit was dropped, since main's
commit_stops_cpusdoes the same. Ten conflicts were resolved keeping main's code next to ours. The seven display and audio commits applied unchanged.Evidence
Builds on this head: full build rc=0; every commit builds alone with W=1, no new warnings; the sleep KUnit test compiles, not run. checkpatch --strict on the deep-sleep commits before the rebase (the rebased ones that changed give the same): 5 USLEEP_RANGE (udelay with interrupts off), 2 LONG_LINE, 2 FILE_PATH_CHANGES, 2 CONSTANT_COMPARISON (the file's own firmware check), 1 CAMELCASE (the SMC key pmVC), 1 AVOID_EXTERNS. The seven display and audio commits: clean, apart from one existing 104-column
dev_err()line. Built with stock bindgen 0.73.2, not main'stools/aurora-bindgen; the Rust layout assertions passed.dt_binding_checkandCHECK_DTBS: not run.Rows on main 24970e1, the series plus my HDMI blink commit (the head these rows ran on is this PR's head with that one commit on top). HDMI monitor and USB-C monitor attached the whole time:
The first 20-sleep run on this head played its stream to the headphone output, through a fault in my script: the speaker amps had no stream, so their volumes could not come back, and the run stopped at sleep 1. Run again with the stream on the speakers: the row above.
Rows one base earlier (main 5d50604: the same series before the rebase, 73 commits with the one main now has, plus the separate HDMI blink commit on top). HDMI monitor, USB-C monitor and a USB-C dock with nothing behind it attached the whole time:
DisplayPort and HDMI sound, a tone through the monitors' speakers recorded by the internal microphones (the build before, without the blink commit): after a real sleep 51 dB on HDMI and 52 dB on USB-C, against 6 and 8 dB with no tone; after a sleep given up, with the outputs kept lit, 44 dB on HDMI and 38 dB on USB-C (41 and 27 before it).
By hand: lid closed on battery with no external display: deep sleep, woke on lid open, panel lit. USB-C monitor pulled during a sleep: woke at once through the SMC. USB-C monitor plugged in during a sleep: picture after the wake. HDMI plugged in during a sleep: woke, picture. Headphones: tone heard before and after a deep sleep. HDMI pulled while awake, then a sleep, then plugged in: picture. HDMI pulled during a sleep: tested on an earlier version of the display commits, panel and USB-C monitor back, HDMI picture after plugging it back in.