up_rate_limit_us2065 变为 1000000,down_rate_limit_us从50000变1000000,cpu从1512000变816000diff --git a/android/device/softwinner/ceres-c3/init.device.rc b/android/device/softwinner/ceres-c3/init.device.rcindex 45e4cf5..f502b20 100755--- a/android/device/softwinner/ceres-c3/init.device.rc+++ b/android/device/softwinner/ceres-c3/init.device.rc@@ -1,66 +1,71 @@-on init- # Load persistent dm-verity state- verity_load_state--on early-boot- # Update dm-verity state and set partition.*.verified properties- verity_update_state--on verity-logging- exec u:r:slideshow:s0 -- /sbin/slideshow warning/verity_red_1 warning/verity_red_2--on boot- chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor- chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor-- chown system system /sys/class/thermal/thermal_zone0/policy- chmod 0660 /sys/class/thermal/thermal_zone0/policy-- chown system system /sys/class/thermal/thermal_zone0/emul_temp- chmod 0660 /sys/class/thermal/thermal_zone0/emul_temp-- write /sys/class/disp/disp/attr/runtime_enable 1- write /sys/kernel/autohotplug/enable 1- write /sys/kernel/autohotplug/boost_all 0- write /sys/class/axp/axp_reg 0x3651- # Read one page at a time for swap (default is 8)- write /proc/sys/vm/page-cluster 0- setprop persist.vendor.overlay.user_rotation ${ro.primary_display.user_rotation}--on late-fs-### csi module- write /sys/module/i2c_sunxi/parameters/i2c_err_print 0- insmod /vendor/modules/videobuf2-core.ko- insmod /vendor/modules/videobuf2-memops.ko- insmod /vendor/modules/videobuf2-dma-contig.ko- insmod /vendor/modules/videobuf2-v4l2.ko- insmod /vendor/modules/vin_io.ko- #insmod /vendor/modules/gc2385_mipi.ko- #insmod /vendor/modules/gc030a_mipi.ko- #insmod /vendor/modules/gc5025_mipi.ko- #insmod /vendor/modules/gc5035_mipi.ko- #insmod /vendor/modules/ov13850_mipi.ko- #insmod /vendor/modules/gc0310_mipi.ko- #insmod /vendor/modules/actuator.ko- #insmod /vendor/modules/dw9714_act.ko- insmod /vendor/modules/vin_v4l2.ko- # 降低 swappiness,减少 swap 对 DDR 带宽的消耗- write /proc/sys/vm/swappiness 30 - # 延长脏页写回周期,减少后台 I/O 唤醒 DDR- write /proc/sys/vm/dirty_writeback_centisecs 3000- write /proc/sys/vm/dirty_expire_centisecs 500- write /sys/module/i2c_sunxi/parameters/i2c_err_print 1- -service attributewrite /system/bin/attributewrite.sh- user root- group root- disabled- oneshot--on property:sys.boot_completed=1- #inmod tp module- insmod /vendor/modules/gslX680new.ko- chown system system /sys/class/ctp/tp_idle+on init+ # Load persistent dm-verity state+ verity_load_state++on early-boot+ # Update dm-verity state and set partition.*.verified properties+ verity_update_state++on verity-logging+ exec u:r:slideshow:s0 -- /sbin/slideshow warning/verity_red_1 warning/verity_red_2++on boot+ chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor+ chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor++ chown system system /sys/class/thermal/thermal_zone0/policy+ chmod 0660 /sys/class/thermal/thermal_zone0/policy++ chown system system /sys/class/thermal/thermal_zone0/emul_temp+ chmod 0660 /sys/class/thermal/thermal_zone0/emul_temp++ write /sys/class/disp/disp/attr/runtime_enable 1+ write /sys/kernel/autohotplug/enable 1+ write /sys/kernel/autohotplug/boost_all 0+ # Limit CPU max freq to 816MHz (P0: save ~3-10mA, balance perf/power)+ write /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq 816000+ write /sys/class/axp/axp_reg 0x3651+ # Read one page at a time for swap (default is 8)+ write /proc/sys/vm/page-cluster 0+ setprop persist.vendor.overlay.user_rotation ${ro.primary_display.user_rotation}++on late-fs+### csi module+ write /sys/module/i2c_sunxi/parameters/i2c_err_print 0+ insmod /vendor/modules/videobuf2-core.ko+ insmod /vendor/modules/videobuf2-memops.ko+ insmod /vendor/modules/videobuf2-dma-contig.ko+ insmod /vendor/modules/videobuf2-v4l2.ko+ insmod /vendor/modules/vin_io.ko+ #insmod /vendor/modules/gc2385_mipi.ko+ #insmod /vendor/modules/gc030a_mipi.ko+ #insmod /vendor/modules/gc5025_mipi.ko+ #insmod /vendor/modules/gc5035_mipi.ko+ #insmod /vendor/modules/ov13850_mipi.ko+ #insmod /vendor/modules/gc0310_mipi.ko+ #insmod /vendor/modules/actuator.ko+ #insmod /vendor/modules/dw9714_act.ko+ insmod /vendor/modules/vin_v4l2.ko+ # 降低 swappiness,减少 swap 对 DDR 带宽的消耗+ write /proc/sys/vm/swappiness 30 + # 延长脏页写回周期,减少后台 I/O 唤醒 DDR+ write /proc/sys/vm/dirty_writeback_centisecs 3000+ write /proc/sys/vm/dirty_expire_centisecs 500+ write /sys/module/i2c_sunxi/parameters/i2c_err_print 1+ +service attributewrite /system/bin/attributewrite.sh+ user root+ group root+ disabled+ oneshot++on property:sys.boot_completed=1+ #inmod tp module+ insmod /vendor/modules/gslX680new.ko+ chown system system /sys/class/ctp/tp_idle write /sys/class/thermal/thermal_zone0/policy power_allocator- start attributewrite- + # Reduce sugov CPU frequency adjustment rate to cut AXP803 I2C traffic (twi6 -92%)+ write /sys/devices/system/cpu/cpufreq/schedutil/up_rate_limit_us 1000000+ write /sys/devices/system/cpu/cpufreq/schedutil/down_rate_limit_us 1000000+ start attributewrite+ diff --git a/longan/kernel/linux-4.9/drivers/cpufreq/cpufreq-dt.c b/longan/kernel/linux-4.9/drivers/cpufreq/cpufreq-dt.cindex fbb278b..0c8d2bd 100644--- a/longan/kernel/linux-4.9/drivers/cpufreq/cpufreq-dt.c+++ b/longan/kernel/linux-4.9/drivers/cpufreq/cpufreq-dt.c@@ -286,8 +286,8 @@ static int cpufreq_init(struct cpufreq_policy *policy) * Android: set default parameters for parity between schedutil and * schedfreq */- policy-up_transition_delay_us = transition_latency / NSEC_PER_USEC;- policy-down_transition_delay_us = 50000; /* 50ms */+ policy-up_transition_delay_us = 1000000; /* 1s, reduce AXP803 I2C traffic */+ policy-down_transition_delay_us = 1000000; /* 1s, reduce AXP803 I2C traffic */ return 0;diff --git a/longan/kernel/linux-4.9/kernel/sched/cpufreq_schedutil.c b/longan/kernel/linux-4.9/kernel/sched/cpufreq_schedutil.cindex 0526dc0..6c77ed1 100644--- a/longan/kernel/linux-4.9/kernel/sched/cpufreq_schedutil.c+++ b/longan/kernel/linux-4.9/kernel/sched/cpufreq_schedutil.c@@ -1,783 +1,783 @@-/*- * CPUFreq governor based on scheduler-provided CPU utilization data.- *- * Copyright (C) 2016, Intel Corporation- * Author: Rafael J. Wysocki rafael.j.wysocki@intel.com- *- * This program is free software; you can redistribute it and/or modify- * it under the terms of the GNU General Public License version 2 as- * published by the Free Software Foundation.- */--#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt--#include linux/cpufreq.h-#include linux/kthread.h-#include linux/slab.h-#include trace/events/power.h--#include "sched.h"-#include "tune.h"--unsigned long boosted_cpu_util(int cpu);--/* Stub out fast switch routines present on mainline to reduce the backport- * overhead. */-#define cpufreq_driver_fast_switch(x, y) 0-#define cpufreq_enable_fast_switch(x)-#define cpufreq_disable_fast_switch(x)-#define LATENCY_MULTIPLIER (1000)-#define SUGOV_KTHREAD_PRIORITY 50--struct sugov_tunables {- struct gov_attr_set attr_set;- unsigned int up_rate_limit_us;- unsigned int down_rate_limit_us;-};--struct sugov_policy {- struct cpufreq_policy *policy;-- struct sugov_tunables *tunables;- struct list_head tunables_hook;-- raw_spinlock_t update_lock; /* For shared policies */- u64 last_freq_update_time;- s64 min_rate_limit_ns;- s64 up_rate_delay_ns;- s64 down_rate_delay_ns;- unsigned int next_freq;- unsigned int cached_raw_freq;-- /* The next fields are only needed if fast switch cannot be used. */- struct irq_work irq_work;- struct kthread_work work;- struct mutex work_lock;- struct kthread_worker worker;- struct task_struct *thread;- bool work_in_progress;-- bool need_freq_update;-};--struct sugov_cpu {- struct update_util_data update_util;- struct sugov_policy *sg_policy;-- unsigned long iowait_boost;- unsigned long iowait_boost_max;- u64 last_update;-- /* The fields below are only needed when sharing a policy. */- unsigned long util;- unsigned long max;- unsigned int flags;-- /* The field below is for single-CPU policies only. */-#ifdef CONFIG_NO_HZ_COMMON- unsigned long saved_idle_calls;-#endif-};--static DEFINE_PER_CPU(struct sugov_cpu, sugov_cpu);--/************************ Governor internals ***********************/--static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time)-{- s64 delta_ns;-- if (sg_policy-work_in_progress)- return false;-- if (unlikely(sg_policy-need_freq_update)) {- sg_policy-need_freq_update = false;- /*- * This happens when limits change, so forget the previous- * next_freq value and force an update.- */- sg_policy-next_freq = UINT_MAX;- return true;- }-- delta_ns = time - sg_policy-last_freq_update_time;-- /* No need to recalculate next freq for min_rate_limit_us at least */- return delta_ns = sg_policy-min_rate_limit_ns;-}--static bool sugov_up_down_rate_limit(struct sugov_policy *sg_policy, u64 time,- unsigned int next_freq)-{- s64 delta_ns;-- delta_ns = time - sg_policy-last_freq_update_time;-- if (next_freq sg_policy-next_freq - delta_ns sg_policy-up_rate_delay_ns)- return true;-- if (next_freq sg_policy-next_freq - delta_ns sg_policy-down_rate_delay_ns)- return true;-- return false;-}--static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,- unsigned int next_freq)-{- struct cpufreq_policy *policy = sg_policy-policy;-- if (sugov_up_down_rate_limit(sg_policy, time, next_freq)) {- /* Reset cached freq as next_freq isn't changed */- sg_policy-cached_raw_freq = 0;- return;- }-- if (sg_policy-next_freq == next_freq)- return;-- sg_policy-next_freq = next_freq;- sg_policy-last_freq_update_time = time;-- if (policy-fast_switch_enabled) {- next_freq = cpufreq_driver_fast_switch(policy, next_freq);- if (next_freq == CPUFREQ_ENTRY_INVALID)- return;-- policy-cur = next_freq;- trace_cpu_frequency(next_freq, smp_processor_id());- } else {- sg_policy-work_in_progress = true;- irq_work_queue(sg_policy-irq_work);- }-}--/**- * get_next_freq - Compute a new frequency for a given cpufreq policy.- * @sg_policy: schedutil policy object to compute the new frequency for.- * @util: Current CPU utilization.- * @max: CPU capacity.- *- * If the utilization is frequency-invariant, choose the new frequency to be- * proportional to it, that is- *- * next_freq = C * max_freq * util / max- *- * Otherwise, approximate the would-be frequency-invariant utilization by- * util_raw * (curr_freq / max_freq) which leads to- *- * next_freq = C * curr_freq * util_raw / max- *- * Take C = 1.25 for the frequency tipping point at (util / max) = 0.8.- *- * The lowest driver-supported frequency which is equal or greater than the raw- * next_freq (as calculated above) is returned, subject to policy min/max and- * cpufreq driver limitations.- */-static unsigned int get_next_freq(struct sugov_policy *sg_policy,- unsigned long util, unsigned long max)-{- struct cpufreq_policy *policy = sg_policy-policy;- unsigned int freq = arch_scale_freq_invariant() ?- policy-cpuinfo.max_freq : policy-cur;-- fr