linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
To: Joel Schopp <jschopp@austin.ibm.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@elte.hu>,
	Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>,
	Dipankar Sarma <dipankar@in.ibm.com>,
	Balbir Singh <balbir@in.ibm.com>,
	Gautham R Shenoy <ego@in.ibm.com>,
	Arun Bharadwaj <arun@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [v4 PATCH 2/5]: cpuidle: Implement routines to register and unregister idle function.
Date: Tue, 1 Sep 2009 17:09:41 +0530	[thread overview]
Message-ID: <20090901113941.GI7599@linux.vnet.ibm.com> (raw)
In-Reply-To: <20090901113704.GG7599@linux.vnet.ibm.com>

* Arun R Bharadwaj <arun@linux.vnet.ibm.com> [2009-09-01 17:07:04]:

Implement a LIFO based approach for registering arch dependent
idle routines.

This is a prototype for pseries, needs to be extended
for other platforms.

Signed-off-by: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/idle.c |    5 +++++
 drivers/cpuidle/cpuidle.c  |   37 +++++++++++++++++++++++++++++++++++++
 include/linux/pm.h         |   10 ++++++++++
 3 files changed, 52 insertions(+)

Index: linux.trees.git/arch/powerpc/kernel/idle.c
===================================================================
--- linux.trees.git.orig/arch/powerpc/kernel/idle.c
+++ linux.trees.git/arch/powerpc/kernel/idle.c
@@ -46,6 +46,11 @@ static int __init powersave_off(char *ar
 }
 __setup("powersave=off", powersave_off);
 
+void set_arch_idle(void (*idle)(void))
+{
+	ppc_md.power_save = idle;
+}
+
 /*
  * The body of the idle task.
  */
Index: linux.trees.git/include/linux/pm.h
===================================================================
--- linux.trees.git.orig/include/linux/pm.h
+++ linux.trees.git/include/linux/pm.h
@@ -30,6 +30,16 @@ extern void (*pm_idle)(void);
 extern void (*pm_power_off)(void);
 extern void (*pm_power_off_prepare)(void);
 
+struct idle_function_desc {
+	char			*name;
+	void			(*idle_func)(void);
+	struct list_head	idle_list;
+};
+
+extern void set_arch_idle(void (*idle)(void));
+extern void register_idle_function(struct idle_function_desc *desc);
+extern void unregister_idle_function(struct idle_function_desc *desc);
+
 /*
  * Device power management
  */
Index: linux.trees.git/drivers/cpuidle/cpuidle.c
===================================================================
--- linux.trees.git.orig/drivers/cpuidle/cpuidle.c
+++ linux.trees.git/drivers/cpuidle/cpuidle.c
@@ -44,6 +44,43 @@ static void cpuidle_kick_cpus(void)
 static void cpuidle_kick_cpus(void) {}
 #endif
 
+LIST_HEAD(idle_function_list);
+static DEFINE_MUTEX(idle_list_mutex);
+
+void register_idle_function(struct idle_function_desc *desc)
+{
+	mutex_lock(&idle_list_mutex);
+
+	list_add(&desc->idle_list, &idle_function_list);
+	set_arch_idle(desc->idle_func);
+	cpuidle_kick_cpus();
+
+	mutex_unlock(&idle_list_mutex);
+}
+
+void unregister_idle_function(struct idle_function_desc *desc)
+{
+	struct list_head *pos;
+	struct idle_function_desc *temp_desc;
+
+	mutex_lock(&idle_list_mutex);
+	WARN_ON_ONCE(list_empty(&desc->idle_list) || desc != NULL);
+
+	list_for_each(pos, &idle_function_list) {
+		temp_desc = container_of(pos, struct idle_function_desc,
+					idle_list);
+		if (temp_desc == desc) {
+			list_del(&temp_desc->idle_list);
+			/* Re-using temp_desc here */
+			temp_desc = list_first_entry(&idle_function_list,
+					struct idle_function_desc, idle_list);
+			set_arch_idle(temp_desc->idle_func);
+			cpuidle_kick_cpus();
+		}
+	}
+	mutex_unlock(&idle_list_mutex);
+}
+
 static int __cpuidle_register_device(struct cpuidle_device *dev);
 
 /**

  parent reply	other threads:[~2009-09-01 11:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-01 11:37 [v4 PATCH 0/5]: cpuidle/POWER (REDISIGN): Introducing cpuidle to POWER Arun R Bharadwaj
2009-09-01 11:38 ` [v4 PATCH 1/5]: cpuidle: Cleanup drivers/cpuidle/cpuidle.c Arun R Bharadwaj
2009-09-01 17:28   ` Balbir Singh
2009-09-02  5:21     ` Arun R Bharadwaj
2009-09-02  5:45     ` Arun R Bharadwaj
2009-09-02  5:42   ` Peter Zijlstra
2009-09-03  4:42     ` Arun R Bharadwaj
2009-09-03  9:40       ` Peter Zijlstra
2009-09-01 11:39 ` Arun R Bharadwaj [this message]
2009-09-01 11:40 ` [v4 PATCH 3/5]: pSeries: Incorporate registering of idle loop for pSeries Arun R Bharadwaj
2009-09-01 11:41 ` [v4 PATCH 4/5]: cpuidle: Add Kconfig entry to enable cpuidle for POWER Arun R Bharadwaj
2009-09-01 11:42 ` [v4 PATCH 5/5]: pSeries: Implement pSeries processor idle module Arun R Bharadwaj

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=20090901113941.GI7599@linux.vnet.ibm.com \
    --to=arun@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=balbir@in.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=dipankar@in.ibm.com \
    --cc=ego@in.ibm.com \
    --cc=jschopp@austin.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=svaidy@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).