4 * Copyright 2015 IBM Corp.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/types.h>
14 #include <linux/slab.h>
16 #include <linux/device.h>
17 #include <linux/cpu.h>
19 #include <asm/firmware.h>
20 #include <asm/machdep.h>
22 #include <asm/cputhreads.h>
23 #include <asm/cpuidle.h>
24 #include <asm/code-patching.h>
26 #include <asm/runlatch.h>
27 #include <asm/dbell.h>
32 /* Power ISA 3.0 allows for stop states 0x0 - 0xF */
33 #define MAX_STOP_STATE 0xF
35 #define P9_STOP_SPR_MSR 2000
36 #define P9_STOP_SPR_PSSCR 855
38 static u32 supported_cpuidle_states;
39 struct pnv_idle_states_t *pnv_idle_states;
40 int nr_pnv_idle_states;
43 * The default stop state that will be used by ppc_md.power_save
44 * function on platforms that support stop instruction.
46 static u64 pnv_default_stop_val;
47 static u64 pnv_default_stop_mask;
48 static bool default_stop_found;
51 * First deep stop state. Used to figure out when to save/restore
54 u64 pnv_first_deep_stop_state = MAX_STOP_STATE;
57 * psscr value and mask of the deepest stop idle state.
58 * Used when a cpu is offlined.
60 static u64 pnv_deepest_stop_psscr_val;
61 static u64 pnv_deepest_stop_psscr_mask;
62 static u64 pnv_deepest_stop_flag;
63 static bool deepest_stop_found;
65 static int pnv_save_sprs_for_deep_states(void)
71 * hid0, hid1, hid4, hid5, hmeer and lpcr values are symmetric across
72 * all cpus at boot. Get these reg values of current cpu and use the
73 * same across all cpus.
75 uint64_t lpcr_val = mfspr(SPRN_LPCR);
76 uint64_t hid0_val = mfspr(SPRN_HID0);
77 uint64_t hid1_val = mfspr(SPRN_HID1);
78 uint64_t hid4_val = mfspr(SPRN_HID4);
79 uint64_t hid5_val = mfspr(SPRN_HID5);
80 uint64_t hmeer_val = mfspr(SPRN_HMEER);
81 uint64_t msr_val = MSR_IDLE;
82 uint64_t psscr_val = pnv_deepest_stop_psscr_val;
84 for_each_present_cpu(cpu) {
85 uint64_t pir = get_hard_smp_processor_id(cpu);
86 uint64_t hsprg0_val = (uint64_t)paca_ptrs[cpu];
88 rc = opal_slw_set_reg(pir, SPRN_HSPRG0, hsprg0_val);
92 rc = opal_slw_set_reg(pir, SPRN_LPCR, lpcr_val);
96 if (cpu_has_feature(CPU_FTR_ARCH_300)) {
97 rc = opal_slw_set_reg(pir, P9_STOP_SPR_MSR, msr_val);
101 rc = opal_slw_set_reg(pir,
102 P9_STOP_SPR_PSSCR, psscr_val);
108 /* HIDs are per core registers */
109 if (cpu_thread_in_core(cpu) == 0) {
111 rc = opal_slw_set_reg(pir, SPRN_HMEER, hmeer_val);
115 rc = opal_slw_set_reg(pir, SPRN_HID0, hid0_val);
119 /* Only p8 needs to set extra HID regiters */
120 if (!cpu_has_feature(CPU_FTR_ARCH_300)) {
122 rc = opal_slw_set_reg(pir, SPRN_HID1, hid1_val);
126 rc = opal_slw_set_reg(pir, SPRN_HID4, hid4_val);
130 rc = opal_slw_set_reg(pir, SPRN_HID5, hid5_val);
140 static void pnv_alloc_idle_core_states(void)
143 int nr_cores = cpu_nr_cores();
144 u32 *core_idle_state;
147 * core_idle_state - The lower 8 bits track the idle state of
148 * each thread of the core.
150 * The most significant bit is the lock bit.
152 * Initially all the bits corresponding to threads_per_core
153 * are set. They are cleared when the thread enters deep idle
154 * state like sleep and winkle/stop.
156 * Initially the lock bit is cleared. The lock bit has 2
158 * a. While the first thread in the core waking up from
159 * idle is restoring core state, it prevents other
160 * threads in the core from switching to process
162 * b. While the last thread in the core is saving the
163 * core state, it prevents a different thread from
166 for (i = 0; i < nr_cores; i++) {
167 int first_cpu = i * threads_per_core;
168 int node = cpu_to_node(first_cpu);
169 size_t paca_ptr_array_size;
171 core_idle_state = kmalloc_node(sizeof(u32), GFP_KERNEL, node);
172 *core_idle_state = (1 << threads_per_core) - 1;
173 paca_ptr_array_size = (threads_per_core *
174 sizeof(struct paca_struct *));
176 for (j = 0; j < threads_per_core; j++) {
177 int cpu = first_cpu + j;
179 paca_ptrs[cpu]->core_idle_state_ptr = core_idle_state;
180 paca_ptrs[cpu]->thread_idle_state = PNV_THREAD_RUNNING;
181 paca_ptrs[cpu]->thread_mask = 1 << j;
185 update_subcore_sibling_mask();
187 if (supported_cpuidle_states & OPAL_PM_LOSE_FULL_CONTEXT) {
188 int rc = pnv_save_sprs_for_deep_states();
194 * The stop-api is unable to restore hypervisor
195 * resources on wakeup from platform idle states which
196 * lose full context. So disable such states.
198 supported_cpuidle_states &= ~OPAL_PM_LOSE_FULL_CONTEXT;
199 pr_warn("cpuidle-powernv: Disabling idle states that lose full context\n");
200 pr_warn("cpuidle-powernv: Idle power-savings, CPU-Hotplug affected\n");
202 if (cpu_has_feature(CPU_FTR_ARCH_300) &&
203 (pnv_deepest_stop_flag & OPAL_PM_LOSE_FULL_CONTEXT)) {
205 * Use the default stop state for CPU-Hotplug
208 if (default_stop_found) {
209 pnv_deepest_stop_psscr_val =
210 pnv_default_stop_val;
211 pnv_deepest_stop_psscr_mask =
212 pnv_default_stop_mask;
213 pr_warn("cpuidle-powernv: Offlined CPUs will stop with psscr = 0x%016llx\n",
214 pnv_deepest_stop_psscr_val);
215 } else { /* Fallback to snooze loop for CPU-Hotplug */
216 deepest_stop_found = false;
217 pr_warn("cpuidle-powernv: Offlined CPUs will busy wait\n");
223 u32 pnv_get_supported_cpuidle_states(void)
225 return supported_cpuidle_states;
227 EXPORT_SYMBOL_GPL(pnv_get_supported_cpuidle_states);
229 static void pnv_fastsleep_workaround_apply(void *info)
235 rc = opal_config_cpu_idle_state(OPAL_CONFIG_IDLE_FASTSLEEP,
236 OPAL_CONFIG_IDLE_APPLY);
242 * Used to store fastsleep workaround state
243 * 0 - Workaround applied/undone at fastsleep entry/exit path (Default)
244 * 1 - Workaround applied once, never undone.
246 static u8 fastsleep_workaround_applyonce;
248 static ssize_t show_fastsleep_workaround_applyonce(struct device *dev,
249 struct device_attribute *attr, char *buf)
251 return sprintf(buf, "%u\n", fastsleep_workaround_applyonce);
254 static ssize_t store_fastsleep_workaround_applyonce(struct device *dev,
255 struct device_attribute *attr, const char *buf,
258 cpumask_t primary_thread_mask;
262 if (kstrtou8(buf, 0, &val) || val != 1)
265 if (fastsleep_workaround_applyonce == 1)
269 * fastsleep_workaround_applyonce = 1 implies
270 * fastsleep workaround needs to be left in 'applied' state on all
271 * the cores. Do this by-
272 * 1. Patching out the call to 'undo' workaround in fastsleep exit path
273 * 2. Sending ipi to all the cores which have at least one online thread
274 * 3. Patching out the call to 'apply' workaround in fastsleep entry
276 * There is no need to send ipi to cores which have all threads
277 * offlined, as last thread of the core entering fastsleep or deeper
278 * state would have applied workaround.
280 err = patch_instruction(
281 (unsigned int *)pnv_fastsleep_workaround_at_exit,
284 pr_err("fastsleep_workaround_applyonce change failed while patching pnv_fastsleep_workaround_at_exit");
289 primary_thread_mask = cpu_online_cores_map();
290 on_each_cpu_mask(&primary_thread_mask,
291 pnv_fastsleep_workaround_apply,
295 pr_err("fastsleep_workaround_applyonce change failed while running pnv_fastsleep_workaround_apply");
299 err = patch_instruction(
300 (unsigned int *)pnv_fastsleep_workaround_at_entry,
303 pr_err("fastsleep_workaround_applyonce change failed while patching pnv_fastsleep_workaround_at_entry");
307 fastsleep_workaround_applyonce = 1;
314 static DEVICE_ATTR(fastsleep_workaround_applyonce, 0600,
315 show_fastsleep_workaround_applyonce,
316 store_fastsleep_workaround_applyonce);
318 static unsigned long __power7_idle_type(unsigned long type)
322 if (!prep_irq_for_idle_irqsoff())
325 __ppc64_runlatch_off();
326 srr1 = power7_idle_insn(type);
327 __ppc64_runlatch_on();
329 fini_irq_for_idle_irqsoff();
334 void power7_idle_type(unsigned long type)
338 srr1 = __power7_idle_type(type);
339 irq_set_pending_from_srr1(srr1);
342 void power7_idle(void)
347 power7_idle_type(PNV_THREAD_NAP);
350 static unsigned long __power9_idle_type(unsigned long stop_psscr_val,
351 unsigned long stop_psscr_mask)
356 if (!prep_irq_for_idle_irqsoff())
359 psscr = mfspr(SPRN_PSSCR);
360 psscr = (psscr & ~stop_psscr_mask) | stop_psscr_val;
362 __ppc64_runlatch_off();
363 srr1 = power9_idle_stop(psscr);
364 __ppc64_runlatch_on();
366 fini_irq_for_idle_irqsoff();
371 void power9_idle_type(unsigned long stop_psscr_val,
372 unsigned long stop_psscr_mask)
376 srr1 = __power9_idle_type(stop_psscr_val, stop_psscr_mask);
377 irq_set_pending_from_srr1(srr1);
381 * Used for ppc_md.power_save which needs a function with no parameters
383 void power9_idle(void)
385 power9_idle_type(pnv_default_stop_val, pnv_default_stop_mask);
388 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
390 * This is used in working around bugs in thread reconfiguration
391 * on POWER9 (at least up to Nimbus DD2.2) relating to transactional
392 * memory and the way that XER[SO] is checkpointed.
393 * This function forces the core into SMT4 in order by asking
394 * all other threads not to stop, and sending a message to any
395 * that are in a stop state.
396 * Must be called with preemption disabled.
398 void pnv_power9_force_smt4_catch(void)
401 int awake_threads = 1; /* this thread is awake */
402 int poke_threads = 0;
403 int need_awake = threads_per_core;
405 cpu = smp_processor_id();
406 cpu0 = cpu & ~(threads_per_core - 1);
407 for (thr = 0; thr < threads_per_core; ++thr) {
408 if (cpu != cpu0 + thr)
409 atomic_inc(&paca_ptrs[cpu0+thr]->dont_stop);
411 /* order setting dont_stop vs testing requested_psscr */
413 for (thr = 0; thr < threads_per_core; ++thr) {
414 if (!paca_ptrs[cpu0+thr]->requested_psscr)
417 poke_threads |= (1 << thr);
420 /* If at least 3 threads are awake, the core is in SMT4 already */
421 if (awake_threads < need_awake) {
422 /* We have to wake some threads; we'll use msgsnd */
423 for (thr = 0; thr < threads_per_core; ++thr) {
424 if (poke_threads & (1 << thr)) {
426 ppc_msgsnd(PPC_DBELL_MSGTYPE, 0,
427 paca_ptrs[cpu0+thr]->hw_cpu_id);
430 /* now spin until at least 3 threads are awake */
432 for (thr = 0; thr < threads_per_core; ++thr) {
433 if ((poke_threads & (1 << thr)) &&
434 !paca_ptrs[cpu0+thr]->requested_psscr) {
436 poke_threads &= ~(1 << thr);
439 } while (awake_threads < need_awake);
442 EXPORT_SYMBOL_GPL(pnv_power9_force_smt4_catch);
444 void pnv_power9_force_smt4_release(void)
448 cpu = smp_processor_id();
449 cpu0 = cpu & ~(threads_per_core - 1);
451 /* clear all the dont_stop flags */
452 for (thr = 0; thr < threads_per_core; ++thr) {
453 if (cpu != cpu0 + thr)
454 atomic_dec(&paca_ptrs[cpu0+thr]->dont_stop);
457 EXPORT_SYMBOL_GPL(pnv_power9_force_smt4_release);
458 #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
460 #ifdef CONFIG_HOTPLUG_CPU
462 void pnv_program_cpu_hotplug_lpcr(unsigned int cpu, u64 lpcr_val)
464 u64 pir = get_hard_smp_processor_id(cpu);
466 mtspr(SPRN_LPCR, lpcr_val);
469 * Program the LPCR via stop-api only if the deepest stop state
470 * can lose hypervisor context.
472 if (supported_cpuidle_states & OPAL_PM_LOSE_FULL_CONTEXT)
473 opal_slw_set_reg(pir, SPRN_LPCR, lpcr_val);
477 * pnv_cpu_offline: A function that puts the CPU into the deepest
478 * available platform idle state on a CPU-Offline.
479 * interrupts hard disabled and no lazy irq pending.
481 unsigned long pnv_cpu_offline(unsigned int cpu)
484 u32 idle_states = pnv_get_supported_cpuidle_states();
486 __ppc64_runlatch_off();
488 if (cpu_has_feature(CPU_FTR_ARCH_300) && deepest_stop_found) {
491 psscr = mfspr(SPRN_PSSCR);
492 psscr = (psscr & ~pnv_deepest_stop_psscr_mask) |
493 pnv_deepest_stop_psscr_val;
494 srr1 = power9_offline_stop(psscr);
496 } else if ((idle_states & OPAL_PM_WINKLE_ENABLED) &&
497 (idle_states & OPAL_PM_LOSE_FULL_CONTEXT)) {
498 srr1 = power7_idle_insn(PNV_THREAD_WINKLE);
499 } else if ((idle_states & OPAL_PM_SLEEP_ENABLED) ||
500 (idle_states & OPAL_PM_SLEEP_ENABLED_ER1)) {
501 srr1 = power7_idle_insn(PNV_THREAD_SLEEP);
502 } else if (idle_states & OPAL_PM_NAP_ENABLED) {
503 srr1 = power7_idle_insn(PNV_THREAD_NAP);
505 /* This is the fallback method. We emulate snooze */
506 while (!generic_check_cpu_restart(cpu)) {
514 __ppc64_runlatch_on();
521 * Power ISA 3.0 idle initialization.
523 * POWER ISA 3.0 defines a new SPR Processor stop Status and Control
524 * Register (PSSCR) to control idle behavior.
527 * ----------------------------------------------------------
528 * | PLS | /// | SD | ESL | EC | PSLL | /// | TR | MTL | RL |
529 * ----------------------------------------------------------
530 * 0 4 41 42 43 44 48 54 56 60
533 * Bits 0:3 - Power-Saving Level Status (PLS). This field indicates the
534 * lowest power-saving state the thread entered since stop instruction was
537 * Bit 41 - Status Disable(SD)
538 * 0 - Shows PLS entries
539 * 1 - PLS entries are all 0
541 * Bit 42 - Enable State Loss
542 * 0 - No state is lost irrespective of other fields
543 * 1 - Allows state loss
545 * Bit 43 - Exit Criterion
546 * 0 - Exit from power-save mode on any interrupt
547 * 1 - Exit from power-save mode controlled by LPCR's PECE bits
549 * Bits 44:47 - Power-Saving Level Limit
550 * This limits the power-saving level that can be entered into.
552 * Bits 60:63 - Requested Level
553 * Used to specify which power-saving level must be entered on executing
557 int validate_psscr_val_mask(u64 *psscr_val, u64 *psscr_mask, u32 flags)
562 * psscr_mask == 0xf indicates an older firmware.
563 * Set remaining fields of psscr to the default values.
564 * See NOTE above definition of PSSCR_HV_DEFAULT_VAL
566 if (*psscr_mask == 0xf) {
567 *psscr_val = *psscr_val | PSSCR_HV_DEFAULT_VAL;
568 *psscr_mask = PSSCR_HV_DEFAULT_MASK;
573 * New firmware is expected to set the psscr_val bits correctly.
574 * Validate that the following invariants are correctly maintained by
576 * - ESL bit value matches the EC bit value.
577 * - ESL bit is set for all the deep stop states.
579 if (GET_PSSCR_ESL(*psscr_val) != GET_PSSCR_EC(*psscr_val)) {
580 err = ERR_EC_ESL_MISMATCH;
581 } else if ((flags & OPAL_PM_LOSE_FULL_CONTEXT) &&
582 GET_PSSCR_ESL(*psscr_val) == 0) {
583 err = ERR_DEEP_STATE_ESL_MISMATCH;
590 * pnv_arch300_idle_init: Initializes the default idle state, first
591 * deep idle state and deepest idle state on
594 * @np: /ibm,opal/power-mgt device node
595 * @flags: cpu-idle-state-flags array
596 * @dt_idle_states: Number of idle state entries
597 * Returns 0 on success
599 static int __init pnv_power9_idle_init(void)
601 u64 max_residency_ns = 0;
605 * Set pnv_first_deep_stop_state, pnv_deepest_stop_psscr_{val,mask},
606 * and the pnv_default_stop_{val,mask}.
608 * pnv_first_deep_stop_state should be set to the first stop
609 * level to cause hypervisor state loss.
611 * pnv_deepest_stop_{val,mask} should be set to values corresponding to
612 * the deepest stop state.
614 * pnv_default_stop_{val,mask} should be set to values corresponding to
615 * the shallowest (OPAL_PM_STOP_INST_FAST) loss-less stop state.
617 pnv_first_deep_stop_state = MAX_STOP_STATE;
618 for (i = 0; i < nr_pnv_idle_states; i++) {
620 struct pnv_idle_states_t *state = &pnv_idle_states[i];
621 u64 psscr_rl = state->psscr_val & PSSCR_RL_MASK;
623 if ((state->flags & OPAL_PM_LOSE_FULL_CONTEXT) &&
624 pnv_first_deep_stop_state > psscr_rl)
625 pnv_first_deep_stop_state = psscr_rl;
627 err = validate_psscr_val_mask(&state->psscr_val,
631 report_invalid_psscr_val(state->psscr_val, err);
637 if (max_residency_ns < state->residency_ns) {
638 max_residency_ns = state->residency_ns;
639 pnv_deepest_stop_psscr_val = state->psscr_val;
640 pnv_deepest_stop_psscr_mask = state->psscr_mask;
641 pnv_deepest_stop_flag = state->flags;
642 deepest_stop_found = true;
645 if (!default_stop_found &&
646 (state->flags & OPAL_PM_STOP_INST_FAST)) {
647 pnv_default_stop_val = state->psscr_val;
648 pnv_default_stop_mask = state->psscr_mask;
649 default_stop_found = true;
653 if (unlikely(!default_stop_found)) {
654 pr_warn("cpuidle-powernv: No suitable default stop state found. Disabling platform idle.\n");
656 ppc_md.power_save = power9_idle;
657 pr_info("cpuidle-powernv: Default stop: psscr = 0x%016llx,mask=0x%016llx\n",
658 pnv_default_stop_val, pnv_default_stop_mask);
661 if (unlikely(!deepest_stop_found)) {
662 pr_warn("cpuidle-powernv: No suitable stop state for CPU-Hotplug. Offlined CPUs will busy wait");
664 pr_info("cpuidle-powernv: Deepest stop: psscr = 0x%016llx,mask=0x%016llx\n",
665 pnv_deepest_stop_psscr_val,
666 pnv_deepest_stop_psscr_mask);
669 pr_info("cpuidle-powernv: Requested Level (RL) value of first deep stop = 0x%llx\n",
670 pnv_first_deep_stop_state);
676 * Probe device tree for supported idle states
678 static void __init pnv_probe_idle_states(void)
682 if (nr_pnv_idle_states < 0) {
683 pr_warn("cpuidle-powernv: no idle states found in the DT\n");
687 if (cpu_has_feature(CPU_FTR_ARCH_300)) {
688 if (pnv_power9_idle_init())
692 for (i = 0; i < nr_pnv_idle_states; i++)
693 supported_cpuidle_states |= pnv_idle_states[i].flags;
697 * This function parses device-tree and populates all the information
698 * into pnv_idle_states structure. It also sets up nr_pnv_idle_states
699 * which is the number of cpuidle states discovered through device-tree.
702 static int pnv_parse_cpuidle_dt(void)
704 struct device_node *np;
705 int nr_idle_states, i;
709 const char **temp_string;
711 np = of_find_node_by_path("/ibm,opal/power-mgt");
713 pr_warn("opal: PowerMgmt Node not found\n");
716 nr_idle_states = of_property_count_u32_elems(np,
717 "ibm,cpu-idle-state-flags");
719 pnv_idle_states = kcalloc(nr_idle_states, sizeof(*pnv_idle_states),
721 temp_u32 = kcalloc(nr_idle_states, sizeof(u32), GFP_KERNEL);
722 temp_u64 = kcalloc(nr_idle_states, sizeof(u64), GFP_KERNEL);
723 temp_string = kcalloc(nr_idle_states, sizeof(char *), GFP_KERNEL);
725 if (!(pnv_idle_states && temp_u32 && temp_u64 && temp_string)) {
726 pr_err("Could not allocate memory for dt parsing\n");
732 if (of_property_read_u32_array(np, "ibm,cpu-idle-state-flags",
733 temp_u32, nr_idle_states)) {
734 pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-flags in DT\n");
738 for (i = 0; i < nr_idle_states; i++)
739 pnv_idle_states[i].flags = temp_u32[i];
742 if (of_property_read_u32_array(np, "ibm,cpu-idle-state-latencies-ns",
743 temp_u32, nr_idle_states)) {
744 pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-latencies-ns in DT\n");
748 for (i = 0; i < nr_idle_states; i++)
749 pnv_idle_states[i].latency_ns = temp_u32[i];
751 /* Read residencies */
752 if (of_property_read_u32_array(np, "ibm,cpu-idle-state-residency-ns",
753 temp_u32, nr_idle_states)) {
754 pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-latencies-ns in DT\n");
758 for (i = 0; i < nr_idle_states; i++)
759 pnv_idle_states[i].residency_ns = temp_u32[i];
762 if (cpu_has_feature(CPU_FTR_ARCH_300)) {
763 /* Read pm_crtl_val */
764 if (of_property_read_u64_array(np, "ibm,cpu-idle-state-psscr",
765 temp_u64, nr_idle_states)) {
766 pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr in DT\n");
770 for (i = 0; i < nr_idle_states; i++)
771 pnv_idle_states[i].psscr_val = temp_u64[i];
773 /* Read pm_crtl_mask */
774 if (of_property_read_u64_array(np, "ibm,cpu-idle-state-psscr-mask",
775 temp_u64, nr_idle_states)) {
776 pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr-mask in DT\n");
780 for (i = 0; i < nr_idle_states; i++)
781 pnv_idle_states[i].psscr_mask = temp_u64[i];
785 * power8 specific properties ibm,cpu-idle-state-pmicr-mask and
786 * ibm,cpu-idle-state-pmicr-val were never used and there is no
787 * plan to use it in near future. Hence, not parsing these properties
790 if (of_property_read_string_array(np, "ibm,cpu-idle-state-names",
791 temp_string, nr_idle_states) < 0) {
792 pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-names in DT\n");
796 for (i = 0; i < nr_idle_states; i++)
797 strlcpy(pnv_idle_states[i].name, temp_string[i],
799 nr_pnv_idle_states = nr_idle_states;
808 static int __init pnv_init_idle_states(void)
811 supported_cpuidle_states = 0;
813 /* In case we error out nr_pnv_idle_states will be zero */
814 nr_pnv_idle_states = 0;
815 if (cpuidle_disable != IDLE_NO_OVERRIDE)
817 rc = pnv_parse_cpuidle_dt();
820 pnv_probe_idle_states();
822 if (!(supported_cpuidle_states & OPAL_PM_SLEEP_ENABLED_ER1)) {
824 (unsigned int *)pnv_fastsleep_workaround_at_entry,
827 (unsigned int *)pnv_fastsleep_workaround_at_exit,
831 * OPAL_PM_SLEEP_ENABLED_ER1 is set. It indicates that
832 * workaround is needed to use fastsleep. Provide sysfs
833 * control to choose how this workaround has to be applied.
835 device_create_file(cpu_subsys.dev_root,
836 &dev_attr_fastsleep_workaround_applyonce);
839 pnv_alloc_idle_core_states();
841 if (supported_cpuidle_states & OPAL_PM_NAP_ENABLED)
842 ppc_md.power_save = power7_idle;
847 machine_subsys_initcall(powernv, pnv_init_idle_states);