Lines Matching +full:idle +full:- +full:state +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
3 * intel_idle.c - native hardware idle loop for modern Intel processors
5 * Copyright (c) 2013 - 2020, Intel Corporation.
20 * All CPUs have same idle states as boot CPU
23 * for preventing entry into deep C-states
25 * CPU will flush caches as needed when entering a C-state via MWAIT
33 * ACPI has a .suspend hack to turn off deep c-statees during suspend
39 /* un-comment DEBUG to enable pr_debug() statements */
55 #include <asm/intel-family.h>
56 #include <asm/nospec-branch.h>
63 .name = "intel_idle",
67 static int max_cstate = CPUIDLE_STATE_MAX - 1;
79 * Hardware C-state auto-demotion may not always be optimal.
94 * Enable this state by default even if the ACPI _CST does not list it.
99 * Disable IBRS across idle (when KERNEL_IBRS), is exclusive vs IRQ_ENABLE
105 * MWAIT takes an 8-bit "hint" in EAX "suggesting"
106 * the C-state (top nibble) and sub-state (bottom nibble)
109 * We store the hint at the top of our "flags" for each state.
115 * intel_idle - Ask the processor to enter the given idle state.
118 * @index: Target idle state index.
121 * @dev is idle and it can try to enter the idle state corresponding to @index.
123 * If the local APIC timer is not known to be reliable in the target idle state,
124 * enable one-shot tick broadcasting for the target CPU before executing MWAIT.
134 struct cpuidle_state *state = &drv->states[index]; in intel_idle() local
135 unsigned long eax = flg2MWAIT(state->flags); in intel_idle()
162 * intel_idle_s2idle - Ask the processor to enter the given idle state.
165 * @index: Target idle state index.
168 * @dev is idle and it can try to enter the idle state corresponding to @index.
170 * Invoked as a suspend-to-idle callback routine with frozen user space, frozen
176 unsigned long eax = flg2MWAIT(drv->states[index].flags); in intel_idle_s2idle()
191 .name = "C1",
199 .name = "C1E",
207 .name = "C3",
215 .name = "C6",
228 .name = "C1",
236 .name = "C1E",
244 .name = "C3",
252 .name = "C6",
260 .name = "C7",
273 .name = "C1",
281 .name = "C6N",
289 .name = "C6S",
297 .name = "C7",
305 .name = "C7S",
318 .name = "C1",
326 .name = "C6N",
334 .name = "C6S",
342 .name = "C7",
350 .name = "C7S",
363 .name = "C1",
371 .name = "C1E",
379 .name = "C3",
387 .name = "C6",
395 .name = "C7",
408 .name = "C1",
416 .name = "C1E",
424 .name = "C3",
432 .name = "C6",
445 .name = "C1",
453 .name = "C1E",
461 .name = "C3",
469 .name = "C6",
482 .name = "C1",
490 .name = "C1E",
498 .name = "C3",
506 .name = "C6",
519 .name = "C1",
527 .name = "C1E",
535 .name = "C3",
543 .name = "C6",
551 .name = "C7s",
559 .name = "C8",
567 .name = "C9",
575 .name = "C10",
587 .name = "C1",
595 .name = "C1E",
603 .name = "C3",
611 .name = "C6",
619 .name = "C7s",
627 .name = "C8",
635 .name = "C9",
643 .name = "C10",
656 .name = "C1",
664 .name = "C1E",
672 .name = "C3",
680 .name = "C6",
688 .name = "C7s",
696 .name = "C8",
704 .name = "C9",
712 .name = "C10",
725 .name = "C1",
733 .name = "C1E",
741 .name = "C6",
754 .name = "C1",
762 .name = "C1E",
770 .name = "C6",
783 .name = "C1E",
791 .name = "C2",
799 .name = "C4",
807 .name = "C6",
819 .name = "C1",
827 .name = "C4",
835 .name = "C6",
843 .name = "C7",
851 .name = "C9",
863 .name = "C1",
871 .name = "C6",
883 .name = "C1",
891 .name = "C6",
904 .name = "C1",
912 .name = "C1E",
920 .name = "C6",
928 .name = "C7s",
936 .name = "C8",
944 .name = "C9",
952 .name = "C10",
965 .name = "C1",
973 .name = "C1E",
981 .name = "C6",
1169 static bool __init intel_idle_state_needs_timer_stop(struct cpuidle_state *state) in intel_idle_state_needs_timer_stop() argument
1171 unsigned long eax = flg2MWAIT(state->flags); in intel_idle_state_needs_timer_stop()
1177 * Switch over to one-shot tick broadcast if the target C-state in intel_idle_state_needs_timer_stop()
1188 MODULE_PARM_DESC(no_acpi, "Do not use ACPI _CST for building the idle states list");
1192 MODULE_PARM_DESC(use_acpi, "Use ACPI _CST for building the idle states list");
1197 * intel_idle_cst_usable - Check if the _CST information can be used.
1199 * Check if all of the C-states listed by _CST in the max_cstate range are
1212 if (cx->entry_method != ACPI_CSTATE_FFH) in intel_idle_cst_usable()
1234 if (acpi_processor_evaluate_cst(pr->handle, cpu, &acpi_state_table)) in intel_idle_acpi_cst_extract()
1263 struct cpuidle_state *state; in intel_idle_init_cstates_acpi() local
1265 if (intel_idle_max_cstate_reached(cstate - 1)) in intel_idle_init_cstates_acpi()
1270 state = &drv->states[drv->state_count++]; in intel_idle_init_cstates_acpi()
1272 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d_ACPI", cstate); in intel_idle_init_cstates_acpi()
1273 strlcpy(state->desc, cx->desc, CPUIDLE_DESC_LEN); in intel_idle_init_cstates_acpi()
1274 state->exit_latency = cx->latency; in intel_idle_init_cstates_acpi()
1276 * For C1-type C-states use the same number for both the exit in intel_idle_init_cstates_acpi()
1278 * C1 in the majority of the static C-states tables above. in intel_idle_init_cstates_acpi()
1279 * For the other types of C-states, however, set the target in intel_idle_init_cstates_acpi()
1281 * a reasonable balance between energy-efficiency and in intel_idle_init_cstates_acpi()
1284 state->target_residency = cx->latency; in intel_idle_init_cstates_acpi()
1285 if (cx->type > ACPI_STATE_C1) in intel_idle_init_cstates_acpi()
1286 state->target_residency *= 3; in intel_idle_init_cstates_acpi()
1288 state->flags = MWAIT2flg(cx->address); in intel_idle_init_cstates_acpi()
1289 if (cx->type > ACPI_STATE_C2) in intel_idle_init_cstates_acpi()
1290 state->flags |= CPUIDLE_FLAG_TLB_FLUSHED; in intel_idle_init_cstates_acpi()
1293 state->flags |= CPUIDLE_FLAG_OFF; in intel_idle_init_cstates_acpi()
1295 if (intel_idle_state_needs_timer_stop(state)) in intel_idle_init_cstates_acpi()
1296 state->flags |= CPUIDLE_FLAG_TIMER_STOP; in intel_idle_init_cstates_acpi()
1298 state->enter = intel_idle; in intel_idle_init_cstates_acpi()
1299 state->enter_s2idle = intel_idle_s2idle; in intel_idle_init_cstates_acpi()
1308 * If there are no _CST C-states, do not disable any C-states by in intel_idle_off_by_default()
1334 * ivt_idle_state_table_update - Tune the idle states table for Ivy Town.
1336 * Tune IVT multi-socket targets.
1341 /* IVT uses a different table for 1-2, 3-4, and > 4 sockets */ in ivt_idle_state_table_update()
1363 * irtl_2_usec - IRTL to microseconds conversion.
1384 * bxt_idle_state_table_update - Fix up the Broxton idle states table.
1432 * sklh_idle_state_table_update - Fix up the Sky Lake idle states table.
1434 * On SKL-H (model 0x5e) skip C8 and C9 if C10 is enabled and SGX disabled.
1452 /* PC10 is not enabled in PKG C-state limit */ in sklh_idle_state_table_update()
1469 skl_cstates[5].flags |= CPUIDLE_FLAG_UNUSABLE; /* C8-SKL */ in sklh_idle_state_table_update()
1470 skl_cstates[6].flags |= CPUIDLE_FLAG_UNUSABLE; /* C9-SKL */ in sklh_idle_state_table_update()
1479 /* Ignore the C-state if there are NO sub-states in CPUID for it. */ in intel_idle_verify_cstate()
1484 mark_tsc_unstable("TSC halts in idle states deeper than C2"); in intel_idle_verify_cstate()
1516 /* If marked as unusable, skip this state. */ in intel_idle_init_cstates_icpu()
1518 pr_debug("state %s is disabled\n", in intel_idle_init_cstates_icpu()
1519 cpuidle_state_table[cstate].name); in intel_idle_init_cstates_icpu()
1528 drv->states[drv->state_count] = cpuidle_state_table[cstate]; in intel_idle_init_cstates_icpu()
1532 drv->states[drv->state_count].enter = intel_idle_ibrs; in intel_idle_init_cstates_icpu()
1535 if ((disabled_states_mask & BIT(drv->state_count)) || in intel_idle_init_cstates_icpu()
1536 ((icpu->use_acpi || force_use_acpi) && in intel_idle_init_cstates_icpu()
1539 drv->states[drv->state_count].flags |= CPUIDLE_FLAG_OFF; in intel_idle_init_cstates_icpu()
1541 if (intel_idle_state_needs_timer_stop(&drv->states[drv->state_count])) in intel_idle_init_cstates_icpu()
1542 drv->states[drv->state_count].flags |= CPUIDLE_FLAG_TIMER_STOP; in intel_idle_init_cstates_icpu()
1544 drv->state_count++; in intel_idle_init_cstates_icpu()
1547 if (icpu->byt_auto_demotion_disable_flag) { in intel_idle_init_cstates_icpu()
1554 * intel_idle_cpuidle_driver_init - Create the list of available idle states.
1562 drv->states[0].flags |= CPUIDLE_FLAG_OFF; in intel_idle_cpuidle_driver_init()
1564 drv->state_count = 1; in intel_idle_cpuidle_driver_init()
1591 * intel_idle_cpu_init - Register the target CPU with the cpuidle core.
1602 dev->cpu = cpu; in intel_idle_cpu_init()
1606 return -EIO; in intel_idle_cpu_init()
1631 if (!dev->registered) in intel_idle_cpu_online()
1638 * intel_idle_cpuidle_devices_uninit - Unregister all cpuidle devices.
1654 /* Do not load intel_idle at all for now if idle= is passed */ in intel_idle_init()
1656 return -ENODEV; in intel_idle_init()
1660 return -EPERM; in intel_idle_init()
1667 return -ENODEV; in intel_idle_init()
1672 return -ENODEV; in intel_idle_init()
1676 return -ENODEV; in intel_idle_init()
1683 return -ENODEV; in intel_idle_init()
1687 icpu = (const struct idle_cpu *)id->driver_data; in intel_idle_init()
1689 cpuidle_state_table = icpu->state_table; in intel_idle_init()
1690 auto_demotion_disable_flags = icpu->auto_demotion_disable_flags; in intel_idle_init()
1691 disable_promotion_to_c1e = icpu->disable_promotion_to_c1e; in intel_idle_init()
1692 if (icpu->use_acpi || force_use_acpi) in intel_idle_init()
1695 return -ENODEV; in intel_idle_init()
1703 return -ENOMEM; in intel_idle_init()
1711 drv ? drv->name : "none"); in intel_idle_init()
1715 retval = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "idle/intel:online", in intel_idle_init()
1721 boot_cpu_has(X86_FEATURE_ARAT) ? "all C-states" : "C1"); in intel_idle_init()
1737 * support "intel_idle.max_cstate=..." at boot and also a read-only export of
1738 * it at /sys/module/intel_idle/parameters/max_cstate -- so using module_param
1744 * idle states to be disabled by default (as reflected by the names of the
1745 * corresponding idle state directories in sysfs, "state0", "state1" ...
1746 * "state<i>" ..., where <i> is the index of the given state).
1749 MODULE_PARM_DESC(states_off, "Mask of disabled idle states");