.. | .. |
---|
37 | 37 | #include <linux/slab.h> |
---|
38 | 38 | #include <uapi/linux/sched/types.h> |
---|
39 | 39 | #include <linux/sched/clock.h> |
---|
| 40 | +#include <soc/rockchip/rockchip_system_monitor.h> |
---|
40 | 41 | |
---|
41 | 42 | #define CREATE_TRACE_POINTS |
---|
42 | 43 | #include <trace/events/cpufreq_interactive.h> |
---|
.. | .. |
---|
100 | 101 | int touchboostpulse_duration_val; |
---|
101 | 102 | /* End time of touchboost pulse in ktime converted to usecs */ |
---|
102 | 103 | u64 touchboostpulse_endtime; |
---|
| 104 | + bool touchboost, is_touchboosted; |
---|
103 | 105 | #endif |
---|
104 | 106 | bool boosted; |
---|
105 | 107 | |
---|
.. | .. |
---|
520 | 522 | sampling_rate = icpu->ipolicy->tunables->sampling_rate; |
---|
521 | 523 | icpu->last_sample_time = local_clock(); |
---|
522 | 524 | 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); |
---|
524 | 527 | } |
---|
525 | 528 | } |
---|
526 | 529 | |
---|
.. | .. |
---|
606 | 609 | for_each_cpu(cpu, &tmp_mask) { |
---|
607 | 610 | struct interactive_cpu *icpu = &per_cpu(interactive_cpu, cpu); |
---|
608 | 611 | struct cpufreq_policy *policy; |
---|
| 612 | +#ifdef CONFIG_ARCH_ROCKCHIP |
---|
| 613 | + struct interactive_tunables *tunables; |
---|
| 614 | + bool update_policy = false; |
---|
| 615 | + u64 now; |
---|
609 | 616 | |
---|
| 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 |
---|
610 | 650 | policy = cpufreq_cpu_get(cpu); |
---|
611 | 651 | if (!policy) |
---|
612 | 652 | continue; |
---|
.. | .. |
---|
1012 | 1052 | return count; |
---|
1013 | 1053 | } |
---|
1014 | 1054 | |
---|
| 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 | + |
---|
1015 | 1093 | show_one(hispeed_freq, "%u"); |
---|
1016 | 1094 | show_one(go_hispeed_load, "%lu"); |
---|
1017 | 1095 | show_one(min_sample_time, "%lu"); |
---|
.. | .. |
---|
1019 | 1097 | show_one(boost, "%u"); |
---|
1020 | 1098 | show_one(boostpulse_duration, "%u"); |
---|
1021 | 1099 | show_one(io_is_busy, "%u"); |
---|
| 1100 | +show_one(touchboost_freq, "%lu"); |
---|
1022 | 1101 | |
---|
1023 | 1102 | gov_attr_rw(target_loads); |
---|
1024 | 1103 | gov_attr_rw(above_hispeed_delay); |
---|
.. | .. |
---|
1031 | 1110 | gov_attr_wo(boostpulse); |
---|
1032 | 1111 | gov_attr_rw(boostpulse_duration); |
---|
1033 | 1112 | gov_attr_rw(io_is_busy); |
---|
| 1113 | +gov_attr_rw(touchboost_freq); |
---|
| 1114 | +gov_attr_rw(touchboost_duration); |
---|
1034 | 1115 | |
---|
1035 | 1116 | static struct attribute *interactive_attributes[] = { |
---|
1036 | 1117 | &target_loads.attr, |
---|
.. | .. |
---|
1044 | 1125 | &boostpulse.attr, |
---|
1045 | 1126 | &boostpulse_duration.attr, |
---|
1046 | 1127 | &io_is_busy.attr, |
---|
| 1128 | + &touchboost_freq.attr, |
---|
| 1129 | + &touchboost_duration.attr, |
---|
1047 | 1130 | NULL |
---|
1048 | 1131 | }; |
---|
1049 | 1132 | |
---|
.. | .. |
---|
1245 | 1328 | cpumask_set_cpu(i, &speedchange_cpumask); |
---|
1246 | 1329 | pcpu->loc_hispeed_val_time = |
---|
1247 | 1330 | ktime_to_us(ktime_get()); |
---|
| 1331 | + tunables->touchboost = true; |
---|
1248 | 1332 | anyboost = 1; |
---|
1249 | 1333 | } |
---|
1250 | 1334 | |
---|
.. | .. |
---|
1555 | 1639 | idle_notifier_unregister(&cpufreq_interactive_idle_nb); |
---|
1556 | 1640 | #ifdef CONFIG_ARCH_ROCKCHIP |
---|
1557 | 1641 | input_unregister_handler(&cpufreq_interactive_input_handler); |
---|
| 1642 | + if (tunables->touchboost) { |
---|
| 1643 | + tunables->touchboost = false; |
---|
| 1644 | + rockchip_monitor_clear_boosted(); |
---|
| 1645 | + } |
---|
1558 | 1646 | #endif |
---|
1559 | 1647 | } |
---|
1560 | 1648 | |
---|