Skip to content

linux-omarchy: take native PCIe PME control on Apple machines - #3475

Draft
makoni wants to merge 3 commits into
omacom:masterfrom
makoni:linux-omarchy-apple-native-pme
Draft

makoni wants to merge 3 commits into
omacom:masterfrom
makoni:linux-omarchy-apple-native-pme

Conversation

@makoni

@makoni makoni commented Nov 25, 2026 •

Copy link
Copy Markdown

Draft. It proposes a backport of an upstream fix that is queued for 7.5. The patch is unsigned, unlike the numbered series, and 0779 is a placeholder number (#3393 holds 0778). If you would rather fold upstream 2d89ca89b01f into the next signed release than merge this, that works just as well, and this PR can carry the test results.

Problem

On Apple machines, negotiate_os_control() in drivers/acpi/pci_root.c skips _OSC, because the firmware fails it once _OSI("Darwin") has been answered. Instead it assumes control of every PCIe feature except PME (~OSC_PCI_EXPRESS_PME_CONTROL, since 7bc5a2bad0b8). As a result, portdrv never starts the PME service on any root port.

A device that runtime-suspends still arms PME# and asserts it when it needs attention, but nothing services the root port interrupt. The PCI core's once-a-second PME poll can't help either: it skips a device whose upstream bridge is runtime-suspended.

On a MacBookPro14,3 this breaks USB-C hot-plug. Each of the two Alpine Ridge Thunderbolt controllers contains an xHCI. When the USB-C ports are idle, that xHCI and the downstream port in front of it runtime-suspend to D3hot. A USB 3 device plugged in then produces no kernel message at all until something else wakes the controller. omacom/omarchy#7044 (14,3) and omacom/omarchy#15537 (14,1) work around the same symptom from userspace by keeping the controllers awake.

Change

The fix is upstream 2d89ca89b01f ("ACPI: PCI: take native PME control on Apple machines") by Francisco Beltrán Millalén. Rafael Wysocki queued it in linux-pm for 7.5: https://patch.msgid.link/[email protected].

  • On Apple machines it assumes the same control set that _OSC would have requested (calculate_control()), PME included. On this machine the _OSC line goes from [PCIeHotplug SHPCHotplug AER PCIeCapability LTR DPC] to the same list plus PME.
  • The code is identical to the upstream commit; only the hunk offset differs. On this branch's base, master's 1:7.3.6-5 (plain v7.3.6), it applies at offset -3 with --fuzz=0.
  • No other patch in these packages touches drivers/acpi/pci_root.c, drivers/pci/pcie/pme.c or pciehp_core.c.
  • It is added as 0779-acpi-pci-take-native-pme-control-on-apple.patch to linux-omarchy, linux-omarchy-eevdf and linux-omarchy-muqss, with pkgrel bumped in each. All three variants carry the same patches apart from the scheduler ones, so leaving it out of two would make a Mac on eevdf or muqss behave differently. Only linux-omarchy was built and booted, on 7.2.15 and on 7.3.7 (see Testing).
  • linux-omarchy: mark the EC GPE wake-capable on the MacBookPro14,3 #3393 also bumps these PKGBUILDs, so whichever lands later needs a re-bump.
  • Drop it when linux-omarchy reaches 7.5. The upstream commit has Fixes: but no Cc: stable. If a stable release picks it up anyway, this patch will no longer apply and the build will fail.

Side effects

Upstream also points out that this makes pme_is_native() true for pciehp. On the Alpine Ridge hot-plug ports, pciehp_runtime_suspend() and system suspend now disable the slot interrupt. A Thunderbolt PCIe device plugged into a runtime-suspended hot-plug port then has to be noticed through PME. The carried 0605 (rescan after a PCIe tunnel is set up) may cover that case. I have no Thunderbolt PCIe device and didn't test that path. Bjorn Helgaas copied the Thunderbolt maintainers on the upstream thread, and none of them replied.

x86_apple_machine covers every Intel Mac, but the MacBookPro14,3 is the only model tested so far, by the author, by Darrell Gum and here. Darrell's Tested-by was on 7.2.5-3, together with the author's PCI/PM series and an Alpine Ridge quirk, not bisected, and hot-plug still worked across an S3 cycle. Matthew Garrett, who wrote the original _OSC skip, asked in the thread for testing on older machines. T2 Macs use linux-t2, which this PR doesn't touch. The Macs this could newly affect on linux-omarchy are mainly non-T2 Intel Macs.

There is no switch to turn the change off except pcie_ports=compat, which also disables pciehp and AER. Reverting means booting the previous kernel or a snapshot.

Each plug-in also logs pcieport 0000:00:01.x: PME: Spurious native interrupt! once, just before the device is resumed. The patch's original posting explains it: pcie_pme_walk_bus() does not attribute a PME from a PCIe device behind a switch, but the device is still resumed.

Testing

MacBookPro14,3 (two Alpine Ridge JHL6540, firmware 529.140.2.0.0), Omarchy 4.5.0-3, kernel command line without pcie_ports.

There were two test kernels, both built with makepkg in an archlinux container with GCC 16.2.1:

  • 7.2.15: the linux-omarchy 7.2.15-4 recipe (b571666) with this patch appended. GCC was the same version as for the stock package.
  • 7.3.7: this branch's linux-omarchy recipe at a07a101, i.e. 7.3.7-2.

The branch has since followed master back to 1:7.3.6-5 (#4205; now pkgrel 6), and I haven't rebuilt for it. 7.3.7-2 was v7.3.6 plus patch-7.3.7-rc2. Neither that patch nor the recipe patches added or dropped in the move touch pci_root.c, pme.c or pciehp_core.c. The xHCI code does differ from the tested build (0612 is new, and rc2's xHCI fixes are gone), but the PME path doesn't.

In both, pkgbase was renamed so the kernel could be installed next to the stock one and booted from its own Limine entry. The recipe's out-of-tree module packages were left out: the NVIDIA open modules, and on 7.3.7 also IPU7, v4l2loopback and OpenRazer. For 7.3.7 the headers' libcrypto.so dependency was changed to openssl, because this machine is still on stable with OpenSSL 3.6.

On 7.3.7 the boot log has the same _OSC line, and 7.3's new summary line reads OS native features: SHPCHotplug+ PCIeHotplug+ PME+ AER+ DPC+ LTR+.

Hot-plug without sleep, 7.2.15, kernel defaults.

  • My local udev rule and boot script were off for this boot, so everything stayed at the kernel defaults: the root ports and Thunderbolt bridges at power/control = auto, and d3cold_allowed = 1.
  • About 35 s after boot, both xHCIs, the ports in front of them and the other hot-plug ports were in D3hot.
  • I plugged a USB 3 SSD into the left far port. It was attached as usb 4-2 (SuperSpeed, uas) 0.24 s after the root port 00:01.1 PME interrupt, and sda1 appeared 0.8 s after that.
  • I unplugged it and, 61 s later, plugged it into the right port, which is on the other controller and root port 00:01.2. It came up the same way, 0.23 s after the PME interrupt.
  • Reading 512 MiB from it with O_DIRECT gave no errors.
  • For comparison, on the stock 7.2.15-4 kernel with the same bridges at auto (the root ports were kept at on in that run), a plugged-in SSD produced no kernel message at all.

Hot-plug without sleep, 7.3.7.

  • This time I set the defaults at runtime rather than at boot: everything below both root ports at d3cold_allowed = 1, with the bridges at power/control = auto. The root ports themselves stayed at on. Both xHCIs and the ports in front of them went to D3hot.
  • That is the same state as in the stock 7.2.15 comparison run above: the PME poll still can't reach the xHCIs, because the ports in front of them are suspended. I didn't repeat the stock comparison on 7.3.7.
  • The SSD in the left near port was attached as usb 4-1 (SuperSpeed, uas) 0.24 s after the 00:01.1 PME interrupt, and sda1 appeared 0.8 s later.
  • Moved to the right port 5 s later, it came up as usb 6-2, 0.24 s after the 00:01.2 PME interrupt.
  • Reading 512 MiB with O_DIRECT gave no errors.

One s2idle cycle on each kernel.

  • The setup was this machine's usual sleep setup, with the udev rule and boot script back on. Its local sleep hook is an s2idle variant of the remove-and-rescan hook proposed in Suspend on 2016-2017 MacBook Pros: keep USB-C and Thunderbolt working across S3 omarchy#11570: it removes both Alpine Ridge trees before sleep and rescans them after resume. So no Alpine Ridge device went through suspend and resume itself, and these cycles mainly show that the rest of the system is unaffected.
  • On 7.2.15 the machine was suspended for 3 min 23 s, on 7.3.7 for 8 min 7 s. Both times it woke on lid open, with no other resume, and suspend_stats read success 1, fail 0. There were no AER, DPC or pciehp errors. On 7.3.7 the 00:01.1 interrupt count went up by one across the cycle, with no PME message.
  • After each wake, I set the re-created bridges back to auto (the root ports stayed at on) and plugged in the SSD. On both kernels it enumerated 0.24 s after the PME interrupt.

Other warnings.

  • On 7.2.15, every kernel warning in the test boot that a same-day stock boot lacks also appears in earlier stock boots:
    • USB address errors while the SSD was being pulled out;
    • a brcmfmac flowring timeout as Wi-Fi went down before sleep;
    • hid_field_extract from the T1's HID sensor hub after resume.
  • On 7.3.7 the brcmfmac flowring timeout showed up again, and a hid_field_extract warning, this time from the T1's touchpad interface before sleep (also common in stock boots). There were no USB address errors. One warning appears in no earlier boot: amdgpu: Failed to populate edc leakage registers!, at boot and again on resume, from the Radeon Pro 560. I haven't checked it on a stock 7.3.7 kernel.
  • Unrelated to this patch, but worth knowing before 7.3 reaches Omarchy stable: on 7.3 the hardware cursor is invisible on this Radeon (Polaris) with Hyprland 0.56.2 and aquamarine 0.15.1. It is Hardware cursor invisible on RX 580 with kernel 7.3 hyprwm/aquamarine#476: amdgpu now advertises modifiers on pre-GFX9 GPUs. The fix is in aquamarine 0.16.0-1.3 on edge and rc (aquamarine 0.16.0-1.3: show the cursor on pre-Vega amdgpu with Linux 7.3 #4164, see Invisible hardware cursor on pre-Vega AMD GPUs with linux-omarchy 7.3 (needs aquamarine#499) omarchy#20918). Until it reaches stable, setting Hyprland's cursor.no_hardware_cursors to 1 works around it. With the same Hyprland setup, the cursor is fine on stock 7.2.15.
  • Both test boots also had some of this machine's out-of-tree modules loaded: the T1 bridge and Touch Bar drivers, an EC wake helper and acpi_call, plus the audio codec on 7.2.15 and a locally patched Wi-Fi driver on 7.3.7. None of them deal with PCIe port services.

Not tested: other Mac models, S3, Thunderbolt PCIe devices, eevdf and muqss, more than one sleep cycle per kernel, and battery drain.

Checking on another Mac

  1. Remove anything that keeps these controllers awake:
  2. Boot, then check that the boot log lists PME in the _OSC line.
  3. With nothing on USB-C, wait until the Thunderbolt xHCI's power/runtime_status reads suspended.
  4. Plug in a USB 3 drive. It should enumerate within a second or two.

The omacom/omarchy#7044 and omacom/omarchy#15537 rules are harmless alongside this patch. On the 14,3 they are no longer needed once it ships; the 14,1 is untested.

Backport 2d89ca89b01f ("ACPI: PCI: take native PME control on Apple
machines"), queued in linux-pm for 7.5.

On Apple machines Linux skips _OSC and assumes control of every PCIe
feature except PME, so no root port runs the PME service. A runtime
suspended device behind a suspended bridge is then never resumed by its
PME. On a MacBookPro14,3 a USB 3 device plugged into an idle USB-C port
is not detected until something else wakes the Thunderbolt xHCI.

Carried as 0779 in linux-omarchy, linux-omarchy-eevdf and
linux-omarchy-muqss.
Carry 0779 onto the 7.3.7 kernels (pkgrel 2). The patch applies to
v7.3.6 at offset -3 with no fuzz, and patch-7.3.7-rc2 does not touch
drivers/acpi/pci_root.c.
Carry 0779 onto the 1:7.3.6-5 kernels (pkgrel 6, epoch kept). The
patch applies to v7.3.6 at offset -3 with no fuzz, and no other patch
in these packages touches drivers/acpi/pci_root.c.

This branch has not been deployed

No deployments
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.

1 participant