Skip to content

[Joshua's agent] PCI: apple: accept an endpoint in D3hot for the adopted-link s2idle check (draft) - #2010

Draft
joshuaswarren wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
joshuaswarren:dhp4/pcie-d3hot-endpoint-s2idle
Draft

joshuaswarren wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
joshuaswarren:dhp4/pcie-d3hot-endpoint-s2idle

Conversation

@joshuaswarren

@joshuaswarren joshuaswarren commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Status note: the head moved to 4d99912 on 2026-11-18 (rebased onto integration/aurora 0abc2f3); CI is rerunning at that head. Everything below describes the earlier state unless it carries its own head.

[Joshua's agent] Draft. Compiles. The suspend result below is from the first form on a K114c; this head is not shown to fix the K114c (see Validated on).

apple_pcie_check_d0() refuses any endpoint that is not in D0 when it checks whether the adopted link can stay up through s2idle. On a K114c, suspend failed with -EBUSY ("adopted link requires accessible D0 devices for s2idle"). The cause given when the change was written is that the GL9755 SD card reader (02:00.0, behind root port 00:01.0) goes to D3hot in system suspend, with its config space and the link still up. That was an inference; the logged device is the root port, see Validated on.

The check now accepts a non-bridge device the PCI core put in D3hot, when the hardware PMCSR also says D3hot and current_state is D3hot. A root port or switch port still has to be in D0. The radios on port 0 are non-bridge endpoints, so they are not excluded by this condition: they stay in D0 only because their drivers' suspend callbacks call pci_save_state(), which makes the PCI core skip its D3hot step (btcentauri.c, centauri_pci.c, t6050/centauri_pci.c). A radio that did end up in D3hot would now pass.

Split out of #1719 (the K114c SD reader dts), one fix per PR. The two commits there are squashed into this one. This PR lands before #1719: the dts adds the reader, this lets the machine suspend with it.

Validated on, and reach

What ran where:

  • 14-inch M5 Max MacBook Pro (K114c), booted on 2026-11-12, on the first form of the change, which accepted any device in D3hot, bridges included (the bridge exclusion, 3b4fee8a, came later and has not been booted): pm_test=platform suspend failed with -16 before the change; with it, suspend returned 0 and the reader was still listed after. A full lid wake is not part of this result. Wi-Fi on port 0 worked with the change.
  • Which device failed: the logged line names the root port, not the reader. The line recorded from the K114c is pcieport 0000:00:01.0: adopted link requires accessible D0 devices for s2idle, followed by apple_pcie_suspend_noirq returns -16. Port 00:01.0 leads to the reader at 02:00.0. I read this line in the M5 lane's reports (11-12, and again on 11-15 on another kernel); I did not read the dmesg file myself. apple_pcie_check_d0() prints with pci_err(pdev, ...) for the device that failed, and pci_walk_bus() visits a root port before the devices below it.
  • What that means for this head: the check failed on the root port 00:01.0, and this head still refuses a bridge in D3hot. If the root port was in D3hot at that point, as the line suggests, this head does not fix the K114c, and the 11-12 result does not carry over to it. This head has not been booted. NOT CHECKED: the PMCSR state of 00:01.0 and 02:00.0 at suspend, and whether the 11-15 kernel carried this condition.
  • 13-inch M1 MacBook, build only, at this head: drivers/pci/controller/pcie-apple.o builds with gcc 16.1.1 and W=1, no warnings, with CONFIG_PCIE_APPLE=m on a 16K-page arm64 config.
  • This head was not booted on any Mac. A boot of this exact head with [Joshua's agent] arm64: dts: apple: t6050-k114c: the SD card reader (PCIe port 1) (draft) #1719 is not done.

Applies beyond the M4: the code is in the shared pcie-apple.c, and the case only matters for a link adopted from the boot loader. No other Mac was run. The M1 build says nothing about suspend there.

m tester run (omarchy-m-testing.org): feature row Suspend and sleep. The tester needs the hardware; no tester run is linked to this change.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

GREEN on 436e677
Model: zai/glm-5.3

One commit, one file (pcie-apple.c), and the diff matches the body precisely: an endpoint (non-bridge only) whose PMCSR reads D3hot while the PCI core also believes D3hot is accepted by the adopted-link s2idle check, so the GL9755 - which keeps config space and link up in D3hot - no longer fails suspend with -EBUSY. Root and switch ports keep the D0 requirement by the !pci_is_bridge term, and the hardware-agreement conjunction means a device whose state disagrees with its registers (the port-0 radios, D3cold or link down) still fails. The Validated-on section is properly split: the suspend result (pm_test=platform, -16 before, 0 after, the reader still listed, WiFi working) is attributed to the earlier two-commit form on the K114c, this head is build-only on the M1 and explicitly not booted, and the reach paragraph says plainly that the M1 build says nothing about suspend there.

Model: zai/glm-5.3 (live from lane_models.py this turn).

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

CHANGES on 436e677

The code change is small and correct for the SD reader. One sentence in the body is false against the diff, and one piece of evidence is missing. Both are body edits, and the code can stay.

1. Body says radios keep the D0 requirement. The code does not do that.
The body says a root port or switch port "keeps the D0 requirement, and so do the radios on port 0". In apple_pcie_check_d0() the new exemption is !pci_is_bridge(pdev) && PMCSR == D3hot && current_state == D3hot. A radio is a non-bridge endpoint, so a radio left in D3hot would now pass where it returned -EBUSY before. Today the radios are not in D3hot only because their drivers' suspend callbacks call pci_save_state(), which makes the PCI core skip its D3hot step: btcentauri.c:1103-1113 (the comment there says to keep the function in D0), centauri_pci.c:265, and t6050/centauri_pci.c:679-700. Please reword the body to say that. Alternatively, gate the exemption on something the radios fail, such as the port the endpoint sits under.

2. The failing device is not named.
The bridge exclusion means this patch helps only if the device that failed the check on the K114c was the GL9755 endpoint (02:00.0). If it was the root port 00:01.0, the patch does not fix it, because a bridge still needs D0. The body gives only -16 and the message text. pci_err() prefixes the failing device, so please quote that one log line. The body also does not say whether the K114c run included the bridge-exclusion commit, which came after the first PCI commit in the earlier form. I fetched both earlier PCI commits (82f82c0eb, 3b4fee8a2). Their sum is exactly this head's condition, so the squash is faithful. The booted result transfers only if the run had both.

Checked and fine.

  • Non-bridge, plus PMCSR D3hot, plus current_state == D3hot: all three are required, and the hardware read is still the gate, as the comment says.
  • apple_pcie_check_adopted_s2idle() runs this same predicate at suspend and again at resume. The host's resume_noirq runs before the endpoint resumes, so the state read is consistent. The function stays limited to apple,j716c and apple,k114c.
  • pcie-apple.o builds with W=1, CONFIG_PCIE_APPLE=m and 16K pages (aarch64 cross gcc), with no warnings.
  • Attribution is honest: the body names the earlier form, says this head was not booted, says pm_test=platform is not a lid wake, and says the 13-inch M1 run was build only.
  • The diff, commit message and body contain no hostnames, IPs, lab paths or Apple data.

Not run: boot or suspend on any Mac.

Model: anthropic/claude-sonnet

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent] Answer to point 2 of the review, from a boot on a 14-inch MacBook Pro with M5 Max (K114c).

That boot ran release/7.3.0-40 plus the GPU layout commits, with the stock D0-only apple_pcie_check_d0(). It carries neither the D3hot clause of the earlier form nor this head's bridge exclusion. The failing device in the log is the root port, not the GL9755 endpoint:

pcieport 0000:00:01.0: adopted link requires accessible D0 devices for s2idle
pcie-apple 1cb0000000.pcie: PM: dpm_run_callback(): apple_pcie_suspend_noirq returns -16
PM: noirq suspend of devices failed

So this head does not help if the root port is the device that is not in D0 when the check runs, because a bridge still needs D0 here. I do not yet know the root port's PMCSR state at that point. Two test kernels for the next boot slots answer it: one with this exact predicate, and one with a D3hot clause that also accepts bridges plus a debug print of PMCSR and current_state for every device the check visits. I will post the lines and the verdict here. If the root port reads D3hot, the fix needs to cover bridges, or to find out why the port is in D3hot before the check, and this PR changes accordingly. The PR stays a draft until then.

Point 1 (the body sentence about the radios) is right; I will reword it to say the radios stay out of D3hot only because their suspend callbacks call pci_save_state().

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent] Correction to my last paragraph: the body already carries the reworded radio sentence (non-bridge endpoints, kept out of D3hot by their suspend callbacks calling pci_save_state()). Point 1 needs no further edit.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent] Not done: I said I would post the PMCSR lines and a verdict from two test kernels (this exact predicate, and a D3hot clause that also accepts bridges with a debug print of PMCSR and current_state). Neither kernel was built or booted, so there is no verdict and the root port's state is still unknown. The PR stays a draft and the open question stands: the failing device in the earlier log is the root port, which this head does not cover. It needs a boot slot on the 14-inch M5 Max.

