Skip to content

Commit

Permalink
a20 sunxi - write speed improvement. Need testings.
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed May 11, 2019
1 parent 067160b commit c4281e5
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Greetings and thanks.

@ThomasKaiser
Copy link
Contributor

@ThomasKaiser ThomasKaiser commented on c4281e5 May 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

@igorpecovnik igorpecovnik commented on c4281e5 May 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@igorpecovnik
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@ThomasKaiser ThomasKaiser commented on c4281e5 May 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

@calhemp calhemp commented on c4281e5 May 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.