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

Commit 35e30b35 authored by Raghavendra Kakarla's avatar Raghavendra Kakarla Committed by Gerrit - the friendly Code Review server
Browse files

drivers: cpuidle: lpm-levels: Update CPU prediction timer



Use per cpu timer to wake up cpu when LPM prediction fails.

Change-Id: I42e56a54decb1b98651a85f0087fd37542b68425
Signed-off-by: default avatarRaghavendra Kakarla <rkakarla@codeaurora.org>
parent 64766974
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ static DEFINE_PER_CPU(struct lpm_history, hist);
static DEFINE_PER_CPU(struct lpm_cpu*, cpu_lpm);
static bool suspend_in_progress;
static struct hrtimer lpm_hrtimer;
static struct hrtimer histtimer;
static DEFINE_PER_CPU(struct hrtimer, histtimer);
static struct lpm_debug *lpm_debug;
static phys_addr_t lpm_debug_phys;
static const int num_dbg_elements = 0x100;
@@ -345,7 +345,10 @@ static enum hrtimer_restart lpm_hrtimer_cb(struct hrtimer *h)

static void histtimer_cancel(void)
{
	hrtimer_try_to_cancel(&histtimer);
	unsigned int cpu = raw_smp_processor_id();
	struct hrtimer *cpu_histtimer = &per_cpu(histtimer, cpu);

	hrtimer_try_to_cancel(cpu_histtimer);
}

static enum hrtimer_restart histtimer_fn(struct hrtimer *h)
@@ -361,9 +364,11 @@ static void histtimer_start(uint32_t time_us)
{
	uint64_t time_ns = time_us * NSEC_PER_USEC;
	ktime_t hist_ktime = ns_to_ktime(time_ns);
	unsigned int cpu = raw_smp_processor_id();
	struct hrtimer *cpu_histtimer = &per_cpu(histtimer, cpu);

	histtimer.function = histtimer_fn;
	hrtimer_start(&histtimer, hist_ktime, HRTIMER_MODE_REL_PINNED);
	cpu_histtimer->function = histtimer_fn;
	hrtimer_start(cpu_histtimer, hist_ktime, HRTIMER_MODE_REL_PINNED);
}

static void cluster_timer_init(struct lpm_cluster *cluster)
@@ -1643,6 +1648,8 @@ static int lpm_probe(struct platform_device *pdev)
{
	int ret;
	int size;
	unsigned int cpu;
	struct hrtimer *cpu_histtimer;
	struct kobject *module_kobj = NULL;
	struct md_region md_entry;

@@ -1666,7 +1673,11 @@ static int lpm_probe(struct platform_device *pdev)
	 */
	suspend_set_ops(&lpm_suspend_ops);
	hrtimer_init(&lpm_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	hrtimer_init(&histtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	for_each_possible_cpu(cpu) {
		cpu_histtimer = &per_cpu(histtimer, cpu);
		hrtimer_init(cpu_histtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	}

	cluster_timer_init(lpm_root_node);

	size = num_dbg_elements * sizeof(struct lpm_debug);