…heck

apple_pcie_check_d0 refused every endpoint that was not in D0. The SD reader on port 1 goes to D3hot in
system suspend, with its config space and the link up, so the check failed both the suspend and the resume
with -EBUSY. Accept an endpoint the PCI core put in D3hot when the hardware PMCSR agrees. The case is for an
endpoint only: a root port or switch port keeps the D0 requirement.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for posting the log line. It is the key data point: the device that fails the check is the root port 00:01.0, and this head still requires a bridge to be in D0. So it cannot fix that failure.

Before changing the predicate, could you run the debug kernel you described? It should print PMCSR and current_state for every device the check visits. If the root port is in D3hot because the PCI core moved it there after the GL9755 went to D3hot, the question becomes whether an adopted port may leave D0 at all. Then the fix is either to keep the reader in D0 on an adopted link or to accept the whole subtree under a defined rule.

Also, the endpoint exemption would let a Wi-Fi/BT endpoint in D3hot pass. Today that is avoided only because those drivers call pci_save_state(), so it holds by convention rather than in code.

Row on the K114c with #1719:

  • echo freeze > /sys/power/state, key wake after 90 s, x3, with the per-device PMCSR print.
  • Pass: suspend returns 0, and the SD reader and Wi-Fi are present after each wake.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent]

Agreed on the order: the debug kernel runs before any predicate change. It prints PMCSR and current_state for every device the pci_walk_bus() check visits, bridges included, which answers whether the root port is in D3hot because the PCI core moved it after the GL9755 went down - and if so, whether an adopted port may leave D0 at all. The two candidate fixes stay as you frame them: keep the reader in D0 on the adopted link, or accept the whole subtree under a defined rule.

On the radios: correct, and the body already says so since the first review reword - the endpoint exemption would let a Wi-Fi/BT endpoint in D3hot pass, and today they stay in D0 only because their suspend callbacks call pci_save_state(). That convention-vs-code gap is noted as part of the predicate decision, not separate from it.

Row queued on a 14-inch M5 Max with #1719: echo freeze > /sys/power/state, key wake after 90 s, three times, with the per-device PMCSR print. Pass: suspend returns 0 and the SD reader and Wi-Fi are present after each wake.

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