Skip to content

soc: apple: admit M4 Mac mini (J773g) in T8132 SEP profile and desktop apple-sleep gates - #2763

Open
DjDeveloperr wants to merge 4 commits into
integration/aurorafrom
djdev/j773g-s2r-sep-sleep
Open

DjDeveloperr wants to merge 4 commits into
integration/aurorafrom
djdev/j773g-s2r-sep-sleep

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Summary

Two core driver changes required for deep sleep (S2R) on desktop T8132 boards (M4 Mac mini J773g on macOS 27.2):

  1. soc: apple: sep: admit J773g under the T8132 profile: admit apple,j773g alongside apple,j713 and apple,j715 in drivers/soc/apple/profile.rs (plus KUnit selection test) so apple_sep binds and registers its deep-sleep PM hooks (J773g has no Touch ID SPI sensor, which apple_sep already handles cleanly).
  2. soc: apple: sleep: allow desktop display[0] disabled and keep port0 PERST:
    • When display[0] (&dcp) is disabled in DT (desktop J773g on 27.2 where &dcpext0 is the active HDMI display), require every available external display coprocessor to be bound (and at least one bound) instead of refusing unconditionally on !s->display[0].bound. Keep the exact display[0].bound check whenever display[0] is available or absent.
    • Stop scanning &pcie0 children in apple_sleep_find_radio_perst() once the first port's PERST# is recorded so enabling port02 (J773g Broadcom Ethernet) does not overwrite port00's radio PERST#.

