Skip to content

arm64: dts & PCI: apple: enable J773g port 2 Ethernet and T8132 multi-port deep sleep - #2770

Open
DjDeveloperr wants to merge 4 commits into
djdev/t8132-apcie-port2-shared-regsfrom
djdev/j773g-apcie-port2-s2r
Open

DjDeveloperr wants to merge 4 commits into
djdev/t8132-apcie-port2-shared-regsfrom
djdev/j773g-apcie-port2-s2r

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enable Broadcom Gigabit Ethernet on J773g APCIe port 2 (port02 / dart_apcie2) alongside the port 0 radio, and add per-port suspend/resume link retraining for multi-port T8132 PCIe controllers across real deep sleep.

Commits

  1. b5b337568c161 — arm64: dts: apple: t8132-j773g: enable Broadcom Ethernet on APCIe port 2: drops port-0-only apple,managed-sids / apple,dma-range clamps on &dart_apcie0 and &pcie0, maps bus 0x200 to &dart_apcie2, and enables &dart_apcie2 and &port02.
  2. 3a049d07710e5 — arm64: dts: apple: t8132: wire apcie clkreq GPIOs and J773g link speeds: wires clkreq-gpios for port 2 (AP GPIO 162, active low) and J773g port 0 (AP GPIO 160, active low) plus ADT max-link-speed caps (Gen2 on port00, Gen1 on port02).
  3. edcee3b20673e — PCI: apple: suspend and retrain T8132 multi-port controllers across deep sleep: saves each port's interrupt mask, clock policy, MSI, and RID2SID mappings in suspend_noirq, and on real deep wake restores port defaults, DT tunables, PHY refclks, DBI link speed/width, RID2SID/MSI tables, host-resumed DART, and root port config space before deasserting PERST#, retraining each link, and calling apple_sleep_radio_port_up().

Dependencies

Live Verification — 3/3 Real Deep Sleep (dcp66-m4prod5-deepsleep)

Tested on live M4 Mac mini (J773g / T8132, macOS 27.2 26B123, 7.3.0-ARCH-m4prod5):

Cycle boot object resumes port 0 (Radio) port 2 (Ethernet) tg3 end0 Errors
1 0 -> 1 port 0: link restored after deep sleep (5GT/s x1) port 2: link restored after deep sleep (2.5GT/s x1) UP 1000Mb/s Full 0
2 1 -> 2 port 0: link restored after deep sleep (5GT/s x1) port 2: link restored after deep sleep (2.5GT/s x1) UP 1000Mb/s Full 0
3 2 -> 3 port 0: link restored after deep sleep (5GT/s x1) port 2: link restored after deep sleep (2.5GT/s x1) UP 1000Mb/s Full 0

scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks on all 3 commits. 0 oops/warnings/SErrors across all 3 wakes.

Enable the J773g Broadcom Gigabit Ethernet root port (port02) and its
DART (dart_apcie2) alongside the port00 radio:

- Drop the port-0-only apple,managed-sids / apple,dma-range clamps on
  &dart_apcie0 and &pcie0 and map bus 0x200 to &dart_apcie2 in iommu-map.
- Drop dart_apcie2's power-domains reference (matching dart_apcie0, since
  ps_apcie_sys_gp stays off under the T8132 PMGR policy) and mark
  &dart_apcie2 and &port02 status = "okay".

Signed-off-by: Diljit Singh <[email protected]>
Describe the AP CLKREQ# GPIO on T8132 PCIe port 2 (AP GPIO 162, active
low) in t8132-apcie-port2.dtsi and port 0's CLKREQ# GPIO (AP GPIO 160,
active low) plus both ports' ADT maximum-link-speed values (Gen2 on
port00, Gen1 on port02) in t8132-j773g.dts.

These properties let the PCIe host driver restore CLKREQ# input direction
and root-port link-speed caps when retraining T8132 multi-port links
after deep sleep.

Signed-off-by: Diljit Singh <[email protected]>
…eep sleep

Multi-port T8132 PCIe hosts (such as J773g with port0 radio and port2
Ethernet) do not use the J713 single-port managed-radio transaction.
During deep sleep, apple-sleep lowers the shared apcie_gp and
apcie_phy_sw domains, wiping every port's registers, RID2SID and MSI
tables, and PHY state while leaving endpoints powered under PERST#.

