hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
kernel/drivers/cpufreq/cpufreq_interactive.c
....@@ -37,6 +37,7 @@
3737 #include <linux/slab.h>
3838 #include <uapi/linux/sched/types.h>
3939 #include <linux/sched/clock.h>
40
+#include <soc/rockchip/rockchip_system_monitor.h>
4041
4142 #define CREATE_TRACE_POINTS
4243 #include <trace/events/cpufreq_interactive.h>
....@@ -100,6 +101,7 @@
100101 int touchboostpulse_duration_val;
101102 /* End time of touchboost pulse in ktime converted to usecs */
102103 u64 touchboostpulse_endtime;
104
+ bool touchboost, is_touchboosted;
103105 #endif
104106 bool boosted;
105107
....@@ -520,7 +522,8 @@
520522 sampling_rate = icpu->ipolicy->tunables->sampling_rate;
521523 icpu->last_sample_time = local_clock();
522524 icpu->next_sample_jiffies = usecs_to_jiffies(sampling_rate) + jiffies;
523
- cpufreq_interactive_update(icpu);
525
+ icpu->work_in_progress = true;
526
+ irq_work_queue_on(&icpu->irq_work, icpu->cpu);
524527 }
525528 }
526529
....@@ -606,7 +609,44 @@
606609 for_each_cpu(cpu, &tmp_mask) {
607610 struct interactive_cpu *icpu = &per_cpu(interactive_cpu, cpu);
608611 struct cpufreq_policy *policy;
612
+#ifdef CONFIG_ARCH_ROCKCHIP
613
+ struct interactive_tunables *tunables;
614
+ bool update_policy = false;
615
+ u64 now;
609616
617
+ now = ktime_to_us(ktime_get());
618
+ if (!down_read_trylock(&icpu->enable_sem))
619
+ continue;
620
+
621
+ if (!icpu->ipolicy) {
622
+ up_read(&icpu->enable_sem);
623
+ continue;
624
+ }
625
+
626
+ tunables = icpu->ipolicy->tunables;
627
+ if (!tunables) {
628
+ up_read(&icpu->enable_sem);
629
+ continue;
630
+ }
631
+
632
+ if (tunables->touchboost &&
633
+ now > tunables->touchboostpulse_endtime) {
634
+ tunables->touchboost = false;
635
+ rockchip_monitor_clear_boosted();
636
+ update_policy = true;
637
+ }
638
+
639
+ if (!tunables->is_touchboosted && tunables->touchboost) {
640
+ rockchip_monitor_set_boosted();
641
+ update_policy = true;
642
+ }
643
+
644
+ tunables->is_touchboosted = tunables->touchboost;
645
+
646
+ up_read(&icpu->enable_sem);
647
+ if (update_policy)
648
+ cpufreq_update_policy(cpu);
649
+#endif
610650 policy = cpufreq_cpu_get(cpu);
611651 if (!policy)
612652 continue;
....@@ -1012,6 +1052,44 @@
10121052 return count;
10131053 }
10141054
1055
+static ssize_t store_touchboost_freq(struct gov_attr_set *attr_set,
1056
+ const char *buf, size_t count)
1057
+{
1058
+ struct interactive_tunables *tunables = to_tunables(attr_set);
1059
+ unsigned long val;
1060
+ int ret;
1061
+
1062
+ ret = kstrtoul(buf, 0, &val);
1063
+ if (ret < 0)
1064
+ return ret;
1065
+
1066
+ tunables->touchboost_freq = val;
1067
+
1068
+ return count;
1069
+}
1070
+
1071
+static ssize_t show_touchboost_duration(struct gov_attr_set *attr_set, char *buf)
1072
+{
1073
+ struct interactive_tunables *tunables = to_tunables(attr_set);
1074
+
1075
+ return sprintf(buf, "%d\n", tunables->touchboostpulse_duration_val);
1076
+}
1077
+
1078
+static ssize_t store_touchboost_duration(struct gov_attr_set *attr_set,
1079
+ const char *buf, size_t count)
1080
+{
1081
+ struct interactive_tunables *tunables = to_tunables(attr_set);
1082
+ int val, ret;
1083
+
1084
+ ret = kstrtoint(buf, 0, &val);
1085
+ if (ret < 0)
1086
+ return ret;
1087
+
1088
+ tunables->touchboostpulse_duration_val = val;
1089
+
1090
+ return count;
1091
+}
1092
+
10151093 show_one(hispeed_freq, "%u");
10161094 show_one(go_hispeed_load, "%lu");
10171095 show_one(min_sample_time, "%lu");
....@@ -1019,6 +1097,7 @@
10191097 show_one(boost, "%u");
10201098 show_one(boostpulse_duration, "%u");
10211099 show_one(io_is_busy, "%u");
1100
+show_one(touchboost_freq, "%lu");
10221101
10231102 gov_attr_rw(target_loads);
10241103 gov_attr_rw(above_hispeed_delay);
....@@ -1031,6 +1110,8 @@
10311110 gov_attr_wo(boostpulse);
10321111 gov_attr_rw(boostpulse_duration);
10331112 gov_attr_rw(io_is_busy);
1113
+gov_attr_rw(touchboost_freq);
1114
+gov_attr_rw(touchboost_duration);
10341115
10351116 static struct attribute *interactive_attributes[] = {
10361117 &target_loads.attr,
....@@ -1044,6 +1125,8 @@
10441125 &boostpulse.attr,
10451126 &boostpulse_duration.attr,
10461127 &io_is_busy.attr,
1128
+ &touchboost_freq.attr,
1129
+ &touchboost_duration.attr,
10471130 NULL
10481131 };
10491132
....@@ -1245,6 +1328,7 @@
12451328 cpumask_set_cpu(i, &speedchange_cpumask);
12461329 pcpu->loc_hispeed_val_time =
12471330 ktime_to_us(ktime_get());
1331
+ tunables->touchboost = true;
12481332 anyboost = 1;
12491333 }
12501334
....@@ -1555,6 +1639,10 @@
15551639 idle_notifier_unregister(&cpufreq_interactive_idle_nb);
15561640 #ifdef CONFIG_ARCH_ROCKCHIP
15571641 input_unregister_handler(&cpufreq_interactive_input_handler);
1642
+ if (tunables->touchboost) {
1643
+ tunables->touchboost = false;
1644
+ rockchip_monitor_clear_boosted();
1645
+ }
15581646 #endif
15591647 }
15601648