8000 Optimizing power draw (under Linux) · Issue #5 · mudkipme/awesome-minisforum-v3 · GitHub
[go: up one dir, main page]

Skip to content
10000

Optimizing power draw (under Linux) #5

Open

Description

@JamiKettunen

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 lowest 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 the following (setting the value to 0 turns the screen back on as per https://gitlab.gnome.org/GNOME/mutter/-/blob/46.4/data/dbus-interfaces/org.gnome.Mutter.DisplayConfig.xml#L255-283):

dbus-send --session \
    --dest=org.gnome.Mutter.DisplayConfig --type=method_call \
    /org/gnome/Mutter/DisplayConfig org.freedesktop.DBus.Properties.Set \
    string:org.gnome.Mutter.DisplayConfig string:PowerSaveMode variant:int32:3

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:

  • Without backlight enabled: ~100 mW/h
  • Backlight at level 1: ~500 mW/h
  • Backlight at level 2: ~830 mW/h
  • Backlight at level 3: ~1.2 W/h
  • Backlight at level 4: ~1.6 W/h

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.

Activity

  1. digital-cowboy-91 commented on Aug 6, 2024

    @digital-cowboy-91

    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.

  2. twlswan commented on Aug 20, 2024

    @twlswan

    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.

    a bit late but havent you read the "my setup" section?

    @JamiKettunen Thanks a ton for sharing. Have you found a fix for the higher wattage after wake?

    I'd really love to get this device as it's pretty much exactly what I was looking for and even more, but that 16w consumption in idle from notebookcheck left me quite surprised, and I'm even more surprised hearing that you only saw 5 on gnome with just basic changes and 4.2 after the tweaks. The display seems very very wasteful, even more so than 2.8K oleds... What's the power draw like when the brightness is set at 50% (and refresh at 60) with 2-3 tabs of firefox open?

  3. JamiKettunen commented on Aug 30, 2024

    @JamiKettunen
    ContributorAuthor

    @digital-cowboy-91 Did you have a bunch of programs running before suspending? You may want to look into journalctl -b logs upon resume to see if something is blocking the suspend from working properly perhaps.

    @JakoDel While the display may seem wasteful I'm not sure an OLED would do much better while watching video/something else mostly non-static due to all the changing pixels instead of being pitch black and thus turned off, certainly it still was the biggest power sipper most likely thanks to the "big" display size -> large surface area backlight. A proper comparison sure would be nice where only display power draw is somehow measured under different conditions though.

    From lowest brightness to 50% it adds another ~1.4 W/h (so total 4 W/h just for display) and brings the baseline to ~5.6 W/h without programs open.

    I don't know what tabs to open since each page (with different interactivity if not idle) will produce different results: 2 static webpages will be very different from having 2 streaming sites open and playing video (or maybe even a video call on teams or whatever), but in general for video playback power consumption at least I noticed chromium is somewhat better (7 vs 8 W/h during playback) and is on track to get optimizations such as overlay DRM plane video as described in https://issues.chromium.org/issues/355605696 while firefox may not be as simple if https://gitlab.freedesktop.org/drm/amd/-/issues/3195#note_2504529 is anything to go by. Even then previously during youtube video playback it previously at least started suddenly using more power (~10 W/h total) for seemingly no reason with just the one tab open after a while.

    I've more or less paused the investigations for now but there's still certainly more to find out like which kernel modules for hardware being loaded use the most power etc which could be interesting for those who could live without them.

  4. digital-cowboy-91 commented on Aug 31, 2024

    @digital-cowboy-91

    Hi @JamiKettunen, I am not running any excessive tasks I would say. I thought docker could possibly block the suspension, but today I have find out the issue might be related to secure boot.

    I've suspended PC yesterday evening at 11:47PM and woke it up at 11:28AM. In almost 12h The battery went down by 16%. The journalctl does not show any activity between these hours, however during suspending it logged a message Lockdown: systemd-logind: hibernation is restricted; see man kernel_lockdown.7 . So the device is suspended but possibly not hibernated which I think might be the issue. By brief googling, this seems to be related to secure boot. I will turn it off tonight and see if it makes any difference.

    Would you be able to confirm if you have secure boot on?

  5. JamiKettunen commented on Aug 31, 2024

    @JamiKettunen
    ContributorAuthor

    I don't use secure boot since it would require me to manually deal with signing my bootloader, kernel image and modules, initramfs which I really can't be bothered to do at the moment. Additionally it limits ryzenadj too (though I currently don't use it)

    Afaik hibernation isn't really supported on modern laptops where s2idle could be the only choice for suspend too, but I've not looked into this much nor even created a swap partition/file to try hibernate.

  6. twlswan commented on Sep 1, 2024

    @twlswan

    @digital-cowboy-91 Did you have a bunch of programs running before suspending? You may want to look into journalctl -b logs upon resume to see if something is blocking the suspend from working properly perhaps.

    @JakoDel While the display may seem wasteful I'm not sure an OLED would do much better while watching video/something else mostly non-static due to all the changing pixels instead of being pitch black and thus turned off, certainly it still was the biggest power sipper most likely thanks to the "big" display size -> large surface area backlight. A proper comparison sure would be nice where only display power draw is somehow measured under different conditions though.

    From lowest brightness to 50% it adds another ~1.4 W/h (so total 4 W/h just for display) and brings the baseline to ~5.6 W/h without programs open.

    I don't know what tabs to open since each page (with different interactivity if not idle) will produce different results: 2 static webpages will be very different from having 2 streaming sites open and playing video (or maybe even a video call on teams or whatever), but in general for video playback power consumption at least I noticed chromium is somewhat better (7 vs 8 W/h during playback) and is on track to get optimizations such as overlay DRM plane video as described in https://issues.chromium.org/issues/355605696 while firefox may not be as simple if https://gitlab.freedesktop.org/drm/amd/-/issues/3195#note_2504529 is anything to go by. Even then previously during youtube video playback it previously at least started suddenly using more power (~10 W/h total) for seemingly no reason with just the one tab open after a while.

    I've more or less paused the investigations for now but there's still certainly more to find out like which kernel modules for hardware being loaded use the most power etc which could be interesting for those who could live without them.

    Welp I was actually trying to say that OLEDs are worse.. because in fact, they are even with dark mode enabled, and this is a common misconception. just look at notebookcheck, the redmibook 14 with a 2.8k IPS has like double the battery life of any oled laptop with the same specs.
    IPS displays are almost always more efficient, its just that this specific IPS display seemed a tad wasteful to me.

    But all good, aside from that weird 10w peak it actually looks like it has a pretty low draw, and even more optimizations are on
    the way, that's great. thanks for sharing

  7. trijpstra-fourlights commented on Sep 2, 2024

    @trijpstra-fourlights

    Thanks a lot for your findings. I've been getting much better battery life using these tweaks.

    On KDE, you can switch between 60Hz and 165Hz using the following commands:

    # Switch to 60hz
    kscreen-doctor output.1.mode.1
    
    # Switch to 165hz
    kscreen-doctor output.1.mode.0
    

    Furthermore, I've created an AUR package to help with ASPM configuration on the Minisforum V3.

    1. https://aur.archlinux.org/packages/minisforum-v3-pcie-aspm-config

    NOTE: I've assumed that the PCI enumerations are the same on all Minisforum V3. If that's not the case, then this package is obviously not useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0