Skip to content

M3 Air 15 (J615): read NVRAM from the QSPIMC NOR - #2593

Open
RyanTheTide wants to merge 4 commits into
integration/aurorafrom
j615io/t8122-j615-qspi-nvram
Open

RyanTheTide wants to merge 4 commits into
integration/aurorafrom
j615io/t8122-j615-qspi-nvram

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On the M3 MacBook Air 15" (J615) there is no nvram device: the J615 tree describes the NVRAM NOR on SPI1 (the M1/M2 layout), which finds nothing ("spi-nor spi0.0: unrecognized JEDEC id bytes: 00"), so asahi-bless / aurora-bless cannot even read the boot volume. The J615's ADT puts the NOR on QSPIMC (nvram at 0x700000, 1 MiB), as t8122-j613-qspi.dtsi already describes, but only the 25G83 variants include it, and spi-apple-qspi additionally refuses any T8122 QSPIMC that is not on a J613.

Change

  • spi: apple-qspi: drop the J613-only probe check for apple,t8122-qspi. The device tree decides whether the controller exists; writes are unchanged and still need a qualified board entry, so a board without one only reads.
  • t8122-j615.dts: include t8122-j613-qspi.dtsi with the nvram partition read-only (no J615 write entry exists). t8122-j615-25g83.dts drops its now-inherited copy; its DTB is byte-identical, as is the J613's.
  • The runtime-suspend change (7127d73) is reverted here (1a6e3db) and moved to spi: apple-qspi: runtime suspend QSPIMC controllers in a power domain, powered while NVRAM writes are armed #2824, together with a fix that keeps the controller powered while NVRAM writes are armed. This PR is the J615 read-only fix only; its tree is identical to d7e3179.

Testing

