From 055bdde67804e422fd089c58d08ed8e961e38c4c Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Wed, 2 Dec 2026 19:28:08 -0500 Subject: [PATCH 1/2] accel/ane: h16: stop poisoning output surfaces on every execute 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 --- drivers/accel/ane/ane_h16_accel.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/accel/ane/ane_h16_accel.c b/drivers/accel/ane/ane_h16_accel.c index 20bfc2ebb03ed..a5a68c2bf0442 100644 --- a/drivers/accel/ane/ane_h16_accel.c +++ b/drivers/accel/ane/ane_h16_accel.c @@ -720,12 +720,8 @@ static int ane_h16_exec_ioctl(struct drm_device *drm, void *data, struct drm_fil locked = ktime_get_ns(); /* This program's shared surfaces are ours through the final copy-out. */ for (i = 0; i < args->count && !in_place; i++) { - void *cpu = p->surfaces[i]->cpu; - if (p->resources[i].permissions == 1) - ane_h16_user_copy(&user[i], cpu, false); - else - memset(cpu, 0xff, buffers[i].size); + ane_h16_user_copy(&user[i], p->surfaces[i]->cpu, false); } ane_h16_session_sync(a->session, p, true); copied = ktime_get_ns(); From d309550e34af6e32a7751743b66084f6b37549e4 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 3 Dec 2026 05:51:28 +0000 Subject: [PATCH 2/2] Documentation: accel: apple-ane: H16_EXEC no longer poisons the output 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 --- Documentation/accel/apple-ane.rst | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Documentation/accel/apple-ane.rst b/Documentation/accel/apple-ane.rst index 06a4912034354..d817cf9335527 100644 --- a/Documentation/accel/apple-ane.rst +++ b/Documentation/accel/apple-ane.rst @@ -884,15 +884,18 @@ descriptor (BAR ID, bit offset and width) adds one custom-BAR record with selector 1, value type 0 and the first pool DSID, 36. The scratch form sends none. -Each H16_EXEC copies inputs into the private input mappings and poisons the -output mapping. It then sends 0x002d with 0, keeps the request UUID pending -before publishing EXECUTE on channel 7, and treats the channel-7 reply as -transport acknowledgment only. Completion is a state-1 0x0300 report whose -UUID, program, process and procedure IDs all match. Then 0x002d with 1 and -a DMA read barrier precede the output copy. A state-2 report, a mismatched -ID, a malformed report or a timeout quarantines the session. Reports with -an unknown UUID never complete a request. Closing the file sends TERMINATE -then UNLOAD. Mappings stay until reboot. +Each H16_EXEC copies inputs into the private input mappings and does not +touch the output mapping. The surfaces are zeroed at H16_LOAD and belong to +one open file, so output bytes that the engine does not write keep the +value of that file's previous execute. H16_EXEC then sends 0x002d with 0, +keeps the request UUID pending before publishing EXECUTE on channel 7, and +treats the channel-7 reply as transport acknowledgment only. Completion is +a state-1 0x0300 report whose UUID, program, process and procedure IDs all +match. Then 0x002d with 1 and a DMA read barrier precede the output copy. A +state-2 report, a mismatched ID, a malformed report or a timeout +quarantines the session. Reports with an unknown UUID never complete a +request. Closing the file sends TERMINATE then UNLOAD. Mappings stay until +reboot. One program lifetime per firmware boot is mandatory. On this firmware family the first EXECUTE of a newly loaded program can write into the