If you’ve been following this blog long enough, you may remember that all linux-sunxi community work aiming at improving u-boot and Linux software support on Allwinner processors started with Allwinner A10 processor found in MeLE A1000 TV box back in 2012, which at the time provided an interesting alternative to Raspberry Pi board that was in short supply at launch time and several months after.
One of the most interesting feature found in Allwinner A10 single core Arm Cortex-A8 processor was its SATA interface, and Allwinner A20 was announced a few months later with a dual core Cortex-A7 processor and virtually the same peripherals as Allwinner A10, including SATA. However when I tested CubieTruck board connected to a mechanical drive, I noticed sequential SATA performance was fine for reads (~180MB/s), but writes were fairly slow at around 36 MB/s.
Other people complained about it, and some looked into it, and at one point it appeared the maximum SATA write performance for Allwinner A10/A20 was 45MB/s either due to buggy silicon and driver problems.
It turns out it may just have been a driver problem as a recent patch changing one line of code enables write speeds up about three times faster (200% improvement).
Most of us are not familiar with Allwinner SATA DMA registers, but luckily the patch explains what’s going on here:
Increasing the SATA/AHCI DMA TX/RX FIFOs (P0DMACR.TXTS and .RXTS) from default 0x0 each to 0x3 each gives a write performance boost of 120MB/s from lame 36MB/s to 45MB/s previously. Read performance is about 200MB/s [tested on SSD using dd bs=4K count=512K].
Tested on the Banana Pi R1 (aka Lamobo R1) and Banana Pi M1 SBCs
with Allwinner A20 32bit-SoCs (ARMv7-a / arm-linux-gnueabihf).
I tried to look into Allwinner A20 public documentation, but I could not find anything about P0DMACR or much details about SATA registers, as only the SATA clock appears to be documented. Maybe that explains why it took 7 years to fix this performance issue…
Igor of Armbian tested the patch on Cubietruck with the more reliable iozone benchmark, and the results look great:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Samsung SSD 840 Pro 256 GB @ Cubietruck iozone -e -I -a -s 100M -r 4k -r 16k -r 512k -r 1024k -r 16384k -i 0 -i 1 -i 2 Kernel 3.4.y random random reclen write rewrite read reread read write 102400 4 10714 15285 31921 32280 16328 14767 102400 16 21757 25767 57812 58010 45695 25201 102400 512 33403 32429 128245 116062 109591 33595 102400 1024 34846 35240 129965 131121 129515 35227 102400 16384 37895 37918 207564 204627 204340 38019 Kernel 4.19.y with SATA improvement patch 102400 4 22876 32704 37686 39143 22571 30990 102400 16 54254 69325 94749 97225 61354 68529 102400 512 110670 113325 190346 163677 186012 112679 102400 1024 113971 115928 206044 207406 184936 115069 102400 16384 127084 127588 243400 253305 252148 127611 without 102400 4 18053 22336 45249 46338 24860 22292 102400 16 30692 32188 106052 106577 71526 32746 102400 512 39632 39978 186433 185444 178097 39939 102400 1024 39860 40163 189900 191076 188446 40098 102400 16384 38875 41508 241939 244088 243405 41314 |
A sequential write of 38875 KB/s with Linux 4.19 was vastly improved to 127084 KB/s by applying this one line patch. It’s great, and there does not seem to be side-effects so far. The patch looks fairly new, so more testing may be needed. If you are running Armbian and can wait a bit, you won’t need to apply the patch yourself since it is part of Debian & Ubuntu releases. Uenal Mutlu also submitted his patch to the Linux Kernel mailing list, so it should be part of Linux 5.2.

Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress