@@ -66,6 +66,7 @@ struct idle_inject_thread {
*/
struct idle_inject_device {
struct hrtimer timer;
+ int state;
unsigned int idle_duration_us;
unsigned int run_duration_us;
unsigned long int cpumask[0];
@@ -140,7 +141,7 @@ static void idle_inject_fn(unsigned int cpu)
iit->should_run = 0;
play_idle(READ_ONCE(ii_dev->idle_duration_us),
- cpuidle_find_deepest_state());
+ READ_ONCE(ii_dev->state));
}
/**
@@ -171,6 +172,16 @@ void idle_inject_get_duration(struct idle_inject_device *ii_dev,
*idle_duration_us = READ_ONCE(ii_dev->idle_duration_us);
}
+/**
+ * idle_inject_set_state - set the idle state to inject
+ * @state: an integer for the idle state to inject
+ */
+void idle_inject_set_state(struct idle_inject_device *ii_dev, int state)
+{
+ if (state >= CPUIDLE_STATE_NOUSE && state < CPUIDLE_STATE_MAX)
+ WRITE_ONCE(ii_dev->state, state);
+}
+
/**
* idle_inject_start - start idle injections
* @ii_dev: idle injection control device structure
@@ -299,6 +310,7 @@ struct idle_inject_device *idle_inject_register(struct cpumask *cpumask)
cpumask_copy(to_cpumask(ii_dev->cpumask), cpumask);
hrtimer_init(&ii_dev->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
ii_dev->timer.function = idle_inject_timer_fn;
+ ii_dev->state = cpuidle_find_deepest_state();
for_each_cpu(cpu, to_cpumask(ii_dev->cpumask)) {
@@ -26,4 +26,7 @@ void idle_inject_set_duration(struct idle_inject_device *ii_dev,
void idle_inject_get_duration(struct idle_inject_device *ii_dev,
unsigned int *run_duration_us,
unsigned int *idle_duration_us);
+
+void idle_inject_set_state(struct idle_inject_device *ii_dev, int state);
+
#endif /* __IDLE_INJECT_H__ */