arm64: dts: marvell: armada-37xx: mark EIP97 as dma-coherent
Subsystems (2)
PATCH 1/1 arm64: dts: marvell: armada-37xx: mark EIP97 as dma-coherent
Armada 37xx has coherent bus, similar to Armada 7k/8k. Cache synchronization consumes a lot of CPU cycles. Enabling coherent DMA increases IOPS performance up to 4 times. Some numbers:
Data length
Algo MB 16 64 128 256 1024 1424 4096
DES-ECB 1 +21 % +5 % +5 % +7 % +7 % +3 % +20 %
AES-ECB-128 1 +21 % +6 % +6 % +6 % +9 % +8 % +22 %
AES-CBC-128 1 +21 % +5 % +5 % +5 % +6 % +7 % +23 %
AES-CBC-256 1 +23 % +7 % +8 % +6 % +11 % +13 % +20 %
Data length
Algo MB 16 64 256 512 1024 1420 4096 8192
AES-GCM-128 1 +44 % +42 % +31 % +32 % +27 % +30 % +32 % +30 %
AES-GCM-128 8 +319 % +326 % +163 % +148 % +75 % +72 % +74 % +41 %
AES-GCM-128 4096 +123 % +128 % +90 % +83 % +116 % +59 % +38 % +28 %
Data length
Algo MB 16 64 256 1024 2048 4096 8192
MD5 1 +21 % +15 % +29 % +25 % +50 % +16 % +20 %
SHA1 1 +24 % +22 % +27 % +22 % +18 % +20 % +20 %
SHA256 1 +30 % +24 % +25 % +26 % +21 % +41 % +19 %
SHA512 1 +4 % +3 % +8 % +10 % +24 % +10 % +11 %
Tested on Armada 3720. Platform passes testmgr selftests.
--- arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +1 -0
@@ -437,6 +437,7 @@ crypto: crypto@90000 { interrupt-names = "ring0", "ring1", "ring2", "ring3", "eip", "mem"; clocks = <&nb_periph_clk 15>; + dma-coherent; }; rwtm: mailbox@b0000 {
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Critical] Incorrectly marking the crypto engine as `dma-coherent` on the non-coherent Armada 37xx SoC…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Incorrectly marking the crypto engine as dma-coherent on the non-coherent Armada 37xx SoC bypasses necessary software cache maintenance, leading to silent data corruption. --
commit cb353bcdff0077f7b4e65e2e644ffb6462f3946f
Author: Aleksander Jan Bajkowski <[email protected]>
Subject: arm64: dts: marvell: armada-37xx: mark EIP97 as dma-coherent
This commit marks the crypto engine (EIP97) on the Armada 37xx SoC as dma-coherent to skip software cache synchronization.
arch/arm64/boot/dts/marvell/armada-37xx.dtsi crypto: crypto@90000 { · line 440
Quoted 9 lines
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +1
-0@@ -437,6 +437,7 @@ crypto: crypto@90000 { interrupt-names = "ring0", "ring1", "ring2", "ring3", "eip", "mem"; clocks = <&nb_periph_clk 15>; + dma-coherent;
[Severity: Critical]
Could this bypass necessary software cache maintenance on the non-coherent Armada 37xx SoC?
Unlike the Armada 7k/8k, the Armada 37xx SoC does not appear to support hardware I/O cache coherency for its peripheral interconnect.
Adding the dma-coherent property to the crypto node instructs the DMA API to skip software cache maintenance, such as cleaning dirty CPU cache lines to RAM before DMA transmission and invalidating them before CPU reads.
The observed performance improvement likely comes from bypassing these essential CPU operations.
Without cache maintenance, could the crypto engine read stale data from memory, and the CPU read stale data from its caches, resulting in silent cryptographic data corruption?
Passing testmgr selftests is a common false positive for this regression, as small test payloads often happen to be clean in the cache or benefit from incidental cache states during early boot.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Gregory CLEMENT
maintainerHello Aleksander,
Quoted 23 lines
Armada 37xx has coherent bus, similar to Armada 7k/8k. Cache synchronization consumes a lot of CPU cycles. Enabling coherent DMA increases IOPS performance up to 4 times. Some numbers:
Data length
Algo MB 16 64 128 256 1024 1424 4096
DES-ECB 1 +21 % +5 % +5 % +7 % +7 % +3 % +20 %
AES-ECB-128 1 +21 % +6 % +6 % +6 % +9 % +8 % +22 %
AES-CBC-128 1 +21 % +5 % +5 % +5 % +6 % +7 % +23 %
AES-CBC-256 1 +23 % +7 % +8 % +6 % +11 % +13 % +20 %Data length
Algo MB 16 64 256 512 1024 1420 4096 8192
AES-GCM-128 1 +44 % +42 % +31 % +32 % +27 % +30 % +32 % +30 %
AES-GCM-128 8 +319 % +326 % +163 % +148 % +75 % +72 % +74 % +41 %
AES-GCM-128 4096 +123 % +128 % +90 % +83 % +116 % +59 % +38 % +28 %Data length
Algo MB 16 64 256 1024 2048 4096 8192
MD5 1 +21 % +15 % +29 % +25 % +50 % +16 % +20 %
SHA1 1 +24 % +22 % +27 % +22 % +18 % +20 % +20 %
SHA256 1 +30 % +24 % +25 % +26 % +21 % +41 % +19 %
SHA512 1 +4 % +3 % +8 % +10 % +24 % +10 % +11 %
Quoted 3 lines
Tested on Armada 3720. Platform passes testmgr selftests.
Signed-off-by Aleksander Jan Bajkowski <[email protected]>
I'm surprised that we didn't enable it when submitting the support for Armada 3700, but indeed the datasheet mentions I/O coherency support. I didn't see any specific register to configure it. Moreover, if none of the tests failed, we can assume that the bus is indeed coherent.
Applied on mvebu/dt64
Thanks,
Gregory
Quoted 19 lines
--- arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 1 + 1 file changed, 1 insertion(+)arch/arm64/boot/dts/marvell/armada-37xx.dtsi +1
-0@@ -437,6 +437,7 @@ crypto: crypto@90000 { interrupt-names = "ring0", "ring1", "ring2", "ring3", "eip", "mem"; clocks = <&nb_periph_clk 15>; + dma-coherent; }; rwtm: mailbox@b0000 {Signature · 1 line
2.53.0
Signature · 3 lines
Grégory CLEMENT, Bootlin Embedded Linux and Kernel engineering https://bootlin.com