From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Len Brown <len.brown@intel.com>, Zhang Rui <rui.zhang@intel.com>
Subject: [PATCH 2/8] intel_idle: Fold intel_idle_probe() into intel_idle_init()
Date: Fri, 10 Jan 2020 11:44:58 +0100 [thread overview]
Message-ID: <1620893.3AGvmZJH3P@kreacher> (raw)
In-Reply-To: <14127826.m9lEolTOYu@kreacher>
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)
next prev parent reply other threads:[~2020-01-10 10:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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 ` [PATCH 4/8] intel_idle: Rearrange intel_idle_cpuidle_driver_init() 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
2020-01-10 10:51 ` [PATCH 6/8] intel_idle: Annotate initialization code and data structures 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
2020-01-14 23:00 ` [PATCH 8/8][update] " Rafael J. Wysocki
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=1620893.3AGvmZJH3P@kreacher \
--to=rjw@rjwysocki.net \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rui.zhang@intel.com \
/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