From: Thomas Renninger <trenn@suse.de>
To: lenb@kernel.org
Cc: trenn@suse.de, linux-acpi@vger.kernel.org
Subject: [PATCH 3/5] intel_idle: Split up and provide per CPU initialization func
Date: Thu, 17 Nov 2011 23:36:59 +0100 [thread overview]
Message-ID: <1321569421-46220-4-git-send-email-trenn@suse.de> (raw)
In-Reply-To: <1321569421-46220-1-git-send-email-trenn@suse.de>
Function split up, should have no functional change
Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: Len Brown <lenb@kernel.org>
CC: linux-acpi@vger.kernel.org
---
drivers/idle/intel_idle.c | 108 +++++++++++++++++++++-----------------------
include/linux/cpuidle.h | 7 +++
2 files changed, 59 insertions(+), 56 deletions(-)
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index a46dddf..c108d2a 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -397,77 +397,67 @@ static void intel_idle_cpuidle_devices_uninit(void)
return;
}
/*
- * intel_idle_cpuidle_devices_init()
+ * intel_idle_cpu_init()
* allocate, initialize, register cpuidle_devices
+ * @cpu: cpu/core to initialize
*/
-static int intel_idle_cpuidle_devices_init(void)
+int intel_idle_cpu_init(int cpu)
{
- int i, cstate;
+ int cstate;
struct cpuidle_device *dev;
- intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
- if (intel_idle_cpuidle_devices == NULL)
- return -ENOMEM;
+ dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu);
- for_each_online_cpu(i) {
- dev = per_cpu_ptr(intel_idle_cpuidle_devices, i);
+ dev->state_count = 1;
- dev->state_count = 1;
-
- for (cstate = 1; cstate < MWAIT_MAX_NUM_CSTATES; ++cstate) {
- int num_substates;
-
- if (cstate > max_cstate) {
- printk(PREFIX "max_cstate %d reached\n",
- max_cstate);
- break;
- }
-
- /* does the state exist in CPUID.MWAIT? */
- num_substates = (mwait_substates >> ((cstate) * 4))
- & MWAIT_SUBSTATE_MASK;
- if (num_substates == 0)
- continue;
- /* is the state not enabled? */
- if (cpuidle_state_table[cstate].enter == NULL) {
- /* does the driver not know about the state? */
- if (*cpuidle_state_table[cstate].name == '\0')
- pr_debug(PREFIX "unaware of model 0x%x"
- " MWAIT %d please"
- " contact lenb@kernel.org",
- boot_cpu_data.x86_model, cstate);
- continue;
- }
-
- if ((cstate > 2) &&
- !boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
- mark_tsc_unstable("TSC halts in idle"
- " states deeper than C2");
-
- dev->states[dev->state_count] = /* structure copy */
- cpuidle_state_table[cstate];
-
- dev->state_count += 1;
+ for (cstate = 1; cstate < MWAIT_MAX_NUM_CSTATES; ++cstate) {
+ int num_substates;
+
+ if (cstate > max_cstate) {
+ printk(PREFIX "max_cstate %d reached\n", max_cstate);
+ break;
}
- dev->cpu = i;
- if (cpuidle_register_device(dev)) {
- pr_debug(PREFIX "cpuidle_register_device %d failed!\n",
- i);
- intel_idle_cpuidle_devices_uninit();
- return -EIO;
+ /* does the state exist in CPUID.MWAIT? */
+ num_substates = (mwait_substates >> ((cstate) * 4))
+ & MWAIT_SUBSTATE_MASK;
+ if (num_substates == 0)
+ continue;
+ /* is the state not enabled? */
+ if (cpuidle_state_table[cstate].enter == NULL) {
+ /* does the driver not know about the state? */
+ if (*cpuidle_state_table[cstate].name == '\0')
+ pr_debug(PREFIX "unaware of model 0x%x MWAIT "
+ "%d please contact lenb@kernel.org",
+ boot_cpu_data.x86_model, cstate);
+ continue;
}
+
+ if ((cstate > 2) && !boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
+ mark_tsc_unstable("TSC halts in idle"
+ " states deeper than C2");
+
+ dev->states[dev->state_count] = /* structure copy */
+ cpuidle_state_table[cstate];
+ dev->state_count += 1;
+ }
+ dev->cpu = cpu;
+ if (cpuidle_register_device(dev)) {
+ pr_debug(PREFIX "cpuidle_register_device %d failed!\n", cpu);
+ intel_idle_cpuidle_devices_uninit();
+ return -EIO;
}
if (auto_demotion_disable_flags)
- smp_call_function(auto_demotion_disable, NULL, 1);
+ smp_call_function_single(cpu, auto_demotion_disable, NULL, 1);
return 0;
}
+EXPORT_SYMBOL(intel_idle_cpu_init);
static int __init intel_idle_init(void)
{
- int retval;
+ int retval, i;
/* Do not load intel_idle at all for now if idle= is passed */
if (boot_option_idle_override != IDLE_NO_OVERRIDE)
@@ -484,10 +474,16 @@ static int __init intel_idle_init(void)
return retval;
}
- retval = intel_idle_cpuidle_devices_init();
- if (retval) {
- cpuidle_unregister_driver(&intel_idle_driver);
- return retval;
+ intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
+ if (intel_idle_cpuidle_devices == NULL)
+ return -ENOMEM;
+
+ for_each_online_cpu(i) {
+ retval = intel_idle_cpu_init(i);
+ if (retval) {
+ cpuidle_unregister_driver(&intel_idle_driver);
+ return retval;
+ }
}
return 0;
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index b51629e..15bd1bd 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -179,7 +179,14 @@ struct cpuidle_governor {
extern int cpuidle_register_governor(struct cpuidle_governor *gov);
extern void cpuidle_unregister_governor(struct cpuidle_governor *gov);
+#ifdef CONFIG_INTEL_IDLE
+extern int intel_idle_cpu_init(int cpu);
#else
+static inline int intel_idle_cpu_init(int cpu) { return -1; }
+#endif
+
+#else
+static inline int intel_idle_cpu_init(int cpu) { return -1; }
static inline int cpuidle_register_governor(struct cpuidle_governor *gov)
{return 0;}
--
1.7.6.1
next prev parent reply other threads:[~2011-11-17 22:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1321569421-46220-1-git-send-email-trenn@suse.de>
2011-11-17 22:36 ` [PATCH 1/5] ACPI processor: Do not export acpi_idle_driver in processor.h Thomas Renninger
2012-01-17 11:25 ` Len Brown
2012-01-17 14:08 ` Thomas Renninger
2011-11-17 22:36 ` [PATCH 2/5] ACPI processor: Avoid WARN message on processor driver removal Thomas Renninger
2012-01-17 11:02 ` Len Brown
2012-01-17 14:25 ` Thomas Renninger
2012-01-17 14:41 ` Bjorn Helgaas
2012-01-17 14:58 ` Thomas Renninger
2011-11-17 22:36 ` Thomas Renninger [this message]
2011-11-17 22:44 ` [PATCH 3/5] intel_idle: Split up and provide per CPU initialization func Thomas Renninger
2012-01-17 11:06 ` Len Brown
2012-01-17 13:26 ` Thomas Renninger
2012-01-17 16:10 ` Thomas Renninger
2011-11-17 22:37 ` [PATCH 4/5] ACPI processor: Fix error path, also remove sysdev link Thomas Renninger
2011-11-17 22:37 ` [PATCH 5/5] ACPI processor: Remove unneeded variable passed by acpi_processor_hotadd_init Thomas Renninger
2012-01-17 11:10 ` Len Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321569421-46220-4-git-send-email-trenn@suse.de \
--to=trenn@suse.de \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).