J615, macOS 27.2 stub, one-shot lab boot with this device tree layout and the probe check removed:

  • NOR probes on QSPIMC, JEDEC ef6517 (W25Q64, the J613's part); /proc/mtd lists nvram 1 MiB, not writeable;
  • the whole partition reads back (NVRAM v3 store header);
  • asahi-bless --get-boot and --list-volumes work (Macintosh HD, Aurora Fedora Remix);
  • no write attempted.
  • tools/asahi/qspi-nvram-tests.py: 27/27 pass; DTBs: J615 changes only (QSPIMC on, SPI1 off, nvram alias moved), J613 and J615-25G83 identical; driver builds; checkpatch --strict clean.

Still to run

  • J613 boot (unchanged NVRAM path, same JEDEC, writeable as before) and a J615-25G83 boot.
  • J615 writes are a separate change. They should be qualified from DT properties, not a new apple_qspi_boards[] entry. Until then a macOS next-boot can't be selected from Linux.
  • The 13" J613 non-25G83 tree still describes SPI1 too; not changed here (no J613 on hand to test).
Lab boot details

Kernel: J615 lab kernel (bring-up tree) with the same probe-check removal; Stage 2 DTB = the J615 tree with the same QSPIMC + read-only nvram nodes applied by fdtput. Evidence kept in the lab store (traces/kernel/20261121-j615-io-nvram); no NVRAM contents were stored.

Assisted-by: LLM (Claude:Opus 5.5)

…s it

The probe refuses an apple,t8122-qspi controller unless the machine is
the J613, so on another M3 Mac whose device tree describes the boot
NOR on QSPIMC (the 15-inch Air, J615) the NOR never probes and there
is no nvram device.

Drop the board check. The device tree decides whether the controller
exists; writes are unchanged: they still need a qualified board entry
(apple_qspi_boards[]: machine, aperture, nvram window, JEDEC), so a
board without one only reads, whatever its partition says.

Tested on the J615 with its NOR described on QSPIMC: JEDEC ef6517
(the J613's W25Q64), the 1 MiB nvram partition reads back with an
NVRAM v3 store header, asahi-bless lists the boot volumes; writes are
refused. tools/asahi/qspi-nvram-tests.py passes.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The J615 includes the J613/J615 common tree, which places the NVRAM on
SPI1 as on the M1 and M2 Macs. The J615's ADT has its boot NOR on
QSPIMC instead, with nvram at 0x700000 (1 MiB), the layout
t8122-j613-qspi.dtsi describes. Probing SPI1 finds nothing
("unrecognized JEDEC id bytes: 00"), so the J615 has no nvram device
and cannot read or select its boot volume.

Include t8122-j613-qspi.dtsi in the J615 tree and keep the partition
read-only: there is no NVRAM write entry for this board. The 25G83
variant got both from its own lines, which go now that it inherits
them; its DTB is unchanged, as is the J613's.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Looks good; approve once the row below is run on this exact tree.

The change is sound. With the probe check gone (drivers/spi/spi-apple-qspi.c:1017-1020), whether the controller probes comes from the DT alone. On the J615 a write is still blocked twice: the nvram_qspi partition is read-only (arch/arm64/boot/dts/apple/t8122-j615.dts:166-172), and apple_qspi_nvram_write_board() (:927-940) finds no J615 entry, so nvram_write_candidate stays false. The J615-25G83 tree now gets the include and the read-only override from its parent, which leaves the same nodes as before. Commits have a human Signed-off-by and no agent trailers.

  1. Follow-up, not a blocker here: "Still to run" says a J615 write needs another apple_qspi_boards[] entry (spi-apple-qspi.c:122-153). Please don't add one. Each field the table matches on is already available from the machine. The controller aperture is the node's reg. The nvram window is the partition that apple_qspi_nvram_window() already parses. The JEDEC ID is what the part answers at probe. The block-protect bits left set at boot could be a property on the flash node. Writes could then be qualified from those plus a DT property that opts the partition in, instead of a list of machines. The J613/J713/J616s/J700 entries would collapse into it the same way.

HW row: J615, 27.2 stub, this PR on the fleet kernel with the DTB built from this tree (not fdtput), default command line. Pass: nvram in /proc/mtd non-writeable, a full partition read, --get-boot/--list-volumes correct, 0 AVC, 0 failed units, 0 new kernel errors. Also a J613 boot showing that its nvram path is unchanged (same JEDEC, writeable as before).

Assisted-by: LLM (Claude:Opus 5.5)

Runtime PM was enabled only for the T8140 controller. Every other one
holds its power domain on for as long as the driver is bound. On the
J615, whose tree now describes the NVRAM NOR on the QSPIMC, that keeps
the qspi and spi_p domains on: blank idle went from 2.8 W to 3.45 W.

The runtime suspend and resume paths already restore what a gated block
loses (the reset helper re-applies timing, FIFO thresholds and
interrupt state; mode, divider and descriptors are set per operation).
Use them for every controller whose node puts it in a power domain,
instead of a per-SoC flag.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J615 row, and a fix pushed (d7e3179..7127d73, fast-forward).

Row at d7e3179. J615 production default, 7.3.0-aurora-fleet79 (integration 92fd860 plus 25 PR heads including this one; the DTB is built from the tree), Stage 2 aura main 7d8e91f8, default command line:

  • /proc/mtd: mtd3 "nvram", 1 MiB NOR, flags 0x800 (MTD_WRITEABLE not set).
  • A full partition read returns 1048576 bytes in 0.85 s.
  • asahi-bless --get-boot returns "Aurora Fedora Remix"; --list-volumes lists Macintosh HD and *Aurora Fedora Remix.
  • Enforcing, 0 failed units, 0 AVC, 0 new kernel errors.

Regression found on the same default, fixed in 7127d73. With this tree the J615's blank idle went from 2.8 W to 3.45 W (measured by the J615 integrator). apple-qspi enabled runtime PM only for T8140, so a bound controller held the qspi and spi_p power domains on. 7127d73 enables it for any controller whose node puts it in a power domain, instead of using a per-SoC flag. The runtime suspend/resume paths already restore what a gated block loses.

Module A/B on the same boot, no reboot (stock fleet79 module, then the fleet79 source plus 7127d73, then stock again):

module qspi / spi_p runtime status
stock on / on unsupported
fixed, 3 s after probe off / off suspended
fixed, during a read on / on active
fixed, 2 s after each access off / off suspended

NVRAM content was identical across the A/B, and asahi-bless --list-volumes worked with the domains gated. The qspi host test passes; the driver builds W=1 clean.

Still to run.

  • A blank-idle power row on a kernel with 7127d73.
  • Rows on the other controllers that now runtime suspend: T6041 (J616s, NVRAM enabled), T8132 and T6050 where their NOR is enabled. T8140 is unchanged.
  • J613 (unchanged path).

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train adversarial review (MERGETRAIN-LINUX2) at 7127d73: BLOCKERS.

Not merging until the blockers below are fixed or answered; the details have file:line and a failure case.

Full review

#2593 M3 Air 15 (J615): read NVRAM from the QSPIMC NOR @7127d731

VERDICT: BLOCKERS

Blockers:

  1. Commit 7127d731 ("runtime suspend any controller in a power domain") changes behaviour on every M4-family Mac, NVRAM-write boards included, and none of them has a row.
    • drivers/spi/spi-apple-qspi.c:1084 now enables runtime PM and autosuspend at 100 ms (:92) for every controller with dev->pm_domain. Before, that was T8140 only.
    • That means T8132 (t8132-jxxx.dtsi:131: J713/J715 Airs, J604, J623, J624, J773g) and T6041/T6040 (t604x-j614-j616.dtsi:310, t6041-j614c-j616c.dtsi:2706, t6040-j773s.dts:217). Their ps_qspi domains are not always-on (t8132-pmgr.dtsi:473, t604x-pmgr.dtsi:626), so they will really gate.
    • J713, J715, J604, J623, J624, J773g and J616s are qualified NVRAM-write boards (spi-apple-qspi.c:121-150).
    • After a gate, apple_qspi_runtime_resume (:1208-1219) restores only what apple_qspi_hw_reset/apple_qspi_init_config write (:443-481). CONFIG_48 is read-modify-written from its reset value, not the iBoot value (:458-459). Any iBoot-programmed register that init_config does not touch is lost.
    • Concrete failure: spi-nor issues a sector erase (0x20) and the following page programs (0x02) as separate spi-mem ops, each with its own runtime-PM window (:912-914). A userspace bless (MEMERASE, then write) easily leaves more than 100 ms between them. If the restored controller state is not enough on T8132 or T6041, the erase succeeds and the program then fails verify (:806-812). The sector is left erased, and write_fault and read_only are latched until reboot (:824-830). The result is a damaged NVRAM bank on an M4 Air, and the user cannot re-bless without a reboot.
    • The only evidence that hw_reset is enough after a gate on a non-T8140 controller is a J615 read-only module A/B. The PR's own "Still to run" lists J616s and T8132 and says the head kernel was never booted.
    • Fix: split 7127d731 out of this PR, or land it only with rows on J713 and J616s. Each should do an aurora-bless --set-boot round trip with idle gaps longer than 100 ms between erase and program, one s2idle round, and the power numbers. Plus J615 on the head kernel.

Nits:

  1. Commit 1 (86809d34, removing spi-apple-qspi.c:1020-1022 in the old file) is the right direction: it removes a board gate. But the write path is still a per-board table (apple_qspi_boards[], :121-150: machine + aperture + window + JEDEC). The PR body proposes a J615 "twin" entry as the next step. Under the no-board-gates rule, that next step should be a DT capability, not another { "apple,t8122-qspi", "apple,j615", ... } row. Examples: a write-allowed nvram partition plus a JEDEC/bp_ok property on the flash node.
  2. The PR body says "T8132/T6050 where their NOR is enabled". T6050 (apple,t6050-qspi, apple,t8140-qspi fallback, t6050-die0.dtsi:749) already had runtime PM through the T8140 match data, so it is unchanged. The real new set is T8122, T8132 and T6041/T6040.
  3. t8122-j613-qspi.dtsi:16 drives QSPIMC from clk_200m. arm64: dts: apple: t8122: SPI2 and SPI4 run from the 24 MHz reference, not 200 MHz #1598 (3f09f2d2) just found that T8122 SPI2's real input is 24 MHz clkref, not 200 MHz. If QSPIMC shares that input, apple_qspi_set_frequency (:484-503) computes div = 20 for 10 MHz and the bus really runs at about 1.2 MHz. Reads would still work but be slow. Worth checking the J615/J613 ADT clock for QSPIMC.
  4. t8122-j613.dts (J613 non-25G83) still has NVRAM on SPI1, the same bug as the J615 had. The driver gate is gone now, so the fix there is DT-only.
  5. Removing the gate also makes QSPIMC probe on t8122-j615-25g83. It already had QSPIMC on and SPI1 off, so before this PR that variant had no NVRAM at all. That is a behaviour change, untested (see rows).

Missing rows:

  • J615 on the head kernel (with 7127d731): blank-idle power, NVRAM reads after an autosuspend, and one s2idle with a read after resume.
  • J713 and J616s (and ideally one M4 Air J715): NVRAM read and write round trip under autosuspend gaps, s2idle, and the qspi/spi_p genpd states.
  • J615-25G83 boot.
  • J613-25G83 (the only J613 write board): unchanged in DTB, but its controller now runtime-suspends. No row.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J615 row at head 7127d73 (runtime suspend for any controller in a power domain): PASS.

Kernel: the fleet79 test set with this head merged in, default command line, default boot chain (tree DTB with the QSPIMC NOR), kernel-only one-shot.

  • Idle: runtime_status suspended, genpd qspi and spi_p off.
  • Each full NVRAM read (/dev/mtdXro) powers both on; 3 s later both are off again (3/3). NVRAM sha256 is identical across all reads.
  • asahi-bless --list-volumes works; the domains are off again afterwards.
  • s2idle 2/2 in the same boot, 0 QSPI/SPI-NOR errors, 0 oops.

Review of 7127d73: no blockers. Runtime PM is chosen by whether the node sits in a power domain (dev->pm_domain), not by SoC. Every MMIO path outside probe goes through spi-mem (which takes the runtime reference), including the flash_status attribute. The IRQ is disabled while the block is gated, and system sleep uses pm_runtime_force_suspend()/force_resume(). Note: this turns runtime PM on for the T8132 and T6041 controllers too, so those two need an NVRAM read + bless row on this head before merge.

Power: blank idle on this boot is 3.46 W, about the same as without the change. The powered-domain set now matches an earlier boot that had no QSPI node at all, so the remaining difference from older 2.8 W numbers is not QSPI. That boot also had a live USB4 link and a second sink port that the older one didn't.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J713 (M4 Air, T8132) row for 7127d73. The runtime-PM change now turns on there because the QSPI controller sits in the qspi domain. PASS, no regression.

I tested with a live module A/B/A of spi-apple-qspi on the J713 default kernel (7.3.0-bj713t6+, default cmdline, macOS 27.2): A and C are the stock module, B is this PR's driver diff. The NOR stayed read-only throughout; nothing was written.

  • With this PR, the controller runtime-suspends between accesses (qspi reads off-0) and resumes for every read. The nvram, adt and aura log partitions read back identically in all three arms, also after 5 s idle, and aurora-bless --get-boot works in all three.
  • Without it, runtime PM shows unsupported and qspi stays on, as before.
  • No measurable power change on the J713: the 3.8 V rail read 3579 / 3407 / 3421 mW (A/B/C), which is within the drift between arms. The T8132 DT marks the parent spi_p apple,always-on, so only the qspi leaf gates here, unlike the J615 where both went off.
  • spi-nor spi0.0: Software reset failed: -13 (the NVRAM read-only policy denying opcode 0x66) appears on every module unbind, with the stock module too. It is not from this PR.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr 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.

Pre-PR checklist review at live head 7127d7310c1b1c4b2e61d9885400b0ca423233f3 (CI: 2/2 green; §2 default cmdline, §4 human commit attribution/SoB, §6 naming clean).

Commits 86809d34 (dropping the J613-only probe gate) and d7e3179f (describing J615's read-only QSPIMC NVRAM) are clean, remove a §1 board gate, keep J615 writes double-blocked (read-only in DT and absent from apple_qspi_boards[]), and have a clean J615 boot + regression row.

Blockers (commit 7127d731)

  1. §1 multi-Mac proof & §3 boot-NOR write safety gap (drivers/spi/spi-apple-qspi.c:1084-1095)

    • Commit 7127d731 turns on runtime-PM autosuspend (100 ms, :91) and ps_qspi power-domain gating for every QSPIMC controller with dev->pm_domain, which now includes all M3/M4 qualified NVRAM-write boards (T8132: J713/J715/J604/J623/J624/J773g; T6041: J616s; T8122: J613-25G83).
    • In apple_qspi_nvram_modify() (:720-836), sector erase (0x20) and subsequent page programs (0x02) run as separate spi_mem_exec_op() calls, each dropping its runtime PM ref (:913-914). A >100 ms gap between MEMERASE and program will gate ps_qspi off mid-bless; on resume apple_qspi_hw_reset() -> apple_qspi_init_config() (:457-458) RMWs CONFIG_48 from its post-gate reset state rather than iBoot's state. If any restored state differs on T8132 or T6041, erase succeeds and verify fails (:810-812), latching write_fault + read_only until reboot with an erased NVRAM sector.
    • Despite expanding gating to every M4 QSPIMC board, there is 0 NVRAM-write verification across >100 ms autosuspend gaps on any newly gated write board (the J713 row was read-only module A/B only) and 0 testing of any kind on T6041 (J616s, available in the lab) or J613-25G83.
  2. Disproven motivation in 7127d731 commit message

    • 7127d731's commit message claims disabling QSPI gating caused J615 blank idle to rise from 2.8 W to 3.45 W. Your own 11-22 J615 head test showed blank idle remained 3.46 W with 7127d731 applied (the delta came from the USB4 link / second sink, not QSPI).

Path forward

  • Fastest: Split 7127d731 out into its own PR. With 86809d34 + d7e3179f alone, the J615 read-only QSPIMC NVRAM fix is proven and ready once t8122-j615 (and ideally j615-25g83/J613) stay clean.
  • Or keep 7127d731: Correct its commit message to drop the disproven J615 power claim, and add §1/§3/§5 rows at the live head on T8132 (J713) and T6041 (J616s) covering an aurora-bless --set-boot round trip with >100 ms autosuspend gaps between erase and program, s2idle + post-resume read, genpd qspi state, and 0 SELinux AVC denials / 0 failed units / 0 new kernel errors.

Non-blocking note

  • As already noted in the thread, please avoid adding a J615 entry to apple_qspi_boards[] in the future write-enablement follow-up — qualify writes from DT properties instead of a per-machine table (§1).

Assisted-by: LLM (Gemini 4 Neon)

…main"

This reverts commit 7127d73.

That change turns on runtime suspend for every QSPIMC controller in a
power domain, including the T8132 and T6041 boards that write NVRAM,
and it has no NVRAM write row across an autosuspend gap on any of
them. Its stated motivation also did not hold: the J615 blank idle
stayed at 3.46 W with it applied.

It moves to its own pull request, together with holding the controller
powered across a whole NVRAM erase/program/verify sequence. This
series stays the J615 read-only NVRAM fix it was tested as.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Took the fastest path from Dj's 11-22 review: 7127d73 is reverted on this branch (1a6e3db, fast-forward, no force push). The tree is now identical to d7e3179, so this PR is the J615 read-only NVRAM fix that the J615 row at d7e3179 covered.

The runtime-suspend change has moved to its own draft, #2824:

  • the same code, with a corrected commit message. It no longer claims a J615 blank-idle saving: the J615 measured 3.46 W with it.
  • a fix that comes first, for the erase/program gap you described. While NVRAM writes are armed, each write-candidate controller holds a runtime-PM reference, so an erase and its programs run in one power session; disarming, a write fault or unbind release it. T8140 (J700) already runtime-suspends, so this applies there today. Host test 31/31, including a model of the gap and three changed-guard controls.
Rows #2824 needs before review
  • J713 (T8132) and J616s (T6041), spi: apple-qspi: runtime suspend QSPIMC controllers in a power domain, powered while NVRAM writes are armed #2824 head on the fleet kernel, default cmdline: arm writes, then do an aurora-bless --set-boot round trip with idle gaps longer than 100 ms between erase and program. Read back and verify; expect no "NVRAM write fault" and write_fault clear. Also check genpd qspi on while armed and gating after disarm, one s2idle followed by a read, and 0 AVC, 0 failed units, 0 new kernel errors.
  • J700: one bless round trip (write hold on an already-gating controller).

Still open here: the J613 and J615-25G83 boots from the earlier review.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 1a6e3db: no blockers.

Both blockers from the 2026-11-22 08:47 review were against 7127d73 (runtime-PM autosuspend on every QSPIMC controller, and its power claim). 1a6e3db reverts it, and the PR's tree at 1a6e3db is byte-identical to d7e3179 (git diff d7e3179f 1a6e3dbe is empty, both trees db2322ae), so the J615 row at d7e3179 covers this head. Nothing of 7127d73 survives: drivers/spi/spi-apple-qspi.c differs from integration/aurora only by the three removed lines of the board check (:1017-1019 at the base). A non-squash merge brings 7127d73 and its revert into history; the net change is zero.

Full review

Net change vs integration/aurora 8b360dc (3 files, +9/-9):

  • drivers/spi/spi-apple-qspi.c: drops the apple,t8122-qspi + !of_machine_is_compatible("apple,j613") probe refusal. Whether the controller exists is now down to the device tree. Writes are unchanged: apple_qspi_nvram_write_board() still needs an apple_qspi_boards[] entry (:926-940), and there is none for the J615. The read_only default (:156) and the write-fault latch (:830) are untouched.
  • arch/arm64/boot/dts/apple/t8122-j615.dts:14: includes t8122-j613-qspi.dtsi, which enables QSPIMC with the nvram partition at 0x700000 (1 MiB) and disables &spi1. That leaves one nvram alias and avoids a duplicate nvram device. :166-172 marks &nvram_qspi read-only.
  • t8122-j615-25g83.dts: drops its own include and read-only override, which it now inherits. Its DTB is unchanged.
  • Which T8122 trees enable QSPIMC at head: only t8122-j613-25g83.dts, t8122-j615.dts and, through it, t8122-j615-25g83.dts. The base node in t8122-peripheral-buses.dtsi stays disabled, so dropping the check probes nothing new on the other M3 boards.

Commits (git log integration/aurora..1a6e3dbe): 86809d3, d7e3179, 7127d73, 1a6e3db. All are authored and committed by a human, and each has exactly one trailer, Signed-off-by. No other trailers.

Checks

  • No new SoC, board or firmware-version condition. One board condition is removed. No new module or cmdline parameter (the existing read_only parameter is untouched). No delays.
  • CI at 1a6e3db: dt-checks and host-tests pass. GitHub reports MERGEABLE/CLEAN; git merge-tree against integration/aurora 8b360dc is clean.
  • PR body ends with the Assisted-by line.

Non-blocking

  • t8122-j615-25g83.dts now probes QSPIMC as well, read-only. It has not had a boot row on its own firmware. QSPIMC reads do not depend on the macOS version, so I am not holding the PR for it.
  • A later J615 write enablement should be qualified from DT properties, not from a new apple_qspi_boards[] entry.

Assisted-by: LLM (Claude:Opus 5.5)

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