Verification

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Read at 922c890 (draft).

  1. drivers/soc/apple/profile.rs:713: this extends a board list (apple,j713 || apple,j715 || apple,j773g), and the next T8132 Mac (J604, the iMacs) will need the same one-line edit. What the profile needs to know is whether this SEP block behaves like the Airs', which is a property of the SoC's SEP and its firmware, not of the board. The comment already says the J773g differs only in having no Touch ID sensor, which apple_sep handles. Please select the T8132 profile on apple,t8132 (or on the SEP node's compatible) and let the sensor's absence come from the tree, as it already does, with the "unread" boards covered by a row instead of a list.
  2. sleep.c, the display check: when display[0] is disabled, the new branch refuses unless at least one external display coprocessor is bound. On a mini with no external display processor enabled (no 27.2 image handed over, or a headless setup where the gate leaves them off) nothing is running that needs lowering, yet any_bound is false and every sleep is refused. Refuse only for an available display coprocessor that isn't bound, and allow the case where none is available.
  3. apple_sleep_find_radio_perst(): stopping at the first &pcie0 child with a PERST# relies on port00 being first in the tree. If the radio is meant, select the port that carries the radio (its child node or a property on it) rather than the first one found, so a reordered or differently populated tree can't pick the Ethernet port.

Rows: the J773g deep-sleep run you mention, plus one J713 deep sleep on this head (it goes through both changed paths in sleep.c).

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr
DjDeveloperr force-pushed the djdev/j773g-s2r-sep-sleep branch from 922c890 to b88b87d Compare November 22, 2026 02:27
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Addressed all three review points at b88b87d812258:

  1. drivers/soc/apple/profile.rs: dropped the T8132 board allowlist and selected &T8132 directly on apple,t8132, updating the apple_sep_profile KUnit tests (t8132_selection_matches_the_soc and t8142_sensor_boards_require_the_matching_soc).
  2. drivers/soc/apple/sleep.c (apple_sleep_refuse): when display[0] is disabled in DT, refuse only for an available external display coprocessor that is unbound — allowing headless setups where no external display coprocessor is available.
  3. drivers/soc/apple/sleep.c (apple_sleep_find_radio_perst): added apple_sleep_port_is_radio() matching the port carrying the radio (via /aliases/wifi0 parent match or a wifi/bluetooth child node) rather than relying on DT child order.

Verified scripts/checkpatch.pl --strict (0/0/0 across both commits). Live J773g 27.2 deep-sleep verification is running now (dcp63-m4prod3-full), and we will re-verify this exact head + J713 row before leaving Draft.

Assisted-by: LLM (Gemini:4 Neon)

@DjDeveloperr
DjDeveloperr force-pushed the djdev/j773g-s2r-sep-sleep branch from b88b87d to b1f547a Compare November 22, 2026 05:16
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Rebased onto integration/aurora and added b1f547a0a8955 (soc: apple: sleep: stop all enabled apcie ports before lowering apcie), which stops and asserts PERST# on every enabled APCIe port (such as J773g port 2 Ethernet alongside port 0 radio) before lowering APCIe, while preserving apple_sleep_port_is_radio() for s->radio_perst and upstream apcie_ports_unowned clock restore.

Live Verification — 3/3 Real Deep Sleep (dcp66-m4prod5-deepsleep)

Tested on live M4 Mac mini (J773g / T8132, macOS 27.2 26B123, 7.3.0-ARCH-m4prod5):

Cycle boot object resumes Wake Source apple_sep Resume /dev/hwrng Errors
1 0 -> 1 NUB.SPMI0.SW3 5395 us 16B OK 0
2 1 -> 2 NUB.SPMI0.SW3 5408 us 16B OK 0
3 2 -> 3 NUB.SPMI0.SW3 5408 us 16B OK 0

0 oops/warnings/SErrors across all 3 wakes.

Assisted-by: LLM (Gemini:4 Neon)

Select the T8132 SEP profile on apple,t8132 rather than maintaining a
per-board allowlist (apple,j713 || apple,j715). Every T8132 Mac shares the
same SEP block and firmware, and boards without a Touch ID sensor such as
J773g (M4 Mac mini) already omit the sensor node in DT so apple_sep binds
the SEP for key store, hwrng, and suspend-to-RAM without trying to probe a
missing sensor.

Update the apple_sep_profile KUnit tests accordingly.

Signed-off-by: Diljit Singh <hey@djdev.me>
On desktop T8132 boards such as J773g on macOS 27.2, display[0] (&dcp) is
disabled in DT while display[1] (&dcpext0) is enabled and bound by
appledrm with s2r_ext support (or headless with no external display
coprocessor enabled). Requiring s->display[0].bound unconditionally in
apple_sleep_refuse() refused deep sleep even when every available display
coprocessor was bound.

Keep the exact display[0].bound check whenever display[0] is available (or
absent from DT); when display[0] is disabled in DT, refuse only when an
available external display coprocessor is unbound, allowing headless setups
where none is available.

In apple_sleep_find_radio_perst(), explicitly match the PCIe root port that
carries the wireless radio (via the /aliases/wifi0 parent or a wifi /
bluetooth child node) instead of taking whichever port appears last or
first, so enabling port02 (Ethernet/SD) cannot overwrite the radio PERST#.

Signed-off-by: Diljit Singh <hey@djdev.me>
Multi-port T8132 hosts such as J773g enable both port0 (radio) and
port2 (Ethernet) under the shared apcie controller. Previously
apple_sleep_map_apcie() only mapped port0/phy0 and
apple_sleep_find_radio_perst() stopped after the first child port's
PERST# GPIO, leaving port2 running when apcie_gp and apcie_phy_sw are
lowered during deep sleep.

Map portN/phyN and AP reset-gpios for every available child port of
apple,apcie (falling back to port0/phy0 when the host is disabled) and
stop all mapped ports in sleep_apcie_port_stop_once(), while keeping
the PIO-DMA engine teardown on port 0 and preserving radio_perst for
T8142.

Signed-off-by: Diljit Singh <hey@djdev.me>
…ership

When pcie-apple manages T8132 APCIe ports across real sleep directly
(without the single-port apple,managed-sids radio contract), two issues
arise in apple-sleep:

1. t8132_wake() re-clocks all ports under apcie_ports_unowned right
   before pcie-apple's noirq resume drops and re-requests REFCLK0/1.
2. apcie_port_down is a single boolean across all ports, so if one port
   recovers on wake and another fails to retrain, the next suspend
   either skips the working port or tries to stop the failed one.

Add apple_sleep_apcie_ports_owned() (kept out of struct apple_sleep so
probe order does not matter) so apple-sleep skips its fallback
unowned-port clocking when the PCIe host owns recovery, and track each
port's down state individually with apple_sleep_apcie_port_up(idx)
(while keeping apple_sleep_radio_port_up() clearing all ports for the
existing single-port managed-radio callers).

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr force-pushed the djdev/j773g-s2r-sep-sleep branch from b1f547a to 2dfb6d6 Compare November 22, 2026 09:52
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

@RyanTheTide Rebased onto integration/aurora (32bf9dd3569d2) and force-pushed v2 (2dfb6d6301ff2):

  1. Per-port APCIe state tracking & host ownership (2dfb6d6301ff2): Added apple_sleep_apcie_ports_owned(bool) and apple_sleep_apcie_port_up(unsigned int idx) (tracking APCIe port down state per port instead of a single boolean, and letting pcie-apple claim ownership so apple-sleep skips its unowned-port fallback REFCLK setup while preserving apple_sleep_radio_port_up() for existing single-port managed-radio callers). This directly resolves the #2770 review items on per-port restore tracking and sleep.c REFCLK overlap.
  2. Checks: scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES is 0/0/0 across all 4 commits (1aaed3b404f31, 879bc89f05289, 1d66cf2881b78, 2dfb6d6301ff2).
  3. Live hardware verification (dcp72-m4prod11-wave5-v7tc-s2r, M4 Mac mini J773g / T8132, 7.3.0-ARCH-m4prod11):
    • 2/2 consecutive real deep sleeps (rtcwake -d /dev/rtc1 -m mem -s 15): success=2 fail=0, boot object resumes 0 -> 1 -> 2, 302600000.gpu stop reported 1; physical sleep completed, wake source NUB.SPMI0.SW3, zero SErrors/BUGs/WARNs.
    • apple_sep /dev/hwrng returned live 16-byte random reads on both wakes; tg3 0000:02:00.0 end0: Link is up at 1000 Mbps, full duplex on both wakes; apple-pmc floors/rails/DCS restored cleanly.

Assisted-by: LLM (Gemini:4 Neon)

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review November 22, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants