treewide: revert kernel boosting changes
Squashed commit of the following: commit 8a39f97027a0155282a5f108ddf420d41d763a47 Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 07:39:14 2020 +0000 Revert "devfreq_boost: Introduce devfreq boost driver" This reverts commit574fbb390d. commit 3ff01b6c2c45a08bb0e0354318f13d31f7e8aea8 Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 07:39:08 2020 +0000 Revert "devfreq_boost: Mark boost kthreads as performance critical" This reverts commit99cfb3cd59. commit 8b040082b8fef7eb1ba9dedf37ff64a10fbd5907 Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 07:38:15 2020 +0000 Revert "mm: Boost when memory pressure becomes high" This reverts commitbf459bce2c. commit 46bc11a1e8b00eb3ac0e71a28adcb5555b47777b Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 07:37:05 2020 +0000 Revert "drm/atomic: boost DDR bus when committing a new frame" This reverts commitcd504c975d. commit 9ac11686c1a70967ad3861ef1ff5c7b917f9a6ad Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 07:36:59 2020 +0000 Revert "devfreq_boost: Update and expand to handle CPUBW/LLCCBW boosting" This reverts commit77817b0443. commit 19930f3b514d57cb6e1e343f4322ede8c7b25c7a Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 07:35:48 2020 +0000 Revert "devfreq_boost: perform max devfreq boost for 250ms on touch events" This reverts commit7daee3c1b6. commit 81d4c4e91dc341f15da738c9a3c752daec6c22a2 Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 07:24:41 2020 +0000 Revert "ARM64: configs: raphael: Enable and Configure DEVFREQ_BOOST" This reverts commit560aedd879. commit b5ef5130e8fb813436a7ac1b5c69d99c8a0b100d Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 07:00:08 2020 +0000 Revert "cpu_input_boost: Introduce driver for event-based CPU boosting" This reverts commitb8ba38485c. commit 727aa5a4eff5d70c234779637ced05d05e4d612b Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 07:00:01 2020 +0000 Revert "cpu_input_boost: Mark boost kthread as performance critical" This reverts commit7f2e816b50. commit 80df9a40821c1165d66792f6aa7651cb6dc3aa90 Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 06:59:11 2020 +0000 Revert "cpufreq: cpu_input_boost: Remove all input boost code and adjust" This reverts commit6899944bb3. commit 9526ef9d1b73dcddeb6b36b365f991a4054b2eb6 Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 06:58:15 2020 +0000 Revert "kernel: Boost to the max for when zygote forks" This reverts commitab25cbf8fb. commit 29847b0eb3e35321a5fc28f79b55906500fffc1a Author: kondors1995 <normandija1945@gmail.com> Date: Wed Sep 9 06:58:08 2020 +0000 Revert "kernel: Boost whenever a zygote-forked process becomes a top app" This reverts commit1237497eba.
This commit is contained in:
@@ -4289,11 +4289,6 @@ CONFIG_DEVFREQ_SIMPLE_DEV=y
|
||||
CONFIG_QCOM_DEVFREQ_DEVBW=y
|
||||
# CONFIG_DEVFREQ_SPDM is not set
|
||||
CONFIG_DEVFREQ_GOV_CDSPL3=y
|
||||
CONFIG_DEVFREQ_BOOST=y
|
||||
CONFIG_DEVFREQ_INPUT_BOOST_DURATION_MS=64
|
||||
CONFIG_DEVFREQ_WAKE_BOOST_DURATION_MS=1000
|
||||
CONFIG_DEVFREQ_MSM_CPUBW_BOOST_FREQ=4577
|
||||
CONFIG_DEVFREQ_MSM_LLCCBW_BOOST_FREQ=2597
|
||||
# CONFIG_PM_DEVFREQ_EVENT is not set
|
||||
CONFIG_EXTCON=y
|
||||
|
||||
|
||||
@@ -295,44 +295,6 @@ config CPU_FREQ_DEFAULT_PRIME_MIN
|
||||
|
||||
If in doubt, say 0 to use the hardware's minimum frequency.
|
||||
|
||||
config CPU_INPUT_BOOST
|
||||
bool "CPU Input Boost"
|
||||
help
|
||||
Boosts the CPU on touchscreen and touchpad input, and allows for
|
||||
boosting on other custom events, mainly which is intended to be for
|
||||
boosting when there is a new frame ready to be rendered to the
|
||||
display. The boost frequencies for this driver should be set so that
|
||||
frame drops are near-zero at the boosted frequencies and power
|
||||
consumption is minimized at said frequency combination.
|
||||
|
||||
if CPU_INPUT_BOOST
|
||||
|
||||
config WAKE_BOOST_DURATION_MS
|
||||
int "Wake boost duration"
|
||||
default "1000"
|
||||
help
|
||||
Wake boost duration in milliseconds.
|
||||
|
||||
config MAX_BOOST_FREQ_LP
|
||||
int "Low-power cluster max-boost freq"
|
||||
default "0"
|
||||
help
|
||||
Max-boost frequency for the low-power CPU cluster.
|
||||
|
||||
config MAX_BOOST_FREQ_PERF
|
||||
int "Performance cluster max-boost freq"
|
||||
default "0"
|
||||
help
|
||||
Max-boost frequency for the performance CPU cluster.
|
||||
|
||||
config MAX_BOOST_FREQ_PERFP
|
||||
int "Prime cluster max-boost freq"
|
||||
default "0"
|
||||
help
|
||||
Max-boost frequency for the prime CPU cluster.
|
||||
|
||||
endif
|
||||
|
||||
comment "CPU frequency scaling drivers"
|
||||
|
||||
config CPUFREQ_DT
|
||||
|
||||
@@ -19,9 +19,6 @@ obj-$(CONFIG_CPU_FREQ_GOV_COMMON) += cpufreq_governor.o
|
||||
obj-$(CONFIG_CPU_FREQ_GOV_ATTR_SET) += cpufreq_governor_attr_set.o
|
||||
obj-$(CONFIG_CPU_BOOST) += cpu-boost.o
|
||||
|
||||
# CPU Input Boost
|
||||
obj-$(CONFIG_CPU_INPUT_BOOST) += cpu_input_boost.o
|
||||
|
||||
obj-$(CONFIG_CPUFREQ_DT) += cpufreq-dt.o
|
||||
obj-$(CONFIG_CPUFREQ_DT_PLATDEV) += cpufreq-dt-platdev.o
|
||||
|
||||
|
||||
@@ -1,239 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (C) 2018-2019 Sultan Alsawaf <sultan@kerneltoast.com>.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "cpu_input_boost: " fmt
|
||||
|
||||
#include <linux/cpu.h>
|
||||
#include <linux/cpufreq.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/msm_drm_notify.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
/* The sched_param struct is located elsewhere in newer kernels */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
|
||||
#include <uapi/linux/sched/types.h>
|
||||
#endif
|
||||
|
||||
enum {
|
||||
SCREEN_OFF,
|
||||
MAX_BOOST
|
||||
};
|
||||
|
||||
struct boost_drv {
|
||||
struct delayed_work max_unboost;
|
||||
struct notifier_block cpu_notif;
|
||||
struct notifier_block msm_drm_notif;
|
||||
wait_queue_head_t boost_waitq;
|
||||
atomic_long_t max_boost_expires;
|
||||
unsigned long state;
|
||||
};
|
||||
|
||||
static void max_unboost_worker(struct work_struct *work);
|
||||
|
||||
static struct boost_drv boost_drv_g __read_mostly = {
|
||||
.max_unboost = __DELAYED_WORK_INITIALIZER(boost_drv_g.max_unboost,
|
||||
max_unboost_worker, 0),
|
||||
.boost_waitq = __WAIT_QUEUE_HEAD_INITIALIZER(boost_drv_g.boost_waitq)
|
||||
};
|
||||
|
||||
static unsigned int get_max_boost_freq(struct cpufreq_policy *policy)
|
||||
{
|
||||
unsigned int freq;
|
||||
|
||||
if (cpumask_test_cpu(policy->cpu, cpu_lp_mask))
|
||||
freq = CONFIG_MAX_BOOST_FREQ_LP;
|
||||
else if (cpumask_test_cpu(policy->cpu, cpu_perf_mask))
|
||||
freq = CONFIG_MAX_BOOST_FREQ_PERF;
|
||||
else
|
||||
freq = CONFIG_MAX_BOOST_FREQ_PERFP;
|
||||
|
||||
return min(freq, policy->max);
|
||||
}
|
||||
|
||||
static unsigned int get_min_freq(struct cpufreq_policy *policy)
|
||||
{
|
||||
unsigned int freq;
|
||||
|
||||
if (cpumask_test_cpu(policy->cpu, cpu_lp_mask))
|
||||
freq = CONFIG_CPU_FREQ_DEFAULT_LITTLE_MIN;
|
||||
else if (cpumask_test_cpu(policy->cpu, cpu_perf_mask))
|
||||
freq = CONFIG_CPU_FREQ_DEFAULT_BIG_MIN;
|
||||
else
|
||||
freq = CONFIG_CPU_FREQ_DEFAULT_PRIME_MIN;
|
||||
|
||||
return max(freq, policy->cpuinfo.min_freq);
|
||||
}
|
||||
|
||||
static void update_online_cpu_policy(void)
|
||||
{
|
||||
unsigned int cpu;
|
||||
|
||||
/* Only one CPU from each cluster needs to be updated */
|
||||
get_online_cpus();
|
||||
cpu = cpumask_first_and(cpu_lp_mask, cpu_online_mask);
|
||||
cpufreq_update_policy(cpu);
|
||||
cpu = cpumask_first_and(cpu_perf_mask, cpu_online_mask);
|
||||
cpufreq_update_policy(cpu);
|
||||
cpu = cpumask_first_and(cpu_perfp_mask, cpu_online_mask);
|
||||
cpufreq_update_policy(cpu);
|
||||
put_online_cpus();
|
||||
}
|
||||
|
||||
static void __cpu_input_boost_kick_max(struct boost_drv *b,
|
||||
unsigned int duration_ms)
|
||||
{
|
||||
unsigned long boost_jiffies = msecs_to_jiffies(duration_ms);
|
||||
unsigned long curr_expires, new_expires;
|
||||
|
||||
if (test_bit(SCREEN_OFF, &b->state))
|
||||
return;
|
||||
|
||||
do {
|
||||
curr_expires = atomic_long_read(&b->max_boost_expires);
|
||||
new_expires = jiffies + boost_jiffies;
|
||||
|
||||
/* Skip this boost if there's a longer boost in effect */
|
||||
if (time_after(curr_expires, new_expires))
|
||||
return;
|
||||
} while (atomic_long_cmpxchg(&b->max_boost_expires, curr_expires,
|
||||
new_expires) != curr_expires);
|
||||
|
||||
set_bit(MAX_BOOST, &b->state);
|
||||
if (!mod_delayed_work(system_unbound_wq, &b->max_unboost,
|
||||
boost_jiffies))
|
||||
wake_up(&b->boost_waitq);
|
||||
}
|
||||
|
||||
void cpu_input_boost_kick_max(unsigned int duration_ms)
|
||||
{
|
||||
struct boost_drv *b = &boost_drv_g;
|
||||
|
||||
__cpu_input_boost_kick_max(b, duration_ms);
|
||||
}
|
||||
|
||||
static void max_unboost_worker(struct work_struct *work)
|
||||
{
|
||||
struct boost_drv *b = container_of(to_delayed_work(work),
|
||||
typeof(*b), max_unboost);
|
||||
|
||||
clear_bit(MAX_BOOST, &b->state);
|
||||
wake_up(&b->boost_waitq);
|
||||
}
|
||||
|
||||
static int cpu_boost_thread(void *data)
|
||||
{
|
||||
static const struct sched_param sched_max_rt_prio = {
|
||||
.sched_priority = MAX_RT_PRIO - 1
|
||||
};
|
||||
struct boost_drv *b = data;
|
||||
unsigned long old_state = 0;
|
||||
|
||||
sched_setscheduler_nocheck(current, SCHED_FIFO, &sched_max_rt_prio);
|
||||
|
||||
while (1) {
|
||||
bool should_stop = false;
|
||||
unsigned long curr_state;
|
||||
|
||||
wait_event(b->boost_waitq,
|
||||
(curr_state = READ_ONCE(b->state)) != old_state ||
|
||||
(should_stop = kthread_should_stop()));
|
||||
|
||||
if (should_stop)
|
||||
break;
|
||||
|
||||
old_state = curr_state;
|
||||
update_online_cpu_policy();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpu_notifier_cb(struct notifier_block *nb, unsigned long action,
|
||||
void *data)
|
||||
{
|
||||
struct boost_drv *b = container_of(nb, typeof(*b), cpu_notif);
|
||||
struct cpufreq_policy *policy = data;
|
||||
|
||||
if (action != CPUFREQ_ADJUST)
|
||||
return NOTIFY_OK;
|
||||
|
||||
/* Unboost when the screen is off */
|
||||
if (test_bit(SCREEN_OFF, &b->state))
|
||||
goto min;
|
||||
|
||||
/* Boost CPU to max frequency for max boost */
|
||||
if (test_bit(MAX_BOOST, &b->state)) {
|
||||
policy->min = get_max_boost_freq(policy);
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
|
||||
min:
|
||||
/* Set policy->min to the absolute min freq for the CPU */
|
||||
policy->min = get_min_freq(policy);
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
|
||||
static int msm_drm_notifier_cb(struct notifier_block *nb, unsigned long action,
|
||||
void *data)
|
||||
{
|
||||
struct boost_drv *b = container_of(nb, typeof(*b), msm_drm_notif);
|
||||
struct msm_drm_notifier *evdata = data;
|
||||
int *blank = evdata->data;
|
||||
|
||||
/* Parse framebuffer blank events as soon as they occur */
|
||||
if (action != MSM_DRM_EARLY_EVENT_BLANK)
|
||||
return NOTIFY_OK;
|
||||
|
||||
/* Boost when the screen turns on and unboost when it turns off */
|
||||
if (*blank == MSM_DRM_BLANK_UNBLANK) {
|
||||
clear_bit(SCREEN_OFF, &b->state);
|
||||
__cpu_input_boost_kick_max(b, CONFIG_WAKE_BOOST_DURATION_MS);
|
||||
} else {
|
||||
set_bit(SCREEN_OFF, &b->state);
|
||||
wake_up(&b->boost_waitq);
|
||||
}
|
||||
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
|
||||
static int __init cpu_input_boost_init(void)
|
||||
{
|
||||
struct boost_drv *b = &boost_drv_g;
|
||||
struct task_struct *thread;
|
||||
int ret;
|
||||
|
||||
b->cpu_notif.notifier_call = cpu_notifier_cb;
|
||||
ret = cpufreq_register_notifier(&b->cpu_notif, CPUFREQ_POLICY_NOTIFIER);
|
||||
if (ret) {
|
||||
pr_err("Failed to register cpufreq notifier, err: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
b->msm_drm_notif.notifier_call = msm_drm_notifier_cb;
|
||||
b->msm_drm_notif.priority = INT_MAX;
|
||||
ret = msm_drm_register_client(&b->msm_drm_notif);
|
||||
if (ret) {
|
||||
pr_err("Failed to register msm_drm notifier, err: %d\n", ret);
|
||||
goto unregister_cpu_notif;
|
||||
}
|
||||
|
||||
thread = kthread_run_perf_critical(cpu_boost_thread, b, "cpu_boostd");
|
||||
if (IS_ERR(thread)) {
|
||||
ret = PTR_ERR(thread);
|
||||
pr_err("Failed to start CPU boost thread, err: %d\n", ret);
|
||||
goto unregister_fb_notif;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
unregister_fb_notif:
|
||||
msm_drm_unregister_client(&b->msm_drm_notif);
|
||||
unregister_cpu_notif:
|
||||
cpufreq_unregister_notifier(&b->cpu_notif, CPUFREQ_POLICY_NOTIFIER);
|
||||
return ret;
|
||||
}
|
||||
subsys_initcall(cpu_input_boost_init);
|
||||
@@ -263,46 +263,6 @@ config DEVFREQ_GOV_CDSPL3
|
||||
CDSP resource manager will use this governor to vote for L3 clock
|
||||
for IO-coherent traffic generated from CDSP
|
||||
|
||||
config DEVFREQ_BOOST
|
||||
bool "Devfreq Boost"
|
||||
help
|
||||
Boosts enumerated devfreq devices upon input, and allows for boosting
|
||||
specific devfreq devices on other custom events. The boost frequencies
|
||||
for this driver should be set so that frame drops are near-zero at the
|
||||
boosted frequencies and power consumption is minimized at said
|
||||
frequencies. The goal of this driver is to provide an interface to
|
||||
achieve optimal device performance by requesting boosts on key events,
|
||||
such as when a frame is ready to rendered to the display.
|
||||
|
||||
if DEVFREQ_BOOST
|
||||
|
||||
config DEVFREQ_INPUT_BOOST_DURATION_MS
|
||||
int "Input boost duration"
|
||||
default "100"
|
||||
help
|
||||
Input boost duration in milliseconds for all boostable devices.
|
||||
|
||||
config DEVFREQ_WAKE_BOOST_DURATION_MS
|
||||
int "Wake boost duration"
|
||||
default "1000"
|
||||
help
|
||||
Wake boost duration in milliseconds for all boostable devices.
|
||||
|
||||
config DEVFREQ_MSM_CPUBW_BOOST_FREQ
|
||||
int "Boost freq for cpubw device"
|
||||
default "0"
|
||||
help
|
||||
CPUBW boost frequency for the MSM DDR bus.
|
||||
|
||||
|
||||
config DEVFREQ_MSM_LLCCBW_BOOST_FREQ
|
||||
int "Boost freq for llccbw device"
|
||||
default "0"
|
||||
help
|
||||
LLCCBW boost frequency for the MSM DDR bus.
|
||||
|
||||
endif
|
||||
|
||||
source "drivers/devfreq/event/Kconfig"
|
||||
|
||||
endif # PM_DEVFREQ
|
||||
|
||||
@@ -30,6 +30,3 @@ obj-$(CONFIG_DEVFREQ_SPDM) += devfreq_spdm.o devfreq_spdm_debugfs.o
|
||||
|
||||
# DEVFREQ Event Drivers
|
||||
obj-$(CONFIG_PM_DEVFREQ_EVENT) += event/
|
||||
|
||||
# DEVFREQ Boost
|
||||
obj-$(CONFIG_DEVFREQ_BOOST) += devfreq_boost.o
|
||||
|
||||
@@ -263,15 +263,10 @@ int update_devfreq(struct devfreq *devfreq)
|
||||
if (!devfreq->governor)
|
||||
return -EINVAL;
|
||||
|
||||
if (devfreq->max_boost) {
|
||||
/* Use the max freq for max boosts */
|
||||
freq = ULONG_MAX;
|
||||
} else {
|
||||
/* Reevaluate the proper frequency */
|
||||
err = devfreq->governor->get_target_freq(devfreq, &freq);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
/* Reevaluate the proper frequency */
|
||||
err = devfreq->governor->get_target_freq(devfreq, &freq);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/*
|
||||
* Adjust the frequency with user freq and QoS.
|
||||
@@ -1133,10 +1128,6 @@ static ssize_t min_freq_store(struct device *dev, struct device_attribute *attr,
|
||||
int ret;
|
||||
unsigned long max;
|
||||
|
||||
/* Minfreq is managed by devfreq_boost */
|
||||
if (df->is_boost_device)
|
||||
return count;
|
||||
|
||||
ret = sscanf(buf, "%lu", &value);
|
||||
if (ret != 1)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -1,337 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (C) 2018-2019 Sultan Alsawaf <sultan@kerneltoast.com>.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "devfreq_boost: " fmt
|
||||
|
||||
#include <linux/devfreq_boost.h>
|
||||
#include <linux/msm_drm_notify.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/slab.h>
|
||||
#include <uapi/linux/sched/types.h>
|
||||
|
||||
enum {
|
||||
SCREEN_OFF,
|
||||
INPUT_BOOST,
|
||||
MAX_BOOST
|
||||
};
|
||||
|
||||
struct boost_dev {
|
||||
struct devfreq *df;
|
||||
struct delayed_work input_unboost;
|
||||
struct delayed_work max_unboost;
|
||||
wait_queue_head_t boost_waitq;
|
||||
atomic_long_t max_boost_expires;
|
||||
unsigned long boost_freq;
|
||||
unsigned long state;
|
||||
};
|
||||
|
||||
struct df_boost_drv {
|
||||
struct boost_dev devices[DEVFREQ_MAX];
|
||||
struct notifier_block msm_drm_notif;
|
||||
};
|
||||
|
||||
static void devfreq_input_unboost(struct work_struct *work);
|
||||
static void devfreq_max_unboost(struct work_struct *work);
|
||||
|
||||
#define BOOST_DEV_INIT(b, dev, freq) .devices[dev] = { \
|
||||
.input_unboost = \
|
||||
__DELAYED_WORK_INITIALIZER((b).devices[dev].input_unboost, \
|
||||
devfreq_input_unboost, 0), \
|
||||
.max_unboost = \
|
||||
__DELAYED_WORK_INITIALIZER((b).devices[dev].max_unboost, \
|
||||
devfreq_max_unboost, 0), \
|
||||
.boost_waitq = \
|
||||
__WAIT_QUEUE_HEAD_INITIALIZER((b).devices[dev].boost_waitq), \
|
||||
.boost_freq = freq \
|
||||
}
|
||||
|
||||
static struct df_boost_drv df_boost_drv_g __read_mostly = {
|
||||
BOOST_DEV_INIT(df_boost_drv_g, DEVFREQ_MSM_CPUBW,
|
||||
CONFIG_DEVFREQ_MSM_CPUBW_BOOST_FREQ),
|
||||
BOOST_DEV_INIT(df_boost_drv_g, DEVFREQ_MSM_LLCCBW,
|
||||
CONFIG_DEVFREQ_MSM_LLCCBW_BOOST_FREQ)
|
||||
};
|
||||
|
||||
static void __devfreq_boost_kick(struct boost_dev *b)
|
||||
{
|
||||
if (!READ_ONCE(b->df) || test_bit(SCREEN_OFF, &b->state))
|
||||
return;
|
||||
|
||||
set_bit(INPUT_BOOST, &b->state);
|
||||
if (!mod_delayed_work(system_unbound_wq, &b->input_unboost,
|
||||
msecs_to_jiffies(CONFIG_DEVFREQ_INPUT_BOOST_DURATION_MS)))
|
||||
wake_up(&b->boost_waitq);
|
||||
}
|
||||
|
||||
void devfreq_boost_kick(enum df_device device)
|
||||
{
|
||||
struct df_boost_drv *d = &df_boost_drv_g;
|
||||
|
||||
__devfreq_boost_kick(d->devices + device);
|
||||
}
|
||||
|
||||
static void __devfreq_boost_kick_max(struct boost_dev *b,
|
||||
unsigned int duration_ms)
|
||||
{
|
||||
unsigned long boost_jiffies = msecs_to_jiffies(duration_ms);
|
||||
unsigned long curr_expires, new_expires;
|
||||
|
||||
if (!READ_ONCE(b->df) || test_bit(SCREEN_OFF, &b->state))
|
||||
return;
|
||||
|
||||
do {
|
||||
curr_expires = atomic_long_read(&b->max_boost_expires);
|
||||
new_expires = jiffies + boost_jiffies;
|
||||
|
||||
/* Skip this boost if there's a longer boost in effect */
|
||||
if (time_after(curr_expires, new_expires))
|
||||
return;
|
||||
} while (atomic_long_cmpxchg(&b->max_boost_expires, curr_expires,
|
||||
new_expires) != curr_expires);
|
||||
|
||||
set_bit(MAX_BOOST, &b->state);
|
||||
if (!mod_delayed_work(system_unbound_wq, &b->max_unboost,
|
||||
boost_jiffies))
|
||||
wake_up(&b->boost_waitq);
|
||||
}
|
||||
|
||||
void devfreq_boost_kick_max(enum df_device device, unsigned int duration_ms)
|
||||
{
|
||||
struct df_boost_drv *d = &df_boost_drv_g;
|
||||
|
||||
__devfreq_boost_kick_max(d->devices + device, duration_ms);
|
||||
}
|
||||
|
||||
void devfreq_register_boost_device(enum df_device device, struct devfreq *df)
|
||||
{
|
||||
struct df_boost_drv *d = &df_boost_drv_g;
|
||||
struct boost_dev *b;
|
||||
|
||||
df->is_boost_device = true;
|
||||
b = d->devices + device;
|
||||
WRITE_ONCE(b->df, df);
|
||||
}
|
||||
|
||||
static void devfreq_input_unboost(struct work_struct *work)
|
||||
{
|
||||
struct boost_dev *b = container_of(to_delayed_work(work),
|
||||
typeof(*b), input_unboost);
|
||||
|
||||
clear_bit(INPUT_BOOST, &b->state);
|
||||
wake_up(&b->boost_waitq);
|
||||
}
|
||||
|
||||
static void devfreq_max_unboost(struct work_struct *work)
|
||||
{
|
||||
struct boost_dev *b = container_of(to_delayed_work(work),
|
||||
typeof(*b), max_unboost);
|
||||
|
||||
clear_bit(MAX_BOOST, &b->state);
|
||||
wake_up(&b->boost_waitq);
|
||||
}
|
||||
|
||||
static void devfreq_update_boosts(struct boost_dev *b, unsigned long state)
|
||||
{
|
||||
struct devfreq *df = b->df;
|
||||
|
||||
mutex_lock(&df->lock);
|
||||
if (test_bit(SCREEN_OFF, &state)) {
|
||||
df->min_freq = df->profile->freq_table[0];
|
||||
df->max_boost = false;
|
||||
} else {
|
||||
df->min_freq = test_bit(INPUT_BOOST, &state) ?
|
||||
min(b->boost_freq, df->max_freq) :
|
||||
df->profile->freq_table[0];
|
||||
df->max_boost = test_bit(MAX_BOOST, &state);
|
||||
}
|
||||
update_devfreq(df);
|
||||
mutex_unlock(&df->lock);
|
||||
}
|
||||
|
||||
static int devfreq_boost_thread(void *data)
|
||||
{
|
||||
static const struct sched_param sched_max_rt_prio = {
|
||||
.sched_priority = MAX_RT_PRIO - 1
|
||||
};
|
||||
struct boost_dev *b = data;
|
||||
unsigned long old_state = 0;
|
||||
|
||||
sched_setscheduler_nocheck(current, SCHED_FIFO, &sched_max_rt_prio);
|
||||
|
||||
while (1) {
|
||||
bool should_stop = false;
|
||||
unsigned long curr_state;
|
||||
|
||||
wait_event(b->boost_waitq,
|
||||
(curr_state = READ_ONCE(b->state)) != old_state ||
|
||||
(should_stop = kthread_should_stop()));
|
||||
|
||||
if (should_stop)
|
||||
break;
|
||||
|
||||
old_state = curr_state;
|
||||
devfreq_update_boosts(b, curr_state);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_drm_notifier_cb(struct notifier_block *nb, unsigned long action,
|
||||
void *data)
|
||||
{
|
||||
struct df_boost_drv *d = container_of(nb, typeof(*d), msm_drm_notif);
|
||||
int i;
|
||||
struct msm_drm_notifier *evdata = data;
|
||||
int *blank = evdata->data;
|
||||
|
||||
/* Parse framebuffer blank events as soon as they occur */
|
||||
if (action != MSM_DRM_EARLY_EVENT_BLANK)
|
||||
return NOTIFY_OK;
|
||||
|
||||
/* Boost when the screen turns on and unboost when it turns off */
|
||||
for (i = 0; i < DEVFREQ_MAX; i++) {
|
||||
struct boost_dev *b = d->devices + i;
|
||||
|
||||
if (*blank == MSM_DRM_BLANK_UNBLANK) {
|
||||
clear_bit(SCREEN_OFF, &b->state);
|
||||
__devfreq_boost_kick_max(b,
|
||||
CONFIG_DEVFREQ_WAKE_BOOST_DURATION_MS);
|
||||
} else {
|
||||
set_bit(SCREEN_OFF, &b->state);
|
||||
wake_up(&b->boost_waitq);
|
||||
}
|
||||
}
|
||||
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
|
||||
static void devfreq_boost_input_event(struct input_handle *handle,
|
||||
unsigned int type, unsigned int code,
|
||||
int value)
|
||||
{
|
||||
struct df_boost_drv *d = handle->handler->private;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DEVFREQ_MAX; i++)
|
||||
__devfreq_boost_kick_max(d->devices + i, 250);
|
||||
}
|
||||
|
||||
static int devfreq_boost_input_connect(struct input_handler *handler,
|
||||
struct input_dev *dev,
|
||||
const struct input_device_id *id)
|
||||
{
|
||||
struct input_handle *handle;
|
||||
int ret;
|
||||
|
||||
handle = kzalloc(sizeof(*handle), GFP_KERNEL);
|
||||
if (!handle)
|
||||
return -ENOMEM;
|
||||
|
||||
handle->dev = dev;
|
||||
handle->handler = handler;
|
||||
handle->name = "devfreq_boost_handle";
|
||||
|
||||
ret = input_register_handle(handle);
|
||||
if (ret)
|
||||
goto free_handle;
|
||||
|
||||
ret = input_open_device(handle);
|
||||
if (ret)
|
||||
goto unregister_handle;
|
||||
|
||||
return 0;
|
||||
|
||||
unregister_handle:
|
||||
input_unregister_handle(handle);
|
||||
free_handle:
|
||||
kfree(handle);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void devfreq_boost_input_disconnect(struct input_handle *handle)
|
||||
{
|
||||
input_close_device(handle);
|
||||
input_unregister_handle(handle);
|
||||
kfree(handle);
|
||||
}
|
||||
|
||||
static const struct input_device_id devfreq_boost_ids[] = {
|
||||
/* Multi-touch touchscreen */
|
||||
{
|
||||
.flags = INPUT_DEVICE_ID_MATCH_EVBIT |
|
||||
INPUT_DEVICE_ID_MATCH_ABSBIT,
|
||||
.evbit = { BIT_MASK(EV_ABS) },
|
||||
.absbit = { [BIT_WORD(ABS_MT_POSITION_X)] =
|
||||
BIT_MASK(ABS_MT_POSITION_X) |
|
||||
BIT_MASK(ABS_MT_POSITION_Y) }
|
||||
},
|
||||
/* Touchpad */
|
||||
{
|
||||
.flags = INPUT_DEVICE_ID_MATCH_KEYBIT |
|
||||
INPUT_DEVICE_ID_MATCH_ABSBIT,
|
||||
.keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
|
||||
.absbit = { [BIT_WORD(ABS_X)] =
|
||||
BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) }
|
||||
},
|
||||
/* Keypad */
|
||||
{
|
||||
.flags = INPUT_DEVICE_ID_MATCH_EVBIT,
|
||||
.evbit = { BIT_MASK(EV_KEY) }
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct input_handler devfreq_boost_input_handler = {
|
||||
.event = devfreq_boost_input_event,
|
||||
.connect = devfreq_boost_input_connect,
|
||||
.disconnect = devfreq_boost_input_disconnect,
|
||||
.name = "devfreq_boost_handler",
|
||||
.id_table = devfreq_boost_ids
|
||||
};
|
||||
|
||||
static int __init devfreq_boost_init(void)
|
||||
{
|
||||
struct df_boost_drv *d = &df_boost_drv_g;
|
||||
struct task_struct *thread[DEVFREQ_MAX];
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < DEVFREQ_MAX; i++) {
|
||||
struct boost_dev *b = d->devices + i;
|
||||
|
||||
thread[i] = kthread_run_perf_critical(devfreq_boost_thread, b,
|
||||
"devfreq_boostd/%d", i);
|
||||
if (IS_ERR(thread[i])) {
|
||||
ret = PTR_ERR(thread[i]);
|
||||
pr_err("Failed to create kthread, err: %d\n", ret);
|
||||
goto stop_kthreads;
|
||||
}
|
||||
}
|
||||
|
||||
devfreq_boost_input_handler.private = d;
|
||||
ret = input_register_handler(&devfreq_boost_input_handler);
|
||||
if (ret) {
|
||||
pr_err("Failed to register input handler, err: %d\n", ret);
|
||||
goto stop_kthreads;
|
||||
}
|
||||
|
||||
d->msm_drm_notif.notifier_call = msm_drm_notifier_cb;
|
||||
d->msm_drm_notif.priority = INT_MAX;
|
||||
ret = msm_drm_register_client(&d->msm_drm_notif);
|
||||
if (ret) {
|
||||
pr_err("Failed to register fb notifier, err: %d\n", ret);
|
||||
goto unregister_handler;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
unregister_handler:
|
||||
input_unregister_handler(&devfreq_boost_input_handler);
|
||||
stop_kthreads:
|
||||
while (i--)
|
||||
kthread_stop(thread[i]);
|
||||
return ret;
|
||||
}
|
||||
late_initcall(devfreq_boost_init);
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <trace/events/power.h>
|
||||
#include <linux/msm-bus.h>
|
||||
#include <linux/msm-bus-board.h>
|
||||
#include <linux/devfreq_boost.h>
|
||||
|
||||
/* Has to be ULL to prevent overflow where this macro is used. */
|
||||
#define MBYTE (1ULL << 20)
|
||||
@@ -238,12 +237,6 @@ int devfreq_add_devbw(struct device *dev)
|
||||
return PTR_ERR(d->df);
|
||||
}
|
||||
|
||||
if (!strcmp(dev_name(dev), "soc:qcom,cpu-cpu-llcc-bw"))
|
||||
devfreq_register_boost_device(DEVFREQ_MSM_CPUBW, d->df);
|
||||
|
||||
if (!strcmp(dev_name(dev), "soc:qcom,cpu-llcc-ddr-bw"))
|
||||
devfreq_register_boost_device(DEVFREQ_MSM_LLCCBW, d->df);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <drm/drm_mode.h>
|
||||
#include <drm/drm_print.h>
|
||||
#include <linux/sync_file.h>
|
||||
#include <linux/devfreq_boost.h>
|
||||
|
||||
#include "drm_crtc_internal.h"
|
||||
|
||||
@@ -2248,11 +2247,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
|
||||
(arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
|
||||
return -EINVAL;
|
||||
|
||||
if (!(arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)) {
|
||||
devfreq_boost_kick(DEVFREQ_MSM_CPUBW);
|
||||
devfreq_boost_kick(DEVFREQ_MSM_LLCCBW);
|
||||
}
|
||||
|
||||
drm_modeset_acquire_init(&ctx, 0);
|
||||
|
||||
state = drm_atomic_state_alloc(dev);
|
||||
|
||||
17
fs/exec.c
17
fs/exec.c
@@ -77,16 +77,6 @@ int suid_dumpable = 0;
|
||||
static LIST_HEAD(formats);
|
||||
static DEFINE_RWLOCK(binfmt_lock);
|
||||
|
||||
#define ZYGOTE32_BIN "/system/bin/app_process32"
|
||||
#define ZYGOTE64_BIN "/system/bin/app_process64"
|
||||
static struct signal_struct *zygote32_sig;
|
||||
static struct signal_struct *zygote64_sig;
|
||||
|
||||
bool task_is_zygote(struct task_struct *p)
|
||||
{
|
||||
return p->signal == zygote32_sig || p->signal == zygote64_sig;
|
||||
}
|
||||
|
||||
void __register_binfmt(struct linux_binfmt * fmt, int insert)
|
||||
{
|
||||
BUG_ON(!fmt);
|
||||
@@ -1809,13 +1799,6 @@ static int do_execveat_common(int fd, struct filename *filename,
|
||||
if (retval < 0)
|
||||
goto out;
|
||||
|
||||
if (is_global_init(current->parent)) {
|
||||
if (unlikely(!strcmp(filename->name, ZYGOTE32_BIN)))
|
||||
zygote32_sig = current->signal;
|
||||
else if (unlikely(!strcmp(filename->name, ZYGOTE64_BIN)))
|
||||
zygote64_sig = current->signal;
|
||||
}
|
||||
|
||||
/* execve succeeded */
|
||||
current->fs->in_exec = 0;
|
||||
current->in_execve = 0;
|
||||
|
||||
@@ -139,7 +139,6 @@ extern int prepare_bprm_creds(struct linux_binprm *bprm);
|
||||
extern void install_exec_creds(struct linux_binprm *bprm);
|
||||
extern void set_binfmt(struct linux_binfmt *new);
|
||||
extern ssize_t read_code(struct file *, unsigned long, loff_t, size_t);
|
||||
extern bool task_is_zygote(struct task_struct *p);
|
||||
|
||||
extern int do_execve(struct filename *,
|
||||
const char __user * const __user *,
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (C) 2018-2019 Sultan Alsawaf <sultan@kerneltoast.com>.
|
||||
*/
|
||||
#ifndef _CPU_INPUT_BOOST_H_
|
||||
#define _CPU_INPUT_BOOST_H_
|
||||
|
||||
#ifdef CONFIG_CPU_INPUT_BOOST
|
||||
void cpu_input_boost_kick_max(unsigned int duration_ms);
|
||||
#else
|
||||
static inline void cpu_input_boost_kick_max(unsigned int duration_ms)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CPU_INPUT_BOOST_H_ */
|
||||
@@ -154,8 +154,6 @@ struct devfreq {
|
||||
|
||||
unsigned long min_freq;
|
||||
unsigned long max_freq;
|
||||
bool is_boost_device;
|
||||
bool max_boost;
|
||||
bool stop_polling;
|
||||
|
||||
/* information for device frequency transition */
|
||||
@@ -388,11 +386,6 @@ static inline int devfreq_update_stats(struct devfreq *df)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int update_devfreq(struct devfreq *devfreq)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif /* CONFIG_PM_DEVFREQ */
|
||||
|
||||
#endif /* __LINUX_DEVFREQ_H__ */
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (C) 2018-2019 Sultan Alsawaf <sultan@kerneltoast.com>.
|
||||
*/
|
||||
#ifndef _DEVFREQ_BOOST_H_
|
||||
#define _DEVFREQ_BOOST_H_
|
||||
|
||||
#include <linux/devfreq.h>
|
||||
|
||||
enum df_device {
|
||||
DEVFREQ_MSM_CPUBW,
|
||||
DEVFREQ_MSM_LLCCBW,
|
||||
DEVFREQ_MAX
|
||||
};
|
||||
|
||||
#ifdef CONFIG_DEVFREQ_BOOST
|
||||
void devfreq_boost_kick(enum df_device device);
|
||||
void devfreq_boost_kick_max(enum df_device device, unsigned int duration_ms);
|
||||
void devfreq_register_boost_device(enum df_device device, struct devfreq *df);
|
||||
#else
|
||||
static inline
|
||||
void devfreq_boost_kick(enum df_device device)
|
||||
{
|
||||
}
|
||||
static inline
|
||||
void devfreq_boost_kick_max(enum df_device device, unsigned int duration_ms)
|
||||
{
|
||||
}
|
||||
static inline
|
||||
void devfreq_register_boost_device(enum df_device device, struct devfreq *df)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _DEVFREQ_BOOST_H_ */
|
||||
@@ -13,8 +13,6 @@
|
||||
#include <linux/delayacct.h>
|
||||
#include <linux/pid_namespace.h>
|
||||
#include <linux/cgroupstats.h>
|
||||
#include <linux/binfmts.h>
|
||||
#include <linux/cpu_input_boost.h>
|
||||
|
||||
#include <trace/events/cgroup.h>
|
||||
|
||||
@@ -553,11 +551,6 @@ static ssize_t __cgroup1_procs_write(struct kernfs_open_file *of,
|
||||
|
||||
ret = cgroup_attach_task(cgrp, task, threadgroup);
|
||||
|
||||
/* This covers boosting for app launches and app transitions */
|
||||
if (!ret && !threadgroup && !strcmp(of->kn->parent->name, "top-app") &&
|
||||
task_is_zygote(task->parent))
|
||||
cpu_input_boost_kick_max(1000);
|
||||
|
||||
out_finish:
|
||||
cgroup_procs_write_finish(task);
|
||||
out_unlock:
|
||||
|
||||
@@ -95,7 +95,6 @@
|
||||
#include <linux/cpufreq_times.h>
|
||||
#include <linux/scs.h>
|
||||
#include <linux/simple_lmk.h>
|
||||
#include <linux/cpu_input_boost.h>
|
||||
|
||||
#include <asm/pgtable.h>
|
||||
#include <asm/pgalloc.h>
|
||||
@@ -2207,10 +2206,6 @@ long _do_fork(unsigned long clone_flags,
|
||||
int trace = 0;
|
||||
long nr;
|
||||
|
||||
/* Boost CPU to the max for 3000 ms when userspace launches an app */
|
||||
if (task_is_zygote(current))
|
||||
cpu_input_boost_kick_max(3000);
|
||||
|
||||
/*
|
||||
* Determine whether and which event to report to ptracer. When
|
||||
* called from kernel_thread or CLONE_UNTRACED is explicitly
|
||||
|
||||
@@ -69,7 +69,6 @@
|
||||
#include <linux/lockdep.h>
|
||||
#include <linux/nmi.h>
|
||||
#include <linux/psi.h>
|
||||
#include <linux/devfreq_boost.h>
|
||||
|
||||
#include <asm/sections.h>
|
||||
#include <asm/tlbflush.h>
|
||||
@@ -4227,10 +4226,6 @@ retry:
|
||||
if (costly_order && !(gfp_mask & __GFP_RETRY_MAYFAIL))
|
||||
goto nopage;
|
||||
|
||||
/* Boost when memory is low so allocation latency doesn't get too bad */
|
||||
devfreq_boost_kick_max(DEVFREQ_MSM_LLCCBW, 100);
|
||||
devfreq_boost_kick_max(DEVFREQ_MSM_CPUBW, 100);
|
||||
|
||||
if (should_reclaim_retry(gfp_mask, order, ac, alloc_flags,
|
||||
did_some_progress > 0, &no_progress_loops))
|
||||
goto retry;
|
||||
|
||||
Reference in New Issue
Block a user