2022-02-27 03:14:27 +00:00
|
|
|
#!/bin/bash
|
2022-02-05 14:23:32 +00:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
|
|
|
|
|
|
|
|
. /etc/os-release
|
|
|
|
|
2022-06-01 21:22:25 +00:00
|
|
|
|
|
|
|
set_cpu_gov() {
|
2023-01-02 20:37:06 +00:00
|
|
|
for POLICY in $(ls /sys/devices/system/cpu/cpufreq 2>/dev/null | grep policy[0-9])
|
2022-02-05 22:40:57 +00:00
|
|
|
do
|
2023-01-02 20:48:29 +00:00
|
|
|
if [ -e "/sys/devices/system/cpu/cpufreq/${POLICY}/scaling_governor" ]
|
2022-10-05 10:22:07 +00:00
|
|
|
then
|
2023-01-02 20:47:33 +00:00
|
|
|
echo $1 >/sys/devices/system/cpu/cpufreq/${POLICY}/scaling_governor 2>/dev/null
|
2022-10-05 10:22:07 +00:00
|
|
|
fi
|
2022-02-05 22:40:57 +00:00
|
|
|
done
|
2022-06-01 21:22:25 +00:00
|
|
|
}
|
2022-02-05 22:40:57 +00:00
|
|
|
|
2022-06-01 21:22:25 +00:00
|
|
|
set_dmc_gov() {
|
2022-10-05 10:22:07 +00:00
|
|
|
if [ -e "${DMC_FREQ}/governor" ]
|
|
|
|
then
|
|
|
|
echo $1 >${DMC_FREQ}/governor 2>/dev/null || echo dmc_$1 >${DMC_FREQ}/governor 2>/dev/null
|
|
|
|
fi
|
2022-06-01 21:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set_gpu_gov() {
|
2022-10-05 10:22:07 +00:00
|
|
|
if [ -e "${GPU_FREQ}/governor" ]
|
|
|
|
then
|
|
|
|
echo $1 >${GPU_FREQ}/governor 2>/dev/null || echo dmc_$1 >${GPU_FREQ}/governor 2>/dev/null
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
set_amdgpu_perf() {
|
2023-01-02 20:37:06 +00:00
|
|
|
for AMDGPU_PERF_DEVICE in $(find /sys/devices -name power_dpm_force_performance_level 2>/dev/null)
|
|
|
|
do
|
2022-10-05 10:22:07 +00:00
|
|
|
echo $1 >${AMDGPU_PERF} 2>/dev/null
|
2023-01-02 20:37:06 +00:00
|
|
|
done
|
2022-02-05 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
2022-06-01 10:56:46 +00:00
|
|
|
performance() {
|
2022-06-01 21:22:25 +00:00
|
|
|
set_cpu_gov performance
|
2022-10-05 10:22:07 +00:00
|
|
|
set_amdgpu_perf profile_peak
|
2022-06-01 21:22:25 +00:00
|
|
|
set_gpu_gov performance
|
|
|
|
set_dmc_gov performance
|
2022-02-05 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
2022-06-01 10:56:46 +00:00
|
|
|
ondemand() {
|
2022-06-01 21:22:25 +00:00
|
|
|
set_cpu_gov ondemand
|
2022-10-05 10:22:07 +00:00
|
|
|
set_amdgpu_perf auto
|
2022-06-01 21:22:25 +00:00
|
|
|
set_gpu_gov ondemand
|
|
|
|
set_dmc_gov ondemand
|
2022-02-05 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
2022-12-21 22:24:01 +00:00
|
|
|
schedutil() {
|
|
|
|
set_cpu_gov schedutil
|
2022-10-05 10:22:07 +00:00
|
|
|
set_amdgpu_perf auto
|
2022-06-01 21:22:25 +00:00
|
|
|
set_gpu_gov ondemand
|
|
|
|
set_dmc_gov ondemand
|
2022-06-01 10:56:46 +00:00
|
|
|
}
|
|
|
|
|
2022-02-05 14:23:32 +00:00
|
|
|
powersave() {
|
2022-06-01 21:22:25 +00:00
|
|
|
set_cpu_gov powersave
|
2022-10-05 10:22:07 +00:00
|
|
|
set_amdgpu_perf low
|
2022-06-01 21:22:25 +00:00
|
|
|
set_gpu_gov powersave
|
|
|
|
set_dmc_gov powersave
|
2022-02-05 14:23:32 +00:00
|
|
|
}
|