zenfone7: Add init.qcom.power.rc for libperfmgr
Co-authored-by: Ramii Ahmed <ramy@ahmedramy.com>
Change-Id: Ia5f59d183056728dc2966b99ff74dbb4fcc83c7b
Signed-off-by: micky387 <mickaelsaibi@free.fr>
diff --git a/prebuilt/vendor/etc/init/hw/init.qcom.power.rc b/prebuilt/vendor/etc/init/hw/init.qcom.power.rc
new file mode 100644
index 0000000..bbfc3da
--- /dev/null
+++ b/prebuilt/vendor/etc/init/hw/init.qcom.power.rc
@@ -0,0 +1,161 @@
+# Copyright (c) 2012-2013, 2016-2020, The Linux Foundation. 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 The Linux Foundation 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 enable-low-power
+ # Enable PowerHAL hint processing
+ setprop vendor.powerhal.init 1
+
+on property:sys.boot_completed=1
+ trigger enable-low-power
+
+ # Runtime fs tuning
+ write /sys/block/sda/queue/nr_requests 128
+ write /sys/block/sda/queue/iostats 1
+
+ # Block layer tuning: discard chunk size up to 128MB
+ # Otherwise, contiguous discards can be merged
+ write /sys/block/sda/queue/discard_max_bytes 134217728
+
+ # Back to default VM settings
+ write /proc/sys/vm/dirty_expire_centisecs 3000
+ write /proc/sys/vm/dirty_background_ratio 10
+
+ # Setup runtime cpusets
+ write /dev/cpuset/top-app/cpus 0-7
+ write /dev/cpuset/foreground/cpus 0-3,5-6
+ write /dev/cpuset/background/cpus 0-1
+ write /dev/cpuset/system-background/cpus 0-3
+ write /dev/cpuset/restricted/cpus 0-3
+
+ # Setup runtime schedTune
+ write /dev/stune/foreground/schedtune.prefer_idle 1
+ write /dev/stune/foreground/schedtune.prefer_high_cap 0
+ write /dev/stune/foreground/schedtune.boost 0
+ write /dev/stune/schedtune.prefer_idle 0
+ write /dev/stune/schedtune.prefer_high_cap 0
+ write /dev/stune/schedtune.boost 0
+ write /dev/stune/top-app/schedtune.prefer_idle 1
+ write /dev/stune/top-app/schedtune.prefer_high_cap 0
+ write /dev/stune/top-app/schedtune.boost 10
+
+ # Setup runtime blkio
+ # value for group_idle is us
+ write /dev/blkio/blkio.weight 1000
+ write /dev/blkio/background/blkio.weight 200
+ write /dev/blkio/blkio.group_idle 2000
+ write /dev/blkio/background/blkio.group_idle 0
+
+on property:init.svc.recovery=running
+ trigger enable-low-power
+
+on early-init
+ # configure governor settings
+ 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/cpu4/cpufreq/scaling_governor schedutil
+ write /sys/devices/system/cpu/cpu4/cpufreq/schedutil/up_rate_limit_us 500
+ write /sys/devices/system/cpu/cpu4/cpufreq/schedutil/down_rate_limit_us 20000
+
+ # configure governor settings for big big CPU
+ write /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor schedutil
+ write /sys/devices/system/cpu/cpu7/cpufreq/schedutil/up_rate_limit_us 500
+ write /sys/devices/system/cpu/cpu7/cpufreq/schedutil/down_rate_limit_us 20000
+
+ # Disable UFS clock scaling
+ write /sys/bus/platform/devices/1d84000.ufshc/clkscale_enable 0
+
+on init
+ # Setup permission for Power HAL
+ chown system system /dev/stune/top-app/schedtune.boost
+ chown system system /dev/cpu_dma_latency
+
+ chmod 0664 /dev/stune/top-app/schedtune.boost
+ chmod 0664 /dev/cpu_dma_latency
+
+ # Boot time cpuset and stune
+ write /dev/cpuset/top-app/cpus 0-7
+ write /dev/cpuset/foreground/cpus 0-7
+ write /dev/cpuset/background/cpus 0-5
+ write /dev/cpuset/system-background/cpus 0-5
+ write /dev/cpuset/restricted/cpus 2-5
+ write /dev/stune/foreground/schedtune.prefer_idle 1
+ write /dev/stune/foreground/schedtune.prefer_high_cap 1
+ write /dev/stune/foreground/schedtune.boost 100
+ write /dev/stune/schedtune.prefer_idle 1
+ write /dev/stune/schedtune.prefer_high_cap 1
+ write /dev/stune/schedtune.boost 100
+ write /dev/stune/top-app/schedtune.prefer_idle 1
+ write /dev/stune/top-app/schedtune.prefer_high_cap 1
+ write /dev/stune/top-app/schedtune.boost 100
+
+ # Boot time fs tuning
+ write /sys/block/sda/queue/iostats 0
+ write /sys/block/sda/queue/scheduler cfq
+ write /sys/block/sda/queue/iosched/slice_idle 0
+ write /sys/block/sda/queue/nr_requests 256
+
+ # Disable UFS powersaving
+ write /sys/devices/platform/soc/${ro.boot.bootdevice}/clkgate_enable 0
+
+ # Disable powersaving
+ write /sys/module/lpm_levels/parameters/sleep_disabled 1
+
+ # bring back all cores
+ 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
+
+ mkdir /dev/cpuset/camera-daemon-dedicated
+ write /dev/cpuset/camera-daemon-dedicated/cpus 0-7
+ write /dev/cpuset/camera-daemon-dedicated/mems 0
+ chown system system /dev/cpuset/camera-daemon-dedicated
+ chown system system /dev/cpuset/camera-daemon-dedicated/tasks
+ chmod 0664 /dev/cpuset/camera-daemon-dedicated/tasks
+
+ # create an stune group for camera-specific processes
+ mkdir /dev/stune/camera-daemon
+ write /dev/stune/camera-daemon/schedtune.prefer_idle 1
+ write /dev/stune/camera-daemon/schedtune.boost 0
+ chown system system /dev/stune/camera-daemon
+ chown system system /dev/stune/camera-daemon/tasks
+ chmod 0664 /dev/stune/camera-daemon/tasks
+
+ # set default schedTune value for camera-daemon
+ write /dev/stune/camera-daemon/schedtune.prefer_idle 1
+ write /dev/stune/camera-daemon/schedtune.boost 0
+
+ # report max frequency to unity tasks.
+ write /proc/sys/kernel/sched_lib_name "UnityMain,libunity.so"
+ write /proc/sys/kernel/sched_lib_mask_force 255
diff --git a/prebuilt/vendor/etc/init/hw/init.qcom.rc b/prebuilt/vendor/etc/init/hw/init.qcom.rc
index ae0a034..2d5658b 100644
--- a/prebuilt/vendor/etc/init/hw/init.qcom.rc
+++ b/prebuilt/vendor/etc/init/hw/init.qcom.rc
@@ -32,6 +32,7 @@
import /vendor/etc/init/hw/init.asus.usb.rc
import /vendor/etc/init/hw/init.target.rc
import /vendor/etc/init/hw/init.qcom.factory.rc
+import /vendor/etc/init/hw/init.qcom.power.rc
#ASUS_BSP +++ frank_tao "[ZS670KS][Thermal] Thermal Service"
import init.asus.thermald_ZS670KS.rc