Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

Commit

Permalink
cpu_input_boost: Introduce configurable frame boost timeout
Browse files Browse the repository at this point in the history
This aims to further mitigate unnecessary boosting by limiting the
amount of time a frame boost can be invoked following the last
user input event and can also be used to disable frame
boosting entirely if a negative value is applied. A default
timeout of 3250ms is set to cover an average duration of the
longest measurable fling events. Setting a timeout of 0 will
restore default frame boost behavior, not accounting for last
input events.

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
[@0ctobot: Adapted from kdrag0n/proton_bluecross@2866d2e
and squashed with the following commits:
kdrag0n/proton_bluecross@e8702b8
kdrag0n/proton_bluecross@950db83
kdrag0n/proton_bluecross@825008d
kdrag0n/proton_bluecross@1305d13
kdrag0n/proton_bluecross@6f17085
kdrag0n/proton_bluecross@14c1ff9
kdrag0n/proton_bluecross@9c3b1db
kdrag0n/proton_bluecross@31475c9]
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
  • Loading branch information
kdrag0n authored and 0ctobot committed Apr 4, 2019
1 parent a85f4f2 commit 13b370b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
7 changes: 7 additions & 0 deletions drivers/cpufreq/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ config INPUT_STUNE_BOOST
of process groups in order to bias core selection as well as CPU
frequency selection. A value of 0 disables this functionality.

config FRAME_BOOST_TIMEOUT
int "Post-input timeout for frame boost"
default "3250"
help
The amount of time in milliseconds to boost on frame updates after the
last input event.

config REMOVE_INPUT_BOOST_FREQ_LP
int "Low-power cluster return frequency"
default "0"
Expand Down
18 changes: 18 additions & 0 deletions drivers/cpufreq/cpu_input_boost.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
#include <linux/msm_drm_notify.h>
#include <linux/slab.h>

unsigned long last_input_jiffies;

static __read_mostly unsigned int input_boost_freq_lp = CONFIG_INPUT_BOOST_FREQ_LP;
static __read_mostly unsigned int input_boost_freq_hp = CONFIG_INPUT_BOOST_FREQ_PERF;
static __read_mostly unsigned int input_boost_return_freq_lp = CONFIG_REMOVE_INPUT_BOOST_FREQ_LP;
static __read_mostly unsigned int input_boost_return_freq_hp = CONFIG_REMOVE_INPUT_BOOST_FREQ_PERF;
static __read_mostly unsigned int frame_boost_freq_lp = CONFIG_FRAME_BOOST_FREQ_LP;
static __read_mostly unsigned int frame_boost_freq_hp = CONFIG_FRAME_BOOST_FREQ_PERF;
static __read_mostly unsigned short input_boost_duration = CONFIG_INPUT_BOOST_DURATION_MS;
static __read_mostly int frame_boost_timeout = CONFIG_FRAME_BOOST_TIMEOUT;

module_param(input_boost_freq_lp, uint, 0644);
module_param(input_boost_freq_hp, uint, 0644);
Expand All @@ -27,6 +30,7 @@ module_param_named(remove_input_boost_freq_perf, input_boost_return_freq_hp, uin
module_param(frame_boost_freq_lp, uint, 0644);
module_param(frame_boost_freq_hp, uint, 0644);
module_param(input_boost_duration, short, 0644);
module_param(frame_boost_timeout, int, 0644);

#ifdef CONFIG_DYNAMIC_STUNE_BOOST
static __read_mostly int input_stune_boost = CONFIG_INPUT_STUNE_BOOST;
Expand Down Expand Up @@ -149,6 +153,18 @@ static void unboost_all_cpus(struct boost_drv *b)
clear_stune_boost(b, &b->frame_stune_active, b->frame_stune_slot);
}

bool should_kick_frame_boost(void)
{
if (frame_boost_timeout == 0)
return true;

if (frame_boost_timeout < 0)
return false;

return time_before(jiffies, last_input_jiffies +
msecs_to_jiffies(frame_boost_timeout));
}

static void __cpu_input_boost_kick(struct boost_drv *b)
{
if (!(get_boost_state(b) & SCREEN_AWAKE))
Expand Down Expand Up @@ -378,6 +394,8 @@ static void cpu_input_boost_input_event(struct input_handle *handle,
struct boost_drv *b = handle->handler->private;

__cpu_input_boost_kick(b);

last_input_jiffies = jiffies;
}

static int cpu_input_boost_input_connect(struct input_handler *handler,
Expand Down
7 changes: 6 additions & 1 deletion drivers/gpu/drm/drm_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1906,10 +1906,15 @@ 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)) {
#ifdef CONFIG_CPU_INPUT_BOOST
if (!(arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) &&
should_kick_frame_boost()) {
cpu_frame_boost_kick(64);
#ifdef CONFIG_DEVFREQ_BOOST
devfreq_boost_kick(DEVFREQ_MSM_CPUBW);
#endif
}
#endif

drm_modeset_acquire_init(&ctx, 0);

Expand Down
9 changes: 9 additions & 0 deletions include/linux/cpu_input_boost.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
#define _CPU_INPUT_BOOST_H_

#ifdef CONFIG_CPU_INPUT_BOOST
extern unsigned long last_input_jiffies;

void cpu_input_boost_kick(void);
void cpu_input_boost_kick_max(unsigned int duration_ms);
void cpu_frame_boost_kick(unsigned int duration_ms);

bool should_kick_frame_boost(void);
#else
static inline void cpu_input_boost_kick(void)
{
Expand All @@ -19,6 +23,11 @@ static inline void cpu_input_boost_kick_max(unsigned int duration_ms)
static inline void cpu_frame_boost_kick(unsigned int duration_ms)
{
}

static inline bool should_kick_frame_boost(void)
{
return false;
}
#endif

#endif /* _CPU_INPUT_BOOST_H_ */

0 comments on commit 13b370b

Please sign in to comment.