Working through some gpu profile and battery life improvements.

This commit is contained in:
fewtarius 2023-06-23 10:57:57 +00:00
parent 021933765e
commit 171c2a372f
No known key found for this signature in database
GPG key ID: F4AE55305D1B8C1A
8 changed files with 123 additions and 33 deletions

View file

@ -42,6 +42,13 @@ then
set_setting system.cpugovernor schedutil
fi
### Set the default GPU performance mode
GPUPERF=$(get_setting system.gpuperf)
if [ -n "${GPUPERF}" ]
then
gpu_performance_level ${GPUPERF}
fi
### Configure suspend mode.
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -n "${MYSLEEPMODE}" ]

View file

@ -135,14 +135,10 @@ then
fi
GPUPERF=$(get_setting "gpuperf" "${PLATFORM}" "${ROMNAME##*/}")
if [ ! "${GPUPERF}" = "system" ] && \
[ ! -z "${GPUPERF}" ]
if [ ! -z ${GPUPERF} ]
then
if [ ! "${GPUPERF}" = "default" ]
then
echo "${GPUPERF}" >/tmp/.gpuperf
systemctl restart powerstate
fi
gpu_performance_level ${GPUPERF}
get_gpu_performance_level >/tmp/.gpu_performance_level
fi
if [ "${DEVICE_HAS_FAN}" = "true" ]
@ -466,12 +462,14 @@ then
fi
fi
### Remove GPU performance helper
if [ -e "/tmp/.gpuperf" ]
GPUPERF=$(get_setting "system.gpuperf")
if [ ! -z ${GPUPERF} ]
then
rm -f /tmp/.gpuperf
systemctl restart powerstate
gpu_performance_level ${GPUPERF}
else
gpu_performance_level auto
fi
rm -f /tmp/.gpu_performance_level 2>/dev/null
### Backup save games
CLOUD_BACKUP=$(get_setting "cloud.backup")

View file

@ -0,0 +1,88 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2022-present Fewtarius (https://github.com/fewtarius)
get_gpu_power_profile() {
cat /sys/class/drm/card0/device/power_dpm_state 2>/dev/null
}
gpu_power_profile() {
for card in /sys/class/drm/card*/device/power_dpm_state
do
if [ -e "${card}" ]
then
echo ${1} >${card} 2>/dev/null
fi
done
}
get_gpu_performance_level() {
cat /sys/class/drm/card0/device/power_dpm_force_performance_level 2>/dev/null
}
gpu_performance_level() {
for card in /sys/class/drm/card*/device/power_dpm_force_performance_level
do
if [ -e "${card}" ]
then
echo ${1} >${card} 2>/dev/null
fi
done
}
pcie_aspm_policy() {
if [ -e "/sys/module/pcie_aspm/parameters/policy" ]
then
echo ${1} >/sys/module/pcie_aspm/parameters/policy 2>/dev/null
fi
}
cpu_perftune() {
CPU="$(awk '/vendor_id/ {print $3;exit}' /proc/cpuinfo)"
if [ "${CPU}" = "AuthenticAMD" ]
then
if [ "${1}" = "battery" ]
then
ryzenadj --power-saving >/dev/null 2>&1
else
ryzenadj --max-performance >/dev/null 2>&1
fi
elif [ "${CPU}" = "GenuineIntel" ]
then
for policy in $(find /sys/devices/system/cpu/cpufreq/policy*/ -name energy_performance_preference)
do
if [ "${1}" = "battery" ]
then
echo power >${policy} >/dev/null 2>&1
else
echo performance >${policy} >/dev/null 2>&1
fi
done
fi
}
audio_powersave() {
for MODULE in snd_hda_intel snd_ac97_codec
do
if [ -e "/sys/module/${MODULE}/parameters/power_save" ]
then
echo ${1} >/sys/module/${MODULE}/parameters/power_save 2>/dev/null
fi
done
}
device_powersave() {
case ${1} in
1)
PSMODE=auto
;;
*)
PSMODE=on
;;
esac
find /sys/devices -name control -print0 | \
while read -r -d '' DEVICE
do
echo ${PSMODE} >"${DEVICE}" 2>/dev/null
done
}