Register a per-port deep sleep recovery path for non-managed,
non-tunneled apple,t8132-pcie hosts. Save each port's interrupt mask,
clock policy, MSI configuration, and RID2SID mappings in suspend_noirq
and keep the host on the awake path so apple-sleep stops all ports
cleanly. On resume_noirq after a real deep wake, restore each port's
defaults, DT tunables (falling back to port 0's tables when a peer
port omits them), PHY refclks, DBI link speed and x1 width, RID2SID
and MSI mappings, host-resumed DART, and root port config space, then
deassert AP PERST# and retrain the link. Notify apple-sleep via
apple_sleep_radio_port_up() once a port comes back up.

Signed-off-by: Diljit Singh <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Review of the three commits on top of #2762 (b5b3375, 3a049d0, edcee3b) at edcee3b.

J713 looks unchanged. The managed-SID and dma-range clamps stay in t8132-jxxx.dtsi and are deleted only in t8132-j773g.dts. apple_pcie_t8132_sleep_probe() bails on managed_sids (pcie-apple.c:5048-5053), so the new suspend/resume branches (7252, 7786) can't be reached there.

Error paths in the retrain (edcee3b):

  • pcie-apple.c:5297-5302: a port that fails apple_pcie_t8132_port_restore() is skipped, but port->link_failed is never set. The endpoint driver then resumes onto a link that never trained, with its DART not resumed. The other recovery paths in this driver set link_failed to block config access (e.g. 7780-7781). Please do the same here and leave PERST# asserted.
  • pcie-apple.c:5121-5147: the next suspend re-reads RID2SID, the MSI map and the MSI base/address from every port, including one whose restore failed before 5239 and whose tables the sleep wiped. A later good wake then restores zeros, and that endpoint's SID and MSI routing is lost until reboot. Keep the last good snapshot, or skip ports marked failed.
  • pcie-apple.c:5307-5310: apple_sleep_radio_port_up() runs if any port came up. It clears the single apcie_port_down flag that gates sleep_apcie_port_stop_once() (sleep.c:3842-3850, "Only with the port set up ... or it aborts"). If port0 fails and port2 comes back, the next suspend stops an unprogrammed port0, and with soc: apple: admit M4 Mac mini (J773g) in T8132 SEP profile and desktop apple-sleep gates #2763 the same goes for a failed port2. Call it only when every port is back, or track ports separately.

Overlap with apple-sleep:

Values and constants:

  • pcie-apple.c:5151-5159: defaults[] is another variant of the port reset table. It differs from the Neo and T6050 tables at 0x104, 0x13c, 0x808 and 0x130, and writes the late group before the RID2SID/MSI restore rather than after it. Please say where the T8132 values and order come from. If they match an existing table, share it.
  • pcie-apple.c:5196-5197: BIT(9)/BIT(10) is PHY_LANE_CFG_REFCLKEN (line 123).
  • pcie-apple.c:5261, 5265, 5272 and 5268-5269: the three 100 ms sleeps and the 500 ms LTSSM timeout have no stated source. PCIE_T_PVPERL_MS and PCIE_RESET_CONFIG_WAIT_MS cover the first and last. What is the 100 ms between PERST# release and LTSSM start for? Ports retrain one after another, so this is at least 300 ms of wake time per port.
  • pcie-apple.c:5230-5235: link mode, width and LNKCAP MLW are forced to x1. Please take them from num-lanes, or keep the pre-sleep value.
  • pcie-apple.c:5110-5115: a port with no apple,tunable-* silently inherits port 0's tables. These are per-port ADT values (pci-bridge0 vs pci-bridge2). A port without its own tables should skip deep-sleep recovery, not borrow another port's.
  • pcie-apple.c:5048: the rest of this path is keyed off pcie->hw, so a flag in the T8132 hw_info would be cleaner than of_device_is_compatible() here.

DT:

  • t8132-j773g.dts:313-316: the commit message says ps_apcie_sys_gp stays off on T8132, but only t8132-j713-pmgr.dtsi disables it, and J773g leaves it enabled. If dart-apcie2 is really not in that domain, please fix t8132-apcie-port2.dtsi:25 (J604 uses it too). If it is in that domain, dropping the reference lets genpd power it off under a live DART.
  • t8132-j773g.dts:308-311: please say in the commit why the radio no longer needs the 0x100000-0x3fe00000 apple,dma-range window once it is off the managed path.
  • t8132-apcie-port2.dtsi:64: clkreq 162 is in the dtsi J604 shares. Please confirm the J604 ADT pci-bridge2 function-clkreq is also 162, or move it to j773g.dts as was done for port00.

