Skip to content

storage: Read NVMe on the T8011 (A10X) - #24

Merged
henrikklee merged 2 commits into
OrchardLinux:mainfrom
grierj:t8011-apcie-nvme
Dec 4, 2026
Merged

henrikklee merged 2 commits into
OrchardLinux:mainfrom
grierj:t8011-apcie-nvme

Conversation

@grierj

@grierj grierj commented Dec 4, 2026

Copy link
Copy Markdown

Summary

Adds apcie,t8011 NVMe storage support to apcie_nvme and main_storage_start() so m1n1's boot manager (orchard launch) can boot installed systems from internal storage on A10X (T8011) boards (J120, J121, J207, J208).

Refs OrchardLinux/orchard#553.

Details

  • Parameterizes apcie_soc with reg_rc, reg_phy, and has_nand_sysclk (T8011 has 6 PCIe ports so RC and PHY sit at /arm-io/apcie reg[13] and reg[14] rather than reg[9]/reg[10]).
  • Implements t8011_setup_common() and t8011_setup_link() following Linux's pcie-apple-h9p.c and iPadOS's AppleT8011PCIe (PHY tunables, RC common + port 0 tunables, NAND sysclk enable, pipe reset release, pipe-clock ungated poll, config + storage port tunables).
  • Tears down NAND sysclk and port 0 clocks cleanly in port_down().
  • Adds apcie,t8011 to main_storage_start() in src/utils.c.

Testing

Tested on iPad Pro (10.5-inch, Wi-Fi) (J207 / iPad7,3):

  • Built inside Orchard's m1n1 builder image (boot/m1n1/Containerfile).
  • Ran orchard launch --m1n1 build/m1n1.bin --busy-cpu: m1n1 initialized internal NVMe, loaded omarchy-a-7cbbc672-7.3.0-rc1-orchard-apple-16k from the BOOT partition, and booted installed Omarchy A directly into Linux in 16 s.
  • Verified via SSH (tablet@172.16.42.1) that Linux pcie-apple-h9p cleanly brings up both root ports after apcie_nvme_shutdown() with zero PCIe/NVMe/DART errors:
    • 0000:01:00.0 [106b:2002] NVMe S3E (nvme0n1: p1 p2 p3, / mounted r/w)
    • 0000:02:00.0 [14e4:43dc] BCM4355 Wi-Fi (wld0 UP)

adt_getprop_copy() copied the full ADT property value into the caller
buffer via p.copy_raw() before checking whether the property size matched
len, overflowing smaller destination buffers when an ADT property was
larger than expected.

Check p.size as usize != len before copying so mismatched properties
return AdtError::BadLength without touching the output buffer.

Assisted-by: LLM
Signed-off-by: Grier Johnson <grier@scooterfarm.com>
Add an apcie,t8011 entry to apcie_nvme so m1n1's boot manager can read
internal storage on A10X boards (iPad Pro 2: J120, J121, J207, J208).

T8011 has six PCIe ports instead of four, shifting the RC and PHY
register windows in /arm-io/apcie from reg[9]/reg[10] to reg[13]/reg[14],
and brings up port 0 via the NAND sysclk enable, pipe reset release, and
pipe-clock ungated poll (matching Linux's pcie-apple-h9p.c and iPadOS's
AppleT8011PCIe). DART, NVMMU, BAR mapping, L1SS, and GPIO setup match
T8010.

Additional hardening:
- Validate T8011 lane-cfg (length and value) in read_adt() before
  powering hardware.
- If port 0 link is already up at entry, assert PERST# and reset the
  port cleanly before reprogramming NVMMU/DART mappings, and read LTSSM
  once per decision.
- Require the PCIe capability on the root port and update Link Control 2
  with mask16() instead of a 32-bit RMW.
- Track init stages (port_started, link_up after endpoint ID,
  nvmmu_started, dart_started) so early failure only unwinds initialized
  hardware.
- Validate completion sq_id and cid in submit(), and disable/shut down
  the controller before retiring a timed-out DMA tag so a late transfer
  cannot contaminate a subsequent boot attempt.

On shutdown, gate NAND sysclk and clear port 0 clocks cleanly so Linux's
pcie-apple-h9p brings up both NVMe (port 0) and Wi-Fi (port 2) without
errors.

Tested on J207 (iPad Pro 10.5-inch, Wi-Fi): orchard launch --m1n1
boots installed Omarchy A directly from internal NVMe, and Linux brings
up NVMe and BCM4355 Wi-Fi cleanly.

Ref: OrchardLinux/orchard#553
Assisted-by: LLM
Signed-off-by: Grier Johnson <grier@scooterfarm.com>
@henrikklee
henrikklee merged commit 6dde868 into OrchardLinux:main Dec 4, 2026
7 checks passed
@henrikklee

Copy link
Copy Markdown

Merged, thank you @grierj, and welcome! A great first contribution here: the T8011 bring-up follows the iPadOS driver and the Linux one closely, and your test on the 10.5-inch iPad Pro (installed Omarchy A up in 16 s, both PCIe ports clean in Linux afterwards) was exactly the evidence we needed.

What this brings: m1n1 can now read the internal storage of the A10X iPad Pros (12.9-inch and 10.5-inch, Wi-Fi and Cellular), so orchard launch starts an installed system on them instead of failing with "this loader has no storage support for the device".

Nothing was changed on your branch and nothing was left out.

Follow-up on our side: orchard moves its m1n1 lock to this merge, records launch from storage in the four boards' device data and closes OrchardLinux/orchard#553. The 12.9-inch models and the 10.5-inch Cellular use the same code and should just work; reports from owners are welcome.

@grierj

grierj commented Dec 5, 2026

Copy link
Copy Markdown
Author

Updated (97141f2, c69ecbd) to address review findings and re-verified live on J207 (iPad Pro 10.5-inch, Wi-Fi):

  • Hardening added:
    • rust/src/adt.rs: check p.size as usize != len before calling p.copy_raw() in adt_getprop_copy().
    • Validate T8011 lane-cfg (length and value) in read_adt() before powering hardware.
    • Reset warm links via PERST# before reprogramming NVMMU/DART, and read LTSSM once per check.
    • Require the root port's PCIe capability and update Link Control 2 with mask16().
    • Track init stages (port_started, link_up after endpoint ID, nvmmu_started, dart_started) so early failures only unwind initialized hardware.
    • Validate CQE sq_id and cid in submit() (polling status phase first and re-invalidating/settling to avoid torn DMA reads), and abort/shut down the controller before retiring a timed-out DMA tag.
  • Live J207 verification (c69ecbd):
    • orchard launch --m1n1 booted installed Omarchy A cleanly from internal NVMe in 23 s; Linux enumerated NVMe (nvme0n1: p1 p2 p3), mounted rootfs, and brought up BCM4355 Wi-Fi (wld0 UP) with zero pcie-apple-h9p/nvme/brcmfmac errors.

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