Skip to content

Add Mali GPU power_policy sysfs on other SoC profiles#129

Merged
Rem01Gaming merged 1 commit into
Rem01Gaming:mainfrom
Neebe3289:main
Jun 21, 2026
Merged

Add Mali GPU power_policy sysfs on other SoC profiles#129
Rem01Gaming merged 1 commit into
Rem01Gaming:mainfrom
Neebe3289:main

Conversation

@Neebe3289

@Neebe3289 Neebe3289 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Implement sysfs handling for Mali GPU power_policy across platforms.

  • MediaTek: Add power_policy sysfs handling with adaptive fallbacks.
  • Exynos: Align power_policy handling in powersave profile using native mali_sysfs lookup.
  • Tensor: Add power_policy handling, make same as other profiles.

@Rem01Gaming Rem01Gaming left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good commit but since the power_policy are not MediaTek specific only but every chipset that uses Mali GPU, might as well we add it to other SoC like tensor.

@Neebe3289

Copy link
Copy Markdown
Contributor Author

Good commit but since the power_policy are not MediaTek specific only but every chipset that uses Mali GPU, might as well we add it to other SoC like tensor.

Fair point. I've also double-checked several tensor kernel sources and confirmed had same power_policy node. Will update tensor profiles functions to include this as well if you want. Thanks for feedback!"

@Rem01Gaming Rem01Gaming changed the title add mali gpu power_policy sysfs on mediatek profiles Add Mali GPU power_policy sysfs on other SoC profiles Jun 19, 2026
@Rem01Gaming

Copy link
Copy Markdown
Owner

Yup let's do it

@Neebe3289 Neebe3289 force-pushed the main branch 2 times, most recently from 838452d to 8cafd6d Compare June 19, 2026 10:52
@Neebe3289 Neebe3289 changed the title Add Mali GPU power_policy sysfs on other SoC profiles Overhaul Mali GPU sysfs on other SoC profiles Jun 19, 2026
@Neebe3289

Copy link
Copy Markdown
Contributor Author

Yup let's do it

feel free to check and feedback sir

@Rem01Gaming Rem01Gaming left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some particular changes that I didn't like, however MediaTek profile changes seems clean.

More context on /sys/kernel/gpu: As far as my knowing, this are Samsung only sysfs and based on SoC it can do different things, in Exynos they act as the primary frequency settings, however in MediaTek they simply exist as read only sysfs (GED_SKI).

Additionally, you may need to get more careful when using other modules as reference, especially on modules that primary use are performance slash gaming. They tend to have questionable code and tweaks which exactly what Encore Tweaks trying to eliminate.

Comment thread scripts/encore_profiler.sh Outdated
Comment on lines +396 to +445
# GPU Frequency
gpu_path=$(find /sys/devices/platform/ -type d -iname "*.mali" -print -quit 2>/dev/null)
[ -n "$gpu_path" ] && {
max_freq=$(which_maxfreq "$gpu_path/available_frequencies")
apply "$max_freq" "$gpu_path/scaling_max_freq"
# GPU Frequency & Power Policy
for gpu_path in $(find /sys/devices/platform/ -type d -iname "*.mali" 2>/dev/null) /sys/kernel/gpu; do
[ -d "$gpu_path" ] && {
# Check if 'performance' policy is supported, otherwise fallback to 'always_on'
if grep -q "performance" "$gpu_path/power_policy" 2>/dev/null; then
apply performance "$gpu_path/power_policy"
else
apply always_on "$gpu_path/power_policy"
fi

if [ $LITE_MODE -eq 0 ]; then
apply "$max_freq" "$gpu_path/scaling_min_freq"
else
min_freq=$(which_minfreq "$gpu_path/available_frequencies")
apply "$min_freq" "$gpu_path/scaling_min_freq"
fi
}
# Get available frequency node
freq_node=""
if [ -f "$gpu_path/gpu_available_frequencies" ]; then
freq_node="$gpu_path/gpu_available_frequencies"
elif [ -f "$gpu_path/gpu_freq_table" ]; then
freq_node="$gpu_path/gpu_freq_table"
elif [ -f "$gpu_path/available_frequencies" ]; then
freq_node="$gpu_path/available_frequencies"
fi

if [ -n "$freq_node" ]; then
max_freq=$(which_maxfreq "$freq_node")
if [ -n "$max_freq" ]; then
apply "$max_freq" "$gpu_path/gpu_max_clock"
apply "$max_freq" "$gpu_path/max_freq"
apply "$max_freq" "$gpu_path/scaling_max_freq"

if [ $LITE_MODE -eq 0 ]; then
apply "$max_freq" "$gpu_path/gpu_min_clock"
apply "$max_freq" "$gpu_path/min_freq"
apply "$max_freq" "$gpu_path/scaling_min_freq"
else
min_freq=$(which_minfreq "$freq_node")
if [ -n "$min_freq" ]; then
apply "$min_freq" "$gpu_path/gpu_min_clock"
apply "$min_freq" "$gpu_path/min_freq"
apply "$min_freq" "$gpu_path/scaling_min_freq"
fi
fi
fi
fi
}
done

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/sys/kernel/gpu is Samsung specific only, and current changes actually adds a lot of unnecessary checks that would be useless for Tensor slash Google Pixel devices.

You could simply just add a write the power_policy without over-complicating the current profile script.

Comment thread scripts/encore_profiler.sh Outdated
Comment on lines +564 to +577
exynos_normal() {
# GPU Frequency
gpu_path="/sys/kernel/gpu"
[ -d "$gpu_path" ] && {
max_freq=$(which_maxfreq "$gpu_path/gpu_available_frequencies")
min_freq=$(which_minfreq "$gpu_path/gpu_available_frequencies")
write "$max_freq" "$gpu_path/gpu_max_clock"
write "$min_freq" "$gpu_path/gpu_min_clock"
}
# GPU Frequency & Power Policy
for gpu_path in $(find /sys/devices/platform/ -type d -iname "*.mali" 2>/dev/null) /sys/kernel/gpu; do
[ -d "$gpu_path" ] && {
apply coarse_demand "$gpu_path/power_policy"

mali_sysfs=$(find /sys/devices/platform/ -iname "*.mali" -print -quit 2>/dev/null)
apply coarse_demand "$mali_sysfs/power_policy"
max_freq=$(which_maxfreq "$gpu_path/gpu_available_frequencies")
min_freq=$(which_minfreq "$gpu_path/gpu_available_frequencies")
if [ -n "$max_freq" ] && [ -n "$min_freq" ]; then
write "$max_freq" "$gpu_path/gpu_max_clock"
write "$min_freq" "$gpu_path/gpu_min_clock"
fi
}
done

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to change this code style, it technically not wrong but just not clean and overall unnecessary change imo.

Comment thread scripts/encore_profiler.sh Outdated
Comment on lines +594 to +629
# GPU Frequency & Power Policy
for gpu_path in $(find /sys/devices/platform/ -type d -iname "*.mali" 2>/dev/null) /sys/kernel/gpu; do
[ -d "$gpu_path" ] && {
# Check if 'interactive' policy is supported, otherwise revert to 'coarse_demand'
if grep -q "interactive" "$gpu_path/power_policy" 2>/dev/null; then
apply interactive "$gpu_path/power_policy"
else
apply coarse_demand "$gpu_path/power_policy"
fi

# Get available frequency node
freq_node=""
if [ -f "$gpu_path/gpu_available_frequencies" ]; then
freq_node="$gpu_path/gpu_available_frequencies"
elif [ -f "$gpu_path/gpu_freq_table" ]; then
freq_node="$gpu_path/gpu_freq_table"
elif [ -f "$gpu_path/available_frequencies" ]; then
freq_node="$gpu_path/available_frequencies"
fi

if [ -n "$freq_node" ]; then
max_freq=$(which_maxfreq "$freq_node")
min_freq=$(which_minfreq "$freq_node")

if [ -n "$max_freq" ] && [ -n "$min_freq" ]; then
write "$max_freq" "$gpu_path/gpu_max_clock"
write "$max_freq" "$gpu_path/max_freq"
write "$max_freq" "$gpu_path/scaling_max_freq"

write "$min_freq" "$gpu_path/gpu_min_clock"
write "$min_freq" "$gpu_path/min_freq"
write "$min_freq" "$gpu_path/scaling_min_freq"
fi
fi
}
done

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue with previous tensor profile change.

Comment thread scripts/encore_profiler.sh Outdated
Comment on lines +686 to +702
# GPU Frequency & Power Policy
for gpu_path in $(find /sys/devices/platform/ -type d -iname "*.mali" 2>/dev/null) /sys/kernel/gpu; do
[ -d "$gpu_path" ] && {
# Fallback to 'coarse_demand' if 'adaptive' policy is unsupported
if grep -q "adaptive" "$gpu_path/power_policy" 2>/dev/null; then
apply adaptive "$gpu_path/power_policy"
else
apply coarse_demand "$gpu_path/power_policy"
fi

min_freq=$(which_minfreq "$gpu_path/gpu_available_frequencies")
if [ -n "$min_freq" ]; then
apply "$min_freq" "$gpu_path/gpu_min_clock"
apply "$min_freq" "$gpu_path/gpu_max_clock"
fi
}
done

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue with previous exynos profile change.

Comment thread scripts/encore_profiler.sh Outdated
Comment on lines +712 to +747
# GPU Frequency & Power Policy
for gpu_path in $(find /sys/devices/platform/ -type d -iname "*.mali" 2>/dev/null) /sys/kernel/gpu; do
[ -d "$gpu_path" ] && {
# Fallback check: 'powersave' -> 'adaptive' -> 'coarse_demand'
if grep -q "powersave" "$gpu_path/power_policy" 2>/dev/null; then
apply powersave "$gpu_path/power_policy"
elif grep -q "adaptive" "$gpu_path/power_policy" 2>/dev/null; then
apply adaptive "$gpu_path/power_policy"
else
apply coarse_demand "$gpu_path/power_policy"
fi

# Get available frequency node
freq_node=""
if [ -f "$gpu_path/gpu_available_frequencies" ]; then
freq_node="$gpu_path/gpu_available_frequencies"
elif [ -f "$gpu_path/gpu_freq_table" ]; then
freq_node="$gpu_path/gpu_freq_table"
elif [ -f "$gpu_path/available_frequencies" ]; then
freq_node="$gpu_path/available_frequencies"
fi

if [ -n "$freq_node" ]; then
min_freq=$(which_minfreq "$freq_node")
if [ -n "$min_freq" ]; then
apply "$min_freq" "$gpu_path/gpu_min_clock"
apply "$min_freq" "$gpu_path/min_freq"
apply "$min_freq" "$gpu_path/scaling_min_freq"

apply "$min_freq" "$gpu_path/gpu_max_clock"
apply "$min_freq" "$gpu_path/max_freq"
apply "$min_freq" "$gpu_path/scaling_max_freq"
fi
fi
}
done

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue with previous tensor profile change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aye, lemme revert and improve that

@Rem01Gaming Rem01Gaming added the enhancement New feature or request label Jun 19, 2026
@Neebe3289 Neebe3289 changed the title Overhaul Mali GPU sysfs on other SoC profiles Add Mali GPU power_policy sysfs on other SoC profiles Jun 19, 2026
@Neebe3289

Copy link
Copy Markdown
Contributor Author

Already rewritten, feel free to check it 🙌

@Rem01Gaming Rem01Gaming left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if there's performance, powersave, nor interactive policy, let's assume available power_policy to only always_on, adaptive, and coarse_demand.

I can't confirm this because I don't have other device beside my Realme C25 which also have Mali GPU.

Since adaptive is the default policy on my device, I think it might be more suitable for general use and coarse_demand for powersaving usecases. You can update the policies used for each profiles.

…forms

Implement sysfs handling for Mali GPU power_policy across platforms.

- MediaTek: Add power_policy sysfs handling with adaptive fallbacks.
- Exynos: Align power_policy handling in powersave profile using native mali_sysfs lookup.
- Tensor: Add power_policy handling, make same as other profiles.

Change-Id: I3f40892b77c067c10e3bf3acace0d5258217e9a0
@Neebe3289

Copy link
Copy Markdown
Contributor Author

I'm not sure if there's performance, powersave, nor interactive policy, let's assume available power_policy to only always_on, adaptive, and coarse_demand.

I can't confirm this because I don't have other device beside my Realme C25 which also have Mali GPU.

Since adaptive is the default policy on my device, I think it might be more suitable for general use and coarse_demand for powersaving usecases. You can update the policies used for each profiles.

Ya, Since we don't have enough Tensor device on hand or lack information to safely test and verify vendor-specific policies (which might trigger kernel rejections on some setups), so sticking to always_on, adaptive, and coarse_demand for now. 👍

@Rem01Gaming Rem01Gaming merged commit 596f073 into Rem01Gaming:main Jun 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants