Downclocking or limiting i.MX8MP? (interim fix for suspend)

Is it possible to throttle the Pocket default CPU such that you could force it to use less power? If you have the display off, and the session locked, this seems like it could be a good way to help extend battery life away from the wall?

Good idea or pointless?

5 Likes

Yes, it should be possible to do some kind of pseudo suspend by forcing everything to the lowest clocks using cpufreq-set. Maybe there’s also something possible for the GPU, but haven’t looked yet. And turning off 3 of the CPU cores, and all the lights, and perhaps network interfaces.

1 Like

Yesterday I did a very quick test with things like:

  • screen off
  • turn off wifi radio
  • almost all daemons (including bluetooth and network-manager) and almost no programs running.
  • set cpu frequency to 1.2Ghz

My notes are on the Reform itself but I can not boot it right now, don´t remember if I did something else. It went from 57% to 34% in 1:30 hours, which would translate to 6:30 hours from 100% to 0%.

I did not shut down cpu cores, but I’ll try that too. Also, the user session resides on a cgroup2, so it could be completely frozen and resumed, but anyway I killed everything except for sway itself.

1 Like

Doing a quick test, putting offline 3 of the 4 cpus, does not make cpu temperature go down, so I suspect that wouldn’t make any difference neither.

1 Like

what about power draw?

Update, this is exactly what I have done, and the results are power draw in mA as given by the command sensors. The computer had no network and no ethernet cable.

Unfortunately, lowering the frequency and putting cpu cores offline do not yield a real consumption improvement, at least in this quick&dirty test.

Still, if somebody is interested in, say, putting the computer in the lowest posible comsuption mode, instead of having to shutdown it, like you don’t want to close all your programs, and you will pause your work only for some minutes, consuming 530mA is still better than nothing.

I have not tested it, but a real script would also freeze the whole user session with with something like echo 1 > /sys/fs/cgroup/user.slice/user-1000.slice/cgroup.freeze, and all the user programs whould freeze.

#!/usr/bin/env bash

# login as root

set -eu

declare -i sleep_time=2

do_test() {
        local filename
        filename="/root/test_${1}"

        echo > "${filename}"

        for i in {0..119}; do
                sleep "${sleep_time}"
                sensors >> "${filename}"
        done
}

main() {
        do_test "start"

        setterm --blank=force

        do_test "screen_blank"

        nmcli radio wifi off || true

        do_test "wifi_off"

        systemctl stop exim4.service || true
        systemctl stop bluetooth.service || true
        systemctl stop NetworkManager.service || true
        systemctl stop ntpd.service || true

        do_test "daemons_off"

        echo powersave >  /sys/devices/system/cpu/cpufreq/policy0/scaling_governor

        do_test cpu_powersave

        echo 0 > /proc/sys/kernel/nmi_watchdog

        do_test nmi_watchdog

        echo 20000 > /proc/sys/vm/dirty_writeback_centisecs

        do_test disk_writeback

        echo 0 > /sys/devices/system/cpu/cpu1/online
        echo 0 > /sys/devices/system/cpu/cpu2/online
        echo 0 > /sys/devices/system/cpu/cpu3/online

        do_test offline
}

main "${@}"

Each do_test takes 120 samples over 4 minutes, 1 sample each 2 seconds.

run 1:

base display wifi daemons off powersave nmi watchdog disk writeback cpu offline
min 612 537 537 537 537 487 487 487
max 887 662 687 737 662 662 612 637
main 698 588 579 581 585 550 540 525

run 2:

base display wifi daemons off powersave nmi watchdog disk writeback cpu offline
min 562 487 487 487 487 487 487 487
max 737 612 612 587 612 612 612 612
main 614 535 523 528 530 532 530 520
2 Likes

EDIT: Just checked, setting the maximum frequency on first cpu sets it on the other three.

1 Like

You are the on the Reform or the Pocket Reform? For me normal active running consumption is between 600-1200mA. With the norm being around 1A. So cutting power to 500mA is a doubling of battery life. Seems kind of promising.

I am on a Pocket.

I updated the tests, have extended them a bit.

1 Like

