Skip to content
Permalink
Browse files

a20 sunxi - write speed improvement. Need testings.

  • Loading branch information...
igorpecovnik committed May 11, 2019
1 parent 067160b commit c4281e5957734d8d2eb300c02e713077bf296c4d
@@ -0,0 +1,36 @@
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).
These devices are RaspberryPi-like small devices.

RFC: Since more than about 25 similar SBC/SoC models do use the
ahci_sunxi driver, users are encouraged to test it on all the
affected boards and give feedback.

List of the affected sunxi and other boards and SoCs with SATA using
the ahci_sunxi driver:
$ grep -i -e "^&ahci" arch/arm/boot/dts/sun*dts
and http://linux-sunxi.org/Category:Devices_with_SATA_port

Signed-off-by: Uenal Mutlu <um@mutluit.com>
---
drivers/ata/ahci_sunxi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/ahci_sunxi.c b/drivers/ata/ahci_sunxi.c
index 911710643305..257986431c79 100644
--- a/drivers/ata/ahci_sunxi.c
+++ b/drivers/ata/ahci_sunxi.c
@@ -158,7 +158,7 @@ static void ahci_sunxi_start_engine(struct ata_port *ap)
struct ahci_host_priv *hpriv = ap->host->private_data;

/* Setup DMA before DMA start */
- sunxi_clrsetbits(hpriv->mmio + AHCI_P0DMACR, 0x0000ff00, 0x00004400);
+ sunxi_clrsetbits(hpriv->mmio + AHCI_P0DMACR, 0x0000ffff, 0x00004433);

/* Start DMA */
sunxi_setbits(port_mmio + PORT_CMD, PORT_CMD_START);
@@ -0,0 +1,36 @@
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).
These devices are RaspberryPi-like small devices.

RFC: Since more than about 25 similar SBC/SoC models do use the
ahci_sunxi driver, users are encouraged to test it on all the
affected boards and give feedback.

List of the affected sunxi and other boards and SoCs with SATA using
the ahci_sunxi driver:
$ grep -i -e "^&ahci" arch/arm/boot/dts/sun*dts
and http://linux-sunxi.org/Category:Devices_with_SATA_port

Signed-off-by: Uenal Mutlu <um@mutluit.com>
---
drivers/ata/ahci_sunxi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/ahci_sunxi.c b/drivers/ata/ahci_sunxi.c
index 911710643305..257986431c79 100644
--- a/drivers/ata/ahci_sunxi.c
+++ b/drivers/ata/ahci_sunxi.c
@@ -158,7 +158,7 @@ static void ahci_sunxi_start_engine(struct ata_port *ap)
struct ahci_host_priv *hpriv = ap->host->private_data;

/* Setup DMA before DMA start */
- sunxi_clrsetbits(hpriv->mmio + AHCI_P0DMACR, 0x0000ff00, 0x00004400);
+ sunxi_clrsetbits(hpriv->mmio + AHCI_P0DMACR, 0x0000ffff, 0x00004433);

/* Start DMA */
sunxi_setbits(port_mmio + PORT_CMD, PORT_CMD_START);

13 comments on commit c4281e5

@juanesf

This comment has been minimized.

Copy link

replied May 13, 2019

  • Does the patch apply to all Sunxi SoC? example M2U.
  • What would be the way to do the corresponding test?

Greetings and thanks.

@ThomasKaiser

This comment has been minimized.

Copy link
Member

replied May 13, 2019

You need a sunxi next branch with a freshly built kernel. I've no idea whether Igor already rolled out the patched kernel via Armbian's apt repo.

An awful lot of testing is required (since what if Allwinner set the register contents by intention and not by accident since they experienced data corruption back then?!) and the focus needs to be on data integrity. As such testing with a btrfs on a SATA disk is the most simple way to test correctly for potential data corruption issues: https://irclog.whitequark.org/linux-sunxi/2019-05-13#24595322;

@igorpecovnik

This comment has been minimized.

Copy link
Member Author

replied May 13, 2019

@juanesf It could work also on M2U, but DEV kernel only, IIRC NEXT is broken for this board. You only need to download latest images and switch to nightly builds, run apt update/upgrade and see if it works.

@juanesf

This comment has been minimized.

Copy link

replied May 13, 2019

I already have the latest version installed and updates, what would be the fortitude of doing a test?

@igorpecovnik

This comment has been minimized.

Copy link
Member Author

replied May 13, 2019

Report to this thread (even this is not A20 but its successor) https://forum.armbian.com/topic/10352-a20-sata-write-speed-improvement and report numbers with the same iozone command. Numbers from before should also be somewhere.

@ThomasKaiser

This comment has been minimized.

Copy link
Member

replied May 13, 2019

what would be the fortitude of doing a test?

The risk of potential DATA CORRUPTION (that's why testing with data integrity in mind is needed as already mentioned above. The more testers the better).

It would be insane to roll out such a patch without any further testing but according to the Twitter filter bubble it seems that's exactly what has already happened in 'Armbian headquarters'.

@igorpecovnik did you really pushed the patched kernels on apt.armbian.com already?

@igorpecovnik

This comment has been minimized.

Copy link
Member Author

replied May 13, 2019

Not after I ran many tests and found no signs of data corruption. I can put update on hold if you think it was too quick and leave only in 5.1.y DEV branch for testing.

@ThomasKaiser

This comment has been minimized.

Copy link
Member

replied May 13, 2019

IMO it's way too early to push this fix to user installations and on the other hand a 'call for testers' asking for volunteers would've been a great idea.

Without filesystems that checksum not only metadata but also each and every data block it's hard to impossible to spot infrequent data corruption, especially if we're talking about corner cases. That's why I will run an iozone loop on top of btrfs on the only sunxi device I've lying around for tests for the next three days.

@igorpecovnik

This comment has been minimized.

Copy link
Member Author

replied May 13, 2019

especially if we're talking about corner cases.

This was surely not covered. Let's do more tests. Repository update was reverted on NEXT kernel.

@ThomasKaiser

This comment has been minimized.

Copy link
Member

replied May 14, 2019

My test setup survived 24 hours without data corruption. Also no performance degradation. But it's just one single A10 board.

But who else is testing? There's no 'call for testers' in the forum and you clearly communicated the patch would already be part of Armbian at various locations. Why should anybody help testing?

@igorpecovnik

This comment has been minimized.

Copy link
Member Author

replied May 14, 2019

But who else is testing? There's no 'call for testers' in the forum

What would be the best way for an average Joe?

@calhemp

This comment has been minimized.

Copy link

replied May 19, 2019

Hi, to do a try with this patch in my cubieboard1.eos
only I've to build a kernel/uboot DEV with armbian ./compile.sh script and install this result kernel?
or build with next is also posible and this patch will work?
thanks, I'll try iozone before and after.

@calhemp

This comment has been minimized.

Copy link

replied May 19, 2019

sorry, i think that i see this patch in sunxi-next and sunxi-dev folder, i'll try to compile and try. thanks

Please sign in to comment.
You can’t perform that action at this time.