Skip to content

kboot: publish the APCIe tables into a reopened tree off T8140 - #145

Closed
niteria wants to merge 2 commits into
aurora-silicon:feat/t8140-apcie-tables-fdtfrom
niteria:fix/apcie-tables-packed-tree
Closed

niteria wants to merge 2 commits into
aurora-silicon:feat/t8140-apcie-tables-fdtfrom
niteria:fix/apcie-tables-packed-tree

Conversation

@niteria

@niteria niteria commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Stacked on #112: this PR's base is that PR's branch.

On every chip but T8140, prepare_dt() packs the device tree, so when kboot_boot() later calls pcie_apcie_tables_fdt() there is no room left and the tables aren't published. A J713 boots with kboot: APCIe tables not published; deep sleep stays refused. This reopens the tree's spare capacity around the publisher, as dt_disable_j713_pcie() already does, and packs it again.

T8140 is unchanged: its tree is still unpacked at that point and is packed afterwards. On a chip whose ANS isn't behind APCIe the publisher returns at once, so there this only reopens and repacks the tree.

Tested on a J713 (MacBook Air M4), Linux at EL2, with this commit on 1.0.0b9 + #117 + #112, and a kernel device tree that no longer carries its own copy of the tables (aurora-silicon/linux#1314):

  • All ten tables were published, byte-identical to the copy converted from the ADT that the kernel carried before.
  • Linux made deep sleep the default, and 8 of 8 sleeps came back on these tables, each woken by its RTC alarm, with ANS, Wi-Fi, Bluetooth and the GPU back after each.

Not tested on any other chip. On this branch the J713 Stage 2 builds, and test_smp_handoff_gate.py and test_m4_pcie_power_fdt.py pass.

🤖 Generated with Claude Code

DjDeveloperr and others added 2 commits November 8, 2026 05:15
…k back

On every post-M4 Mac ANS runs on an APCIe block whose power an OS cycles
in a deep sleep. Linux's deep sleep brings that block back by itself,
and the ten tables it needs are only in the ADT. Copy them from the APCIe
controller ANS is on (/arm-io/apcie, else /arm-io/apcie0) and its
pci-bridge0 to the DT, each as <offset mask value> records relative to
its window:

- apcie-axi2af-tunables to apple,tunable-axi2af (reg[4], "axi2af")
- apcie-phy-tunables to apple,tunable-phy (reg[2], "phy-block")
- apcie-phy-ip-pll-tunables and apcie-phy-ip-auspma-tunables to
  apple,tunable-phy-ip-pll and -phy-ip-auspma (reg[3], "phy-ip")
- apcie-cio3pllcore-tunables to apple,tunable-cio3pll (reg[5], "cio3pll")
- apcie-pcieclkgen-tunables to apple,tunable-clkgen (reg[6], "clkgen")
- the bridge's apcie-config-tunables to apple,tunable-port (reg[7],
  "port0")
- the bridge's pcie-rc-tunables, pcie-rc-gen3-shadow-tunables and
  pcie-rc-gen4-shadow-tunables to apple,tunable-rc, -rc-gen3 and -rc-gen4
  (reg[0], "config")

The host's go on the DT PCIe host whose "rc" window is the controller's
reg[1], and the bridge's on its pci@0,0. These are the names Linux's
T8140 deep sleep reads. The J700, J713, J773g, J773s and J616c ADTs all
carry the ten under these names. The J604 dump on macOS 27.0 has none, and
gets none published.

Every record must be 32 bits wide, aligned and inside its window, or no
table is published. Each table goes in with one fdt_setprop(), and if one
fails the ones already added are removed, so it is all ten or none.
Adding to the host moves its port, so the port is looked up again for each
table and for the rollback. A failure only logs. On a Mac whose ANS isn't
the post-M4 kind (no nvme-secure-bar) nothing is published.

On the Neo's live ADT (J700, September dumps) all ten pass: 274 records,
3.2 KiB of DT.

Two host-model tests compile pcie_fdt.c and kboot_boot() with their own
stubs, so they get stubs for the new code.

Signed-off-by: Diljit Singh <hey@djdev.me>
prepare_dt() packs the device tree on every chip but T8140, so by the
time kboot_boot() publishes the APCIe tables there is no room left and
the J713 boots without them ("APCIe tables not published; deep sleep
stays refused"). Reopen the tree's spare capacity around the
publisher, as dt_disable_j713_pcie() already does, and pack it again.

Assisted-by: LLM
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for tracking this down on the J713. #112 was merged in a later revision, and its last commit, 5e7406f ("pcie: publish APCIe tables as a DT transaction"), fixes the same problem in a different way. pcie_apcie_tables_fdt() now takes the caller's buffer capacity (kboot_boot() passes dt_bufsize). It opens the tree into a staged copy of that size, publishes there, packs, and copies the result back only once every property is in. A tree that prepare_dt() has already packed now gets the tables on every chip. That makes the reopen/repack here redundant, and the base branch is gone too, so I'm closing this one.

If a J713 on current main (v1.0.0b11 or later) still prints kboot: APCIe tables not published; deep sleep stays refused, please reopen with that boot's Stage 2 log.

@niteria

niteria commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Confirmed on the J713. With 1.0.0b11 as a one-boot aura-try trial, only the aura head changed in this Air's Stage 2 (Stage 1 is b9), Stage 2 logs FDT: /arm-io/apcie tables published, 261 records, the same as with this PR. The ten tables reach Linux byte-identical to the ADT-converted copy, and aurora-silicon/linux#1314's sleep test passed on that boot: 8 of 8 deep sleeps and 2 of 2 last-moment refusals. So nothing to reopen; closing is right.

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.

3 participants