Repository navigation
accel/ane: h17: use IOMMU_CACHE for dma-coherent program surfaces - #4026
Conversation
When the ANE device is marked dma-coherent in the device tree, map H17 program surfaces (PAGE_KERNEL cached pages) with IOMMU_CACHE so the DART2 PTEs clear NO_CACHE and the engine snoops CPU caches directly, matching ane_h16_backend.c and ane_t6021_fwload.c. Skip the software dma_map_sgtable() and per-execute dma_sync_sgtable_*() cache maintenance on coherent devices; non-coherent devices keep the existing software cache-sync path unchanged. Signed-off-by: Satya Benson <satya@benson.earth>
The T6050 ANE DART2 mappings support hardware cache coherency when IOMMU_CACHE clears the DART2 NO_CACHE PTE bit. Mark the T6050 ANE node dma-coherent (already allowed by Documentation/devicetree/bindings/npu/ apple,ane.yaml) so H17 program surfaces use hardware snooping without per-execute software cache flushes. 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. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed 9673fd4. For coherent program surfaces the mapping, DMA allocation bookkeeping and sync paths agree. Non-coherent program surfaces keep the software sync and matched unmap, and other firmware allocations retain their existing path. The reported J775c row verifies the live DT and bit-exact outputs across interleaved inputs.
There was a problem hiding this comment.
Verdict: MERGE at 9673fd4
Checked: The existing ANE binding validates and allows dma-coherent. The shared T6050 node and the standalone J775c node both carry it. Only coherent H17 program surfaces get IOMMU_CACHE and skip DMA sync. The IOMMU consumes physical scatterlist entries, teardown only unmaps DMA-mapped tables, and the transport keeps its publication and completion DMA barriers. Checked the seven DTB results, 354 KUnit cases and the J775c bit-exact interleaved input results.
|
Local checks for
Not run here: hosted apple-build/host-tests/KUnit plan (still queued), KUnit on UML. Hardware is the J775c row in the body. The J714s run follows after the merge: the coherent path runs only where the DT says Two comments for a later cleanup, no change needed now: the |
When an H17 ANE device is marked
dma-coherentin the device tree, map itsPAGE_KERNELprogram surfaces withIOMMU_CACHEso the DART2 PTEs clearAPPLE_DART2_PTE_PROT_NO_CACHEand the engine snoops CPU caches directly (matchingane_h16_backend.candane_t6021_fwload.c), and skipdma_map_sgtable()and per-executedma_sync_sgtable_*()cache maintenance. Mark theT6050ANE nodedma-coherent(already allowed byDocumentation/devicetree/bindings/npu/apple,ane.yaml).Non-coherent devices (without
dma-coherentin DT, includingT8140andT8142until verified on their hardware) keep the existing software cache-sync path unchanged.Tested:
T6050,J775c, default kernel command line) at exact head9673fd472911(batched candidateb74bea916b44=main2b2681932a5c+ unchanged PR commits4e9b344d907b,9673fd472911+ output-poison removal commit): PASS (307200/307200 exact, max 0 ulpacross 5 interleaved 3-input cases + 100 copy runs + 3/3 15 s RTCs2idlecycles,suspend_stats3/0,0failed units,0DART faults,0new kernel errors)./proc/device-tree/soc/ane@508000000/dma-coherentverified present; 5/5 SHA-256 outputs bit-exact against golden outputs captured with softwaredma_sync_sgtable_*.unet-320IN_PLACEcopy_in/copy_outphase drops from41–67 usof software cache sync to0.0 us; copy-modecopy_in19.1 usmean /copy_out12.5 usmean. Combined with accel/ane: h17: set up the T6050 engine bridges at power-up #3964 + cpufreq: apple-soc: honor min frequency floor during idle parking #4016 + arm64: dts: apple: t6050: set CLPC apple,ane-cpu-opp to 3.648 GHz #4017 + accel/ane: h17: wake T6050 firmware waits on the channel IRQ #4018 on the same machine,unet-320reaches475.4 usp50IN_PLACE(502.9 uscopy) vs467.9 usmacOS CoreML.9673fd472911:scripts/checkpatch.pl --strict0/0/0; all 7T6050DTBs (j714s,j716c,j775c,j775d,j873s,k114c,k116c) compile cleanly withdma-coherentverified viadtc; KUnitboot.kunitconfig+transport.kunitconfig334/334PASS,pm.kunitconfig20/20PASS.T8140andT8142(both stay on the existing non-coherent path because their DTs do not setdma-coherent).Risk: two-way; affects H17 ANE program surface mappings on
T6050(dma-coherentenabled) and leaves non-coherent H17 devices on the existing software sync path.