View file

@ -20,22 +20,20 @@ do
case ${STATUS} in
Disch*)
log $0 "Switching to battery mode."
if [ -e "/tmp/.gpuperf" ]
if [ -e "/tmp/.gpu_performance_level" ]
then
GPUMODE=$(cat /tmp/.gpuperf)
GPUPROFILE=$(cat /tmp/.gpu_performance_level)
else
GPUMODE=$(get_setting system.gpuperf)
if [ -z "${GPUMODE}" ]
then
GPUMODE=auto
set_setting system.gpuperf auto
fi
GPUPROFILE=$(get_setting system.gpuperf)
fi
if [ -z "${GPUPROFILE}" ]
then
GPUPROFILE="auto"
fi
ledcontrol
audio_powersave 1
cpu_perftune battery
gpu_performance_level ${GPUMODE}
gpu_power_profile 1
gpu_performance_level ${GPUPROFILE}
pcie_aspm_policy powersave
device_powersave 1
;;
@ -44,8 +42,7 @@ do
ledcontrol
audio_powersave 0
cpu_perftune performance
gpu_performance_level profile_standard
gpu_power_profile 1
gpu_performance_level auto
pcie_aspm_policy default
device_powersave 0
;;

View file

@ -3,7 +3,7 @@
# Copyright (C) 2020-present Fewtarius
PKG_NAME="emulationstation"
PKG_VERSION="22c2c16"
PKG_VERSION="88a3a38"
PKG_GIT_CLONE_BRANCH="main"
PKG_REV="1"
PKG_ARCH="any"

View file

@ -103,7 +103,7 @@ CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
# CONFIG_NO_HZ_FULL is not set
CONFIG_NO_HZ=y
# CONFIG_NO_HZ is not set
CONFIG_HIGH_RES_TIMERS=y
CONFIG_CLOCKSOURCE_WATCHDOG_MAX_SKEW_US=100
# end of Timers subsystem

View file

@ -69,7 +69,7 @@ CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
# CONFIG_NO_HZ_FULL is not set
CONFIG_NO_HZ=y
# CONFIG_NO_HZ is not set
CONFIG_HIGH_RES_TIMERS=y
# CONFIG_PREEMPT_NONE is not set
CONFIG_PREEMPT_VOLUNTARY=y
@ -382,11 +382,11 @@ CONFIG_HOTPLUG_CPU=y
CONFIG_ARCH_NR_GPIO=256
# CONFIG_NUMA is not set
CONFIG_HOLES_IN_ZONE=y
# CONFIG_HZ_100 is not set
CONFIG_HZ_100=y
# CONFIG_HZ_250 is not set
CONFIG_HZ_300=y
# CONFIG_HZ_300 is not set
# CONFIG_HZ_1000 is not set
CONFIG_HZ=300
CONFIG_HZ=100
CONFIG_SCHED_HRTICK=y
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
CONFIG_ARCH_HAS_HOLES_MEMORYMODEL=y

View file

@ -69,7 +69,7 @@ CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
# CONFIG_NO_HZ_FULL is not set
CONFIG_NO_HZ=y
# CONFIG_NO_HZ is not set
CONFIG_HIGH_RES_TIMERS=y
# CONFIG_PREEMPT_NONE is not set
CONFIG_PREEMPT_VOLUNTARY=y
@ -382,11 +382,11 @@ CONFIG_HOTPLUG_CPU=y
CONFIG_ARCH_NR_GPIO=256
# CONFIG_NUMA is not set
CONFIG_HOLES_IN_ZONE=y
# CONFIG_HZ_100 is not set
CONFIG_HZ_100=y
# CONFIG_HZ_250 is not set
CONFIG_HZ_300=y
# CONFIG_HZ_300 is not set
# CONFIG_HZ_1000 is not set
CONFIG_HZ=300
CONFIG_HZ=100
CONFIG_SCHED_HRTICK=y
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
CONFIG_ARCH_HAS_HOLES_MEMORYMODEL=y