From e3e12f52b214121840b44c91de5b3e5af5d3eb84 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Mon, 06 Nov 2023 03:04:41 +0000 Subject: [PATCH] rk3568 rt init --- kernel/drivers/cpufreq/cpufreq_interactive.c | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 89 insertions(+), 1 deletions(-) diff --git a/kernel/drivers/cpufreq/cpufreq_interactive.c b/kernel/drivers/cpufreq/cpufreq_interactive.c index 06f7679..d9c8c7d 100644 --- a/kernel/drivers/cpufreq/cpufreq_interactive.c +++ b/kernel/drivers/cpufreq/cpufreq_interactive.c @@ -37,6 +37,7 @@ #include <linux/slab.h> #include <uapi/linux/sched/types.h> #include <linux/sched/clock.h> +#include <soc/rockchip/rockchip_system_monitor.h> #define CREATE_TRACE_POINTS #include <trace/events/cpufreq_interactive.h> @@ -100,6 +101,7 @@ int touchboostpulse_duration_val; /* End time of touchboost pulse in ktime converted to usecs */ u64 touchboostpulse_endtime; + bool touchboost, is_touchboosted; #endif bool boosted; @@ -520,7 +522,8 @@ sampling_rate = icpu->ipolicy->tunables->sampling_rate; icpu->last_sample_time = local_clock(); icpu->next_sample_jiffies = usecs_to_jiffies(sampling_rate) + jiffies; - cpufreq_interactive_update(icpu); + icpu->work_in_progress = true; + irq_work_queue_on(&icpu->irq_work, icpu->cpu); } } @@ -606,7 +609,44 @@ for_each_cpu(cpu, &tmp_mask) { struct interactive_cpu *icpu = &per_cpu(interactive_cpu, cpu); struct cpufreq_policy *policy; +#ifdef CONFIG_ARCH_ROCKCHIP + struct interactive_tunables *tunables; + bool update_policy = false; + u64 now; + now = ktime_to_us(ktime_get()); + if (!down_read_trylock(&icpu->enable_sem)) + continue; + + if (!icpu->ipolicy) { + up_read(&icpu->enable_sem); + continue; + } + + tunables = icpu->ipolicy->tunables; + if (!tunables) { + up_read(&icpu->enable_sem); + continue; + } + + if (tunables->touchboost && + now > tunables->touchboostpulse_endtime) { + tunables->touchboost = false; + rockchip_monitor_clear_boosted(); + update_policy = true; + } + + if (!tunables->is_touchboosted && tunables->touchboost) { + rockchip_monitor_set_boosted(); + update_policy = true; + } + + tunables->is_touchboosted = tunables->touchboost; + + up_read(&icpu->enable_sem); + if (update_policy) + cpufreq_update_policy(cpu); +#endif policy = cpufreq_cpu_get(cpu); if (!policy) continue; @@ -1012,6 +1052,44 @@ return count; } +static ssize_t store_touchboost_freq(struct gov_attr_set *attr_set, + const char *buf, size_t count) +{ + struct interactive_tunables *tunables = to_tunables(attr_set); + unsigned long val; + int ret; + + ret = kstrtoul(buf, 0, &val); + if (ret < 0) + return ret; + + tunables->touchboost_freq = val; + + return count; +} + +static ssize_t show_touchboost_duration(struct gov_attr_set *attr_set, char *buf) +{ + struct interactive_tunables *tunables = to_tunables(attr_set); + + return sprintf(buf, "%d\n", tunables->touchboostpulse_duration_val); +} + +static ssize_t store_touchboost_duration(struct gov_attr_set *attr_set, + const char *buf, size_t count) +{ + struct interactive_tunables *tunables = to_tunables(attr_set); + int val, ret; + + ret = kstrtoint(buf, 0, &val); + if (ret < 0) + return ret; + + tunables->touchboostpulse_duration_val = val; + + return count; +} + show_one(hispeed_freq, "%u"); show_one(go_hispeed_load, "%lu"); show_one(min_sample_time, "%lu"); @@ -1019,6 +1097,7 @@ show_one(boost, "%u"); show_one(boostpulse_duration, "%u"); show_one(io_is_busy, "%u"); +show_one(touchboost_freq, "%lu"); gov_attr_rw(target_loads); gov_attr_rw(above_hispeed_delay); @@ -1031,6 +1110,8 @@ gov_attr_wo(boostpulse); gov_attr_rw(boostpulse_duration); gov_attr_rw(io_is_busy); +gov_attr_rw(touchboost_freq); +gov_attr_rw(touchboost_duration); static struct attribute *interactive_attributes[] = { &target_loads.attr, @@ -1044,6 +1125,8 @@ &boostpulse.attr, &boostpulse_duration.attr, &io_is_busy.attr, + &touchboost_freq.attr, + &touchboost_duration.attr, NULL }; @@ -1245,6 +1328,7 @@ cpumask_set_cpu(i, &speedchange_cpumask); pcpu->loc_hispeed_val_time = ktime_to_us(ktime_get()); + tunables->touchboost = true; anyboost = 1; } @@ -1555,6 +1639,10 @@ idle_notifier_unregister(&cpufreq_interactive_idle_nb); #ifdef CONFIG_ARCH_ROCKCHIP input_unregister_handler(&cpufreq_interactive_input_handler); + if (tunables->touchboost) { + tunables->touchboost = false; + rockchip_monitor_clear_boosted(); + } #endif } -- Gitblit v1.6.2