Repository navigation
PCI: apple: put a function back in D0 before restoring it after S2R - #3142
Merged
Merged
Conversation
After a real sleep the host trains a conventional port again in its own
resume, but the PCI core's noirq power-up of the functions behind it ran
earlier, with the link still down ("Unable to change power state from
D3hot to D0, device inaccessible"), and left current_state at D3hot. The
GL9755 SD reader's resume then frees and allocates its MSI vector, which
the MSI core refuses for a device that is not in D0: "enable PCI MSI
failed, error=-22", and from then on every command times out.
On the J614c the dead reader also blocks the next suspend (its command
timeouts keep a freezable workqueue busy, "Device or resource busy") and
hangs the kernel's final reboot step until the hardware watchdog resets
the machine.
The port reset brought the function up in D0: record that with
pci_set_power_state() before its saved state is loaded back.
Signed-off-by: Jos Dehaes <[email protected]>
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
This was referenced Nov 25, 2026
satchlj
approved these changes
Nov 25, 2026
satchlj
left a comment
Member
There was a problem hiding this comment.
Verdict: MERGE
Checked: Code review and live CI verification of drivers/pci/controller/pcie-apple.c at fba4ec5680bf against main, including the hib_cold resume path ordering relative to pci_load_saved_state() and pci_restore_state().
Evidence
apple_pcie_resume()iterates functions behind ports that lost power during firmware sleep (port->hib_cold), restores the PCIe link, and now recordspci_set_power_state(fn->pdev, PCI_D0)beforepci_load_saved_state()/pci_restore_state()so PCI core state matches the post-reset D0 hardware state and subsequent driver MSI allocation no longer fails with-EINVAL.- Scoped strictly to
port->hib_coldfunctions; ports that retain power across suspend skip the path unchanged. - Exact-head J614c (M4 Max) deep-sleep verification row is documented in the PR body at
fba4ec5680bf(5 deep sleeps over two boots, SD reader recovers cleanly with nomsi -22or command timeouts, clean reboot). - All 20 CI checks completed green at
fba4ec5680bfwith 0 active and 0 failing checks.
Contributor
|
Hardware verification row — Apple M4 Max 16" (T6041 / J616C) at exact HEAD
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: after a deep sleep, set the functions behind a power-lost PCIe port back to D0 before their saved state is restored, so the J614c's SD reader resumes instead of failing with
msi -22and then blocking the next suspend and the reboot.Tested: J614c (M4 Max) with this commit, fba4ec5, on
main34bdf71 (pcie-apple.cis the same as on this branch's base): 5 deep sleeps over two boots (3 lid, 2rtcwake), the SD reader back after every wake with nomsior command-timeout errors, the reboot after them 18 s. Without it, the reader died at the first wake, the next suspend was refused twice and the reboot hung until the watchdog.Risk: two-way · M4 Max (T6041); only functions behind a port that lost its power in a firmware sleep (
hib_cold)Not yet: other T6041 boards (J616c, J575c), and Macs whose ports keep their power, where the new call isn't reached
On
main, the SD card reader (GL9755, PCIe port 1) of the J614c doesn't survive a deep sleep. Its resume fails withenable PCI MSI failed, error=-22, and every command after that times out. That breaks more than the reader:Device or resource busy, because the reader's command timeouts keep a freezable workqueue busy (Freezing remaining freezable tasks failed ... wq_busy=1);After a real sleep
apple_pcie_resume()trains the conventional port again, but the PCI core's noirq power-up of the functions behind it has already run, with the link still down, and leftcurrent_stateat D3hot. The port reset brings the function up in D0, but nothing records that, and the reader's resume frees and allocates its MSI vector, which the MSI core refuses for a device that isn't in D0. The fix callspci_set_power_state(fn->pdev, PCI_D0)for each such function beforepci_load_saved_state()and the restore.#2215 (T6040 deep sleep) reworks the same resume path (
s2r_ports_lost, ports set up again in the noirq resume), which would also avoid this. This is the minimal fix for what is onmainnow; if #2215 lands first, this can be closed.Evidence
Without the commit (
main34bdf71 plus unrelated local changes), at the first wake:and at the next two lid closes:
With the commit: the
Unable to change power state ... inaccessibleline from the noirq power-up still appears, then nomsi, resume or command-timeout error over 5 sleeps.checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.