Skip to content

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

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

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

Conversation

@DjDeveloperr

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.

Assisted-by: LLM (Gemini:4 Neon)

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 <hey@djdev.me>
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 <hey@djdev.me>
…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 <hey@djdev.me>
@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)

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