Repository navigation
libfdt, kboot: single-pass FDT scans, DART indexing, and batched property writes - #527
Conversation
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Audited all 5 files at e3c158e39320. The single-pass libfdt scans, pcie_apcie_host() parent stack, DART offset-delta indexing, kboot_audio.c per-amp batching, and dcp6_publish() iommu-addresses batching all look clean, with two blockers before approval:
- Pytest failures (2 host test harnesses need updating for the
src/kboot.cchanges):tests/python/test_acio_v2_handoff.py::test_acio_generation_handoffextractsdt_append_acio_tunable()into a standalone C snippet without#include <stdlib.h>, so the newmalloc()/free()calls fail-Wimplicit-function-declaration.tests/python/test_dart_tunables.py::test_dart_tunables_map_by_physical_addressextractsdt_copy_dart_tunable()/dt_copy_dart_tunables()without pulling instruct dt_dart_indexanddt_dart_index_{init,find,adjust}().
- Missing DCO (
Signed-off-by:): commits16a488cb7408(pcie_fdt: track parent stack in pcie_apcie_host()) and7a058f0a232d(kboot: index DART nodes and batch ACIO/DART tunable appends) are missingSigned-off-by:trailers.
Before merge this shared libfdt/kboot path will also need a test row on a second hardware generation.
|
This is a follow-up to yesterday's review. The branch hasn't changed since, and CI at
Maintainer edits are off on this branch, so we can't push these for you. Once CI is green, the shared |
fdt_parent_offset() previously called fdt_node_depth() followed by fdt_supernode_atdepth_offset(), walking the flattened device tree from the root twice on every lookup. Track ancestor offsets up to depth 32 in a single pass and fall back to fdt_supernode_atdepth_offset() only for deeper trees. fdt_node_offset_by_phandle() previously iterated nodes with fdt_next_node() and called fdt_get_phandle() on each node (two property scans plus fdt_next_node's own scan). Scan FDT tags directly in one pass and compare the 4-byte property value before resolving property names. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
pcie_apcie_host() previously called fdt_parent_offset() for every node in the device tree before checking whether the node even had a 'rc' reg-name entry, making the scan O(N^2) in the number of FDT nodes (~1.19 s on a 1,433-node J616s DTB). Check reg-names and reg first and track ancestor offsets in a small stack during the single fdt_next_node() walk. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
dt_copy_dart_tunables() previously rescanned the entire FDT and translated every enabled DART address on each ADT DART tunable lookup (O(M * N^2), ~2.2 s on J616s). Build a single-pass DART address index once and adjust cached offsets by the struct-block size delta after each FDT edit. In dt_append_acio_tunable(), validate all rows into a temporary buffer and perform a single fdt_appendprop() instead of three fdt_appendprop_u32() memmoves per tunable row. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Replace the double-scanning loops in fdt_find_max_phandle(), fdt_get_phandle(), fdt_node_offset_by_prop_value(), and fdt_node_offset_by_compatible() with single-pass FDT tag scans. Verified identical results against the reference implementations across all 1,433 nodes, phandles, compatibles, property values, and error cases of t6040-j616s.dtb (4.2x faster fdt_find_max_phandle, 3.5x faster fdt_node_offset_by_prop_value, 1.95x faster fdt_node_offset_by_compatible). Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Modifying properties on an FDT node only shifts bytes after that node, so its own offset remains valid across consecutive fdt_setprop() / fdt_delprop() calls. Look up each amp node once per amp instead of once per (property, amp) pair, preserving validation order and error logs. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Collect all per-stream iommu-addresses tuples for a reserved-memory segment on the stack and append them in a single fdt_appendprop() call, avoiding redundant /reserved-memory path lookups and repeated FDT tail moves. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
e3c158e to
0ce9b7b
Compare
|
Updated branch at
CI at |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 0ce9b7bb
Thanks for the quick turnaround: Dj's three points from 11-26 are fixed at this head (host tests, the native arm64 start.S job, Signed-off-by on every commit).
Blockers:
- Stage 1 size: this PR is the cause, not main. Main is red on the 4096 B floor, but it still links, with headroom of gcc 3696 B, fedora 4008 B and nix 3152 B. At this head the stage1-size run (https://github.com/aurora-silicon/aura/actions/runs/46118444415) shows fedora 232 B (main 4008 B) and gcc 224 B (main 3696 B), and nix no longer links ("Code and data reach the DCP log buffer"). Fix: keep the new code out of Stage 1, either
AURA_XTEXTon the new helpers or#if !(defined(CHAINLOADING) && !defined(ESP_STAGE2))for Stage-2-only paths, as #545 and #409 did. Alternatively wait for aura#551 (16 KiB link steps, about 90 KB more Stage 1 room), merge main again once it lands, and show the three size jobs linking with headroom no lower than main's. - No hardware rows, and no Tested:/Risk: lines in the body. This changes the shared boot path on every Mac. It needs one boot at this head on your own Mac and one on a second hardware generation, as Dj asked, each with the Mac, sha, result and restore. If you can only do one generation, say which one and we'll run the other on a lab Mac once blocker 1 is fixed.
Checked: Dj's 11-26 items against the diff and CI at this head. The CI step logs for stage1-size, compared with main's run 46110731041 at ca83398.
|
Stage 1 disposition: use the common bounded FDT traversal and DART indexing where they fit the release footprint. Measure against the same #551-based control. Keep Stage 2-only batching out of Stage 1 if needed, with identical DT results for both paths. Verify hosted size and the installed Stage 1 and peer regression rows before landing. |
There was a problem hiding this comment.
Verdict: HOLD at 679bca9c — clean main forward-merge (MERGEABLE); awaiting queued CI (especially Stage 1 release footprint measurement against #551-based main) and the installed Stage 1 + peer regression boot rows.
Blockers:
- Queued CI at
679bca9c(17jobs), specifically verifying Stage 1 release headroom meets the required floor against#551-basedmain(per the Stage 1 disposition, keep Stage 2-only batching out of Stage 1 if footprint still regresses, with identical DT results). - Installed Stage 1 and peer regression hardware boot rows at the final head.
Checked: Clean main forward-merge commit 679bca9c (MERGEABLE), queued CI status, and open Stage 1 disposition gates from 0ce9b7bb.
Evidence
679bca9cmerges currentmaincleanly (MERGEABLE) without altering the already-audited single-passlibfdtscans, DART indexing, and batched property writes.- Note: merge commit
679bca9chas noSigned-off-by:trailer; confirmpolicyCI passes on the merge commit.
|
@jgoyvaerts thanks. Going through the open review points at 1. Stage 1 size (RyanTheTide, 11-28). Fixed by #551 plus the main merge. I ran the 2. Hardware rows on two generations (Dj 11-25, RyanTheTide 11-28). Done at
3. Tested:/Risk: lines. These are still missing from the description. Please add them, or I'll add them from the rows above. Earlier items (Dj 11-25: host tests, DCO, native start.S job). These are fixed at this head, as the 11-28 review already noted. @DjDeveloperr @RyanTheTide: both change requests are answered above. If there is no objection within 60 minutes I'll treat them as non-blocking, and the PR merges once hosted CI is green and the App verdict at this head is in. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: APPROVE at 679bca9c
This replaces our 11-28 change request. Its one blocker (Stage 1 size) is fixed by #551.
- Code is unchanged since our review:
679bca9cis a clean merge of the reviewed0ce9b7bbwith mainb30b2da3(#551), andgit show --remerge-diffis empty. - Stage 1 size on the #551 layout, local clang + lld
tools/stage1_size.shat this head against main1c70ab57: stage1 headroom 94,704 B (main 94,704 B), code room 5,464 B (main 9,160 B). secure-audit/enforce 143,976 B. dev-audit code room 968 B (lab flavour, not required). Together with the ubuntu:24.04 gcc numbers above, nothing is near a floor. - Rows: J413 (M2) and J616s (M4 Pro) Stage 1 chain one-shots at this head both PASS. That covers the second generation asked for.
Merge once the hosted stage1-size, build and test jobs are green at this head.
|
The description now has the Tested: and Risk: lines from your rows at |
Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
|
Stage 1 disposition for the hardware rows (closeout, at
Disposition (Stage 1 owner call): the Stage 1 row for this PR is the method-T chain row of the exact candidate. In that row the installed Stage 1 chainloads this head's raw Stage 1 once, and that loads this head's ESP Stage 2. It ran at Footprint: the hosted |
There was a problem hiding this comment.
Verdict: MERGE at fd9e2b2 after tracked validation.
Checked: Recreated the forward merge from the previously approved parent and current main. Its remerge diff is empty. The two-family method-T owner disposition carries. Current hosted footprint and CI remain.
|
Merging at |
|
Thanks @jgoyvaerts, merged. #526 and #527 landed back to back. The combined tree was checked before the second merge: the fedora:44 Stage 1 size job fits on every flavour, and the full host pytest passes. |
What: Remove O(N^2) device-tree work from
kboot_prepare_dt(): single-passlibfdtscans, a parent stack inpcie_apcie_host(), a one-time DART node index and batchedfdt_appendprop()writes. Companion to #526 (no shared files).Tested: J413 (M2) and J616s (M4 Pro) at
679bca9c: PASS (lab run by @RyanTheTide, thanks): Enforcing, 0 failed units, 0 AVC, 0 DART faults, NVMe 0 errors, AVE h264/h265 md5 equal to production, s2idle 3/3.Risk: two-way door (a plain revert undoes it) · all Macs (shared
libfdt/kbootboot path)Not yet: nothing on hardware; the hosted stage1-size jobs are still queued.
Details
src/libfdt/fdt_ro.c: single-passfdt_parent_offset()(depth stack up to 32 with fallback), single-passfdt_node_offset_by_phandle(), and single-pass scans forfdt_find_max_phandle(),fdt_node_offset_by_prop_value(), andfdt_node_offset_by_compatible().src/pcie_fdt.c: maintain a parent stack during traversal inpcie_apcie_host()instead of callingfdt_parent_offset()on every node.src/kboot.c: index Apple DART nodes once and batch ACIO/DART tunablefdt_appendprop()writes into a single append per tunable table; updatetests/python/test_acio_v2_handoff.pyandtests/python/test_dart_tunables.pyaccordingly.src/kboot_audio.c: apply all amplifier properties per node lookup instead of re-resolving each amp node per property.src/kboot_display_handoff.c: batchiommu-addresseswrites into a singlefdt_appendprop()indcp6_publish().Evidence
679bca9c(Method T: installed Stage 1 chainloads this head's raw Stage 1 once, which loads this head's ESP Stage 2 with the Mac's own DTB/U-Boot tail; nothing installed was written, both Macs restored): J413 and J616s log rings report1.0.0b17-g679bca9c; J616s kernel and DCP error counts equal the production boot just before. Details: libfdt, kboot: single-pass FDT scans, DART indexing, and batched property writes #527 (comment)679bca9c(stage1-size.ymlgcc job inubuntu:24.04): stage1 77,928 B, secure-audit/enforce 143,576 B, dev-audit 61,288 B, every flavour links (floor 4,096 B).0ce9b7bon 7.3.0-m4.187/m4.190:make RELEASE=1,tests/run-logo.sh,tests/run-kboot-audio.sh(38/38),tests/run-{pmp-boot-data,fdt-disable,aop-os-ram}.sh,pytest tests/python/{test_acio_v2_handoff,test_dart_tunables}.pypass,clang-formatclean.pcie_apcie_host()1,193 ms -> <1 ms, DART/ACIO tunable copy 2,216 ms -> 26 ms (85x),kboot_prepare_dt()~340 ms total; 0 failed units, 0 new kernel errors; display, audio, PCIe, NVMe, Wi-Fi and Touch ID verified.