friendlyarm / h3_lichee

BSP for FriendlyARM NanoPi H3
106 stars 104 forks source link

Think about lowering DRAM clock #4

Closed ThomasKaiser closed 7 years ago

ThomasKaiser commented 7 years ago

The following works:

diff --git a/drivers/devfreq/dramfreq/sunxi-ddrfreq.c b/drivers/devfreq/dramfreq/sunxi-ddrfreq.c
index c7c20b7..7581087 100755
--- a/drivers/devfreq/dramfreq/sunxi-ddrfreq.c
+++ b/drivers/devfreq/dramfreq/sunxi-ddrfreq.c
@@ -1666,7 +1666,7 @@ static __devinit int sunxi_ddrfreq_probe(struct platform_device *pdev)
    if (sunxi_ddrfreq_min < SUNXI_DDRFREQ_MINFREQ_MIN)
        sunxi_ddrfreq_min = sunxi_ddrfreq_max / 3;
 #elif defined(CONFIG_ARCH_SUN8IW7P1)
-   sunxi_ddrfreq_min = 408000;
+   sunxi_ddrfreq_min = 132000;
 #else
    type = script_get_item("dram_para", "dram_tpr12", &val);
    if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {

Minimum DRAM clockspeed is then 132 MHz (applications requiring memory bandwidth get somewhat slow) but with 264 MHz DRAM clock and a single core running at 912 MHz a H3 device is still faster than a RPi Zero. Some details/ideas: http://forum.armbian.com/index.php/topic/1614-running-h3-boards-with-minimal-consumption/

My idea is to come up with settings that allow idle consumption as low as an RPi Zero while being able to jump to full performance if needed within moments. Pretty simple: adjust DRAM clockspeed in fex file back to 624 MHz, define first THS trip point a bit lower without real throttling so sunxi's budget cooling code will automatically adjust DRAM clockspeed set from userspace to the fex value when needed.

So NanoPi would idle with 4 CPU cores at 480 MHz and DRAM clocked down to 132 MHz (allowing to stay below the 100mA barrier), in case serious work has to be done the user can define whether H3 should be allowed to reach 1200 MHz (VDD_CPUX: 1.3V) or just 912 MHz (VDD_CPUX: 1.1V -- 2200mW consumption less when running heavy workloads like cpuburn-a7) and in case heavy load lasts longer the budget cooling code will automagically increase DRAM clockspeed from 132 MHz to 624 MHz (and a cronjob will set DRAM clockspeed back to 132 MHz when CPU utilization is low again later).

Do you ship developer samples? If yes I would be glad to implement this in Armbian so we could provide not only desktop and server images but also IoT images minimizing consumption intelligently (providing a tool for the user to adjust settings of course, eg. maximum clockspeed or disabled USB ports and so on)

wuweidong0107 commented 7 years ago

Sorry I didn't read this msg util now... It's a good and workable idea. Need some time to implement this.Maybe you can try it by yourself first....

ThomasKaiser commented 7 years ago

We will implement something like this in Armbian for sure (I now have the ability to measure pretty precisely even low consumption differences and also very noisy situations with averaged values). Just check the relevant thread in Armbian forums from time to time. Unfortunately still no NanoPi dev samples arrived so I lack testing capabilities with NEO.