* [PATCH 1/8] intel_idle: Eliminate __setup_broadcast_timer()
2020-01-10 10:42 [PATCH 0/8] intel_idle: Assorted cleanups Rafael J. Wysocki
@ 2020-01-10 10:43 ` Rafael J. Wysocki
2020-01-10 10:44 ` [PATCH 2/8] intel_idle: Fold intel_idle_probe() into intel_idle_init() Rafael J. Wysocki
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2020-01-10 10:43 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Len Brown, Zhang Rui
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
The __setup_broadcast_timer() static function is only called in one
place and "true" is passed to it as the argument in there, so
effectively it is a wrapper arround tick_broadcast_enable().
To simplify the code, call tick_broadcast_enable() directly instead
of __setup_broadcast_timer() and drop the latter.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/idle/intel_idle.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
Index: linux-pm/drivers/idle/intel_idle.c
===================================================================
--- linux-pm.orig/drivers/idle/intel_idle.c
+++ linux-pm/drivers/idle/intel_idle.c
@@ -967,14 +967,6 @@ static bool intel_idle_verify_cstate(uns
return true;
}
-static void __setup_broadcast_timer(bool on)
-{
- if (on)
- tick_broadcast_enable();
- else
- tick_broadcast_disable();
-}
-
static void auto_demotion_disable(void)
{
unsigned long long msr_bits;
@@ -1624,7 +1616,7 @@ static int intel_idle_cpu_online(unsigne
struct cpuidle_device *dev;
if (lapic_timer_reliable_states != LAPIC_TIMER_ALWAYS_RELIABLE)
- __setup_broadcast_timer(true);
+ tick_broadcast_enable();
/*
* Some systems can hotplug a cpu at runtime after
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/8] intel_idle: Fold intel_idle_probe() into intel_idle_init()
2020-01-10 10:42 [PATCH 0/8] intel_idle: Assorted cleanups Rafael J. Wysocki
2020-01-10 10:43 ` [PATCH 1/8] intel_idle: Eliminate __setup_broadcast_timer() Rafael J. Wysocki
@ 2020-01-10 10:44 ` Rafael J. Wysocki
2020-01-10 10:45 ` [PATCH 3/8] intel_idle: Clean up NULL pointer check in intel_idle_init() Rafael J. Wysocki
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2020-01-10 10:44 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Len Brown, Zhang Rui
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
There is no particular reason why intel_idle_probe() needs to be
a separate function and folding it into intel_idle_init() causes
the code to be somewhat easier to follow, so do just that.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/idle/intel_idle.c | 97 +++++++++++++++++++---------------------------
1 file changed, 42 insertions(+), 55 deletions(-)
Index: linux-pm/drivers/idle/intel_idle.c
===================================================================
--- linux-pm.orig/drivers/idle/intel_idle.c
+++ linux-pm/drivers/idle/intel_idle.c
@@ -1297,58 +1297,6 @@ static inline bool intel_idle_off_by_def
#endif /* !CONFIG_ACPI_PROCESSOR_CSTATE */
/*
- * intel_idle_probe()
- */
-static int __init intel_idle_probe(void)
-{
- unsigned int eax, ebx, ecx;
- const struct x86_cpu_id *id;
-
- if (max_cstate == 0) {
- pr_debug("disabled\n");
- return -EPERM;
- }
-
- id = x86_match_cpu(intel_idle_ids);
- if (id) {
- if (!boot_cpu_has(X86_FEATURE_MWAIT)) {
- pr_debug("Please enable MWAIT in BIOS SETUP\n");
- return -ENODEV;
- }
- } else {
- id = x86_match_cpu(intel_mwait_ids);
- if (!id)
- return -ENODEV;
- }
-
- if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
- return -ENODEV;
-
- cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates);
-
- if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) ||
- !(ecx & CPUID5_ECX_INTERRUPT_BREAK) ||
- !mwait_substates)
- return -ENODEV;
-
- pr_debug("MWAIT substates: 0x%x\n", mwait_substates);
-
- icpu = (const struct idle_cpu *)id->driver_data;
- if (icpu) {
- cpuidle_state_table = icpu->state_table;
- if (icpu->use_acpi)
- intel_idle_acpi_cst_extract();
- } else if (!intel_idle_acpi_cst_extract()) {
- return -ENODEV;
- }
-
- pr_debug("v" INTEL_IDLE_VERSION " model 0x%X\n",
- boot_cpu_data.x86_model);
-
- return 0;
-}
-
-/*
* intel_idle_cpuidle_devices_uninit()
* Unregisters the cpuidle devices.
*/
@@ -1632,15 +1580,54 @@ static int intel_idle_cpu_online(unsigne
static int __init intel_idle_init(void)
{
+ const struct x86_cpu_id *id;
+ unsigned int eax, ebx, ecx;
int retval;
/* Do not load intel_idle at all for now if idle= is passed */
if (boot_option_idle_override != IDLE_NO_OVERRIDE)
return -ENODEV;
- retval = intel_idle_probe();
- if (retval)
- return retval;
+ if (max_cstate == 0) {
+ pr_debug("disabled\n");
+ return -EPERM;
+ }
+
+ id = x86_match_cpu(intel_idle_ids);
+ if (id) {
+ if (!boot_cpu_has(X86_FEATURE_MWAIT)) {
+ pr_debug("Please enable MWAIT in BIOS SETUP\n");
+ return -ENODEV;
+ }
+ } else {
+ id = x86_match_cpu(intel_mwait_ids);
+ if (!id)
+ return -ENODEV;
+ }
+
+ if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
+ return -ENODEV;
+
+ cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates);
+
+ if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) ||
+ !(ecx & CPUID5_ECX_INTERRUPT_BREAK) ||
+ !mwait_substates)
+ return -ENODEV;
+
+ pr_debug("MWAIT substates: 0x%x\n", mwait_substates);
+
+ icpu = (const struct idle_cpu *)id->driver_data;
+ if (icpu) {
+ cpuidle_state_table = icpu->state_table;
+ if (icpu->use_acpi)
+ intel_idle_acpi_cst_extract();
+ } else if (!intel_idle_acpi_cst_extract()) {
+ return -ENODEV;
+ }
+
+ pr_debug("v" INTEL_IDLE_VERSION " model 0x%X\n",
+ boot_cpu_data.x86_model);
intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
if (intel_idle_cpuidle_devices == NULL)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/8] intel_idle: Clean up NULL pointer check in intel_idle_init()
2020-01-10 10:42 [PATCH 0/8] intel_idle: Assorted cleanups Rafael J. Wysocki
2020-01-10 10:43 ` [PATCH 1/8] intel_idle: Eliminate __setup_broadcast_timer() Rafael J. Wysocki
2020-01-10 10:44 ` [PATCH 2/8] intel_idle: Fold intel_idle_probe() into intel_idle_init() Rafael J. Wysocki
@ 2020-01-10 10:45 ` Rafael J. Wysocki
2020-01-10 10:48 ` [PATCH 4/8] intel_idle: Rearrange intel_idle_cpuidle_driver_init() Rafael J. Wysocki
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2020-01-10 10:45 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Len Brown, Zhang Rui
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Instead of comparing intel_idle_cpuidle_devices with NULL apply
the "!" (not) operator to it when checking it against NULL.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/idle/intel_idle.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-pm/drivers/idle/intel_idle.c
===================================================================
--- linux-pm.orig/drivers/idle/intel_idle.c
+++ linux-pm/drivers/idle/intel_idle.c
@@ -1630,7 +1630,7 @@ static int __init intel_idle_init(void)
boot_cpu_data.x86_model);
intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
- if (intel_idle_cpuidle_devices == NULL)
+ if (!intel_idle_cpuidle_devices)
return -ENOMEM;
intel_idle_cpuidle_driver_init();
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/8] intel_idle: Rearrange intel_idle_cpuidle_driver_init()
2020-01-10 10:42 [PATCH 0/8] intel_idle: Assorted cleanups Rafael J. Wysocki
` (2 preceding siblings ...)
2020-01-10 10:45 ` [PATCH 3/8] intel_idle: Clean up NULL pointer check in intel_idle_init() Rafael J. Wysocki
@ 2020-01-10 10:48 ` Rafael J. Wysocki
2020-01-10 10:49 ` [PATCH 5/8] intel_idle: Move and clean up intel_idle_cpuidle_devices_uninit() Rafael J. Wysocki
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2020-01-10 10:48 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Len Brown, Zhang Rui
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Notice that intel_idle_state_table_update() only needs to be called
if icpu is not NULL, so fold it into intel_idle_init_cstates_icpu(),
and pass a pointer to the driver object to
intel_idle_cpuidle_driver_init() as an argument instead of
referencing it locally in there.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/idle/intel_idle.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
Index: linux-pm/drivers/idle/intel_idle.c
===================================================================
--- linux-pm.orig/drivers/idle/intel_idle.c
+++ linux-pm/drivers/idle/intel_idle.c
@@ -1447,16 +1447,12 @@ static void sklh_idle_state_table_update
skl_cstates[5].flags |= CPUIDLE_FLAG_UNUSABLE; /* C8-SKL */
skl_cstates[6].flags |= CPUIDLE_FLAG_UNUSABLE; /* C9-SKL */
}
-/*
- * intel_idle_state_table_update()
- *
- * Update the default state_table for this CPU-id
- */
-static void intel_idle_state_table_update(void)
+static void intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
{
- switch (boot_cpu_data.x86_model) {
+ int cstate;
+ switch (boot_cpu_data.x86_model) {
case INTEL_FAM6_IVYBRIDGE_X:
ivt_idle_state_table_update();
break;
@@ -1468,11 +1464,6 @@ static void intel_idle_state_table_updat
sklh_idle_state_table_update();
break;
}
-}
-
-static void intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
-{
- int cstate;
for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
unsigned int mwait_hint;
@@ -1515,12 +1506,8 @@ static void intel_idle_init_cstates_icpu
* intel_idle_cpuidle_driver_init()
* allocate, initialize cpuidle_states
*/
-static void __init intel_idle_cpuidle_driver_init(void)
+static void __init intel_idle_cpuidle_driver_init(struct cpuidle_driver *drv)
{
- struct cpuidle_driver *drv = &intel_idle_driver;
-
- intel_idle_state_table_update();
-
cpuidle_poll_state_init(drv);
drv->state_count = 1;
@@ -1633,7 +1620,8 @@ static int __init intel_idle_init(void)
if (!intel_idle_cpuidle_devices)
return -ENOMEM;
- intel_idle_cpuidle_driver_init();
+ intel_idle_cpuidle_driver_init(&intel_idle_driver);
+
retval = cpuidle_register_driver(&intel_idle_driver);
if (retval) {
struct cpuidle_driver *drv = cpuidle_get_driver();
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 5/8] intel_idle: Move and clean up intel_idle_cpuidle_devices_uninit()
2020-01-10 10:42 [PATCH 0/8] intel_idle: Assorted cleanups Rafael J. Wysocki
` (3 preceding siblings ...)
2020-01-10 10:48 ` [PATCH 4/8] intel_idle: Rearrange intel_idle_cpuidle_driver_init() Rafael J. Wysocki
@ 2020-01-10 10:49 ` Rafael J. Wysocki
2020-01-10 10:51 ` [PATCH 6/8] intel_idle: Annotate initialization code and data structures Rafael J. Wysocki
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2020-01-10 10:49 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Len Brown, Zhang Rui
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Move intel_idle_cpuidle_devices_uninit() closer to its caller,
intel_idle_init(), add the __init modifier to its header, drop a
redundant local variable from it and fix up its kerneldoc comment.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/idle/intel_idle.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
Index: linux-pm/drivers/idle/intel_idle.c
===================================================================
--- linux-pm.orig/drivers/idle/intel_idle.c
+++ linux-pm/drivers/idle/intel_idle.c
@@ -1297,21 +1297,6 @@ static inline bool intel_idle_off_by_def
#endif /* !CONFIG_ACPI_PROCESSOR_CSTATE */
/*
- * intel_idle_cpuidle_devices_uninit()
- * Unregisters the cpuidle devices.
- */
-static void intel_idle_cpuidle_devices_uninit(void)
-{
- int i;
- struct cpuidle_device *dev;
-
- for_each_online_cpu(i) {
- dev = per_cpu_ptr(intel_idle_cpuidle_devices, i);
- cpuidle_unregister_device(dev);
- }
-}
-
-/*
* ivt_idle_state_table_update(void)
*
* Tune IVT multi-socket targets
@@ -1565,6 +1550,17 @@ static int intel_idle_cpu_online(unsigne
return 0;
}
+/**
+ * intel_idle_cpuidle_devices_uninit - Unregister all cpuidle devices.
+ */
+static void __init intel_idle_cpuidle_devices_uninit(void)
+{
+ int i;
+
+ for_each_online_cpu(i)
+ cpuidle_unregister_device(per_cpu_ptr(intel_idle_cpuidle_devices, i));
+}
+
static int __init intel_idle_init(void)
{
const struct x86_cpu_id *id;
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 6/8] intel_idle: Annotate initialization code and data structures
2020-01-10 10:42 [PATCH 0/8] intel_idle: Assorted cleanups Rafael J. Wysocki
` (4 preceding siblings ...)
2020-01-10 10:49 ` [PATCH 5/8] intel_idle: Move and clean up intel_idle_cpuidle_devices_uninit() Rafael J. Wysocki
@ 2020-01-10 10:51 ` Rafael J. Wysocki
2020-01-10 10:52 ` [PATCH 7/8] intel_idle: Move 3 functions closer to their callers Rafael J. Wysocki
2020-01-10 10:53 ` [PATCH 8/8] intel_idle: Clean up irtl_2_usec() Rafael J. Wysocki
7 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2020-01-10 10:51 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Len Brown, Zhang Rui
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Annotate the functions that are only used at the initialization time
with __init and the data structures used by them with __initdata or
__initconst.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/idle/intel_idle.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
Index: linux-pm/drivers/idle/intel_idle.c
===================================================================
--- linux-pm.orig/drivers/idle/intel_idle.c
+++ linux-pm/drivers/idle/intel_idle.c
@@ -1148,7 +1148,7 @@ static const struct x86_cpu_id intel_mwa
{}
};
-static bool intel_idle_max_cstate_reached(int cstate)
+static bool __init intel_idle_max_cstate_reached(int cstate)
{
if (cstate + 1 > max_cstate) {
pr_info("max_cstate %d reached\n", max_cstate);
@@ -1164,7 +1164,7 @@ static bool no_acpi __read_mostly;
module_param(no_acpi, bool, 0444);
MODULE_PARM_DESC(no_acpi, "Do not use ACPI _CST for building the idle states list");
-static struct acpi_processor_power acpi_state_table;
+static struct acpi_processor_power acpi_state_table __initdata;
/**
* intel_idle_cst_usable - Check if the _CST information can be used.
@@ -1172,7 +1172,7 @@ static struct acpi_processor_power acpi_
* Check if all of the C-states listed by _CST in the max_cstate range are
* ACPI_CSTATE_FFH, which means that they should be entered via MWAIT.
*/
-static bool intel_idle_cst_usable(void)
+static bool __init intel_idle_cst_usable(void)
{
int cstate, limit;
@@ -1189,7 +1189,7 @@ static bool intel_idle_cst_usable(void)
return true;
}
-static bool intel_idle_acpi_cst_extract(void)
+static bool __init intel_idle_acpi_cst_extract(void)
{
unsigned int cpu;
@@ -1224,7 +1224,7 @@ static bool intel_idle_acpi_cst_extract(
return false;
}
-static void intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
+static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
{
int cstate, limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count);
@@ -1268,7 +1268,7 @@ static void intel_idle_init_cstates_acpi
}
}
-static bool intel_idle_off_by_default(u32 mwait_hint)
+static bool __init intel_idle_off_by_default(u32 mwait_hint)
{
int cstate, limit;
@@ -1302,7 +1302,7 @@ static inline bool intel_idle_off_by_def
* Tune IVT multi-socket targets
* Assumption: num_sockets == (max_package_num + 1)
*/
-static void ivt_idle_state_table_update(void)
+static void __init ivt_idle_state_table_update(void)
{
/* IVT uses a different table for 1-2, 3-4, and > 4 sockets */
int cpu, package_num, num_sockets = 1;
@@ -1329,10 +1329,11 @@ static void ivt_idle_state_table_update(
* Translate IRTL (Interrupt Response Time Limit) MSR to usec
*/
-static unsigned int irtl_ns_units[] = {
- 1, 32, 1024, 32768, 1048576, 33554432, 0, 0 };
+static const unsigned int irtl_ns_units[] __initconst = {
+ 1, 32, 1024, 32768, 1048576, 33554432, 0, 0
+};
-static unsigned long long irtl_2_usec(unsigned long long irtl)
+static unsigned long long __init irtl_2_usec(unsigned long long irtl)
{
unsigned long long ns;
@@ -1349,7 +1350,7 @@ static unsigned long long irtl_2_usec(un
* On BXT, we trust the IRTL to show the definitive maximum latency
* We use the same value for target_residency.
*/
-static void bxt_idle_state_table_update(void)
+static void __init bxt_idle_state_table_update(void)
{
unsigned long long msr;
unsigned int usec;
@@ -1396,7 +1397,7 @@ static void bxt_idle_state_table_update(
* On SKL-H (model 0x5e) disable C8 and C9 if:
* C10 is enabled and SGX disabled
*/
-static void sklh_idle_state_table_update(void)
+static void __init sklh_idle_state_table_update(void)
{
unsigned long long msr;
unsigned int eax, ebx, ecx, edx;
@@ -1433,7 +1434,7 @@ static void sklh_idle_state_table_update
skl_cstates[6].flags |= CPUIDLE_FLAG_UNUSABLE; /* C9-SKL */
}
-static void intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
+static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
{
int cstate;
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 7/8] intel_idle: Move 3 functions closer to their callers
2020-01-10 10:42 [PATCH 0/8] intel_idle: Assorted cleanups Rafael J. Wysocki
` (5 preceding siblings ...)
2020-01-10 10:51 ` [PATCH 6/8] intel_idle: Annotate initialization code and data structures Rafael J. Wysocki
@ 2020-01-10 10:52 ` Rafael J. Wysocki
2020-01-10 10:53 ` [PATCH 8/8] intel_idle: Clean up irtl_2_usec() Rafael J. Wysocki
7 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2020-01-10 10:52 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Len Brown, Zhang Rui
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Move intel_idle_verify_cstate(), auto_demotion_disable() and
c1e_promotion_disable() closer to their callers.
While at it, annotate intel_idle_verify_cstate() with __init,
as it is only used during the initialization of the driver.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/idle/intel_idle.c | 67 +++++++++++++++++++++++-----------------------
1 file changed, 34 insertions(+), 33 deletions(-)
Index: linux-pm/drivers/idle/intel_idle.c
===================================================================
--- linux-pm.orig/drivers/idle/intel_idle.c
+++ linux-pm/drivers/idle/intel_idle.c
@@ -951,39 +951,6 @@ static void intel_idle_s2idle(struct cpu
mwait_idle_with_hints(eax, ecx);
}
-static bool intel_idle_verify_cstate(unsigned int mwait_hint)
-{
- unsigned int mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint) + 1;
- unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) &
- MWAIT_SUBSTATE_MASK;
-
- /* Ignore the C-state if there are NO sub-states in CPUID for it. */
- if (num_substates == 0)
- return false;
-
- if (mwait_cstate > 2 && !boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
- mark_tsc_unstable("TSC halts in idle states deeper than C2");
-
- return true;
-}
-
-static void auto_demotion_disable(void)
-{
- unsigned long long msr_bits;
-
- rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits);
- msr_bits &= ~(icpu->auto_demotion_disable_flags);
- wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits);
-}
-static void c1e_promotion_disable(void)
-{
- unsigned long long msr_bits;
-
- rdmsrl(MSR_IA32_POWER_CTL, msr_bits);
- msr_bits &= ~0x2;
- wrmsrl(MSR_IA32_POWER_CTL, msr_bits);
-}
-
static const struct idle_cpu idle_cpu_nehalem = {
.state_table = nehalem_cstates,
.auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE,
@@ -1434,6 +1401,22 @@ static void __init sklh_idle_state_table
skl_cstates[6].flags |= CPUIDLE_FLAG_UNUSABLE; /* C9-SKL */
}
+static bool __init intel_idle_verify_cstate(unsigned int mwait_hint)
+{
+ unsigned int mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint) + 1;
+ unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) &
+ MWAIT_SUBSTATE_MASK;
+
+ /* Ignore the C-state if there are NO sub-states in CPUID for it. */
+ if (num_substates == 0)
+ return false;
+
+ if (mwait_cstate > 2 && !boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
+ mark_tsc_unstable("TSC halts in idle states deeper than C2");
+
+ return true;
+}
+
static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
{
int cstate;
@@ -1503,6 +1486,24 @@ static void __init intel_idle_cpuidle_dr
intel_idle_init_cstates_acpi(drv);
}
+static void auto_demotion_disable(void)
+{
+ unsigned long long msr_bits;
+
+ rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits);
+ msr_bits &= ~(icpu->auto_demotion_disable_flags);
+ wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits);
+}
+
+static void c1e_promotion_disable(void)
+{
+ unsigned long long msr_bits;
+
+ rdmsrl(MSR_IA32_POWER_CTL, msr_bits);
+ msr_bits &= ~0x2;
+ wrmsrl(MSR_IA32_POWER_CTL, msr_bits);
+}
+
/*
* intel_idle_cpu_init()
* allocate, initialize, register cpuidle_devices
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 8/8] intel_idle: Clean up irtl_2_usec()
2020-01-10 10:42 [PATCH 0/8] intel_idle: Assorted cleanups Rafael J. Wysocki
` (6 preceding siblings ...)
2020-01-10 10:52 ` [PATCH 7/8] intel_idle: Move 3 functions closer to their callers Rafael J. Wysocki
@ 2020-01-10 10:53 ` Rafael J. Wysocki
2020-01-14 23:00 ` [PATCH 8/8][update] " Rafael J. Wysocki
7 siblings, 1 reply; 10+ messages in thread
From: Rafael J. Wysocki @ 2020-01-10 10:53 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Len Brown, Zhang Rui
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Move the irtl_ns_units[] definition into irtl_2_usec() which is the
only user of it, drop the ns local variable from irtl_2_usec() as it
is not really necessary in there, use div_u64() for the division in
there as the divisor is small enough and use the NSEC_PER_USEC symbol
for the divisor.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/idle/intel_idle.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
Index: linux-pm/drivers/idle/intel_idle.c
===================================================================
--- linux-pm.orig/drivers/idle/intel_idle.c
+++ linux-pm/drivers/idle/intel_idle.c
@@ -1292,25 +1292,24 @@ static void __init ivt_idle_state_table_
/* else, 1 and 2 socket systems use default ivt_cstates */
}
-/*
- * Translate IRTL (Interrupt Response Time Limit) MSR to usec
+/**
+ * irtl_2_usec - IRTL to microseconds conversion.
+ *
+ * Translate the IRTL (Interrupt Response Time Limit) MSR value to microseconds.
*/
-
-static const unsigned int irtl_ns_units[] __initconst = {
- 1, 32, 1024, 32768, 1048576, 33554432, 0, 0
-};
-
static unsigned long long __init irtl_2_usec(unsigned long long irtl)
{
- unsigned long long ns;
+ static const unsigned int irtl_ns_units[] __initconst = {
+ 1, 32, 1024, 32768, 1048576, 33554432, 0, 0
+ };
if (!irtl)
return 0;
- ns = irtl_ns_units[(irtl >> 10) & 0x7];
-
- return div64_u64((irtl & 0x3FF) * ns, 1000);
+ return div_u64((irtl & 0x3FF) * irtl_ns_units[(irtl >> 10) & 0x7],
+ NSEC_PER_USEC);
}
+
/*
* bxt_idle_state_table_update(void)
*
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 8/8][update] intel_idle: Clean up irtl_2_usec()
2020-01-10 10:53 ` [PATCH 8/8] intel_idle: Clean up irtl_2_usec() Rafael J. Wysocki
@ 2020-01-14 23:00 ` Rafael J. Wysocki
0 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2020-01-14 23:00 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Len Brown, Zhang Rui, Rafael Wysocki
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Move the irtl_ns_units[] definition into irtl_2_usec() which is the
only user of it, use div_u64() for the division in there (as the
divisor is small enough) and use the NSEC_PER_USEC symbol for the
divisor. Also convert the irtl_2_usec() comment to a proper
kerneldo one.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
The original patch went a bit too far with dropping the local variable
in irtl_2_usec(), so retain it and also document the function argument
in the kerneldoc.
---
drivers/idle/intel_idle.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
Index: linux-pm/drivers/idle/intel_idle.c
===================================================================
--- linux-pm.orig/drivers/idle/intel_idle.c
+++ linux-pm/drivers/idle/intel_idle.c
@@ -1292,16 +1292,17 @@ static void __init ivt_idle_state_table_
/* else, 1 and 2 socket systems use default ivt_cstates */
}
-/*
- * Translate IRTL (Interrupt Response Time Limit) MSR to usec
+/**
+ * irtl_2_usec - IRTL to microseconds conversion.
+ * @irtl: IRTL MSR value.
+ *
+ * Translate the IRTL (Interrupt Response Time Limit) MSR value to microseconds.
*/
-
-static const unsigned int irtl_ns_units[] __initconst = {
- 1, 32, 1024, 32768, 1048576, 33554432, 0, 0
-};
-
static unsigned long long __init irtl_2_usec(unsigned long long irtl)
{
+ static const unsigned int irtl_ns_units[] __initconst = {
+ 1, 32, 1024, 32768, 1048576, 33554432, 0, 0
+ };
unsigned long long ns;
if (!irtl)
@@ -1309,8 +1310,9 @@ static unsigned long long __init irtl_2_
ns = irtl_ns_units[(irtl >> 10) & 0x7];
- return div64_u64((irtl & 0x3FF) * ns, 1000);
+ return div_u64((irtl & 0x3FF) * ns, NSEC_PER_USEC);
}
+
/*
* bxt_idle_state_table_update(void)
*
^ permalink raw reply [flat|nested] 10+ messages in thread