diff options
-rw-r--r-- | drivers/cpuidle/Kconfig | 4 | ||||
-rw-r--r-- | drivers/cpuidle/governors/Makefile | 1 | ||||
-rw-r--r-- | drivers/cpuidle/governors/irq.c | 33 |
3 files changed, 38 insertions, 0 deletions
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index c5029c1209b4..1aae78bc9d95 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig @@ -25,6 +25,10 @@ config CPU_IDLE_GOV_MENU bool "Menu governor (for tickless system)" default y +config CPU_IDLE_GOV_IRQ + bool "Irq governor (for tickless system)" + default y + config DT_IDLE_STATES bool diff --git a/drivers/cpuidle/governors/Makefile b/drivers/cpuidle/governors/Makefile index 1b512722689f..8804ee2f550c 100644 --- a/drivers/cpuidle/governors/Makefile +++ b/drivers/cpuidle/governors/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_CPU_IDLE_GOV_LADDER) += ladder.o obj-$(CONFIG_CPU_IDLE_GOV_MENU) += menu.o +obj-$(CONFIG_CPU_IDLE_GOV_IRQ) += irq.o diff --git a/drivers/cpuidle/governors/irq.c b/drivers/cpuidle/governors/irq.c new file mode 100644 index 000000000000..cb7a0bfbd133 --- /dev/null +++ b/drivers/cpuidle/governors/irq.c @@ -0,0 +1,33 @@ +/* + * irq.c - the irq governor + * + * Copyright (C) 2014 Daniel Lezcano <daniel.lezcano@linaro.org> + * +*/ +#include <linux/ktime.h> +#include <linux/irq.h> +#include <linux/cpuidle.h> + +static int select(struct cpuidle_driver *drv, struct cpuidle_device *dev, + int latency_req, s64 next_timer_event) +{ + s64 next_irq_event = irqt_get_next_prediction(dev->cpu); + s64 next_event = next_irq_event ? + min(next_irq_event, next_timer_event) : next_timer_event; + + return cpuidle_find_state(drv, dev, next_event, latency_req); +} + +static struct cpuidle_governor irq_governor = { + .name = "irq", + .rating = 10, + .select = select, + .owner = THIS_MODULE, +}; + +static int __init irq_init(void) +{ + return cpuidle_register_governor(&irq_governor); +} + +postcore_initcall(irq_init); |