mudkipme / awesome-minisforum-v3

Useful information for Minisforum V3 AMD Tablet users.
MIT License
62 stars 8 forks source link

Optimizing power draw (under Linux) #5

Open JamiKettunen opened 1 month ago

JamiKettunen commented 1 month ago

Wanted to make this to gather other possible solutions people have tried and had success with. I can perhaps update this as I try things over the coming days. Out of the box I had ~5W idle draw on battery with Wi-Fi connected, power saver p-p-d mode enabled at 60 Hz and 0% display brightness.

Once I'm done digging around and perhaps refining some stuff (especially the ASPM script below) the plan is to just add this among the other information in the README doc.

My setup

Disabled SD card slot in BIOS (I don't have much use for it, should check if this affects things) Chimera Linux (rolling release) with GNOME 46 on Wayland Linux mainline kernel v6.10-rc6 power-profiles-daemon from git main for core performance boost control support mesa from git main mostly for fun (I really should test if these things really matter for battery life at least) power draw checked via upower -d, powerstat -d 2 or Vitals shell extension BATT rate monitor

Display panel

echo 0 > /sys/class/backlight/amdgpu_bl0/brightness, 100% scaling (in case that could've affected something under GNOME Wayland) @ 2560x1600 60 Hz I found the panel itself always seems to draw ~2.6 W/h even at these optimal conditions; maybe this is normal for an LCD of this size? Turning the display off for this test I achieved with:

dbus-send --session \
    --dest=org.gnome.ScreenSaver --type=method_call \
    /org/gnome/ScreenSaver org.gnome.ScreenSaver.SetActive \
    boolean:true

Switching from 60 Hz to 165 Hz seems to incur an additional draw of ~1.5 W/h, so at lowest brightness the display power draw alone would account for ~4 W/h

PCIe ASPM

It seems various PCIe devices have active-state power management disabled by default (as seen through e.g. lspci -vv | grep -E '(^[0-9a-z]|LnkCap|LnkCtl)' or in a more consice way lspci -vv | grep 'ASPM.*abled;'). Digging around I found pcie_aspm.policy=powersupersave can be added to kernel cmdline and upon reboot it's already looking much better (assuming the kernel is compiled with CONFIG_PCIEASPM_DEFAULT=y or similar, you can also check cat /sys/module/pcie_aspm/parameters/policy), though some like the Wi-Fi card and USB4 PCIe tunnel bridges were still missed.

So to finish it off I modified https://gist.github.com/baybal/b499fc5811a7073df0c03ab8da4be904 as follows to avoid in total at least a ~450 mW/h drain while idle without seemingly affecting the experience negatively (do report if testing and something breaks due to this!)

--- aspm_dell9360.sh
+++ aspm_v3.sh
@@ -43,8 +43,8 @@

 # You just need to modify these three values:

-ENDPOINT="00:1c.5"
-ROOT_COMPLEX="00:1c.4"
+ENDPOINT="c4:00.1"
+ROOT_COMPLEX="00:08.1"

 # We'll only enable the last 2 bits by using a mask
 # of :3 to setpci, this will ensure we keep the existing
@@ -255,21 +255,24 @@
 fi

 echo -e "${CYAN}Root complex${NORMAL}:"
-ROOT_COMPLEX="00:1c.0"
-enable_aspm_byte $ROOT_COMPLEX
-ROOT_COMPLEX="00:1c.4"
-enable_aspm_byte $ROOT_COMPLEX
-ROOT_COMPLEX="00:1c.5"
-enable_aspm_byte $ROOT_COMPLEX
-ROOT_COMPLEX="00:1d.0"
-enable_aspm_byte $ROOT_COMPLEX
-echo
+for root_complex in 00:02.2 00:03.1 00:04.1 00:02.3 00:08.1 00:08.2; do
+       ROOT_COMPLEX="$root_complex"
+       enable_aspm_byte $ROOT_COMPLEX
+done

+echo
 echo -e "${CYAN}Endpoint${NORMAL}:"
-ENDPOINT="3a:00.0"
-enable_aspm_byte $ENDPOINT
-ENDPOINT="3b:00.0"
-enable_aspm_byte $ENDPOINT
-ENDPOINT="3c:00.0"
-enable_aspm_byte $ENDPOINT
+
+ASPM_SETTING=3 # L1 & L0s
+for ep in c4:00.1 00:08.2 c5:00.0 c5:00.1; do
+       ENDPOINT="$ep"
+       enable_aspm_byte $ENDPOINT
+done
+
+ASPM_SETTING=2 # L1 only
+for ep in 00:02.2 00:03.1 00:04.1 02:00.0 ; do
+       ENDPOINT="$ep"
+       enable_aspm_byte $ENDPOINT
+done
+
 echo

As a result I can consistently idle without apps open on the GNOME desktop at around 4.2 W/h, better than stock but I think this can still be further driven down with other tweaks..

Keyboard case

Having the keyboard plugged in while doing nothing seems to draw:

s2idle

Closing the "lid" with keyboard case connected without shutting down / otherwise triggering "suspend" on my end seems to drain at ~279 mW/h (or ~0.55%/h) so from 80% charge limit it would last just about 6 days, or about 7½ days from 100%. Would be interested to hear if this is in line with what others are seeing including on Windows with modern standby (perhaps that can also be tweaked to work better somehow?).

Waking up from s2idle (suspend) also seems to make the device draw ~300 mW/h more than before, I haven't tracked down yet what exactly this comes down to though; perhaps some ASPM configuration getting undone despite lspci -v not reporting so? -> check without any ASPM tweaking if this is still the case

Powered-off drain

It seems to have drained ~88 mW/h (or ~0.17%/h) so it should at least last just over 19 days fully shut down from 80% or nearly 24 days from 100%. I measured the energy Wh level from upower -d just before shutdown and just after booting after 8 hours, may not be the most accurate way since the device spends some power booting off/on after/before between those two invocations to check the current battery Wh level so this is likely a worst case scenario with some inaccuracy and it should be slightly better maybe.

digital-cowboy-91 commented 1 week ago

Hi mate, this is quite interesting insight, thank you for that. I am wondering what distro are you on? When I suspend the tablet on Fedora 40, it drains almost 50% of battery in like 24h, which is quite wild.