Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c3d3d24 authored by J. Avila's avatar J. Avila
Browse files

ANDROID: GKI: kernel: tick-sched: Add an API for wakeup callbacks



Some modules perform actions on wake, as checked in tick-sched. Add a
function to register callbacks and export it.

Bug: 161415027
Bug: 161414381
Signed-off-by: default avatarJ. Avila <elavila@google.com>
Change-Id: I7e1da4aea9e78ad2a7f0c407d4162fabc0e368a7
parent f35f6c67
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -111,6 +111,8 @@ enum tick_dep_bits {
#define TICK_DEP_MASK_SCHED		(1 << TICK_DEP_BIT_SCHED)
#define TICK_DEP_MASK_CLOCK_UNSTABLE	(1 << TICK_DEP_BIT_CLOCK_UNSTABLE)

extern void register_tick_sched_wakeup_callback(void (*cb)(void));

#ifdef CONFIG_NO_HZ_COMMON
extern bool tick_nohz_enabled;
extern bool tick_nohz_tick_stopped(void);
+21 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <linux/module.h>
#include <linux/irq_work.h>
#include <linux/posix-timers.h>
#include <linux/timer.h>
#include <linux/context_tracking.h>
#include <linux/mm.h>

@@ -1258,6 +1259,9 @@ void tick_irq_enter(void)
 * High resolution timer specific code
 */
#ifdef CONFIG_HIGH_RES_TIMERS

static void (*wake_callback)(void);

/*
 * We rearm the timer until we get disabled by the idle code.
 * Called with interrupts disabled.
@@ -1275,8 +1279,15 @@ static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer)
	 * Do not call, when we are not in irq context and have
	 * no valid regs pointer
	 */
	if (regs)
	if (regs) {
		tick_sched_handle(ts, regs);
		if (wake_callback && tick_do_timer_cpu == smp_processor_id()) {
			/*
			 * wakeup user if needed
			 */
			wake_callback();
		}
	}
	else
		ts->next_tick = 0;

@@ -1393,6 +1404,15 @@ int tick_check_oneshot_change(int allow_nohz)
	return 0;
}

void register_tick_sched_wakeup_callback(void (*cb)(void))
{
	if (!wake_callback)
		wake_callback = cb;
	else
		pr_warn("tick-sched wake cb already exists; skipping.\n");
}
EXPORT_SYMBOL_GPL(register_tick_sched_wakeup_callback);

ktime_t *get_next_event_cpu(unsigned int cpu)
{
	return &(per_cpu(tick_cpu_device, cpu).evtdev->next_event);