All of lore.kernel.org
 help / color / mirror / Atom feed
From: Len Brown <lenb@kernel.org>
To: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Len Brown <len.brown@intel.com>,
	Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH 01/16] APM idle: register apm_cpu_idle via cpuidle
Date: Sun, 10 Feb 2013 00:58:08 -0500	[thread overview]
Message-ID: <2b219d07e0f287c2c713f5465fc8646158fa986e.1360475150.git.len.brown@intel.com> (raw)
In-Reply-To: <1360475903-30007-1-git-send-email-lenb@kernel.org>

From: Len Brown <len.brown@intel.com>

Update APM to register its local idle routine with cpuidle.

This allows us to stop exporting pm_idle to modules on x86.

The Kconfig sub-option, APM_CPU_IDLE, now depends on on CPU_IDLE.

Compile-tested only.

Signed-off-by: Len Brown <len.brown@intel.com>
Cc: Jiri Kosina <jkosina@suse.cz>
---
 arch/x86/Kconfig          |  1 +
 arch/x86/kernel/apm_32.c  | 58 +++++++++++++++++++++++++++++------------------
 arch/x86/kernel/process.c |  3 ---
 3 files changed, 37 insertions(+), 25 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 225543b..1b63586 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1912,6 +1912,7 @@ config APM_DO_ENABLE
 	  this feature.
 
 config APM_CPU_IDLE
+	depends on CPU_IDLE
 	bool "Make CPU Idle calls when idle"
 	---help---
 	  Enable calls to APM CPU Idle/CPU Busy inside the kernel's idle loop.
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index d65464e..18a3cc3 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -232,6 +232,7 @@
 #include <linux/acpi.h>
 #include <linux/syscore_ops.h>
 #include <linux/i8253.h>
+#include <linux/cpuidle.h>
 
 #include <asm/uaccess.h>
 #include <asm/desc.h>
@@ -360,13 +361,37 @@ struct apm_user {
  * idle percentage above which bios idle calls are done
  */
 #ifdef CONFIG_APM_CPU_IDLE
-#warning deprecated CONFIG_APM_CPU_IDLE will be deleted in 2012
 #define DEFAULT_IDLE_THRESHOLD	95
 #else
 #define DEFAULT_IDLE_THRESHOLD	100
 #endif
 #define DEFAULT_IDLE_PERIOD	(100 / 3)
 
+static int apm_cpu_idle(struct cpuidle_device *dev,
+			struct cpuidle_driver *drv, int index);
+
+static struct cpuidle_driver apm_idle_driver = {
+	.name = "apm_idle",
+	.owner = THIS_MODULE,
+	.en_core_tk_irqen = 1,
+	.states = {
+		{ /* entry 0 is for polling */ },
+		{ /* entry 1 is for APM idle */
+			.name = "APM",
+			.desc = "APM idle",
+			.flags = CPUIDLE_FLAG_TIME_VALID,
+			.exit_latency = 250,	/* WAG */
+			.target_residency = 500,	/* WAG */
+			.enter = &apm_cpu_idle
+		},
+	},
+};
+
+static struct cpuidle_device apm_cpuidle_device = {
+	.state_count = 2,
+};
+
+
 /*
  * Local variables
  */
@@ -377,7 +402,6 @@ static struct {
 static int clock_slowed;
 static int idle_threshold __read_mostly = DEFAULT_IDLE_THRESHOLD;
 static int idle_period __read_mostly = DEFAULT_IDLE_PERIOD;
-static int set_pm_idle;
 static int suspends_pending;
 static int standbys_pending;
 static int ignore_sys_suspend;
@@ -884,8 +908,6 @@ static void apm_do_busy(void)
 #define IDLE_CALC_LIMIT	(HZ * 100)
 #define IDLE_LEAKY_MAX	16
 
-static void (*original_pm_idle)(void) __read_mostly;
-
 /**
  * apm_cpu_idle		-	cpu idling for APM capable Linux
  *
@@ -894,7 +916,8 @@ static void (*original_pm_idle)(void) __read_mostly;
  * Furthermore it calls the system default idle routine.
  */
 
-static void apm_cpu_idle(void)
+static int apm_cpu_idle(struct cpuidle_device *dev,
+	struct cpuidle_driver *drv, int index)
 {
 	static int use_apm_idle; /* = 0 */
 	static unsigned int last_jiffies; /* = 0 */
@@ -904,7 +927,6 @@ static void apm_cpu_idle(void)
 	unsigned int jiffies_since_last_check = jiffies - last_jiffies;
 	unsigned int bucket;
 
-	WARN_ONCE(1, "deprecated apm_cpu_idle will be deleted in 2012");
 recalc:
 	if (jiffies_since_last_check > IDLE_CALC_LIMIT) {
 		use_apm_idle = 0;
@@ -950,10 +972,7 @@ recalc:
 				break;
 			}
 		}
-		if (original_pm_idle)
-			original_pm_idle();
-		else
-			default_idle();
+		default_idle();
 		local_irq_disable();
 		jiffies_since_last_check = jiffies - last_jiffies;
 		if (jiffies_since_last_check > idle_period)
@@ -964,6 +983,7 @@ recalc:
 		apm_do_busy();
 
 	local_irq_enable();
+	return index;
 }
 
 /**
@@ -2381,9 +2401,9 @@ static int __init apm_init(void)
 	if (HZ != 100)
 		idle_period = (idle_period * HZ) / 100;
 	if (idle_threshold < 100) {
-		original_pm_idle = pm_idle;
-		pm_idle  = apm_cpu_idle;
-		set_pm_idle = 1;
+		if (!cpuidle_register_driver(&apm_idle_driver))
+			if (cpuidle_register_device(&apm_cpuidle_device))
+				cpuidle_unregister_driver(&apm_idle_driver);
 	}
 
 	return 0;
@@ -2393,15 +2413,9 @@ static void __exit apm_exit(void)
 {
 	int error;
 
-	if (set_pm_idle) {
-		pm_idle = original_pm_idle;
-		/*
-		 * We are about to unload the current idle thread pm callback
-		 * (pm_idle), Wait for all processors to update cached/local
-		 * copies of pm_idle before proceeding.
-		 */
-		kick_all_cpus_sync();
-	}
+	cpuidle_unregister_device(&apm_cpuidle_device);
+	cpuidle_unregister_driver(&apm_idle_driver);
+
 	if (((apm_info.bios.flags & APM_BIOS_DISENGAGED) == 0)
 	    && (apm_info.connection_version > 0x0100)) {
 		error = apm_engage_power_management(APM_DEVICE_ALL, 0);
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 2ed787f..f571a6e 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -272,9 +272,6 @@ EXPORT_SYMBOL(boot_option_idle_override);
  * Powermanagement idle function, if any..
  */
 void (*pm_idle)(void);
-#ifdef CONFIG_APM_MODULE
-EXPORT_SYMBOL(pm_idle);
-#endif
 
 #ifndef CONFIG_SMP
 static inline void play_dead(void)
-- 
1.8.1.3.535.ga923c31


  reply	other threads:[~2013-02-10  5:58 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-10  5:58 pm_idle cleanup patch series Len Brown
2013-02-10  5:58 ` Len Brown [this message]
2013-02-10  5:58   ` [PATCH 02/16] x86 idle: rename global pm_idle to static x86_idle Len Brown
2013-02-10  5:58   ` [PATCH 04/16] sparc idle: rename pm_idle to sparc_idle Len Brown
2013-02-10  5:58     ` Len Brown
2013-02-10 23:08     ` David Miller
2013-02-10 23:08       ` David Miller
2013-02-10  5:58   ` [PATCH 05/16] blackfin idle: delete pm_idle Len Brown
2013-02-18 16:28     ` Lars-Peter Clausen
2013-02-20 17:53       ` Len Brown
2013-02-20 19:52       ` Rafael J. Wysocki
2013-02-20 19:53         ` Lars-Peter Clausen
2013-02-20 19:59           ` Rafael J. Wysocki
2013-02-20 20:21             ` Lars-Peter Clausen
2013-02-20 21:18               ` Rafael J. Wysocki
2013-02-21  9:56                 ` [PATCH] blackfin idle: Fix compile error Lars-Peter Clausen
2013-02-21 16:24                   ` Rafael J. Wysocki
2013-02-10  5:58   ` [PATCH 06/16] ARM idle: delete pm_idle Len Brown
2013-02-10  5:58     ` Len Brown
2013-02-10  5:58     ` Len Brown
2013-02-11 16:02     ` Catalin Marinas
2013-02-11 16:02       ` Catalin Marinas
2013-02-11 16:02       ` Catalin Marinas
2013-02-11 16:11       ` Russell King - ARM Linux
2013-02-11 16:11         ` Russell King - ARM Linux
2013-02-11 16:11         ` Russell King - ARM Linux
2013-02-11 22:42         ` Len Brown
2013-02-11 22:42           ` Len Brown
2013-02-11 22:42           ` Len Brown
2013-02-12 22:04     ` Kevin Hilman
2013-02-12 22:04       ` Kevin Hilman
2013-02-10  5:58   ` [PATCH 07/16] ARM64 " Len Brown
2013-02-10  5:58     ` Len Brown
2013-02-12 11:03     ` Catalin Marinas
2013-02-12 11:03       ` Catalin Marinas
2013-02-12 11:03       ` Catalin Marinas
2013-02-10  5:58   ` [PATCH 08/16] cris idle: delete idle and pm_idle Len Brown
2013-02-11  8:42     ` Jesper Nilsson
2013-02-10  5:58   ` [PATCH 09/16] ia64 idle: delete pm_idle Len Brown
2013-02-10  5:58     ` Len Brown
2013-02-21 10:15     ` Lars-Peter Clausen
2013-02-21 10:15       ` Lars-Peter Clausen
2013-03-26  3:12       ` Brown, Len
2013-03-26  4:29         ` [PATCH] ia64 idle: delete (*idle)() Len Brown
2013-03-26  4:29           ` Len Brown
2013-02-10  5:58   ` [PATCH 10/16] m32r idle: delete pm_idle, and other dead idle code Len Brown
2013-02-10  5:58   ` [PATCH 11/16] microblaze idle: delete pm_idle Len Brown
2013-02-21 10:15     ` [PATCH] microblaze idle: Fix compile error Lars-Peter Clausen
2013-02-21 16:25       ` Rafael J. Wysocki
2013-02-10  5:58   ` [PATCH 12/16] mn10300 idle: delete pm_idle Len Brown
2013-02-10  5:58   ` [PATCH 13/16] openrisc " Len Brown
2013-02-10  5:58     ` Len Brown
2013-02-10 17:31     ` [ORLinux] " Jonas Bonn
2013-02-10 17:31       ` Jonas Bonn
2013-02-10  5:58   ` [PATCH 14/16] unicore32 idle: delete stray pm_idle comment Len Brown
2013-02-10  5:58   ` [PATCH 15/16] PM idle: remove global declaration of pm_idle Len Brown
2013-02-10  5:58   ` [PATCH 16/16] xen idle: make xen-specific macro xen-specific Len Brown
2013-02-11  9:18   ` [PATCH 01/16] APM idle: register apm_cpu_idle via cpuidle Daniel Lezcano
2013-02-11 22:50     ` Len Brown
2013-02-11 23:03     ` APM: Request to Test Len Brown
2013-02-11 23:03       ` [PATCH v2] APM idle: register apm_cpu_idle via cpuidle Len Brown
2013-02-12 15:00         ` Daniel Lezcano
2013-02-12 15:00           ` Daniel Lezcano
2013-02-18 13:30         ` Jiri Kosina
2013-02-20 17:48           ` Len Brown
2013-02-10  5:58 ` [PATCH 03/16] sh idle: rename global pm_idle to static sh_idle Len Brown
2013-02-10  5:58   ` 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=2b219d07e0f287c2c713f5465fc8646158fa986e.1360475150.git.len.brown@intel.com \
    --to=lenb@kernel.org \
    --cc=jkosina@suse.cz \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.