Repository navigation
M4 Max Studio (J575c) deep sleep, one series: SEP, sleep host, PCIe/SMC/display wiring, SEP guard - #3666
M4 Max Studio (J575c) deep sleep, one series: SEP, sleep host, PCIe/SMC/display wiring, SEP guard#3666RyanTheTide wants to merge 17 commits into
Conversation
Desktop Macs without built-in Touch ID still have the SoC's sensor SPI bus, and the SoC device trees describe a disabled sensor node on it. Add a boolean that lets a board say the machine has no fingerprint sensor for the SEP, so the SEP runs without biometrics. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
The first open of /dev/sep-bio activates Touch ID and brings the sensor up, and aurora-sep-ready opens it at boot to ask whether a reader is present. On a machine without one the activation enables the disabled sensor node the SoC device tree carries and probes it: the sensor driver logs "power unavailable" (-ENODEV), and the nonce-session profiles (T8140 and later) then run every attach and late-attach bring-up attempt against a sensor that is not there. When the SEP node has apple,no-biometric-sensor, don't publish /dev/sep-bio, and report diag/touchid as "absent". The identity keybag is still provisioned, and /dev/sep-key, the trusted keys and /dev/sep-bio-rearm (which also carries the per-user key bags) are published as before; aurora-sep-load already handles a machine with no biometric device. Boards without the property are unchanged. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
The J575c ADT (macOS 27.2.1) describes the same SEP as the J614c and J616c: an iop-sep,ascwrap-v6 that iBoot hands over booted (sepfw-booted), at the addresses and interrupts in t604x.dtsi, behind a dart-sep with vm-base 0x10000004000 and vm-size 0x3ff00000. Enable the SEP mailbox and add the sep alias, as the J614c/J616c tree does, so the loader reserves the SEP firmware and apple_sep enables the SEP and its DART. The Mac Studio has no Touch ID sensor (no spi2/mesa in the ADT): spi2 and the sensor node stay disabled, and apple,no-biometric-sensor keeps the SEP from looking for one. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
T6041 desktops (J575c) expose GP PCIe ports 2 and 3 in addition to ports 0 and 1, and T6041 sleep commit powers down cluster +0x0c (DISP_INT) and +0x10 (DISP_EXT, backing DISPEXT_RAIL_V). Map optional port2/port3 and phy2/phy3 windows from apple,apcie while keeping ports 0/1 required, track which mapped GP ports had refclk requested (BIT(0)) before sleep, and restore clocks only for those active ports on wake. Save cluster +0x0c and +0x10 in t6041_save() and restore their low nibble on wake in t6041_sleep_return() when non-zero before sleep. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
The T6041 sleep node stayed disabled at the SoC so that only the J614c and J616c enabled it; the J575c (Mac Studio) stayed on s2idle as "not qualified". Turn the node on in t6041.dtsi and let each board add only what is its own: apple,apcie and apple,atc-phys. The J614c/J616c tree keeps both and drops its status line; the J575c gets its four GP PCIe ports (ADT /arm-io/apcie pci-bridge0..3) and its four ATC PHYs. A desktop has no lid; t6041-sleep saves iBoot's wake masks and puts them back, so there is no per-board wake list to add. The J575c's ports 2 and 3 (Ethernet, ASM3142) come back from deep sleep only with linux#3421, so this goes after it. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
At boot the boot loader leaves each port's USB2 PHY running, and dwc3's core soft reset, which comes before its PHY power-on in dwc3_core_init(), relies on that. A real suspend-to-RAM powers the PHY down with the SoC. A host kept through the sleep has USB2 powered again at its wake (apple_t6040_atcphy_sleep_power_up()), but a controller that is stopped and started instead, such as a Type-C port in device role, then soft-resets over a cold PHY and times out. Its next suspend is refused from the prepare. Do for it what a CIO port already gets: after power loss (a firmware wake, or a resume from disk), the next reset release powers USB2 in the mode dwc3-apple has selected before the core's soft reset. A port that was powered through the sleep, and every s2idle or aborted sleep, is unchanged. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
The Mac Studio (J575c, M4 Max) has no panel, so its device tree describes none under the internal DCP. The boot loader hands that DCP over all the same when the board asks for it as the sleep host (apple,sleep-host-stop), and the display driver then keeps it to stop every display processor for suspend-to-RAM before the display power chains go down. Let the T6041 internal gate enable the DCP, its display and PIODMA when no panel is described; the panel is enabled only where there is one. Boards with a panel are unchanged. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
On desktop firmware the internal processor announces only the AV controller on interface 5 and the deferred DP controller on interface 7, while an external one opens four interfaces or more. The readiness check told the two apart with dcp_has_panel(), so the J575c's internal processor, which drives no panel, waited for interfaces it never opens and its start timed out. Tell them apart by the processor (dcp_desktop_external()). A processor with a panel is internal either way, so nothing changes where there is a panel. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
With no display (no panel, no HPD) the firmware of the J575c's internal DCP takes its pipe down itself during start-up, with a D572(0), and Linux never powers it on. A sleep then has nothing to power off: a second set_power_state(0) gets no D572, and the stop for suspend-to-RAM timed out waiting for one. Mark the pipe off when that D572(0) comes outside a sleep on an internal processor that has no panel and is not active, so that the stop takes its "display already off" path. A processor with a panel is left alone, and only the T6041 sleep reads the mark. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
…r the wake The pipe of a processor with no display stays down after the wake too: dcp_t6041_recommit() powered it on and then waited for a D575 hotplug that such a processor never sends. Remember that the pipe has been off since start-up, until anything powers it on, and leave it off after the wake: no power-on, no mode set. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
A T6041 external display chain may name the display coprocessor it powers. The driver then restarts that coprocessor after the wake from suspend-to-RAM, as T6040 does for its external chains, instead of shutting it down for good. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
…0's path T6040's sleep takes its external links down and restarts their DCPs after the wake (dcp_t6040_ext_link_down(), dcp_t6040_ext_start_one()). On T6041 they were shut down for the sleep and stayed off, so external displays stayed dark after it. Send a T6041 external DCP whose display power chain names it (apple,dcp) the same way: - dcp_t6040_relinks() takes the DCP: true on T6040, and on T6041 only for an external DCP with such a chain; - dcp_t6040_ext_chain() finds that chain by the phandle on T6041 (T6040 keeps its ext%u label); - such a chain's child domains are saved by the power word step, as T6040's are; - T6041's display DARTs are locked, so the two of such a DCP keep their TCR/TTBR words across the sleep (apple_dart_display_keep()), as the internal DCP's do; - the external start pass runs on every SoC; without a chain it does nothing. Chains without apple,dcp, and every T6040 path, are unchanged. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
The T6041 sleep driver sets the ANS link's PCIe up again after the wake
from the axi2af, cio3pll, clkgen, phy-block and phy-ip windows of the PCIe
node (apple,apcie). Without them it offers no deep sleep ("no PCIe tunables
for ANS"). Same blocks, at the same addresses, as on the J614c/J616c.
Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
As on the J614c/J616c, the SMC is given the VDD_CIO rail mask to keep at the sleep commit (apple,sleep-pmvc = <0x101>: port 0 stays powered for atc0_common). Unlike them, no apple,sleep-wake-type: the J575c's SMC has no WKTP key, and writing it fails (-EIO) and aborts the sleep. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
…ollers The J575c's version of #2174: its four back Type-C port controllers (hpm0-3) take the sleep's system power states (apple,sleep-ssps), as the J614c/J616c's do. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
Describe the display power chains (apple,t6041-display-power): the four external chains, each naming its DCP so that it is restarted after the wake, and the internal one. The internal DCP drives no panel on the J575c; it is kept as the sleep host (apple,sleep-host-stop) that stops every display processor before the chains go down, with the display clock it needs, as on the J614c/J616c. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com>
apple_sleep_enclave_stop_all() returns 0 when no enclave registered a sleep request, so t6041-sleep went on to the commit with the SEP still running. On a J575c with no SEP bound that hangs the Mac in the commit instead of sleeping it (reported on linux#3421). The SEP registers its request from its own suspend, so by the platform entry a bound SEP always has one. Refuse the sleep there, while a refusal is still possible, when none is registered: no SEP described, or its probe failed. Boards whose SEP binds (J614c, J616c) are unchanged. Add apple_sleep_enclave_registered() for it. It reads the hook without the lock, as apple_sleep_enclave_stop_all() does, since the entry runs with interrupts off. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
There was a problem hiding this comment.
Verdict: FINISH, then merge at 4d830b9d
Blockers:
dcp_t6041_stop_one()(drivers/gpu/drm/apple/dcp.c:12247-12256,12447-12455) leaksapple_dart_display_keep(..., true)on error unwind for T6041 relinking external DCPs:- Commit
c21b264dsetsapple_dart_display_keep(dcp->s2r_disp_dart / s2r_dcp_dart, ..., true)forrelink && dcp_t6041_ext_keeps(dcp)(whereexternal == true), afterkeep_set = !external;(line 12247). - At
err_unwind:(line 12447),if (keep_set)is both gated byif (!external)and never settruefor the external relinking path. Ifdcp_t6041_stop_one()aborts after line 12249 (e.g.,iomfb_s2r_500_v26_6_desktop(),iomfb_wait_channels_idle(), orapple_rtkit_idle()timeout/error), the external DCP's display/DCP DARTs are left withkeepenabled across the refused sleep. - Fix: Set
keep_set = true;insideif (relink && dcp_t6041_ext_keeps(dcp))and run theif (keep_set)apple_dart_display_keep(..., false)unwind outsideif (!external)inerr_unwind:.
- Commit
- Hosted CI at
4d830b9d:apple-build,dt-checks,kunit,host-tests,rust-build,source,DWC3/ATC,pr-text, andreadinessare still queued. - Hardware verification rows at exact head (as listed in the PR's Merge conditions):
- Exact-head J575c (M4 Max Studio) deep-sleep row (3x RTC wakes with HDMI/USB-C displays, Ethernet, SD, ASM3142, Wi-Fi/BT, and USB).
- J616s (M4 Pro) no-regression row covering shared
drivers/phy/apple/t6040-usb2.c. - J614c/J616c no-regression row covering shared T6041
display-gate/dcp/t6041-sleepchanges.
Checked:
- Audited all 17 commits (
+413/-62across 23 files, DCOSigned-off-byon all 17,MERGEABLEonmain):- SEP without biometric sensor (
0d979d69,2bb52e46,7e4c8dbd):apple,no-biometric-sensorschema, ABI doc (absent),dt::no_biometric_sensor(),diag::touchid_absent()(atomic_cmpxchgfromPENDING->ABSENT), and skippingregister_bio()while keeping keybag/trusted keys/rearm intact are clean. - SEP sleep-entry guard (
4d830b9d):apple_sleep_enclave_registered()checks!!READ_ONCE(apple_sleep_enclave.stop)with interrupts off insidet6041_sleep_enter(), failing closed (-EBUSY) before commit when no SEP has registered its sleep request, with!CONFIG_APPLE_SOC_SLEEPstub returningfalse. - T6041 sleep driver (
1a1cd6b7): extends GP PCIe port save/restore from 2 toT6041_GP_PORTS(4) gated bygp_port[i] && gp_phy[i]andgp_phy_pre[i] & BIT(0)(gp_up), and restoresDISP_INT(+0x0c) /DISP_EXT(+0x10) cluster words only when nonzero before sleep. t6040-usb2.c(2d759c5f):tphy->usb2_cold = !tphy->poweredint6040_power_lost(), consumed and cleared int6040_usb2_reset_deassert()andt6040_usb2_power_on().- Headless internal DCP sleep host (
e69986fc,1a64fa0c,05485124,9b2bb200,7da0068c,c21b264d):display-gate.cguards optionalT6041_PANELcleanly;dcp_dpavctrl_service_init()switches fromdcp_has_panel()to!dcp_desktop_external();dcp_s2r_dart_power()markspipe_off_since_start(cleared oniomfb_poweron) sodcp_t6041_recommit()skips poweron for a headless sleep host;dcp_t6041_parse_chain()uses__free(device_node)forapple,dcpand allocateschild_savedwhenchain->dcpis set;dcp_t6040_relinks(dcp)andtools/asahi/dcpext26-retrain-tests.pyupdated consistently.
- SEP without biometric sensor (
Evidence
drivers/gpu/drm/apple/dcp.cL12247–L12256:keep_set = !external;followed byif (relink && dcp_t6041_ext_keeps(dcp))callingapple_dart_display_keep(..., true)without settingkeep_set = true.drivers/gpu/drm/apple/dcp.cL12447–L12455:err_unwind:only callsapple_dart_display_keep(..., false)insideif (!external) { if (keep_set) { ... } }.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
J616s (M4 Pro, T6040) no-regression row at exact head 4d830b9: PASS This covers the series'
Merge conditions left: the J575c row at this head (owner, asked on #3421), and a J614c/J616c (M4 Max laptop) row if the owner can. |
|
Row at #3666's exact head Setup: kernel built from this head (
Why the row stopped there: with port 2 lost, the next suspend on this head blocks for ever. This is not from the new guard commit. It's the open problem that keeps #3653 a draft: port 2 sometimes does not train after a deep wake. That's 6 losses in about 120 deep wakes so far, this time on the first wake. The endpoint is present but never sends training sets. More resets don't help: probe-style, refclk gating off, 100 ms PERST#. Neither does Wake-on-LAN off. On a local branch I have:
The root cause isn't found yet. Next: I'll run the guard check (one deep attempt with |
Deep sleep (suspend-to-RAM) for the Mac Studio M4 Max (J575c, T6041), as one series, so nothing arms deep sleep before every part it needs is in. Almost all of it is Roberto Dantas' (@7robertodantas) work from his
j575c-deep-sleepbranch (his 6/6 deep-sleep tree), with his authorship and sign-off kept. It is collected here with its dependencies so it can be reviewed and merged as a unit.Commits, in order:
What each part does:
sleep-pmvcwithoutsleep-wake-type: the J575c SMC has no WKTP key), the port controllers' system power state (sleep-ssps), the display power chains, and the sleep-host properties.#3276, #3421 and #3626 are still open on their own. Each is safe alone (#3626 is owner-verified as a no-op on the J575c), and if they merge first, this PR shrinks to the rest.
Tested:
7robertodantas/j575c-deep-sleepcf0ec74 + the guard. One conflict int6041-j575c.dtswas resolved by keeping both the SEP block and the sleep-node block.LLVM=1 W=1builds ofdrivers/soc/apple/,drivers/phy/apple/anddrivers/gpu/drm/apple/add no new warnings (the existing SEP Rust dead-code warnings are on main too).make apple/t6041-{j575c,j614c,j616c}.dtb: builds.fdtgetshows the sleep-controller okay, the SEP mailbox okay andapple,apcieset on all three.checkpatch --stricton the guard commit: 0/0/0.tools/asahi/dcpext26-retrain-tests.py: PASS.Merge conditions:
rtcwake -d rtc1, with HDMI + USB-C displays, Ethernet, SD, ASM3142, Wi-Fi/BT and USB after each wake.phy: apple: t6040-usb2changes the PHY T6040 shares (USB2 power order after the SoC lost power).Risk: two-way · M4 Max (T6041 J575c; J614c/J616c share t6041-sleep, display-gate and dcp), M4 Pro (T6040 USB2 PHY); a plain revert undoes it. The guard turns a hang into a clean refusal on a board without a bound SEP.