Skip to content

isp, dapf, kboot: make ISP placeholder handoff, DAPF sync, and power skip property-driven - #304

Open
astaff wants to merge 2 commits into
aurora-silicon:mainfrom
astaff:t6041/j616c-isp-handoff
Open

astaff wants to merge 2 commits into
aurora-silicon:mainfrom
astaff:t6041/j616c-isp-handoff

Conversation

@astaff

@astaff astaff commented Nov 18, 2026 •

Copy link
Copy Markdown

Make ISP preloaded-segment handoff, dart-isp0 DAPF range sync, and Stage 2 ISP power-up skipping property-driven instead of gating on per-SoC chip lists:

  • src/isp.c / src/kboot.c: Replace the chip_id list in isp_init() with isp_fdt_needs_init(fdt) so Stage 2 skips legacy isp_init() whenever the FDT's isp node is absent/disabled, uses /reserved-memory/isp-firmware-{text,data} placeholders, or binds apple,t8132-isp / apple,t6041-isp (T6040/T6041) / apple,t6050-isp.
  • src/kboot.c (dt_set_isp_fwdata()): Unify J614s and T6040/T6041 segment fill into a single placeholder-driven dt_fill_isp_placeholders() path for any tree carrying isp-firmware-{text,data} placeholders, deriving the remap window from ADT dart-isp vm-base and FDT isp-heap iommu-addresses (32 MiB on T6040/T6041, below Linux's shared DMA allocations).
  • src/dapf.c (dapf_t8110_ranges()): Reuse struct dapf_t8110_config to parse dapf-instance-0 instead of open-coding 52-byte records in kboot.c, and log + fail closed (disabling isp and its placeholders) if dapf-instance-0 is missing, has an unexpected length, or has inverted bounds.

Companion PRs

Still to do

  1. Have the installer extract the sensor tuning file (apple/isp_2224_01XX.dat) for packaging alongside firmware.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for getting the J616c camera streaming.

A few parts don't fit how we usually structure this. The ISP power-up skip grows a chip list (src/isp.c:101 chip_id == T6041 || chip_id == T6050), and the fill takes a T6041-only branch (src/kboot.c:9596). We select behaviour by a hardware property (the tree's ISP node/compatible, what the kernel driver declares it owns), not by the chips where it was tested; T6040 shares this ISP.

src/kboot.c:9313-9338 also parses dapf-instance-0 by hand (52-byte records), next to the existing parser in src/dapf.c. Could it use that parser, and could the ADT segment fill (dt_set_isp_fwdata()) be the one path for every chip whose tree has the placeholders, rather than a T6041 copy of the J614s fill?

format-check also fails on src/kboot.c in this branch. We can run rows on our J616s (M4 Pro) once it is property-driven.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Adding a few points to the earlier review, not repeating it:

  1. The segment check adds bare constants: the remap window 0x10000000000-0x10002000000, a cap lowered from 64 MiB to 32 MiB, and the 52-byte DAPF record used four times. Could these come from named fields (the dapf.c record, an ADT property for the window), with a short note on why the cap changed?
  2. If dapf-instance-0 has an unexpected length, the sync returns quietly and the tree keeps its static apple,dapf-ranges, which may not match the die. A log line and a fail-closed choice there would help.
  3. Could item 1 of the "still to do" list be trimmed to say only that the installer extracts the tuning file, without the sizes and header values? The other roadmap items might fit better in a tracking issue. Once it is property-driven we'll run it on our M4 Pro J616s.

@astaff
astaff force-pushed the t6041/j616c-isp-handoff branch from ae9ef78 to 70455e9 Compare November 19, 2026 18:10
@astaff astaff changed the title isp, kboot: fix T6041 ISP handoff, DAPF filter sync, and power setup isp, dapf, kboot: make ISP placeholder handoff, DAPF sync, and power skip property-driven Nov 19, 2026
@astaff

astaff commented Nov 19, 2026

Copy link
Copy Markdown
Author

Thanks for the review! Updated the branch (70455e9c) to address every point:

  1. Property-driven ISP power skip & unified placeholder fill: Removed the T6041/T6050 chip_id checks in src/isp.c and src/kboot.c. kboot_prepare_dt() now gates isp_init() on isp_fdt_needs_init(fdt) (tree isp compatibles and /reserved-memory/isp-firmware-{text,data} placeholders, covering T6040, T6041, T6050, and T8132), and dt_set_isp_fwdata() uses a single dt_fill_isp_placeholders() path for any tree with the placeholders instead of duplicating the J614s fill.
  2. Named dapf.c parser, ADT/FDT window bounds, and fail-closed dapf-instance-0 sync: Added dapf_t8110_ranges() in src/dapf.c backed by sizeof(struct dapf_t8110_config) (no open-coded 52-byte offsets), derived the remap window from ADT dart-isp vm-base + FDT isp-heap iommu-addresses with a comment explaining the 32 MiB isp-heap bound below Linux's shared DMA pool, and made missing/malformed dapf-instance-0 lengths or inverted bounds log an error and fail closed (disabling isp and both placeholders).
  3. format-check & PR description: Verified clean with clang-format 20.1.8, and trimmed "Still to do" in the PR body to the installer tuning-file extraction note.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thank you for the careful rework: the tree-driven ISP gate, the single placeholder fill, the dapf.c parser and the fail-closed sync address everything we raised. Once the branch is rebased we'll run it on our M4 Pro J616s.

astaff and others added 2 commits November 19, 2026 14:09
…skip property-driven

Select ISP loader power-up and firmware segment handoff from the kernel
device tree and ADT properties rather than per-chip ID lists:

- Gate isp_init() on isp_fdt_needs_init(fdt) so trees whose ISP node is
  disabled, carries /reserved-memory/isp-firmware-{text,data}
  placeholders, or binds a kernel-owned compatible (apple,t8132-isp,
  apple,t6041-isp on T6040/T6041, apple,t6050-isp) skip loader power-up.
- Unify dt_set_isp(), dt_set_isp_fwdata(), and dt_finish_j614s_isp() onto
  a single placeholder-driven dt_fill_isp_placeholders() path for every
  tree with isp-firmware-{text,data} placeholders, deriving the firmware
  IOVA window from ADT dart-isp vm-base and /reserved-memory/isp-heap
  iommu-addresses (32 MiB on T6040/T6041, below the kernel's shared DMA
  allocations).
- Reuse dapf.c's struct dapf_t8110_config parser via dapf_t8110_ranges()
  to sync isp_dart0 apple,dapf-ranges from ADT dapf-instance-0 across
  6-AMCC and 8-AMCC dies, logging an error and failing closed if
  dapf-instance-0 is missing or malformed.

Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
The J713 AOP and ISP DAPF tests disable the inverted-slice check by
rewriting its source text, "config[i].end < config[i].start". The DAPF
parser now copies each packed record before checking it
(entry.end < entry.start), so the rewrite no longer matched and both
tests failed their own mutation control. Point it at the new spelling;
the control again proves an inverted slice is refused.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Rebasing onto main 8fb038f (no content change; the dapf.c/dapf.h conflict with #309 keeps both parsers, with #309's dapf_t8132_ranges() calling the renamed dapf_t8110_slices()). One extra commit on top, see the next comment.

@DjDeveloperr
DjDeveloperr force-pushed the t6041/j616c-isp-handoff branch from 70455e9 to 22f1225 Compare November 19, 2026 19:10
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Added 22f1225 (tests only): #309's test_j713_aop_dapf.py and test_j713_isp_dapf.py disable the inverted-slice check by rewriting config[i].end < config[i].start. This PR now checks a copied entry, so that rewrite stopped matching and both tests failed their own mutation control after the rebase. They now rewrite entry.end < entry.start and pass. @astaff your commit is unchanged apart from the rebase.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Review of 22f1225 (your commit rebased onto main, plus the tests-only commit), from the angle of boards other than the J616c. Device-tree references are to linux integration/aurora 6ae9c3ca9c.

isp_fdt_needs_init() leaves the Neo (apple,t8140-isp, isp alias from isp-common.dtsi, no placeholders), the M2 Pro (apple,t6020-isp) and the M5 (apple,t6050-isp, which already returned early) exactly as before. It does change three other groups, so please confirm these are intended:

  1. T8132 (J713, J773g) and T6040 (J614s, J616s): aura no longer powers up the ISP or carves a loader heap before handoff. None of these trees has an isp alias, and isp_fdt_needs_init() checks fdt_path_offset(fdt, "isp"). Before this PR they ran isp_init() (every chip but T8152). Handing power to the kernel is what Ryan asked for. Has the J713 camera (kboot: hand the J713 ISP its address filter windows from the ADT #309 / linux#2229) been streamed without that power-up? We'll boot-check the M4 mini.
  2. The placeholder fill reaches only trees with an isp alias. dt_set_isp_fwdata() looks the node up by that alias, so on the J616s (t604x-j614-j616.dtsi, no alias) dt_isp_has_placeholders() is true but nothing is filled: the J616s keeps its static 26.6.2 reg/iommu-addresses, and its isp_dart0 apple,dapf-ranges isn't synced. If "T6040 shares this path" should hold, the node could be found by its memory-region owner or by compatible instead of the alias, or the J616s tree could get the alias.
  3. J614s: dt_finish_j614s_isp() now goes through dt_fill_isp_placeholders(isp, false). The heap window must now equal ADT dart-isp0 vm-base instead of the fixed 0x100_0000_0000/32 MiB, the cap is 64 MiB, and there's a new DAPF sync that rewrites isp_dart0 apple,dapf-ranges from dapf-instance-0. Does that sit well with the J614s's own DAPF readiness path (dapf_j614s_isp_ready())?

Smaller points:

  • dapf_t8110_ranges() takes dapf-instance-0 without checking the instance type. kboot: hand the J713 ISP its address filter windows from the ADT #309's dapf_t8132_dapf_index() finds the DAPF bank by type, which would also cover a DART whose first instance isn't the DAPF.
  • With the chip_id == T6050 early return gone, isp_init() would now run on an M5 tree whose isp alias points at a node without apple,t6050-isp. That's unlikely, but a one-line comment at kernel_owned[] saying T6050 relies on it would keep it from being dropped.

Local checks on 22f1225 (aura Actions macOS runners are still stuck) are in the next comment.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Local checks on 22f1225. All 14 Actions jobs on this head are still queued (runner outage), so these were run by hand: clang-format 20.1.8 (the PR's files and make format-check on the whole tree) passes. tools/stage1_size.sh with clang passes all four flavours (Stage 1 headroom 17728 B). The stage1-clang pair (RELEASE=1 CHAINLOADING=1, with and without ESP_STAGE2=1) builds. ESP stage 2 vital size passes both configs (margin 434992 B). Full pytest under clang: 779 passed, 13 failed, and those 13 are exactly the ones that fail on clean main 8fb038f on this host (clang 23 -Wunused-but-set-global in harnesses, updater-script paths). The gcc jobs can't be reproduced here: host gcc 16 can't link aura.

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