Add support for setting "Platform Profile" (#752)
* Add support for setting "Platform Profile" * Add reference for Platform Profile
This commit is contained in:
parent
42a1239068
commit
7ac55199f2
12
README.md
12
README.md
|
@ -303,6 +303,12 @@ governor = performance
|
||||||
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
|
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
|
||||||
energy_performance_preference = performance
|
energy_performance_preference = performance
|
||||||
|
|
||||||
|
# Platform Profiles
|
||||||
|
# https://www.kernel.org/doc/html/latest/userspace-api/sysfs-platform_profile.html
|
||||||
|
# See available options by running:
|
||||||
|
# cat /sys/firmware/acpi/platform_profile_choices
|
||||||
|
# platform_profile = performance
|
||||||
|
|
||||||
# minimum cpu frequency (in kHz)
|
# minimum cpu frequency (in kHz)
|
||||||
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
|
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
|
||||||
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
|
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
|
||||||
|
@ -327,6 +333,12 @@ governor = powersave
|
||||||
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
|
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
|
||||||
energy_performance_preference = power
|
energy_performance_preference = power
|
||||||
|
|
||||||
|
# Platform Profiles
|
||||||
|
# https://www.kernel.org/doc/html/latest/userspace-api/sysfs-platform_profile.html
|
||||||
|
# See available options by running:
|
||||||
|
# cat /sys/firmware/acpi/platform_profile_choices
|
||||||
|
# platform_profile = low-power
|
||||||
|
|
||||||
# minimum cpu frequency (in kHz)
|
# minimum cpu frequency (in kHz)
|
||||||
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
|
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
|
||||||
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
|
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
|
||||||
|
|
|
@ -7,6 +7,12 @@ governor = performance
|
||||||
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
|
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
|
||||||
energy_performance_preference = performance
|
energy_performance_preference = performance
|
||||||
|
|
||||||
|
# Platform Profiles
|
||||||
|
# https://www.kernel.org/doc/html/latest/userspace-api/sysfs-platform_profile.html
|
||||||
|
# See available options by running:
|
||||||
|
# cat /sys/firmware/acpi/platform_profile_choices
|
||||||
|
# platform_profile = performance
|
||||||
|
|
||||||
# minimum cpu frequency (in kHz)
|
# minimum cpu frequency (in kHz)
|
||||||
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
|
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
|
||||||
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
|
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
|
||||||
|
@ -31,6 +37,12 @@ governor = powersave
|
||||||
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
|
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
|
||||||
energy_performance_preference = power
|
energy_performance_preference = power
|
||||||
|
|
||||||
|
# Platform Profiles
|
||||||
|
# https://www.kernel.org/doc/html/latest/userspace-api/sysfs-platform_profile.html
|
||||||
|
# See available options by running:
|
||||||
|
# cat /sys/firmware/acpi/platform_profile_choices
|
||||||
|
# platform_profile = low-power
|
||||||
|
|
||||||
# minimum cpu frequency (in kHz)
|
# minimum cpu frequency (in kHz)
|
||||||
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
|
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
|
||||||
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
|
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
|
||||||
|
|
|
@ -476,6 +476,15 @@ def set_frequencies():
|
||||||
# set the frequency
|
# set the frequency
|
||||||
run(f"cpufreqctl.auto-cpufreq {frequency[freq_type]['cmdargs']} --set={frequency[freq_type]['value']}", shell=True)
|
run(f"cpufreqctl.auto-cpufreq {frequency[freq_type]['cmdargs']} --set={frequency[freq_type]['value']}", shell=True)
|
||||||
|
|
||||||
|
def set_platform_profile(conf, profile):
|
||||||
|
if conf.has_option(profile, "platform_profile"):
|
||||||
|
if not Path("/sys/firmware/acpi/platform_profile").exists():
|
||||||
|
print('Not setting Platform Profile (not supported by system)')
|
||||||
|
else:
|
||||||
|
pp = conf[profile]["platform_profile"]
|
||||||
|
print(f'Setting to use: "{pp}" Platform Profile')
|
||||||
|
run(f"cpufreqctl.auto-cpufreq --pp --set={pp}", shell=True)
|
||||||
|
|
||||||
def set_powersave():
|
def set_powersave():
|
||||||
conf = config.get_config()
|
conf = config.get_config()
|
||||||
gov = conf["battery"]["governor"] if conf.has_option("battery", "governor") else AVAILABLE_GOVERNORS_SORTED[-1]
|
gov = conf["battery"]["governor"] if conf.has_option("battery", "governor") else AVAILABLE_GOVERNORS_SORTED[-1]
|
||||||
|
@ -503,6 +512,7 @@ def set_powersave():
|
||||||
run("cpufreqctl.auto-cpufreq --epp --set=balance_power", shell=True)
|
run("cpufreqctl.auto-cpufreq --epp --set=balance_power", shell=True)
|
||||||
print('Setting to use: "balance_power" EPP')
|
print('Setting to use: "balance_power" EPP')
|
||||||
|
|
||||||
|
set_platform_profile(conf, "battery")
|
||||||
set_frequencies()
|
set_frequencies()
|
||||||
|
|
||||||
cpuload, load1m= get_load()
|
cpuload, load1m= get_load()
|
||||||
|
@ -608,6 +618,8 @@ def set_performance():
|
||||||
else:
|
else:
|
||||||
run("cpufreqctl.auto-cpufreq --epp --set=balance_performance", shell=True)
|
run("cpufreqctl.auto-cpufreq --epp --set=balance_performance", shell=True)
|
||||||
print('Setting to use: "balance_performance" EPP')
|
print('Setting to use: "balance_performance" EPP')
|
||||||
|
|
||||||
|
set_platform_profile(conf, "charger")
|
||||||
set_frequencies()
|
set_frequencies()
|
||||||
|
|
||||||
cpuload, load1m = get_load()
|
cpuload, load1m = get_load()
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
VERSION='20'
|
VERSION='20'
|
||||||
cpucount=`cat /proc/cpuinfo | grep processor | wc -l`
|
cpucount=`cat /proc/cpuinfo | grep processor | wc -l`
|
||||||
FLROOT=/sys/devices/system/cpu
|
FLROOT=/sys/devices/system/cpu
|
||||||
|
FWROOT=/sys/firmware
|
||||||
DRIVER=auto
|
DRIVER=auto
|
||||||
VERBOSE=0
|
VERBOSE=0
|
||||||
|
|
||||||
|
@ -263,6 +264,16 @@ case $OPTION in
|
||||||
set_energy_performance_preference
|
set_energy_performance_preference
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
-p|--pp)
|
||||||
|
if [ ! -z $AVAILABLE ]; then cat $FWROOT/acpi/platform_profile_choices
|
||||||
|
elif [ -z $VALUE ]; then
|
||||||
|
verbose "Getting Platform Profile"
|
||||||
|
cat $FWROOT/acpi/platform_profile
|
||||||
|
else
|
||||||
|
verbose "Getting Platform Profile to "$VALUE
|
||||||
|
echo $VALUE > $FWROOT/acpi/platform_profile
|
||||||
|
fi
|
||||||
|
;;
|
||||||
-f|--frequency)
|
-f|--frequency)
|
||||||
if [ ! -z $AVAILABLE ]; then cat $FLROOT/cpu0/cpufreq/scaling_available_frequencies
|
if [ ! -z $AVAILABLE ]; then cat $FLROOT/cpu0/cpufreq/scaling_available_frequencies
|
||||||
elif [ -z $VALUE ]; then
|
elif [ -z $VALUE ]; then
|
||||||
|
|
Loading…
Reference in New Issue