When driving a 1920x1080-32@60Hz monitor, framebuffer scanout for
screen refresh becomes more bandwidth intensive and challening.
There used to be an old problem, which manifested itself as a
screen shaking effect when CPU or GPU are doing something memory
intensive and competing for the memory bandwidth with the display
controller. A possible explanation for it is that the display
controller just sends the previous scanline over HDMI in the case
if it can't read the current one in time.

Framebuffer scanout can be done either by DEBE or by DEFE. It seems
like DEBE is broken beyond repair. Apparently it is doing isolated
32 byte burst reads at regular intervals to scan out the framebuffer
and send this data over HDMI. The size of this burst is too small.
And if something else (CPU or GPU) is accessing memory at the same
time, we easily get bank conflicts with huge penalties. As these
penalties happen per 32 bytes of data, most of the memory bandwidth
is wasted. The end result is the screen shaking effect and a
significant performance loss for the CPU/GPU. This all is happening
because DEBE is configured to have higher priority than CPU and GPU.
So it can do these tiny bursts and nobody can do anything about it.
If we reduce the priority of DEBE, then the screen shaking effect
becomes much worse.

DEFE is somewhat similar to DEBE. But the key difference is that
it seems to implement some buffering of data and this buffer does
not underrun so easily. So it is possible to drop the priority
of DEFE port and make it the same as CPU/GPU. However in order to
get really perfect results, we need to also increase the "host port
command number" parameter. It is currently set to 0x10 by default
(the same as for CPU and GPU) and from what it looks, it affects
the bandwidth distribution between the ports with equal priority.
To experiment with this, I took A10-OLinuXino-LIME board (which
has a slow 16-bit memory interface) and downclocked DRAM to 408MHz.
Then used lima-memtester and glmark2-es2 programs to reproduce the
screen shaking effect. Increasing the "host port command number"
parameter resulted in a gradual reduction of the image glitches.
And at 0x50, the shaking effect disappeared completely.

So all that we need to do is a simple change "0x1035 -> 0x5031"
for the DEFE host port setup. And even A10-OLinuXino-LIME becomes
able to drive a FullHD monitor at 60Hz and 32bpp without issues
if "fb0_scaler_mode_enable" is set to 1 in the fex file.

Additionally, for A10-OLinuXino-LIME with DRAM clocked at 480MHz
and driving a 1920x1080-32@60Hz monitor in "scaler" mode, the
memset performance improves from 559.3 MB/s to 807.3 MB/s and
the memcpy performance improves from 299.3 MB/s to 317.9 MB/s
after this patch. So the memory bandwidth drain becomes smaller
the the overall system performance improves.

This has been also discussed at:
https://www.mail-archive.com/linux-sunxi@googlegroups.com/msg04085.html

Signed-off-by: Siarhei Siamashka <siarhei.siamas...@gmail.com>
---
 arch/arm/cpu/armv7/sunxi/dram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv7/sunxi/dram.c b/arch/arm/cpu/armv7/sunxi/dram.c
index caf94e9..09bde09 100644
--- a/arch/arm/cpu/armv7/sunxi/dram.c
+++ b/arch/arm/cpu/armv7/sunxi/dram.c
@@ -157,7 +157,7 @@ static u32 hpcr_value[32] = {
        0x0301, 0x0301, 0, 0,
        0, 0, 0, 0,
        0, 0, 0, 0,
-       0x1031, 0x1031, 0x0735, 0x1035,
+       0x1031, 0x1031, 0x0735, 0x5031,
        0x1035, 0x0731, 0x1031, 0x0735,
        0x1035, 0x1031, 0x0731, 0x1035,
        0x1031, 0x0301, 0x0301, 0x0731
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to