Repository navigation
arm: apple: map every DRAM bank on every SoC - #54
RyanTheTide wants to merge 2 commits into
Conversation
dram_init_banksize() hands every /memory range from the boot loader to LMB and EFI, so the MMU has to map every one of them. Only the T8140, T8132 and T6040 maps did; every other SoC mapped bank 0 and left the rest to fault when LMB or EFI handed them out. Keep only the I/O regions in the per-SoC tables and build one map at cache enable time on every SoC: the I/O regions, then each populated bank, then the framebuffer, then the terminator. The tables become const, and a build-time check keeps them within the map's I/O slots. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The map now has the same shape on every SoC: its I/O regions, every DRAM bank, then the framebuffer. Check that for all 14 SoC compatibles, not only T8132 and T8140, and drop the fixed framebuffer slot that a tree without a framebuffer no longer has. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Blockers: 1. The change is right and has no SoC gate.
Coordination: #58 (caches before relocation) pulls the old per-SoC tables, RAM entries included, out through Watch in the rows: page tables are still a fixed 256 KiB (:1166-1168), split between the normal and the emergency copy. The J316s and J413 trees add 8 small ranges near the top of RAM, each of which can need its own level-3 tables. The T6022 table (24 I/O regions) has the least room. A table overflow panics after relocation. HW row: one-shot U-Boot boots on this head, to the U-Boot prompt and then into Linux through EFI:
All with 0 AVC, 0 failed units and no new kernel errors. Assisted-by: LLM (Claude:Opus 5.5) |
dram_init_banksize()gives LMB and EFI every/memoryrange the boot loader passes, so the MMU has to map every one of them. Only the T8140, T8132 and T6040 maps did this. Every other SoC (T8103, T8112, T6000/1/2, T6020/1/2, T8122, T6030/1/4, T8142, T8152) mapped bank 0 only, so anything LMB or EFI placed in a later bank sat outside the page tables.The reason for mapping every bank has nothing to do with which SoC it is, so this applies it everywhere:
const. The fixed-size RAM entries, the framebuffer slots and the terminators are gone.build_mem_map()builds one map for every SoC: the SoC's I/O regions, then each populatedbi_drambank, then/chosen/framebufferif there is one, then the terminator. Banks and framebuffer are page-aligned as before.BUILD_BUG_ONkeeps every table within the map's 24 I/O slots (the largest, T6022, has 24).t8140/t8132/t6040special case and its hard-coded RAM slot indices are gone.The SoC-to-I/O-table selection itself stays, because the I/O address layout really does differ per SoC.
Credit: the per-bank loop is the one from 097a434 ("arm: apple: Map all inherited memory banks on T8140"), extended to T8132 in e7f9187 and to T6040 in c21ef1a.
Why it matters on the older SoCs
The OS trees on our M2 (J413) and M1 Pro (J316s) carry 9 memory ranges, not one: a large main range plus 8 small ranges near the top of RAM (read-only
/proc/device-tree/memory@*/reg, 2026-11-19). Before this change, U-Boot mapped only the first one.Tests
apple_m1_defconfig, GCC 16.1 aarch64: builds with no warnings.board.oalso builds clean with-Werror -Wextra.test/py/tests/test_apple_*.pywith--noconftest: 35 passed, 2 skipped.test_apple_mem_map.pynow checks all 14 SoCs (1, 2 and 16 banks, with and without a framebuffer, plus the T8132 ANS/PCIe I/O coverage), not only T8132 and T8140.build_mem_map()out ofboard.cand runs them for all 14 SoC compatibles, with 1, 6, 11 and 16 banks, with and without a framebuffer, under ASan and UBSan. In all 112 cases every bank is mapped, in order, after the I/O regions, page-aligned, followed by the framebuffer and the terminator.Hardware rows owed (draft until done)
One-shot U-Boot boots, each to the U-Boot prompt and then into Linux through EFI: