amery/linux-allwinner — pull request #39 by lundman (2012-06-19 03:29:42+00:00)
Title: Attempting minor performance enhancement of the A10 wemac NIC driver

I have the ICS4 20120609 image on Mele A2000 and there are some networking issues with the wired 'wemac' NIC. It can not quite stream videos that it can otherwise play perfectly from local storage.

Using the amery 3.0.31+ branch from github, and no other changes (no tweaking, or network settings)
I did a simple network test based on:

# time wget -O /dev/null http://192.168.30.44:8001/testfile.bin

(from Mac Pro running OSX 10.7.3 with llink-2.3.2). Not the best test perhaps, but gave me a good indicator.

Result from 10 such tests were:
2012-06-19 09:33:53 (3.55 MB/s) - `/dev/null' saved [114720238/114720238]
real 0m21.040s
real 0m15.308s
real 0m27.234s
real 0m15.715s
real 0m21.850s
real 0m35.226s
real 0m20.613s
real 0m42.949s
real 0m14.064s
real 0m16.241s

Pretty fluctuating. From 14s to 42s. In fact, it struggles to start, once the tcp.win size starts to increase, it generally finds its feet, and when it hits 5Mb/s to goes up to 9Mb/s without issues.

First thing I noticed in drivers/net/sun4i/sun4i_wemac.c is the CPU Busyloop. I guess some debug 'delay' hack that was left in.
```
- for(i=0;i<1000;i++);
+ //for(i=0;i<1000;i++);
```

and test again:

2012-06-19 09:44:48 (7.69 MB/s) - `/dev/null' saved [114720238/114720238]
real 0m14.499s
sys 0m13.950s
real 0m20.611s
real 0m18.529s
real 0m16.415s
real 0m18.042s
real 0m23.971s
real 0m24.729s
real 0m20.156s
real 0m19.658s

Which is a little better. More stable, but still fluctuating somewhat. I noticed the RX DMA interrupt handler has some udelay(100) code, I try halving them to 50:

real 0m15.632s
real 0m18.445s
real 0m15.785s
real 0m49.516s
real 0m15.115s
real 0m13.810s
real 0m38.116s
real 0m15.428s
real 0m17.187s
real 0m22.096s

That appears to have made it worse. So finally, I change udelay(100) to udelay(150):

real 0m12.270s
real 0m12.248s
real 0m12.138s
real 0m12.155s
real 0m12.145s
real 0m12.159s
real 0m12.182s
real 0m12.122s
real 0m12.533s
real 0m12.134s

Perfect. It no longer struggles, and just starts at 5Mb/s and goes directly to 9Mb/s. This could be somewhat "tweaked" specifically for the Mele A2000 (my hardware) but it sure makes it perform better. I really want to try the ICS4 kernel with this change, but I do not know how to build/boot such a kernel.