# Copyright (c) 2016, Code Aurora Forum. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Code Aurora nor # the names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # on early-init # Enable sched_boost write /proc/sys/kernel/sched_boost 1 on init # Set Permissions for Power HAL chown system system /dev/stune/top-app/schedtune.boost chmod 0664 /dev/stune/top-app/schedtune.boost write /dev/stune/foreground/schedtune.sched_boost_no_override 1 write /dev/stune/top-app/schedtune.sched_boost_no_override 1 write /dev/stune/schedtune.colocate 0 write /dev/stune/background/schedtune.colocate 0 write /dev/stune/system-background/schedtune.colocate 0 write /dev/stune/foreground/schedtune.colocate 0 write /dev/stune/top-app/schedtune.colocate 1 # Disable UFS powersaving write /sys/devices/platform/soc/${ro.boot.bootdevice}/clkgate_enable 0 write /sys/devices/platform/soc/${ro.boot.bootdevice}/hibern8_on_idle_enable 0 # Disable powersaving write /sys/module/lpm_levels/parameters/sleep_disabled 1 # Bring all cores online write /sys/devices/system/cpu/cpu0/online 1 write /sys/devices/system/cpu/cpu1/online 1 write /sys/devices/system/cpu/cpu2/online 1 write /sys/devices/system/cpu/cpu3/online 1 write /sys/devices/system/cpu/cpu4/online 1 write /sys/devices/system/cpu/cpu5/online 1 write /sys/devices/system/cpu/cpu6/online 1 write /sys/devices/system/cpu/cpu7/online 1 # Configure governor settings for little cluster write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "schedutil" write /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us 500 write /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us 20000 # Configure governor settings for big cluster write /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor "schedutil" write /sys/devices/system/cpu/cpu6/cpufreq/schedutil/up_rate_limit_us 500 write /sys/devices/system/cpu/cpu6/cpufreq/schedutil/down_rate_limit_us 20000 # Set default schedTune value for foreground/top-app write /dev/stune/foreground/schedtune.prefer_idle 1 write /dev/stune/top-app/schedtune.boost 1 write /dev/stune/top-app/schedtune.prefer_idle 1 on boot # For cpusets initialize for Silver only first and then Silver + Gold # Silver only configuration cannot work with 0-7 write /dev/cpuset/top-app/cpus 0-3 write /dev/cpuset/audio-app/cpus 1-2 write /dev/cpuset/foreground/cpus 0-3 write /dev/cpuset/foreground/boost/cpus 0-3 write /dev/cpuset/background/cpus 0-3 write /dev/cpuset/system-background/cpus 0-3 write /dev/cpuset/top-app/cpus 0-7 write /dev/cpuset/foreground/cpus 0-7 write /dev/cpuset/foreground/boost/cpus 0-7 write /dev/cpuset/background/cpus 0-7 write /dev/cpuset/system-background/cpus 0-7 # Disable console_suspend to get better logging for kernel crashes write /sys/module/printk/parameters/console_suspend N on property:init.svc.vendor.charger=running setprop persist.sys.usb.config mass_storage # Keep one LITTLE and one big write /sys/devices/system/cpu/cpu1/online 0 write /sys/devices/system/cpu/cpu2/online 0 write /sys/devices/system/cpu/cpu3/online 0 write /sys/devices/system/cpu/cpu5/online 0 write /sys/devices/system/cpu/cpu6/online 0 write /sys/devices/system/cpu/cpu7/online 0 wait /dev/block/bootdevice # Enable UFS powersaving write /sys/devices/platform/soc/${ro.boot.bootdevice}/clkgate_enable 1 write /sys/devices/platform/soc/${ro.boot.bootdevice}/hibern8_on_idle_enable 1 # Turn on sleep modes write /sys/module/lpm_levels/parameters/sleep_disabled 0 # Disable sched_boost write /proc/sys/kernel/sched_boost 0 start vendor.power_off_alarm mount tmpfs tmpfs /data setprop sys.usb.controller 4e00000.dwc3 setprop sys.usb.configfs 1 on enable-low-power # Set the default IRQ affinity to the silver cluster. # When a CPU is isolated/hotplugged, the IRQ affinity is adjusted # to one of the CPU from the default IRQ affinity mask. write /proc/irq/default_smp_affinity "f" # Setting b.L scheduler parameters write /proc/sys/kernel/sched_upmigrate 95 write /proc/sys/kernel/sched_downmigrate 85 write /proc/sys/kernel/sched_group_upmigrate 100 write /proc/sys/kernel/sched_group_downmigrate 95 write /proc/sys/kernel/sched_walt_rotate_big_tasks 1 # Enable bus-dcvs write /sys/class/devfreq/soc:qcom,cpu-cpu-ddr-bw/governor "bw_hwmon" write /sys/class/devfreq/soc:qcom,cpu-cpu-ddr-bw/polling_interval 50 write /sys/class/devfreq/soc:qcom,cpu-cpu-ddr-bw/min_freq 762 write /sys/class/devfreq/soc:qcom,cpu-cpu-ddr-bw/bw_hwmon/mbps_zones "762 1144 1720 2086 2597 2929 3879 5161 5931" write /sys/class/devfreq/soc:qcom,cpu-cpu-ddr-bw/bw_hwmon/sample_ms 4 write /sys/class/devfreq/soc:qcom,cpu-cpu-ddr-bw/bw_hwmon/io_percent 50 write /sys/class/devfreq/soc:qcom,cpu-cpu-ddr-bw/bw_hwmon/hist_memory 20 write /sys/class/devfreq/soc:qcom,cpu-cpu-ddr-bw/bw_hwmon/hyst_length 10 write /sys/class/devfreq/soc:qcom,cpu-cpu-ddr-bw/bw_hwmon/guard_band_mbps 0 write /sys/class/devfreq/soc:qcom,cpu-cpu-ddr-bw/bw_hwmon/up_scale 250 write /sys/class/devfreq/soc:qcom,cpu-cpu-ddr-bw/bw_hwmon/idle_mbps 1600 # Enable mem_latency governor for DDR scaling write /sys/class/devfreq/soc:qcom,cpu0-cpu-ddr-lat/governor "mem_latency" write /sys/class/devfreq/soc:qcom,cpu0-cpu-ddr-lat/polling_interval 10 write /sys/class/devfreq/soc:qcom,cpu0-cpu-ddr-lat/mem_latency/ratio_ceil 400 write /sys/class/devfreq/soc:qcom,cpu6-cpu-ddr-lat/governor "mem_latency" write /sys/class/devfreq/soc:qcom,cpu6-cpu-ddr-lat/polling_interval 10 write /sys/class/devfreq/soc:qcom,cpu6-cpu-ddr-lat/mem_latency/ratio_ceil 400 # Enable mem_latency governor for L3 scaling write /sys/class/devfreq/fd90100.qcom,cpu0-cpu-l3-lat/governor "mem_latency" write /sys/class/devfreq/fd90100.qcom,cpu0-cpu-l3-lat/polling_interval 10 write /sys/class/devfreq/fd90100.qcom,cpu0-cpu-l3-lat/mem_latency/ratio_ceil 400 write /sys/class/devfreq/fd90100.qcom,cpu6-cpu-l3-lat/governor "mem_latency" write /sys/class/devfreq/fd90100.qcom,cpu6-cpu-l3-lat/polling_interval 10 write /sys/class/devfreq/fd90100.qcom,cpu6-cpu-l3-lat/mem_latency/ratio_ceil 400 # Set cpuset parameters write /dev/cpuset/background/cpus 0-1 write /dev/cpuset/system-background/cpus 0-3 write /dev/cpuset/foreground/boost/cpus 0-3,6-7 write /dev/cpuset/foreground/cpus 0-3,6-7 write /dev/cpuset/top-app/cpus 0-7 write /dev/cpuset/restricted/cpus 0-3 # Turn off scheduler boost at the end write /proc/sys/kernel/sched_boost 0 # Turn on sleep modes write /sys/module/lpm_levels/parameters/sleep_disabled 0 # Enable UFS powersaving write /sys/devices/platform/soc/${ro.boot.bootdevice}/clkgate_enable 1 write /sys/devices/platform/soc/${ro.boot.bootdevice}/hibern8_on_idle_enable 1 write /proc/sys/vm/swappiness 100 write /proc/sys/vm/watermark_scale_factor 1 on property:sys.boot_completed=1 trigger enable-low-power # If UART is on, enable console_suspend on boot_complete to save power on property:sys.boot_completed=1 && property:init.svc.console=running write /sys/module/printk/parameters/console_suspend Y on property:init.svc.recovery=running trigger enable-low-power