Add Mali GPU power_policy sysfs on other SoC profiles#129
Conversation
Rem01Gaming
left a comment
There was a problem hiding this comment.
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!" |
power_policy sysfs on other SoC profiles
|
Yup let's do it |
838452d to
8cafd6d
Compare
power_policy sysfs on other SoC profiles
feel free to check and feedback sir |
Rem01Gaming
left a comment
There was a problem hiding this comment.
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.
| # 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 |
There was a problem hiding this comment.
/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.
| 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 |
There was a problem hiding this comment.
I don't think we need to change this code style, it technically not wrong but just not clean and overall unnecessary change imo.
| # 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 |
There was a problem hiding this comment.
Same issue with previous tensor profile change.
| # 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 |
There was a problem hiding this comment.
Same issue with previous exynos profile change.
| # 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 |
There was a problem hiding this comment.
Same issue with previous tensor profile change.
There was a problem hiding this comment.
aye, lemme revert and improve that
power_policy sysfs on other SoC profiles
|
Already rewritten, feel free to check it 🙌 |
Rem01Gaming
left a comment
There was a problem hiding this comment.
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
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. 👍 |
Implement sysfs handling for Mali GPU power_policy across platforms.