Wrote a dirty script, this is what I can expect with it on my pocket:

 05:53:33 PM CEST 2024 curr1:       812.00 mA
 05:53:39 PM CEST 2024 curr1:       687.00 mA
 05:53:44 PM CEST 2024 curr1:       462.00 mA   -> (pseudo) suspend 
 05:53:49 PM CEST 2024 curr1:       462.00 mA 
 05:53:54 PM CEST 2024 curr1:       487.00 mA 
 05:54:00 PM CEST 2024 curr1:       437.00 mA 
 05:54:05 PM CEST 2024 curr1:       437.00 mA 
 05:54:10 PM CEST 2024 curr1:       887.00 mA   -> resume
 05:54:15 PM CEST 2024 curr1:       687.00 mA 
 05:54:21 PM CEST 2024 curr1:       637.00 mA 
 05:54:26 PM CEST 2024 curr1:       612.00 mA 
 05:54:31 PM CEST 2024 curr1:       687.00 mA 
...
7 Likes

Cannot download the psuspend.conf (other two files are OK). Can you please check the permissions?

1 Like

yep, same thing here (HTTP 406 on the .conf file). Interested to try this @amospalla !

The web server does not like a “.conf” extension, renamed. Thank you for noticing @jirka and @andypiper .

3 Likes

Very cool, for me at least this should be a good interim solution until we can get proper standby working on the Pocket. And, I might be able to adapt some this to put my Pinephone into a standby mode as well.

One question though, you mentioned that the screen should go blank, but on mine the screen just freezes. Is there something else I need to do to shut off the display?

Behavior on my pocket:
pressing hyper+ctrl+1 triggers the script, network etc stops, screen freezes.
The screen does NOT black (not sure if it was supposed to?)
Everything resumes happily on repeat trigger.

If I manually black my screen first, it does seem to shave a small but noticeable portion of power usage compared to unfrozen (like 650-750a vs 800-900a)

Interestingly, while mouse input and keyboard do nothing in freeze-mode, if I press hyper+super+1 while frozen (which normally dims brightness) nothing happens until the system is unfrozen and /then/ it applies the dim. Weird! Is it buffering the command somewhere?

Earlier I messed with my input environment variables to get fcitx5 working on sway though, maybe that’s interfering somehow. I only vaguely understand input method stuff. :smiley:

Great, thanks! I need manually to blank the screen and the keyboard backlight but aside of that the script seem to work. Power consumption is reduced slightly (800->600mA) but it’s probably because I don’t use the wifi. A nice improvement anyway! Thanks once more!

@MeLikeyTacos @geodewomb, @jirka the display is shut down if either you are using swayidle (it is signaled with USR1) or you are on a terminal (setterm blanks it). I don’t know of any global way to shut down the screen. What window manager are you using and how do you blank your screen? I can try to include that too.

All processes under user sessions (as understood by cgroups) freeze, but not daemons processes. Think of running a program from a terminal and pressing Control+z, the program freezes until you put it on the foreground with fg, but for all the processes in the computer, except for the kernel and daemons. The ‘focused’ program still receives your keyboard input, but it won’t process that until unfrozen.

I have just added dimming the display to brightness 1 (to consume less power, but also to let the user know it is not really completely blanked because the script does not know how), and keyboard led blanking. The keyboard leds resume colours can be configured.

If you want to test the power consumption while pseudo-suspended, comment out the module “session_freeze_root” on the config file and run under a root ssh session a screen/tmux with something like while sleep 3; do printf "%(%H:%M:%S)T " -1; sensors | grep curr; done. Commenting out makes root sessions (including this command line) to not get frozen.

Also, if your computer hangs or runs out of battery while suspended, on next boot you will need to run nmcli networking on, else your network interfaces won’t go up. Adding something like @reboot /usr/bin/nmcli n on to your root cron would be a good idea.

2 Likes

We need a way to turn off the screen completely. At least the backlight. That is another 100m at least.

Thank you for your efforts! Muchas gracias!

It actually turns off the screen if you use swayidle or the console session is a terminal one.

De nada!

1 Like

Any tips on getting swayidle working in wayfire?

This is my idle config in wayfire.ini:

idle = swayidle before-sleep swaylock -e -i /usr/share/backgrounds/nagaeve.jpg

[idle]
screensaver_timeout = 60
dpms_timeout = 90

The screen stays on but when I undo the psuspend the screen turns immediately off. What I mean by that is that swayidle is working, as the screen does power off 30 seconds after the screensaver comes on.