Testing: the 3/3 J773g deep-sleep table covers the case where both ports come back. Missing are a row where one port fails to retrain (e.g. port 2 held down), followed by a second deep sleep, and a J713 deep-sleep row at edcee3b showing the managed radio path unchanged.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

@RyanTheTide All review items from your 05:27Z review are fixed locally (fac7f711d8bc2, checkpatch.pl --strict 0/0/0 across all 3 commits):

  • port->link_failed + PERST# re-asserted on restore failure; suspend_noirq skips overwriting saved RID2SID/MSI when a previous wake failed.
  • Per-port host ownership & restore tracking via apple_sleep_apcie_ports_owned() / apple_sleep_apcie_port_up() (paired with #2763 v2 2dfb6d6301ff2, eliminating the sleep.c REFCLK overlap).
  • Shared apple_pcie_t8132_port_reset_regs[] with pcie-apple-radio.c, PHY_LANE_CFG_REFCLKEN, PCIE_T_PVPERL_MS/PCIE_RESET_CONFIG_WAIT_MS, num-lanes / pre-sleep link width restore, per-port DT tunables only (no port-0 fallback), t8132_hw.t8132_sleep flag, and board-local port02 clkreq-gpios (162) in t8132-j773g.dts.
  • Live hardware verified (dcp72-m4prod11-wave5-v7tc-s2r, M4 Mac mini J773g / T8132, 7.3.0-ARCH-m4prod11): 2/2 consecutive real deep sleeps passed (boot object resumes 0 -> 1 -> 2), with tg3 0000:02:00.0 end0: Link is up at 1000 Mbps, full duplex restored cleanly on both wakes and zero SErrors/BUGs/WARNs.

Holding the force-push on #2770 until #2763 v2 (2dfb6d6301ff2) merges so CI compiles apple_sleep_apcie_ports_owned() / apple_sleep_apcie_port_up() cleanly — will rebase and force-push immediately once #2763 lands.

Assisted-by: LLM (Gemini:4 Neon)

@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: HOLD at edcee3b2

Blockers:

  1. Targets non-main base branch djdev/t8132-apcie-port2-shared-regs; full main CI has not run.

Checked:

  • Verified base ref is djdev/t8132-apcie-port2-shared-regs with no CI checks recorded at head edcee3b2.
  • Deferred final review until the base branch lands and this PR is retargeted/rebased onto main with green CI.
Evidence
  • Base ref: djdev/t8132-apcie-port2-shared-regs.
  • Checks at edcee3b2: none.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@DjDeveloperr: stale-PR closeout. The fixes for the 11-22 review are described at fac7f711, but that commit was never pushed: the head is still edcee3b2. Please push it. This PR also waits for #2762 and #2763. Once they land, retarget to main and merge main (dts + pcie-apple.c conflict), then run J773g x3 and one J713 cycle at that head. Nothing else is open.

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Merge readiness at 2995b2b3: not ready yet

Check Detail
CI at head ok no CI for this change (the hardware row is the gate)
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 2995b2b3, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:bringup

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

@RyanTheTide

Copy link
Copy Markdown
Contributor

@DjDeveloperr last call on this one. The review fixes you described at fac7f711 (link_failed + PERST# on restore failure, no RID2SID/MSI overwrite after a failed wake) were never pushed, and the head is still edcee3b2 from 11-22. If they're not pushed by 12-01 12:00 AEDT, I'll close this as stale. The J773g port-2 Ethernet mapping would then land through #1898, and the T8132 multi-port deep-sleep part can come back as its own PR from main.

Ryan's review of this series (11-22) asked for the following changes. They
were done on a rewritten copy of the three commits; this commit applies
the same final tree on top of the pushed branch instead of replacing it.

- dts: move port02's clkreq-gpios from the shared t8132-apcie-port2.dtsi
  to the J773g board file, next to its max-link-speed, since the ADT
  function-clkreq line is board wiring.
- dts: drop the bootloader managed-radio apple,dma-range window on
  dart_apcie0 along with the managed-SID clamp, so Linux owns the DART's
  full IOVA range, and explain why dart_apcie2 drops its power-domains
  reference.
- pcie-apple: gate multi-port deep sleep on a t8132_sleep flag in the
  T8132 hw_info, not on the compatible string.
- pcie-apple: apply each port's own sleep tunables; no fallback to
  port0's tables.
- pcie-apple: register APCIe port ownership with apple-sleep for the
  lifetime of the host (devm action), so apple-sleep skips its unowned
  port fallback on wake.
- pcie-apple: snapshot and restore the DBI link mode and width, and keep
  the last good snapshot when a previous wake failed to restore a port.
- pcie-apple-radio: share the T8132 port reset register table with
  pcie-apple.c instead of keeping a second copy.

Signed-off-by: DjDeveloperr <[email protected]>
@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Nov 30, 2026

@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: FIX, then merge at 2995b2b3

Blockers:

  1. Unresolved symbols against base branch: drivers/pci/controller/pcie-apple.c calls apple_sleep_apcie_ports_owned() (lines 187 and 261 of the diff) and apple_sleep_apcie_port_up() (line 476 of the diff), neither of which is declared in include/linux/soc/apple/sleep.h at 2995b2b3 (they live in open PR #2763, which is not in #2762 / djdev/t8132-apcie-port2-shared-regs). Wait for #2762 and #2763 to land and rebase/retarget this PR onto main so full CI builds and runs.
  2. Partial probe failure leaves earlier port DART permanently unresumed across deep sleep (drivers/pci/controller/pcie-apple.c, apple_pcie_t8132_sleep_probe()): inside the list_for_each_entry(port, &pcie->ports, entry) loop, apple_pcie_t8132_port_dart(port) calls apple_dart_set_host_resumes(&pdev->dev) (setting dart->host_resumes = true in drivers/iommu/apple-dart.c:7113). If a later port fails validation (!port->phy, missing/sleeping PERST#, or devm_kcalloc failure) or devm_add_action_or_reset() fails, apple_pcie_t8132_sleep_probe() returns early with pcie->t8132_sleep = false, so apple_pcie_t8132_resume_noirq() never runs while apple-dart.c:7051 skips resuming any DART with host_resumes == true on firmware wake. Defer apple_pcie_t8132_port_dart() / apple_dart_set_host_resumes() to a second pass only after every port passes validation and devm_add_action_or_reset() succeeds.
  3. Missing main CI and exact-head hardware row: full main CI has not run on 2995b2b3, and the 3/3 J773g deep-sleep verification row predates 2995b2b3.

Checked:

  • arch/arm64/boot/dts/apple/t8132-j773g.dts: board-scoped clkreq-gpios and max-link-speed on port00/port02, removal of apple,managed-sids and apple,dma-range on dart_apcie0/pcie0, and documented removal of power-domains on dart_apcie2.
  • drivers/pci/controller/pcie-apple.c and pcie-apple-radio.c: shared apple_pcie_t8132_port_reset_regs[] table (defined before #include "pcie-apple-radio.c"), .t8132_sleep hw_info flag gating, per-port sleep_tables[4] parsing with no cross-port fallback, saved_msimap/saved_rid2sid/saved_link_* save/restore, and t8132_sleep_down handling across non-firmware and firmware resume.
  • Checked include/linux/soc/apple/sleep.h and drivers/iommu/apple-dart.c at 2995b2b3.
Evidence
  • include/linux/soc/apple/sleep.h at 2995b2b3 declares apple_sleep_radio_port_{up,down,wake} only; apple_sleep_apcie_ports_owned and apple_sleep_apcie_port_up are absent.
  • drivers/iommu/apple-dart.c:7051 (if (dart->host_resumes && pm_resume_via_firmware())) relies on the host driver calling apple_dart_host_resume() when host_resumes is set.
  • Non-blocking nit: apple_pcie_t8132_port_dart() holds a device ref from of_find_device_by_node() without a matching devm put_device(), and calling it lazily from apple_pcie_t8132_suspend_noirq() invokes device_link_add() during suspend_noirq — worth binding strictly during probe with devm cleanup when fixing blocker 2.

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

area:bringup Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants