xref: /openbmc/linux/drivers/idle/intel_idle.c (revision eba682a5)
126717172SLen Brown /*
226717172SLen Brown  * intel_idle.c - native hardware idle loop for modern Intel processors
326717172SLen Brown  *
426717172SLen Brown  * Copyright (c) 2010, Intel Corporation.
526717172SLen Brown  * Len Brown <len.brown@intel.com>
626717172SLen Brown  *
726717172SLen Brown  * This program is free software; you can redistribute it and/or modify it
826717172SLen Brown  * under the terms and conditions of the GNU General Public License,
926717172SLen Brown  * version 2, as published by the Free Software Foundation.
1026717172SLen Brown  *
1126717172SLen Brown  * This program is distributed in the hope it will be useful, but WITHOUT
1226717172SLen Brown  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1326717172SLen Brown  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
1426717172SLen Brown  * more details.
1526717172SLen Brown  *
1626717172SLen Brown  * You should have received a copy of the GNU General Public License along with
1726717172SLen Brown  * this program; if not, write to the Free Software Foundation, Inc.,
1826717172SLen Brown  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
1926717172SLen Brown  */
2026717172SLen Brown 
2126717172SLen Brown /*
2226717172SLen Brown  * intel_idle is a cpuidle driver that loads on specific Intel processors
2326717172SLen Brown  * in lieu of the legacy ACPI processor_idle driver.  The intent is to
2426717172SLen Brown  * make Linux more efficient on these processors, as intel_idle knows
2526717172SLen Brown  * more than ACPI, as well as make Linux more immune to ACPI BIOS bugs.
2626717172SLen Brown  */
2726717172SLen Brown 
2826717172SLen Brown /*
2926717172SLen Brown  * Design Assumptions
3026717172SLen Brown  *
3126717172SLen Brown  * All CPUs have same idle states as boot CPU
3226717172SLen Brown  *
3326717172SLen Brown  * Chipset BM_STS (bus master status) bit is a NOP
3426717172SLen Brown  *	for preventing entry into deep C-stats
3526717172SLen Brown  */
3626717172SLen Brown 
3726717172SLen Brown /*
3826717172SLen Brown  * Known limitations
3926717172SLen Brown  *
4026717172SLen Brown  * The driver currently initializes for_each_online_cpu() upon modprobe.
4126717172SLen Brown  * It it unaware of subsequent processors hot-added to the system.
4226717172SLen Brown  * This means that if you boot with maxcpus=n and later online
4326717172SLen Brown  * processors above n, those processors will use C1 only.
4426717172SLen Brown  *
4526717172SLen Brown  * ACPI has a .suspend hack to turn off deep c-statees during suspend
4626717172SLen Brown  * to avoid complications with the lapic timer workaround.
4726717172SLen Brown  * Have not seen issues with suspend, but may need same workaround here.
4826717172SLen Brown  *
4926717172SLen Brown  * There is currently no kernel-based automatic probing/loading mechanism
5026717172SLen Brown  * if the driver is built as a module.
5126717172SLen Brown  */
5226717172SLen Brown 
5326717172SLen Brown /* un-comment DEBUG to enable pr_debug() statements */
5426717172SLen Brown #define DEBUG
5526717172SLen Brown 
5626717172SLen Brown #include <linux/kernel.h>
5726717172SLen Brown #include <linux/cpuidle.h>
5826717172SLen Brown #include <linux/clockchips.h>
5926717172SLen Brown #include <trace/events/power.h>
6026717172SLen Brown #include <linux/sched.h>
612a2d31c8SShaohua Li #include <linux/notifier.h>
622a2d31c8SShaohua Li #include <linux/cpu.h>
637c52d551SPaul Gortmaker #include <linux/module.h>
64b66b8b9aSAndi Kleen #include <asm/cpu_device_id.h>
65bc83ccccSH. Peter Anvin #include <asm/mwait.h>
6614796fcaSLen Brown #include <asm/msr.h>
6726717172SLen Brown 
6826717172SLen Brown #define INTEL_IDLE_VERSION "0.4"
6926717172SLen Brown #define PREFIX "intel_idle: "
7026717172SLen Brown 
7126717172SLen Brown static struct cpuidle_driver intel_idle_driver = {
7226717172SLen Brown 	.name = "intel_idle",
7326717172SLen Brown 	.owner = THIS_MODULE,
7426717172SLen Brown };
7526717172SLen Brown /* intel_idle.max_cstate=0 disables driver */
76137ecc77SLen Brown static int max_cstate = CPUIDLE_STATE_MAX - 1;
7726717172SLen Brown 
78c4236282SLen Brown static unsigned int mwait_substates;
7926717172SLen Brown 
802a2d31c8SShaohua Li #define LAPIC_TIMER_ALWAYS_RELIABLE 0xFFFFFFFF
8126717172SLen Brown /* Reliable LAPIC Timer States, bit 1 for C1 etc.  */
82d13780d4SLen Brown static unsigned int lapic_timer_reliable_states = (1 << 1);	 /* Default to only C1 */
8326717172SLen Brown 
84b66b8b9aSAndi Kleen struct idle_cpu {
85b66b8b9aSAndi Kleen 	struct cpuidle_state *state_table;
8626717172SLen Brown 
8726717172SLen Brown 	/*
8814796fcaSLen Brown 	 * Hardware C-state auto-demotion may not always be optimal.
8914796fcaSLen Brown 	 * Indicate which enable bits to clear here.
9014796fcaSLen Brown 	 */
91b66b8b9aSAndi Kleen 	unsigned long auto_demotion_disable_flags;
9232e95180SLen Brown 	bool disable_promotion_to_c1e;
93b66b8b9aSAndi Kleen };
94b66b8b9aSAndi Kleen 
95b66b8b9aSAndi Kleen static const struct idle_cpu *icpu;
96b66b8b9aSAndi Kleen static struct cpuidle_device __percpu *intel_idle_cpuidle_devices;
97b66b8b9aSAndi Kleen static int intel_idle(struct cpuidle_device *dev,
98b66b8b9aSAndi Kleen 			struct cpuidle_driver *drv, int index);
9925ac7761SDaniel Lezcano static int intel_idle_cpu_init(int cpu);
100b66b8b9aSAndi Kleen 
101b66b8b9aSAndi Kleen static struct cpuidle_state *cpuidle_state_table;
10214796fcaSLen Brown 
10314796fcaSLen Brown /*
104956d033fSLen Brown  * Set this flag for states where the HW flushes the TLB for us
105956d033fSLen Brown  * and so we don't need cross-calls to keep it consistent.
106956d033fSLen Brown  * If this flag is set, SW flushes the TLB, so even if the
107956d033fSLen Brown  * HW doesn't do the flushing, this flag is safe to use.
108956d033fSLen Brown  */
109956d033fSLen Brown #define CPUIDLE_FLAG_TLB_FLUSHED	0x10000
110956d033fSLen Brown 
111956d033fSLen Brown /*
112b1beab48SLen Brown  * MWAIT takes an 8-bit "hint" in EAX "suggesting"
113b1beab48SLen Brown  * the C-state (top nibble) and sub-state (bottom nibble)
114b1beab48SLen Brown  * 0x00 means "MWAIT(C1)", 0x10 means "MWAIT(C2)" etc.
115b1beab48SLen Brown  *
116b1beab48SLen Brown  * We store the hint at the top of our "flags" for each state.
117b1beab48SLen Brown  */
118b1beab48SLen Brown #define flg2MWAIT(flags) (((flags) >> 24) & 0xFF)
119b1beab48SLen Brown #define MWAIT2flg(eax) ((eax & 0xFF) << 24)
120b1beab48SLen Brown 
121b1beab48SLen Brown /*
12226717172SLen Brown  * States are indexed by the cstate number,
12326717172SLen Brown  * which is also the index into the MWAIT hint array.
12426717172SLen Brown  * Thus C0 is a dummy.
12526717172SLen Brown  */
126eba682a5SBartlomiej Zolnierkiewicz static struct cpuidle_state nehalem_cstates[] = {
127e022e7ebSLen Brown 	{
12815e123e5SThomas Renninger 		.name = "C1-NHM",
12926717172SLen Brown 		.desc = "MWAIT 0x00",
130b1beab48SLen Brown 		.flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
13126717172SLen Brown 		.exit_latency = 3,
13226717172SLen Brown 		.target_residency = 6,
13326717172SLen Brown 		.enter = &intel_idle },
134e022e7ebSLen Brown 	{
13532e95180SLen Brown 		.name = "C1E-NHM",
13632e95180SLen Brown 		.desc = "MWAIT 0x01",
13732e95180SLen Brown 		.flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
13832e95180SLen Brown 		.exit_latency = 10,
13932e95180SLen Brown 		.target_residency = 20,
14032e95180SLen Brown 		.enter = &intel_idle },
14132e95180SLen Brown 	{
14215e123e5SThomas Renninger 		.name = "C3-NHM",
14326717172SLen Brown 		.desc = "MWAIT 0x10",
144b1beab48SLen Brown 		.flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
14526717172SLen Brown 		.exit_latency = 20,
14626717172SLen Brown 		.target_residency = 80,
14726717172SLen Brown 		.enter = &intel_idle },
148e022e7ebSLen Brown 	{
14915e123e5SThomas Renninger 		.name = "C6-NHM",
15026717172SLen Brown 		.desc = "MWAIT 0x20",
151b1beab48SLen Brown 		.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
15226717172SLen Brown 		.exit_latency = 200,
15326717172SLen Brown 		.target_residency = 800,
15426717172SLen Brown 		.enter = &intel_idle },
155e022e7ebSLen Brown 	{
156e022e7ebSLen Brown 		.enter = NULL }
15726717172SLen Brown };
15826717172SLen Brown 
159eba682a5SBartlomiej Zolnierkiewicz static struct cpuidle_state snb_cstates[] = {
160e022e7ebSLen Brown 	{
16115e123e5SThomas Renninger 		.name = "C1-SNB",
162d13780d4SLen Brown 		.desc = "MWAIT 0x00",
163b1beab48SLen Brown 		.flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
16432e95180SLen Brown 		.exit_latency = 2,
16532e95180SLen Brown 		.target_residency = 2,
16632e95180SLen Brown 		.enter = &intel_idle },
16732e95180SLen Brown 	{
16832e95180SLen Brown 		.name = "C1E-SNB",
16932e95180SLen Brown 		.desc = "MWAIT 0x01",
17032e95180SLen Brown 		.flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
17132e95180SLen Brown 		.exit_latency = 10,
17232e95180SLen Brown 		.target_residency = 20,
173d13780d4SLen Brown 		.enter = &intel_idle },
174e022e7ebSLen Brown 	{
17515e123e5SThomas Renninger 		.name = "C3-SNB",
176d13780d4SLen Brown 		.desc = "MWAIT 0x10",
177b1beab48SLen Brown 		.flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
178d13780d4SLen Brown 		.exit_latency = 80,
179ddbd550dSLen Brown 		.target_residency = 211,
180d13780d4SLen Brown 		.enter = &intel_idle },
181e022e7ebSLen Brown 	{
18215e123e5SThomas Renninger 		.name = "C6-SNB",
183d13780d4SLen Brown 		.desc = "MWAIT 0x20",
184b1beab48SLen Brown 		.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
185d13780d4SLen Brown 		.exit_latency = 104,
186ddbd550dSLen Brown 		.target_residency = 345,
187d13780d4SLen Brown 		.enter = &intel_idle },
188e022e7ebSLen Brown 	{
18915e123e5SThomas Renninger 		.name = "C7-SNB",
190d13780d4SLen Brown 		.desc = "MWAIT 0x30",
191b1beab48SLen Brown 		.flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
192d13780d4SLen Brown 		.exit_latency = 109,
193ddbd550dSLen Brown 		.target_residency = 345,
194d13780d4SLen Brown 		.enter = &intel_idle },
195e022e7ebSLen Brown 	{
196e022e7ebSLen Brown 		.enter = NULL }
197d13780d4SLen Brown };
198d13780d4SLen Brown 
199eba682a5SBartlomiej Zolnierkiewicz static struct cpuidle_state ivb_cstates[] = {
200e022e7ebSLen Brown 	{
2016edab08cSLen Brown 		.name = "C1-IVB",
2026edab08cSLen Brown 		.desc = "MWAIT 0x00",
203b1beab48SLen Brown 		.flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
2046edab08cSLen Brown 		.exit_latency = 1,
2056edab08cSLen Brown 		.target_residency = 1,
2066edab08cSLen Brown 		.enter = &intel_idle },
207e022e7ebSLen Brown 	{
20832e95180SLen Brown 		.name = "C1E-IVB",
20932e95180SLen Brown 		.desc = "MWAIT 0x01",
21032e95180SLen Brown 		.flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
21132e95180SLen Brown 		.exit_latency = 10,
21232e95180SLen Brown 		.target_residency = 20,
21332e95180SLen Brown 		.enter = &intel_idle },
21432e95180SLen Brown 	{
2156edab08cSLen Brown 		.name = "C3-IVB",
2166edab08cSLen Brown 		.desc = "MWAIT 0x10",
217b1beab48SLen Brown 		.flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
2186edab08cSLen Brown 		.exit_latency = 59,
2196edab08cSLen Brown 		.target_residency = 156,
2206edab08cSLen Brown 		.enter = &intel_idle },
221e022e7ebSLen Brown 	{
2226edab08cSLen Brown 		.name = "C6-IVB",
2236edab08cSLen Brown 		.desc = "MWAIT 0x20",
224b1beab48SLen Brown 		.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
2256edab08cSLen Brown 		.exit_latency = 80,
2266edab08cSLen Brown 		.target_residency = 300,
2276edab08cSLen Brown 		.enter = &intel_idle },
228e022e7ebSLen Brown 	{
2296edab08cSLen Brown 		.name = "C7-IVB",
2306edab08cSLen Brown 		.desc = "MWAIT 0x30",
231b1beab48SLen Brown 		.flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
2326edab08cSLen Brown 		.exit_latency = 87,
2336edab08cSLen Brown 		.target_residency = 300,
2346edab08cSLen Brown 		.enter = &intel_idle },
235e022e7ebSLen Brown 	{
236e022e7ebSLen Brown 		.enter = NULL }
2376edab08cSLen Brown };
2386edab08cSLen Brown 
239eba682a5SBartlomiej Zolnierkiewicz static struct cpuidle_state hsw_cstates[] = {
240e022e7ebSLen Brown 	{
24185a4d2d4SLen Brown 		.name = "C1-HSW",
24285a4d2d4SLen Brown 		.desc = "MWAIT 0x00",
24385a4d2d4SLen Brown 		.flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
24485a4d2d4SLen Brown 		.exit_latency = 2,
24585a4d2d4SLen Brown 		.target_residency = 2,
24685a4d2d4SLen Brown 		.enter = &intel_idle },
247e022e7ebSLen Brown 	{
24832e95180SLen Brown 		.name = "C1E-HSW",
24932e95180SLen Brown 		.desc = "MWAIT 0x01",
25032e95180SLen Brown 		.flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
25132e95180SLen Brown 		.exit_latency = 10,
25232e95180SLen Brown 		.target_residency = 20,
25332e95180SLen Brown 		.enter = &intel_idle },
25432e95180SLen Brown 	{
25585a4d2d4SLen Brown 		.name = "C3-HSW",
25685a4d2d4SLen Brown 		.desc = "MWAIT 0x10",
25785a4d2d4SLen Brown 		.flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
25885a4d2d4SLen Brown 		.exit_latency = 33,
25985a4d2d4SLen Brown 		.target_residency = 100,
26085a4d2d4SLen Brown 		.enter = &intel_idle },
261e022e7ebSLen Brown 	{
26285a4d2d4SLen Brown 		.name = "C6-HSW",
26385a4d2d4SLen Brown 		.desc = "MWAIT 0x20",
26485a4d2d4SLen Brown 		.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
26585a4d2d4SLen Brown 		.exit_latency = 133,
26685a4d2d4SLen Brown 		.target_residency = 400,
26785a4d2d4SLen Brown 		.enter = &intel_idle },
268e022e7ebSLen Brown 	{
26985a4d2d4SLen Brown 		.name = "C7s-HSW",
27085a4d2d4SLen Brown 		.desc = "MWAIT 0x32",
27185a4d2d4SLen Brown 		.flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
27285a4d2d4SLen Brown 		.exit_latency = 166,
27385a4d2d4SLen Brown 		.target_residency = 500,
27485a4d2d4SLen Brown 		.enter = &intel_idle },
275e022e7ebSLen Brown 	{
27686239cebSLen Brown 		.name = "C8-HSW",
27786239cebSLen Brown 		.desc = "MWAIT 0x40",
27886239cebSLen Brown 		.flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
27986239cebSLen Brown 		.exit_latency = 300,
28086239cebSLen Brown 		.target_residency = 900,
28186239cebSLen Brown 		.enter = &intel_idle },
28286239cebSLen Brown 	{
28386239cebSLen Brown 		.name = "C9-HSW",
28486239cebSLen Brown 		.desc = "MWAIT 0x50",
28586239cebSLen Brown 		.flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
28686239cebSLen Brown 		.exit_latency = 600,
28786239cebSLen Brown 		.target_residency = 1800,
28886239cebSLen Brown 		.enter = &intel_idle },
28986239cebSLen Brown 	{
29086239cebSLen Brown 		.name = "C10-HSW",
29186239cebSLen Brown 		.desc = "MWAIT 0x60",
29286239cebSLen Brown 		.flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
29386239cebSLen Brown 		.exit_latency = 2600,
29486239cebSLen Brown 		.target_residency = 7700,
29586239cebSLen Brown 		.enter = &intel_idle },
29686239cebSLen Brown 	{
297e022e7ebSLen Brown 		.enter = NULL }
29885a4d2d4SLen Brown };
29985a4d2d4SLen Brown 
300eba682a5SBartlomiej Zolnierkiewicz static struct cpuidle_state atom_cstates[] = {
301e022e7ebSLen Brown 	{
30232e95180SLen Brown 		.name = "C1E-ATM",
30326717172SLen Brown 		.desc = "MWAIT 0x00",
304b1beab48SLen Brown 		.flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
30532e95180SLen Brown 		.exit_latency = 10,
30632e95180SLen Brown 		.target_residency = 20,
30726717172SLen Brown 		.enter = &intel_idle },
308e022e7ebSLen Brown 	{
30915e123e5SThomas Renninger 		.name = "C2-ATM",
31026717172SLen Brown 		.desc = "MWAIT 0x10",
311b1beab48SLen Brown 		.flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID,
31226717172SLen Brown 		.exit_latency = 20,
31326717172SLen Brown 		.target_residency = 80,
31426717172SLen Brown 		.enter = &intel_idle },
315e022e7ebSLen Brown 	{
31615e123e5SThomas Renninger 		.name = "C4-ATM",
31726717172SLen Brown 		.desc = "MWAIT 0x30",
318b1beab48SLen Brown 		.flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
31926717172SLen Brown 		.exit_latency = 100,
32026717172SLen Brown 		.target_residency = 400,
32126717172SLen Brown 		.enter = &intel_idle },
322e022e7ebSLen Brown 	{
32315e123e5SThomas Renninger 		.name = "C6-ATM",
3247fcca7d9SLen Brown 		.desc = "MWAIT 0x52",
325b1beab48SLen Brown 		.flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
3267fcca7d9SLen Brown 		.exit_latency = 140,
3277fcca7d9SLen Brown 		.target_residency = 560,
3287fcca7d9SLen Brown 		.enter = &intel_idle },
329e022e7ebSLen Brown 	{
330e022e7ebSLen Brown 		.enter = NULL }
33126717172SLen Brown };
33226717172SLen Brown 
33326717172SLen Brown /**
33426717172SLen Brown  * intel_idle
33526717172SLen Brown  * @dev: cpuidle_device
33646bcfad7SDeepthi Dharwar  * @drv: cpuidle driver
337e978aa7dSDeepthi Dharwar  * @index: index of cpuidle state
33826717172SLen Brown  *
33963ff07beSYanmin Zhang  * Must be called under local_irq_disable().
34026717172SLen Brown  */
34146bcfad7SDeepthi Dharwar static int intel_idle(struct cpuidle_device *dev,
34246bcfad7SDeepthi Dharwar 		struct cpuidle_driver *drv, int index)
34326717172SLen Brown {
34426717172SLen Brown 	unsigned long ecx = 1; /* break on interrupt flag */
34546bcfad7SDeepthi Dharwar 	struct cpuidle_state *state = &drv->states[index];
346b1beab48SLen Brown 	unsigned long eax = flg2MWAIT(state->flags);
34726717172SLen Brown 	unsigned int cstate;
34826717172SLen Brown 	int cpu = smp_processor_id();
34926717172SLen Brown 
35026717172SLen Brown 	cstate = (((eax) >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK) + 1;
35126717172SLen Brown 
3526110a1f4SSuresh Siddha 	/*
353c8381cc3SLen Brown 	 * leave_mm() to avoid costly and often unnecessary wakeups
354c8381cc3SLen Brown 	 * for flushing the user TLB's associated with the active mm.
3556110a1f4SSuresh Siddha 	 */
356c8381cc3SLen Brown 	if (state->flags & CPUIDLE_FLAG_TLB_FLUSHED)
3576110a1f4SSuresh Siddha 		leave_mm(cpu);
3586110a1f4SSuresh Siddha 
35926717172SLen Brown 	if (!(lapic_timer_reliable_states & (1 << (cstate))))
36026717172SLen Brown 		clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
36126717172SLen Brown 
36226717172SLen Brown 	if (!need_resched()) {
36326717172SLen Brown 
36426717172SLen Brown 		__monitor((void *)&current_thread_info()->flags, 0, 0);
36526717172SLen Brown 		smp_mb();
36626717172SLen Brown 		if (!need_resched())
36726717172SLen Brown 			__mwait(eax, ecx);
36826717172SLen Brown 	}
36926717172SLen Brown 
37026717172SLen Brown 	if (!(lapic_timer_reliable_states & (1 << (cstate))))
37126717172SLen Brown 		clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
37226717172SLen Brown 
373e978aa7dSDeepthi Dharwar 	return index;
37426717172SLen Brown }
37526717172SLen Brown 
3762a2d31c8SShaohua Li static void __setup_broadcast_timer(void *arg)
3772a2d31c8SShaohua Li {
3782a2d31c8SShaohua Li 	unsigned long reason = (unsigned long)arg;
3792a2d31c8SShaohua Li 	int cpu = smp_processor_id();
3802a2d31c8SShaohua Li 
3812a2d31c8SShaohua Li 	reason = reason ?
3822a2d31c8SShaohua Li 		CLOCK_EVT_NOTIFY_BROADCAST_ON : CLOCK_EVT_NOTIFY_BROADCAST_OFF;
3832a2d31c8SShaohua Li 
3842a2d31c8SShaohua Li 	clockevents_notify(reason, &cpu);
3852a2d31c8SShaohua Li }
3862a2d31c8SShaohua Li 
38725ac7761SDaniel Lezcano static int cpu_hotplug_notify(struct notifier_block *n,
3882a2d31c8SShaohua Li 			      unsigned long action, void *hcpu)
3892a2d31c8SShaohua Li {
3902a2d31c8SShaohua Li 	int hotcpu = (unsigned long)hcpu;
39125ac7761SDaniel Lezcano 	struct cpuidle_device *dev;
3922a2d31c8SShaohua Li 
3932a2d31c8SShaohua Li 	switch (action & 0xf) {
3942a2d31c8SShaohua Li 	case CPU_ONLINE:
39525ac7761SDaniel Lezcano 
39625ac7761SDaniel Lezcano 		if (lapic_timer_reliable_states != LAPIC_TIMER_ALWAYS_RELIABLE)
3972a2d31c8SShaohua Li 			smp_call_function_single(hotcpu, __setup_broadcast_timer,
3982a2d31c8SShaohua Li 						 (void *)true, 1);
39925ac7761SDaniel Lezcano 
40025ac7761SDaniel Lezcano 		/*
40125ac7761SDaniel Lezcano 		 * Some systems can hotplug a cpu at runtime after
40225ac7761SDaniel Lezcano 		 * the kernel has booted, we have to initialize the
40325ac7761SDaniel Lezcano 		 * driver in this case
40425ac7761SDaniel Lezcano 		 */
40525ac7761SDaniel Lezcano 		dev = per_cpu_ptr(intel_idle_cpuidle_devices, hotcpu);
40625ac7761SDaniel Lezcano 		if (!dev->registered)
40725ac7761SDaniel Lezcano 			intel_idle_cpu_init(hotcpu);
40825ac7761SDaniel Lezcano 
4092a2d31c8SShaohua Li 		break;
4102a2d31c8SShaohua Li 	}
4112a2d31c8SShaohua Li 	return NOTIFY_OK;
4122a2d31c8SShaohua Li }
4132a2d31c8SShaohua Li 
41425ac7761SDaniel Lezcano static struct notifier_block cpu_hotplug_notifier = {
41525ac7761SDaniel Lezcano 	.notifier_call = cpu_hotplug_notify,
4162a2d31c8SShaohua Li };
4172a2d31c8SShaohua Li 
41814796fcaSLen Brown static void auto_demotion_disable(void *dummy)
41914796fcaSLen Brown {
42014796fcaSLen Brown 	unsigned long long msr_bits;
42114796fcaSLen Brown 
42214796fcaSLen Brown 	rdmsrl(MSR_NHM_SNB_PKG_CST_CFG_CTL, msr_bits);
423b66b8b9aSAndi Kleen 	msr_bits &= ~(icpu->auto_demotion_disable_flags);
42414796fcaSLen Brown 	wrmsrl(MSR_NHM_SNB_PKG_CST_CFG_CTL, msr_bits);
42514796fcaSLen Brown }
42632e95180SLen Brown static void c1e_promotion_disable(void *dummy)
42732e95180SLen Brown {
42832e95180SLen Brown 	unsigned long long msr_bits;
42932e95180SLen Brown 
43032e95180SLen Brown 	rdmsrl(MSR_IA32_POWER_CTL, msr_bits);
43132e95180SLen Brown 	msr_bits &= ~0x2;
43232e95180SLen Brown 	wrmsrl(MSR_IA32_POWER_CTL, msr_bits);
43332e95180SLen Brown }
43414796fcaSLen Brown 
435b66b8b9aSAndi Kleen static const struct idle_cpu idle_cpu_nehalem = {
436b66b8b9aSAndi Kleen 	.state_table = nehalem_cstates,
437b66b8b9aSAndi Kleen 	.auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE,
43832e95180SLen Brown 	.disable_promotion_to_c1e = true,
439b66b8b9aSAndi Kleen };
440b66b8b9aSAndi Kleen 
441b66b8b9aSAndi Kleen static const struct idle_cpu idle_cpu_atom = {
442b66b8b9aSAndi Kleen 	.state_table = atom_cstates,
443b66b8b9aSAndi Kleen };
444b66b8b9aSAndi Kleen 
445b66b8b9aSAndi Kleen static const struct idle_cpu idle_cpu_lincroft = {
446b66b8b9aSAndi Kleen 	.state_table = atom_cstates,
447b66b8b9aSAndi Kleen 	.auto_demotion_disable_flags = ATM_LNC_C6_AUTO_DEMOTE,
448b66b8b9aSAndi Kleen };
449b66b8b9aSAndi Kleen 
450b66b8b9aSAndi Kleen static const struct idle_cpu idle_cpu_snb = {
451b66b8b9aSAndi Kleen 	.state_table = snb_cstates,
45232e95180SLen Brown 	.disable_promotion_to_c1e = true,
453b66b8b9aSAndi Kleen };
454b66b8b9aSAndi Kleen 
4556edab08cSLen Brown static const struct idle_cpu idle_cpu_ivb = {
4566edab08cSLen Brown 	.state_table = ivb_cstates,
45732e95180SLen Brown 	.disable_promotion_to_c1e = true,
4586edab08cSLen Brown };
4596edab08cSLen Brown 
46085a4d2d4SLen Brown static const struct idle_cpu idle_cpu_hsw = {
46185a4d2d4SLen Brown 	.state_table = hsw_cstates,
46232e95180SLen Brown 	.disable_promotion_to_c1e = true,
46385a4d2d4SLen Brown };
46485a4d2d4SLen Brown 
465b66b8b9aSAndi Kleen #define ICPU(model, cpu) \
466b66b8b9aSAndi Kleen 	{ X86_VENDOR_INTEL, 6, model, X86_FEATURE_MWAIT, (unsigned long)&cpu }
467b66b8b9aSAndi Kleen 
468b66b8b9aSAndi Kleen static const struct x86_cpu_id intel_idle_ids[] = {
469b66b8b9aSAndi Kleen 	ICPU(0x1a, idle_cpu_nehalem),
470b66b8b9aSAndi Kleen 	ICPU(0x1e, idle_cpu_nehalem),
471b66b8b9aSAndi Kleen 	ICPU(0x1f, idle_cpu_nehalem),
4728bf11938SBen Hutchings 	ICPU(0x25, idle_cpu_nehalem),
4738bf11938SBen Hutchings 	ICPU(0x2c, idle_cpu_nehalem),
4748bf11938SBen Hutchings 	ICPU(0x2e, idle_cpu_nehalem),
475b66b8b9aSAndi Kleen 	ICPU(0x1c, idle_cpu_atom),
476b66b8b9aSAndi Kleen 	ICPU(0x26, idle_cpu_lincroft),
4778bf11938SBen Hutchings 	ICPU(0x2f, idle_cpu_nehalem),
478b66b8b9aSAndi Kleen 	ICPU(0x2a, idle_cpu_snb),
479b66b8b9aSAndi Kleen 	ICPU(0x2d, idle_cpu_snb),
4806edab08cSLen Brown 	ICPU(0x3a, idle_cpu_ivb),
48123795e58SLen Brown 	ICPU(0x3e, idle_cpu_ivb),
48285a4d2d4SLen Brown 	ICPU(0x3c, idle_cpu_hsw),
48385a4d2d4SLen Brown 	ICPU(0x3f, idle_cpu_hsw),
48485a4d2d4SLen Brown 	ICPU(0x45, idle_cpu_hsw),
4850b15841bSLen Brown 	ICPU(0x46, idle_cpu_hsw),
486b66b8b9aSAndi Kleen 	{}
487b66b8b9aSAndi Kleen };
488b66b8b9aSAndi Kleen MODULE_DEVICE_TABLE(x86cpu, intel_idle_ids);
489b66b8b9aSAndi Kleen 
49026717172SLen Brown /*
49126717172SLen Brown  * intel_idle_probe()
49226717172SLen Brown  */
49326717172SLen Brown static int intel_idle_probe(void)
49426717172SLen Brown {
495c4236282SLen Brown 	unsigned int eax, ebx, ecx;
496b66b8b9aSAndi Kleen 	const struct x86_cpu_id *id;
49726717172SLen Brown 
49826717172SLen Brown 	if (max_cstate == 0) {
49926717172SLen Brown 		pr_debug(PREFIX "disabled\n");
50026717172SLen Brown 		return -EPERM;
50126717172SLen Brown 	}
50226717172SLen Brown 
503b66b8b9aSAndi Kleen 	id = x86_match_cpu(intel_idle_ids);
504b66b8b9aSAndi Kleen 	if (!id) {
505b66b8b9aSAndi Kleen 		if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
506b66b8b9aSAndi Kleen 		    boot_cpu_data.x86 == 6)
507b66b8b9aSAndi Kleen 			pr_debug(PREFIX "does not run on family %d model %d\n",
508b66b8b9aSAndi Kleen 				boot_cpu_data.x86, boot_cpu_data.x86_model);
50926717172SLen Brown 		return -ENODEV;
510b66b8b9aSAndi Kleen 	}
51126717172SLen Brown 
51226717172SLen Brown 	if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
51326717172SLen Brown 		return -ENODEV;
51426717172SLen Brown 
515c4236282SLen Brown 	cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates);
51626717172SLen Brown 
51726717172SLen Brown 	if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) ||
5185c2a9f06SThomas Renninger 	    !(ecx & CPUID5_ECX_INTERRUPT_BREAK) ||
5195c2a9f06SThomas Renninger 	    !mwait_substates)
52026717172SLen Brown 			return -ENODEV;
52126717172SLen Brown 
522c4236282SLen Brown 	pr_debug(PREFIX "MWAIT substates: 0x%x\n", mwait_substates);
52326717172SLen Brown 
524b66b8b9aSAndi Kleen 	icpu = (const struct idle_cpu *)id->driver_data;
525b66b8b9aSAndi Kleen 	cpuidle_state_table = icpu->state_table;
52626717172SLen Brown 
52756b9aea3SLen Brown 	if (boot_cpu_has(X86_FEATURE_ARAT))	/* Always Reliable APIC Timer */
5282a2d31c8SShaohua Li 		lapic_timer_reliable_states = LAPIC_TIMER_ALWAYS_RELIABLE;
52925ac7761SDaniel Lezcano 	else
53039a74fdeSShaohua Li 		on_each_cpu(__setup_broadcast_timer, (void *)true, 1);
53125ac7761SDaniel Lezcano 
53226717172SLen Brown 	pr_debug(PREFIX "v" INTEL_IDLE_VERSION
53326717172SLen Brown 		" model 0x%X\n", boot_cpu_data.x86_model);
53426717172SLen Brown 
53526717172SLen Brown 	pr_debug(PREFIX "lapic_timer_reliable_states 0x%x\n",
53626717172SLen Brown 		lapic_timer_reliable_states);
53726717172SLen Brown 	return 0;
53826717172SLen Brown }
53926717172SLen Brown 
54026717172SLen Brown /*
54126717172SLen Brown  * intel_idle_cpuidle_devices_uninit()
54226717172SLen Brown  * unregister, free cpuidle_devices
54326717172SLen Brown  */
54426717172SLen Brown static void intel_idle_cpuidle_devices_uninit(void)
54526717172SLen Brown {
54626717172SLen Brown 	int i;
54726717172SLen Brown 	struct cpuidle_device *dev;
54826717172SLen Brown 
54926717172SLen Brown 	for_each_online_cpu(i) {
55026717172SLen Brown 		dev = per_cpu_ptr(intel_idle_cpuidle_devices, i);
55126717172SLen Brown 		cpuidle_unregister_device(dev);
55226717172SLen Brown 	}
55326717172SLen Brown 
55426717172SLen Brown 	free_percpu(intel_idle_cpuidle_devices);
55526717172SLen Brown 	return;
55626717172SLen Brown }
55726717172SLen Brown /*
55846bcfad7SDeepthi Dharwar  * intel_idle_cpuidle_driver_init()
55946bcfad7SDeepthi Dharwar  * allocate, initialize cpuidle_states
56046bcfad7SDeepthi Dharwar  */
56146bcfad7SDeepthi Dharwar static int intel_idle_cpuidle_driver_init(void)
56246bcfad7SDeepthi Dharwar {
56346bcfad7SDeepthi Dharwar 	int cstate;
56446bcfad7SDeepthi Dharwar 	struct cpuidle_driver *drv = &intel_idle_driver;
56546bcfad7SDeepthi Dharwar 
56646bcfad7SDeepthi Dharwar 	drv->state_count = 1;
56746bcfad7SDeepthi Dharwar 
568e022e7ebSLen Brown 	for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
569e022e7ebSLen Brown 		int num_substates, mwait_hint, mwait_cstate, mwait_substate;
57046bcfad7SDeepthi Dharwar 
571e022e7ebSLen Brown 		if (cpuidle_state_table[cstate].enter == NULL)
572e022e7ebSLen Brown 			break;
573e022e7ebSLen Brown 
574e022e7ebSLen Brown 		if (cstate + 1 > max_cstate) {
57546bcfad7SDeepthi Dharwar 			printk(PREFIX "max_cstate %d reached\n",
57646bcfad7SDeepthi Dharwar 				max_cstate);
57746bcfad7SDeepthi Dharwar 			break;
57846bcfad7SDeepthi Dharwar 		}
57946bcfad7SDeepthi Dharwar 
580e022e7ebSLen Brown 		mwait_hint = flg2MWAIT(cpuidle_state_table[cstate].flags);
581e022e7ebSLen Brown 		mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint);
582e022e7ebSLen Brown 		mwait_substate = MWAIT_HINT2SUBSTATE(mwait_hint);
58346bcfad7SDeepthi Dharwar 
584e022e7ebSLen Brown 		/* does the state exist in CPUID.MWAIT? */
585e022e7ebSLen Brown 		num_substates = (mwait_substates >> ((mwait_cstate + 1) * 4))
586e022e7ebSLen Brown 					& MWAIT_SUBSTATE_MASK;
587e022e7ebSLen Brown 
588e022e7ebSLen Brown 		/* if sub-state in table is not enumerated by CPUID */
589e022e7ebSLen Brown 		if ((mwait_substate + 1) > num_substates)
590e022e7ebSLen Brown 			continue;
591e022e7ebSLen Brown 
592e022e7ebSLen Brown 		if (((mwait_cstate + 1) > 2) &&
59346bcfad7SDeepthi Dharwar 			!boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
59446bcfad7SDeepthi Dharwar 			mark_tsc_unstable("TSC halts in idle"
59546bcfad7SDeepthi Dharwar 					" states deeper than C2");
59646bcfad7SDeepthi Dharwar 
59746bcfad7SDeepthi Dharwar 		drv->states[drv->state_count] =	/* structure copy */
59846bcfad7SDeepthi Dharwar 			cpuidle_state_table[cstate];
59946bcfad7SDeepthi Dharwar 
60046bcfad7SDeepthi Dharwar 		drv->state_count += 1;
60146bcfad7SDeepthi Dharwar 	}
60246bcfad7SDeepthi Dharwar 
603b66b8b9aSAndi Kleen 	if (icpu->auto_demotion_disable_flags)
60439a74fdeSShaohua Li 		on_each_cpu(auto_demotion_disable, NULL, 1);
60546bcfad7SDeepthi Dharwar 
60632e95180SLen Brown 	if (icpu->disable_promotion_to_c1e)	/* each-cpu is redundant */
60732e95180SLen Brown 		on_each_cpu(c1e_promotion_disable, NULL, 1);
60832e95180SLen Brown 
60946bcfad7SDeepthi Dharwar 	return 0;
61046bcfad7SDeepthi Dharwar }
61146bcfad7SDeepthi Dharwar 
61246bcfad7SDeepthi Dharwar 
61346bcfad7SDeepthi Dharwar /*
61465b7f839SThomas Renninger  * intel_idle_cpu_init()
61526717172SLen Brown  * allocate, initialize, register cpuidle_devices
61665b7f839SThomas Renninger  * @cpu: cpu/core to initialize
61726717172SLen Brown  */
61825ac7761SDaniel Lezcano static int intel_idle_cpu_init(int cpu)
61926717172SLen Brown {
62065b7f839SThomas Renninger 	int cstate;
62126717172SLen Brown 	struct cpuidle_device *dev;
62226717172SLen Brown 
62365b7f839SThomas Renninger 	dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu);
62426717172SLen Brown 
62526717172SLen Brown 	dev->state_count = 1;
62626717172SLen Brown 
627e022e7ebSLen Brown 	for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
628e022e7ebSLen Brown 		int num_substates, mwait_hint, mwait_cstate, mwait_substate;
62926717172SLen Brown 
630e022e7ebSLen Brown 		if (cpuidle_state_table[cstate].enter == NULL)
631eba682a5SBartlomiej Zolnierkiewicz 			break;
632e022e7ebSLen Brown 
633e022e7ebSLen Brown 		if (cstate + 1 > max_cstate) {
634dc716e96SMarcos Paulo de Souza 			printk(PREFIX "max_cstate %d reached\n", max_cstate);
63526717172SLen Brown 			break;
63626717172SLen Brown 		}
63726717172SLen Brown 
638e022e7ebSLen Brown 		mwait_hint = flg2MWAIT(cpuidle_state_table[cstate].flags);
639e022e7ebSLen Brown 		mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint);
640e022e7ebSLen Brown 		mwait_substate = MWAIT_HINT2SUBSTATE(mwait_hint);
641e022e7ebSLen Brown 
64226717172SLen Brown 		/* does the state exist in CPUID.MWAIT? */
643e022e7ebSLen Brown 		num_substates = (mwait_substates >> ((mwait_cstate + 1) * 4))
64426717172SLen Brown 					& MWAIT_SUBSTATE_MASK;
645e022e7ebSLen Brown 
646e022e7ebSLen Brown 		/* if sub-state in table is not enumerated by CPUID */
647e022e7ebSLen Brown 		if ((mwait_substate + 1) > num_substates)
64826717172SLen Brown 			continue;
64926717172SLen Brown 
65026717172SLen Brown 		dev->state_count += 1;
65126717172SLen Brown 	}
652dc716e96SMarcos Paulo de Souza 
65365b7f839SThomas Renninger 	dev->cpu = cpu;
65426717172SLen Brown 
65526717172SLen Brown 	if (cpuidle_register_device(dev)) {
65665b7f839SThomas Renninger 		pr_debug(PREFIX "cpuidle_register_device %d failed!\n", cpu);
65726717172SLen Brown 		intel_idle_cpuidle_devices_uninit();
65826717172SLen Brown 		return -EIO;
65926717172SLen Brown 	}
66065b7f839SThomas Renninger 
661b66b8b9aSAndi Kleen 	if (icpu->auto_demotion_disable_flags)
66265b7f839SThomas Renninger 		smp_call_function_single(cpu, auto_demotion_disable, NULL, 1);
66326717172SLen Brown 
66426717172SLen Brown 	return 0;
66526717172SLen Brown }
66626717172SLen Brown 
66726717172SLen Brown static int __init intel_idle_init(void)
66826717172SLen Brown {
66965b7f839SThomas Renninger 	int retval, i;
67026717172SLen Brown 
671d1896049SThomas Renninger 	/* Do not load intel_idle at all for now if idle= is passed */
672d1896049SThomas Renninger 	if (boot_option_idle_override != IDLE_NO_OVERRIDE)
673d1896049SThomas Renninger 		return -ENODEV;
674d1896049SThomas Renninger 
67526717172SLen Brown 	retval = intel_idle_probe();
67626717172SLen Brown 	if (retval)
67726717172SLen Brown 		return retval;
67826717172SLen Brown 
67946bcfad7SDeepthi Dharwar 	intel_idle_cpuidle_driver_init();
68026717172SLen Brown 	retval = cpuidle_register_driver(&intel_idle_driver);
68126717172SLen Brown 	if (retval) {
6823735d524SKonrad Rzeszutek Wilk 		struct cpuidle_driver *drv = cpuidle_get_driver();
68326717172SLen Brown 		printk(KERN_DEBUG PREFIX "intel_idle yielding to %s",
6843735d524SKonrad Rzeszutek Wilk 			drv ? drv->name : "none");
68526717172SLen Brown 		return retval;
68626717172SLen Brown 	}
68726717172SLen Brown 
68865b7f839SThomas Renninger 	intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
68965b7f839SThomas Renninger 	if (intel_idle_cpuidle_devices == NULL)
69065b7f839SThomas Renninger 		return -ENOMEM;
69165b7f839SThomas Renninger 
69265b7f839SThomas Renninger 	for_each_online_cpu(i) {
69365b7f839SThomas Renninger 		retval = intel_idle_cpu_init(i);
69426717172SLen Brown 		if (retval) {
69526717172SLen Brown 			cpuidle_unregister_driver(&intel_idle_driver);
69626717172SLen Brown 			return retval;
69726717172SLen Brown 		}
69865b7f839SThomas Renninger 	}
6996f8c2e79SKonrad Rzeszutek Wilk 	register_cpu_notifier(&cpu_hotplug_notifier);
70026717172SLen Brown 
70126717172SLen Brown 	return 0;
70226717172SLen Brown }
70326717172SLen Brown 
70426717172SLen Brown static void __exit intel_idle_exit(void)
70526717172SLen Brown {
70626717172SLen Brown 	intel_idle_cpuidle_devices_uninit();
70726717172SLen Brown 	cpuidle_unregister_driver(&intel_idle_driver);
70826717172SLen Brown 
70925ac7761SDaniel Lezcano 
71025ac7761SDaniel Lezcano 	if (lapic_timer_reliable_states != LAPIC_TIMER_ALWAYS_RELIABLE)
71139a74fdeSShaohua Li 		on_each_cpu(__setup_broadcast_timer, (void *)false, 1);
71225ac7761SDaniel Lezcano 	unregister_cpu_notifier(&cpu_hotplug_notifier);
7132a2d31c8SShaohua Li 
71426717172SLen Brown 	return;
71526717172SLen Brown }
71626717172SLen Brown 
71726717172SLen Brown module_init(intel_idle_init);
71826717172SLen Brown module_exit(intel_idle_exit);
71926717172SLen Brown 
72026717172SLen Brown module_param(max_cstate, int, 0444);
72126717172SLen Brown 
72226717172SLen Brown MODULE_AUTHOR("Len Brown <len.brown@intel.com>");
72326717172SLen Brown MODULE_DESCRIPTION("Cpuidle driver for Intel Hardware v" INTEL_IDLE_VERSION);
72426717172SLen Brown MODULE_LICENSE("GPL");
725