Skip to content

PCI: apple: retire the J713 tunneled port when its stop and undo both fail - #3208

Merged
RyanTheTide merged 2 commits into
mainfrom
fix/pcie-apple-cio-retire-failed-stop
Dec 1, 2026
Merged

RyanTheTide merged 2 commits into
mainfrom
fix/pcie-apple-cio-retire-failed-stop

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

What: When the J713 tunneled port's noirq suspend fails partway and its undo fails too, which is what happens if the dock leaves during the stop, the kernel panicked. Now the port is retired as after a surprise removal and the sleep is refused, the same way the T6050 stop and the resume path already handle it.

Tested: The changed object builds with W=1 on an arm64 16K-page config at cb4b537baacf. No hardware row yet.

Risk: two-way · J713 (M4) with a Thunderbolt dock. Only the path where both the stop and its undo fail changes.

Not yet: A J713 row: dock removed while the suspend stops the port, then plugged back in. A J773g dock attach, detach and sleep smoke (this path runs only on J713).

Details
  • On failure the unwind sets resume_failed and calls apple_pcie_tunnel_hierarchy_gone(), before the PM core resumes the functions below. They are marked disconnected, so their config reads fail fast. Config space also stays closed, because cio_changed stays set.
  • apple_pcie_tunnel_cio_finish() already treats resume_failed as a retired port. It ends the DART transaction and returns 0.
  • port->needs_stop stays set from the undo, so the tunnel teardown that follows (apple_pcie_tunnel_quiesce()) removes the hierarchy and stops the port.
  • The DART stays as the undo left it: closed if the undo failed before turning it back on.
  • This matches apple_pcie_cio_suspend_t6050() and the resume_noirq failure path.
Evidence
  • ./linux-build/build kernel linux-pciewifi-fixes -- -j3 W=1 drivers/pci/controller/pcie-apple.o (pcie-apple-cio.c is included there) with CONFIG_ARM64_16K_PAGES=y: no warnings.
  • scripts/checkpatch.pl --strict: clean.
  • Base: 40e5e29cc915.

… fail

When the noirq suspend of the J713 tunneled port fails partway, it puts
the port back before refusing the sleep. If the dock left during the
stop, that undo fails too, and the kernel panicked.

End it as the T6050 stop and the resume already do: mark the port as
failed and its hierarchy disconnected before the functions below resume
and read their config space, and refuse the sleep. Config space stays
closed, the tunnel teardown that follows removes the hierarchy and
stops the port, and the ACIO host still ends the DART transaction.

Fixes: 37c6514 ("PCI: apple: stop and restart the J713 tunneled port for a deep sleep")
Signed-off-by: Dj <[email protected]>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 26, 2026 07:54
@github-actions github-actions Bot added blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at 4050251b: not ready yet

Check Detail
CI at head no failing: apple-build, host-tests, kunit, KUnit ane-boot, KUnit ane-pm, KUnit dcp-fabric
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok comment at cb4b537b; the changed files are byte-identical at 4050251b
Conflicts ok none
PR text ok Risk: two-way · J713 (M4) with a Thunderbolt dock. Only the path where both the stop and its undo fail changes.

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J773g (M4 Mac mini) second-generation smoke at cb4b537baacf: PASS, without the dock part.

How it was run: a guarded one-shot of main 9a9862253576 plus this PR. The PR's file is identical to its head; the same kernel also carried #3200, #3204 and #3210, with no files overlapping. A boot of main alone is the control.

No dock attach or detach: no Thunderbolt or USB4 device is connected to this Mac (/sys/bus/thunderbolt/devices is empty), and nobody is there to plug one in. So there's no attach or detach here.

What was checked:

As you said, the changed unwind runs only on J713, so on this Mac the row shows only that nothing else changes.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Verdict at cb4b537baacf: ready (code); the J713 dock-removal row listed under "Not yet" is still owed before merge

Blockers: none

Checked

  • The new unwind (pcie-apple-cio.c:444-456) is the same one the T6050 stop uses at 365-377. Set resume_failed, then apple_pcie_tunnel_hierarchy_gone() before the PM core resumes the functions below. Those functions are marked disconnected, config space stays closed because cio_changed stays set, and the sleep is refused with the original error.
  • apple_pcie_tunnel_cio_finish() (60-66) already accepts a changed port when resume_failed is set, ends the DART transaction and returns 0. apple_pcie_tunnel_cio_prepare() (18) refuses the next docked sleep while it's set, and the field is "cleared only by teardown and reprobe" (pcie-apple.c:623). So the port stays retired until the dock comes back.
  • The panic is gone, and nothing else changes when the undo succeeds.
  • No new runtime switches, constants or board gates.

Board gate on this path: it is behind of_machine_is_compatible("apple,j713") in pcie-apple.c:4508-4509, which binds the CIO DART sleep path. There's a matching apple,j714s/apple,j716c gate at 4514-4516, commented "TEST" at 4519. More of these are in pcie-apple-cio.c: in apple_pcie_cio_suspend() (391-392) and at 203, 234 and 246. There's also a cio_s2r module parameter (pcie-apple.c:76-78). Those are board gates and a runtime switch, which the merged-code rules don't allow. But they're already on main; this PR doesn't add or touch them, and the fix is right either way, so they don't block it. A follow-up could select the path from the device tree instead: apple_dart_cio_bind() already returns -EOPNOTSUPP when the DART has no sleep path, so the pcie->hw match plus that binding would do the job. It needs a J773g row, because J773g shares T8132 with J713 and would start taking this path.

Evidence
  • make W=1 drivers/pci/controller/pcie-apple.o (asahi profile, 16K pages, LLVM=1, arm64; pcie-apple-cio.c is included there) at cb4b537baacf: builds, no warnings.
  • checkpatch.pl --strict: clean.
  • git grep resume_failed: set only at the two retire points (375, 454) and in pcie-apple.c (7584, 7708), and read by prepare and finish as above.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 26, 2026
@RyanTheTide
RyanTheTide disabled auto-merge November 27, 2026 07:00

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at cb4b537baacfc179af09877d1533fb3f50e5df53 once hardware evidence is complete.

Blockers: No code blocker found. Keep this unarmed until the J713 stop/undo double-failure and dock reattach are demonstrated, with docked peer smoke or the documented stand-in. The current J773g row had no dock.

Checked: Read the full diff and traced the noirq unwind, DART finish, disconnected child walk, and later quiesce. Successful recovery and the original suspend return value are preserved. On a failed recovery, config remains closed, the existing resume_failed finish path still ends the DART transaction, and needs_stop is left for teardown. Reviewed the green head CI. The patch adds no board gating, bindings, private material, or attribution.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge-train approval (last-push review of the merge-up delta, under the merge bar). 4050251b merges current main on top of the reviewed code. Rows: App-approved, J773g-2nd-gen(cb4b537)+J713-target. Merging once hosted CI is green.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 4050251be5f6 (B2 merge train, 12-01 merge bar). Approval at this head: RyanTheTide,aurora-silicon-review[bot]. Row: J713 target row + J773g at the head comment. CI: linux train L1 = main 595e754 + #3503 #3499 #3240 #3208 #3696 #731 #2634 #2110 #3325 #3441 #3650 (candidate ef98b31c): Apple driver compile (defconfig + asahi.config, LLVM=1, Rust) pass, Apple DTBs W=1 pass, planned KUnit clpc/dcp-fabric/dcp-topology/dcp-display/pmgr-pwrstate/mt7932/asahi all pass; host-tests green (or path-skipped) at this head. The rest of the hosted run is queued behind the ~19 h backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 412f848 into main Dec 1, 2026
19 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:m4 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants