Repository navigation
Conversation
H16_EXEC was filling every output surface with 0xff via memset() before every copy-mode execution, dirtying the full output buffer (614 KB on unet-320 and megabytes on larger models) on every inference. Each program owns its private surfaces for the life of its drm_file; freshly allocated surfaces are zeroed via __GFP_ZERO in both ane_h16_backend.c and ane_fw_cold.c, and recycled spare surfaces are zeroed in h16_take_spare() at H16_LOAD. Remove the redundant per-execute 0xff poison from the hot path. Signed-off-by: Satya Benson <satya@benson.earth>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: MERGE at 055bdde
Checked: Removing the pre-execute fill leaves input upload, device and CPU synchronization, and successful output copy-out intact. Failed executions return before copy-out. Both allocating backends zero new pages, and recycled surfaces are cleared when loaded into a program before any file can read them. Checked the reported 354 KUnit passes and J775c bit-exact copy and interleaved input checks.
RyanTheTide
left a comment
There was a problem hiding this comment.
The copy-mode behavior documented in Documentation/accel/apple-ane-cold.rst changes here. It says each H16_EXEC initializes the output mapping before execution. The output copy still includes the whole buffer, so bytes the engine leaves untouched now come from the previous execute rather than the per-call fill. LOAD-time zeroing cannot preserve that behavior on the second execute. Please preserve the existing behavior for outputs without a full-write guarantee, or document the change and verify that supported programs overwrite every returned byte.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Read at 055bdde67804. The copy-out only runs after a successful execute, the surfaces belong to one open file, and new and recycled surfaces are zeroed (__GFP_ZERO, h16_take_spare()), so the 0xff fill protects nothing. The J775c row covers H17. The same path runs on H16, so it gets one J773g (T8132) run on our side before it lands; we carry that with the J714s run for #4026, whose t6050-peripherals.dtsi change also reaches J714s.
H16_EXEC no longer fills the output mapping before each execute, so the sentence that says so is wrong. Describe what happens now: the surfaces are zeroed at H16_LOAD and belong to one open file, and output bytes that the engine does not write keep the value of the previous execute. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Answer to the 00:55 review: documented at the new head On the full-write question: the J775c row compares every output byte with the golden output for one model ( |
DjDeveloperr
left a comment
There was a problem hiding this comment.
The latest commit documents that a successful copy-mode call returns the full output surface and that bytes the engine skips retain their value from that file's previous execute. It leaves the J775c-tested code unchanged. Before landing, please run the repeated-execute case on H16 (J773g or a T6040/T6041 peer), including an output with an untouched range, and check that a newly loaded program starts with a cleared range.
|
Hardware verification on exact head Tested in matched-DTB one-shot combined batch kernel
Result: PASS on K114s (M5 Pro), J713 (M4 Air), and J616s (M4 Pro) at exact head |
J616s H16G copy-mode hardware row for
|
Remove the per-execute
memset(cpu, 0xff, buffers[i].size)output-surface poison fromane_h16_exec_ioctl().Each loaded program owns private kernel surfaces for the lifetime of its
drm_file. Newly allocated program surfaces are zeroed via__GFP_ZEROin bothane_h16_backend.candane_fw_cold.c, and recycled spare surfaces are zeroed inh16_take_spare()atH16_LOAD. Filling the entire output surface with0xffbefore every copy-mode execution dirties the full output buffer (614 KB onunet-320, and megabytes on larger models) on every inference without security or correctness benefit.Tested:
T6050,J775c, default kernel command line) atd309550e34af(Documentation/accel/apple-ane.rstdocs-only commit on top of unchanged code commit055bdde67804; batched candidateb74bea916b44=main2b2681932a5c+IOMMU_CACHEcommits +055bdde67804): PASS (307200/307200 exact, max 0 ulpacross 5 interleaved 3-input cases + 100/100 copy runs + 3/3 15 s RTCs2idlecycles,suspend_stats3/0,0failed units,0new kernel errors).unet-320copy-modecopy_indrops from23.7 usmean (22.9 usmin) to19.4 usmean (18.4 usmin) oncpu12(19.1 usmean unpinned).d309550e34af(CI 9/9 PASS;scripts/checkpatch.pl --strict0/0/0; KUnitboot.kunitconfig+transport.kunitconfig334/334PASS,pm.kunitconfig20/20PASS).H16(T6040/T6041) hardware execution (requested repeated-execute + untouched-range + fresh-load zeroed-range check on H16 peer before landing; code path verified by KUnit and inspection ofane_h16_alloc_prot__GFP_ZERO+h16_take_sparezeroing).Risk: two-way; affects copy-mode
H16_EXECon H16 and H17 ANE devices only.