Skip to content

Commit

Permalink
tree: Force CPU to highest possible OPP, remove Gameplay CPU gov toggle
Browse files Browse the repository at this point in the history
Previously Encore Tweaks only set governor to performance to achive highest CPU frequency.
bus as more user come to try this module, we had a lot feedback about CPU frequency gets
throttle down by userspace thermal service even with performance as CPU governor. this is the
only choice we left with.

Signed-off-by: Rem01Gaming <[email protected]>
  • Loading branch information
Rem01Gaming committed Nov 16, 2024
1 parent 1a2b601 commit 389bdb1
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 75 deletions.
2 changes: 2 additions & 0 deletions gamelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ com.GameCoaster.ProtectDungeon
com.HoYoverse.Nap
com.HoYoverse.hkrpgoversea
com.PigeonGames.Phigros
com.ProjectMoon.LimbusCompany
com.Psyonix.RL2D
com.RoamingStar.BlueArchive
com.Shooter.ModernWarship
Expand Down Expand Up @@ -90,6 +91,7 @@ com.epsxe.ePSXe
com.fantablade.icey
com.farlightgames.igame.gp
com.feralinteractive.gridas
com.firewick.p42.bilibili
com.firsttouchgames.dls7
com.futuremark.dmandroid.application
com.gabama.monopostolite
Expand Down
1 change: 0 additions & 1 deletion module/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ ui_print "- Encore Tweaks configuration setup"
unzip -o "$ZIPFILE" 'encore_logo.png' -d "/data/local/tmp" >&2
unzip -o "$ZIPFILE" 'gamelist.txt' -d "/data/encore" >&2
[ ! -f /data/encore/kill_logd ] && echo 0 >/data/encore/kill_logd
[ ! -f /data/encore/perf_cpu_gov ] && echo performance >/data/encore/perf_cpu_gov

# Bellavita Toast
if ! pm list packages | grep -q bellavita.toast; then
Expand Down
41 changes: 20 additions & 21 deletions src/scripts/encore-normal
Original file line number Diff line number Diff line change
Expand Up @@ -73,39 +73,38 @@ for path in /sys/class/devfreq/mmc*; do
apply simple_ondemand $path/governor
done &

# CPU governor
# Restore min CPU frequency
for path in /sys/devices/system/cpu/cpufreq/policy*; do
apply "$default_cpu_gov" "$path/scaling_governor"
done &
apply 1 /sys/devices/system/cpu/cpu1/online

if [ -d /proc/ppm ]; then
cluster=0
for path in /sys/devices/system/cpu/cpufreq/policy*; do
cpu_maxfreq=$(cat $path/cpuinfo_max_freq)
cpu_minfreq=$(cat $path/cpuinfo_min_freq)
apply "$cluster $cpu_maxfreq" /proc/ppm/policy/hard_userlimit_max_cpu_freq
apply "$cluster $cpu_minfreq" /proc/ppm/policy/hard_userlimit_min_cpu_freq
((cluster++))
done
else
for path in /sys/devices/system/cpu/*/cpufreq; do
cpu_maxfreq=$(cat $path/cpuinfo_max_freq)
cpu_minfreq=$(cat $path/cpuinfo_min_freq)
apply "$cpu_maxfreq" $path/scaling_max_freq
apply "$cpu_minfreq" $path/scaling_min_freq
done
change_permission 644 /sys/devices/virtual/thermal/thermal_message/cpu_limits
fi

# I/O Tweaks
for queue in /sys/block/mmcblk0/queue /sys/block/mmcblk1/queue /sys/block/sd*/queue; do
# Fallback to latency friendly
apply 128 "$queue/read_ahead_kb"
done &

mediatek_tweak() {
# Restore min CPU frequency
if [ -d /proc/ppm ]; then
cluster=0
for path in /sys/devices/system/cpu/cpufreq/policy*; do
cpu_maxfreq=$(cat $path/cpuinfo_max_freq)
cpu_minfreq=$(cat $path/cpuinfo_min_freq)
apply "$cluster $cpu_maxfreq" /proc/ppm/policy/hard_userlimit_max_cpu_freq
apply "$cluster $cpu_minfreq" /proc/ppm/policy/hard_userlimit_min_cpu_freq
((cluster++))
done
else
for path in /sys/devices/system/cpu/*/cpufreq; do
cpu_maxfreq=$(cat $path/cpuinfo_max_freq)
cpu_minfreq=$(cat $path/cpuinfo_min_freq)
apply "$cpu_maxfreq" $path/scaling_max_freq
apply "$cpu_minfreq" $path/scaling_min_freq
done
change_permission 644 /sys/devices/virtual/thermal/thermal_message/cpu_limits
fi

# PPM throttle
if [ -f /proc/ppm/policy_status ]; then
policy_file="/proc/ppm/policy_status"
Expand Down
43 changes: 21 additions & 22 deletions src/scripts/encore-performance
Original file line number Diff line number Diff line change
Expand Up @@ -68,39 +68,38 @@ for path in /sys/class/devfreq/mmc*; do
apply performance $path/governor
done &

# CPU governor
# Force CPU to highest possible OPP
for path in /sys/devices/system/cpu/cpufreq/policy*; do
apply "$(cat /data/encore/perf_cpu_gov)" "$path/scaling_governor"
apply performance "$path/scaling_governor"
done &
apply 1 /sys/devices/system/cpu/cpu1/online

if [ -d /proc/ppm ]; then
cluster=0
for path in /sys/devices/system/cpu/cpufreq/policy*; do
cpu_maxfreq=$(cat $path/cpuinfo_max_freq)
apply "$cluster $cpu_maxfreq" /proc/ppm/policy/hard_userlimit_max_cpu_freq
apply "$cluster $cpu_maxfreq" /proc/ppm/policy/hard_userlimit_min_cpu_freq
((cluster++))
done
else
change_permission 644 /sys/devices/virtual/thermal/thermal_message/cpu_limits
for path in /sys/devices/system/cpu/*/cpufreq; do
cpu_maxfreq=$(cat $path/cpuinfo_max_freq)
apply "$cpu_maxfreq" $path/scaling_max_freq
apply "$cpu_maxfreq" $path/scaling_min_freq
apply "cpu$(awk '{print $1}' $path/affected_cpus) $cpu_maxfreq" /sys/devices/virtual/thermal/thermal_message/cpu_limits
done
change_permission 000 /sys/devices/virtual/thermal/thermal_message/cpu_limits
fi

# I/O Tweaks
for queue in /sys/block/mmcblk0/queue /sys/block/mmcblk1/queue /sys/block/sd*/queue; do
# Most games nowadays have big assets that requires more throughput
apply 312 "$queue/read_ahead_kb"
done &

mediatek_tweak() {
# Force CPU to highest possible OPP
if [ -d /proc/ppm ]; then
cluster=0
for path in /sys/devices/system/cpu/cpufreq/policy*; do
cpu_maxfreq=$(cat $path/cpuinfo_max_freq)
apply "$cluster $cpu_maxfreq" /proc/ppm/policy/hard_userlimit_max_cpu_freq
apply "$cluster $cpu_maxfreq" /proc/ppm/policy/hard_userlimit_min_cpu_freq
((cluster++))
done
else
change_permission 644 /sys/devices/virtual/thermal/thermal_message/cpu_limits
for path in /sys/devices/system/cpu/*/cpufreq; do
cpu_maxfreq=$(cat $path/cpuinfo_max_freq)
apply "$cpu_maxfreq" $path/scaling_max_freq
apply "$cpu_maxfreq" $path/scaling_min_freq
apply "cpu$(awk '{print $1}' $path/affected_cpus) $cpu_maxfreq" /sys/devices/virtual/thermal/thermal_message/cpu_limits
done
change_permission 000 /sys/devices/virtual/thermal/thermal_message/cpu_limits
fi

# PPM throttle
if [ -f /proc/ppm/policy_status ]; then
policy_file="/proc/ppm/policy_status"
Expand Down
6 changes: 0 additions & 6 deletions src/webui/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ <h2 class="text-lg font-semibold mb-4">Settings</h2>
<option value="powersave" selected>powersave</option>
</select>
</div>
<div class="flex items-center justify-between mb-3">
<p class="text-sm text-white">Gameplay CPU Governor</p>
<select id="cpuGovernorPerf" class="bg-gray-700 text-xs text-white border-none outline-none shadow-none rounded-md p-2">
<option value="performance" selected>performance</option>
</select>
</div>
<div class="flex items-center justify-between mb-3">
<p class="text-sm text-white">Edit Gamelist</p>
<button id="editGamelistButton" class="bg-gray-700 hover:bg-gray-600 text-sm text-white py-1 px-10 rounded-md">Edit</button>
Expand Down
28 changes: 3 additions & 25 deletions src/webui/src/webui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function toggleKillLogdSwitch(isChecked) {
if (isChecked) {
const command = 'encore-utils set_kill_logd 1';
} else {
toast('Reboot to take effect');
toast('Reboot your device to take effect');
const command = 'encore-utils set_kill_logd 0';
}
await exec(command);
Expand All @@ -60,11 +60,6 @@ async function changeCPUGovernor(governor) {
await exec(command);
}

async function changePerfCPUGovernor(governor) {
const command = 'encore-utils set_perf_cpugov ' + governor;
await exec(command);
}

async function changePowersaveCPUGovernor(governor) {
const command = 'encore-utils set_powersave_cpugov ' + governor;
await exec(command);
Expand All @@ -75,12 +70,10 @@ async function populateCPUGovernors() {
if (govErrno === 0) {
const governors = govStdout.trim().split(/\s+/);
const selectElement1 = document.getElementById('cpuGovernor');
const selectElement2 = document.getElementById('cpuGovernorPerf');
const selectElement3 = document.getElementById('cpuGovernorPowersave');
const selectElement2 = document.getElementById('cpuGovernorPowersave');

selectElement1.innerHTML = '';
selectElement2.innerHTML = '';
selectElement3.innerHTML = '';

governors.forEach(gov => {
const option1 = document.createElement('option');
Expand All @@ -92,11 +85,6 @@ async function populateCPUGovernors() {
option2.value = gov;
option2.textContent = gov;
selectElement2.appendChild(option2);

const option3 = document.createElement('option');
option3.value = gov;
option3.textContent = gov;
selectElement3.appendChild(option3);
});

const { errno: defaultErrno, stdout: defaultStdout } = await exec('encore-utils get_default_cpugov');
Expand All @@ -105,16 +93,10 @@ async function populateCPUGovernors() {
selectElement1.value = defaultGovernor;
}

const { errno: perfErrno, stdout: perfStdout } = await exec('encore-utils get_perf_cpugov');
if (perfErrno === 0) {
const defaultPerfGovernor = perfStdout.trim();
selectElement2.value = defaultPerfGovernor;
}

const { errno: powersaveErrno, stdout: powersaveStdout } = await exec('encore-utils get_powersave_cpugov');
if (powersaveErrno === 0) {
const defaultPowersaveGovernor = powersaveStdout.trim();
selectElement3.value = defaultPowersaveGovernor;
selectElement2.value = defaultPowersaveGovernor;
}
}
}
Expand Down Expand Up @@ -166,10 +148,6 @@ document.addEventListener('DOMContentLoaded', async (event) => {
await toggleKillLogdSwitch(this.checked);
});

document.getElementById('cpuGovernorPerf').addEventListener('change', async function() {
await changePerfCPUGovernor(this.value);
});

document.getElementById('cpuGovernorPowersave').addEventListener('change', async function() {
await changePowersaveCPUGovernor(this.value);
});
Expand Down

0 comments on commit 389bdb1

Please sign in to comment.