Add T2 suspend/resume support
Summary
Adds suspend/resume support for Apple T2 Macs. The apple_bce module must be
unloaded before suspend (its PCI PM can't handle D3 entry), but userspace ALSA
clients (PipeWire/WirePlumber) keep it pinned. This service unbinds aaudio before
suspend, unloads apple_bce and dependent T2 modules, then reloads everything
after resume.
Tested on
- Model: MacBookPro15,4 (MacBook Pro 13", 2019)
- Kernel:
6.19.13-arch1-Watanare-T2-1-t2(T2 Arch Linux) - Userspace: PipeWire + WirePlumber (no stop/restart needed across suspend)
Test results (extended suspend/resume testing including overnight and multi-night)
| Condition | Result |
|---|---|
| Clean suspend/resume (audio, Wi-Fi, Touch Bar, USB, keyboard) | Pass |
| External monitor (HDMI) across suspend | Pass |
| Overnight suspend cycle (8+ hours) | Pass |
| Multi-night suspend cycle (48+ hours) | Pass |
| Bluetooth audio (headset playback and mic) across suspend | Pass |
| Built-in webcam after resume | Pass |
invalid position / scheduling while atomic kernel errors |
Gone |
appletbdrm *ERROR* Failed to send message on module unload |
Gone |
brcmfmac: brcmf_pcie_pm_enter_D3: Timeout |
Gone |
| Playback resume after suspend (Spotify, local audio) | Pass |
| Record after resume (microphone input) | Pass |
| Wi-Fi reconnect after resume | Pass |
| Bluetooth stays connected across suspend (not unloaded) | Pass |
| Screen capture (grim) after resume | Pass |
| Audio recording (arecord) after resume | Pass |
For testers
The service installs and enables automatically via Omarchy on T2 Macs
(detected via PCI ID 106b:180[12]). To test:
# After updating Omarchy, the migration runs automatically on next update,
# or run it local manually:
OMARCHY_PATH=~/Projects/omarchy bash ~/Projects/omarchy/migrations/1780075490.sh
# Check status:
systemctl status omarchy-apple-t2-suspend.service
journalctl -t t2-suspend
# Test a suspend cycle:
systemctl suspend
Kernel module requirement (just for clean audio after reload)
This fix requires the os_timestamp patch for the PLAYBACK stream in
apple-bce-drv. Without it, aaudio_pcm_pointer returns a wild position from
the T2 dev_timestamp after module re-probe, causing XRUN and
"scheduling while atomic" from the DMA IRQ context.
The patch is one line in audio/pcm.c: change dev_timestamp → os_timestamp
in the aaudio_handle_stream_timestamp call for the PLAYBACK substream.
The patch is not yet merged upstream. The pull request is open at
t2linux/apple-bce-drv. In the meantime, testers can apply the one-line fix
and rebuild:
git clone https://github.com/t2linux/apple-bce-drv
cd apple-bce-drv
sed -i 's/substream, dev_timestamp)/substream, os_timestamp)/' audio/pcm.c
make -C /lib/modules/$(uname -r)/build M=$PWD
# Backup original compressed module, then install the patched one
sudo mv /lib/modules/$(uname -r)/kernel/drivers/staging/apple-bce/apple-bce.ko.zst \
/lib/modules/$(uname -r)/kernel/drivers/staging/apple-bce/apple-bce.ko.zst.bak
sudo cp apple-bce.ko /lib/modules/$(uname -r)/kernel/drivers/staging/apple-bce/
sudo depmod -a
Model compatibility
The module lists in PRE_MODS/POST_MODS cover all T2 peripherals known on the
MacBookPro15,4. Other T2 models (MacBookAir, Mac mini, Mac Pro, iMac) may need
adjustments if their Wi-Fi chipset or other modules differ. The mod_ld guard
skips absent modules silently, so the service is safe to run on any T2 Mac.
Untested on dGPU-equipped T2 Macs (15"/16" MacBook Pro). Models with a discrete GPU may require additional module handling not covered here.
Debugging
If suspend/resume doesn't work on your model, run these and share the output:
# Did the service run?
journalctl -t t2-suspend
# Kernel errors during suspend/resume
dmesg | grep -iE "XRUN|appletbdrm|brcmfmac|apple_bce|invalid position|scheduling while atomic"
# Module state after resume
lsmod | grep -E "apple|brcmfmac"
# T2 module version
modinfo apple_bce | grep -E "version|srcversion"
# Active suspend method
cat /sys/power/mem_sleep
# Model / Kernel identification
cat /sys/class/dmi/id/product_name
cat /sys/class/dmi/id/product_version
uname -r
cat /proc/cmdline
# T2 PCI devices + GPU
lspci -nn | grep -iE "106b|vga|3d|display"
Awesome. This is very much needed in order to run Omarchy on older Intel MacBooks. Looking forward to trying this out!
Any suggestion on how to test this particular fix on my macbook?
The PR description has step-by-step test instructions under "For testers".
This is awesome and badly needed! Would be great to also get it upstreamed into some of the other distros/build tools for the t2linux wiki. They've been quite responsive the few times I've reached out and opened PRs.
https://wiki.t2linux.org/
I've had good experience with https://github.com/t2linux/T2-Mint in particular
Tested on MacBookAir8,1 (2018 Retina Air, T2) with kernel 7.0.11-arch1-Watanare-T2-1-t2.
Cloned the add-t2-suspend branch and ran the migration. KERNEL_CMDLINE[default]+=" pcie_ports=compat intel_iommu=on iommu=pt pcie_port_pm=off"
The service runs correctly: aaudio unbound, apple_bce and all T2 modules unloaded in order before sleep, all reloaded cleanly after resume. No Thunderbolt D3hot errors, no audio XRUNs, no brcmfmac timeouts. Wi-Fi, keyboard/trackpad, USB-C data and charging all working after resume.
I've been using it as a daily driver and it works fine across multiple suspend cycles.
@jjohnson - Thanks for putting this clean solution together to fix the suspend/resume long standing issue for T2 Mac users.
I have tested using the provided testing steps on my MacBookPro16,1. The suspend/resume now resumes rather than previously hanging the system. However the Wi-Fi does not properly load on resume consistently. The Wi-Fi interface (wlan0) only has properly loaded post resume 1% of the time when testing the fix.
Current result: suspend/resume works, Touch Bar comes back, Wi-Fi does NOT comes back.
Please see the attached t2-debug.txt: t2-debug.txt
Tested on MacBookPro15,4 (MacBook Pro 13", 2019)
- Kernel:
7.0.12-arch1-Watanare-T2-1-t2 - Userspace: PipeWire + WirePlumber
- Suspend mode:
s2idle [deep]
Setup:
- Cloned the
add-t2-suspendbranch and ran migration1780075490.sh - Applied the one-line
os_timestamppatch toapple-bce-drv(audio/pcm.c:304:dev_timestamp→os_timestamp) and rebuilt the module
Results:
| Condition | Result |
|---|---|
| Clean suspend/resume (audio, Wi-Fi, Touch Bar, USB, keyboard) | ✅ Pass |
| Playback resume after suspend (Spotify, local audio) | ✅ Pass |
| Record after resume (microphone input) | ✅ Pass |
| Wi-Fi reconnect after resume | ✅ Pass |
| Touch Bar (tiny-dfr) after resume | ✅ Pass |
invalid position / scheduling while atomic kernel errors |
❌ Gone |
brcmfmac: brcmf_pcie_pm_enter_D3: Timeout |
❌ Gone |
appletbdrm *ERROR* Failed to send message on module unload |
❌ Gone |
Logs:
Jun 15 19:33:59 mbp2019 t2-suspend[2315]: 0000:02:00.3 Unbound
Jun 15 19:33:59 mbp2019 t2-suspend[2353]: Unloaded appletbdrm
Jun 15 19:33:59 mbp2019 t2-suspend[2371]: Unloaded hid_appletb_kbd
Jun 15 19:33:59 mbp2019 t2-suspend[2389]: Unloaded brcmfmac_wcc
Jun 15 19:34:00 mbp2019 t2-suspend[2396]: Unloaded apple_bce
Jun 15 19:34:00 mbp2019 t2-suspend[2398]: Ready to suspend
Jun 15 19:35:52 mbp2019 t2-suspend[2488]: Loaded apple_bce
Jun 15 19:35:54 mbp2019 t2-suspend[2517]: Loaded brcmfmac
Jun 15 19:35:54 mbp2019 t2-suspend[2527]: Loaded brcmfmac_wcc
Jun 15 19:35:55 mbp2019 t2-suspend[2543]: Loaded hid_appletb_kbd
Jun 15 19:35:55 mbp2019 t2-suspend[2552]: Loaded appletbdrm
Jun 15 19:35:55 mbp2019 t2-suspend[2562]: Resume complete
No XRUNs, no brcmfmac D3 timeouts, no appletbdrm errors. Everything working cleanly across multiple suspend/resume cycles. The os_timestamp patch is essential for clean audio after module reload — without it you get XRUNs from wild dev_timestamp after re-probe.
@joshpavlovich Thanks for testing! This is the first data point on a 16,1 and confirms the module lifecycle works — suspend/resume and Touch Bar recovering is good progress.
The Wi-Fi D3cold issue (Unable to change power state from D3cold to D0) is specific to this model.
A couple things to try:
- Add
pcie_port_pm=offto your kernel cmdline — this disables PCIe port power management and should prevent the D3cold entry entirely. This is the simplest fix if it works. - If that doesn't help, try
pcie_aspm=off— more aggressive, disables Active State Power Management at the PCIe link level. - Alternative on the recovery side: try forcing the device out of D3cold before the module reload by adding this to the post-resume path in the script:
echo "on" > /sys/bus/pci/devices/0000:05:00.0/power/controlIf the device leaves D3cold, the existing modprobe brcmfmac should succeed.
Also, if you could collect debug info with collect-t2-debug > ~/t2-debug.txt (defined in the PR description) and attach that file above instead of a lengthy debug in PR.
Hello. I have a target macbook that I can devote to testing if someone can give me appropriate instructions.
I'm sure people have noticed that #5129 is also open; here's making it explicit.