LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2/2] PM: fast power off - driver
@ 2007-01-27 20:05 akuster
  2007-01-28  3:20 ` Andi Kleen
  2007-01-28 18:09 ` Randy Dunlap
  0 siblings, 2 replies; 4+ messages in thread
From: akuster @ 2007-01-27 20:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 72 bytes --]

My apologies, I cc'd the wrong list the first time around.

- Armin
---

[-- Attachment #2: fastpoweroff-1.0_driver.patch --]
[-- Type: text/x-patch, Size: 3040 bytes --]


Fastpoweroff default profile driver

signed-off-by: Armin Kuster <AKuster@mvista.com>
---
 kernel/power/fastoff/Kconfig      |    8 ++++
 kernel/power/fastoff/Makefile     |    2 -
 kernel/power/fastoff/fastoffdrv.c |   69 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+), 1 deletion(-)

Index: linux-2.6_dev/kernel/power/fastoff/fastoffdrv.c
===================================================================
--- /dev/null
+++ linux-2.6_dev/kernel/power/fastoff/fastoffdrv.c
@@ -0,0 +1,69 @@
+/*
+ * kernel/power/fastoff/fastoffdrv.c
+ *
+ * This provides a sysfs interface that allows the user to
+ * bypass running rc kill scripts in the advent the user
+ * needed to power down as fast as possible. This could be
+ * in a low battery conditon and you want to try to keep
+ * data from being corrupted.
+ *
+ * Author: Armin Kuster <AKuster@mvista.com, or source@mvista.com>
+ *
+ * 2006, 2007  (c) MontaVista Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+
+#include "../power.h"
+#include "fpo.h"
+
+static int fsd_default_off(void)
+{
+	/*
+	 * Actions taken:
+	 *
+	 *    1. Freeze all user processes.
+	 *
+	 *    2. Power off
+	 *
+	 *    3. Power off devices
+	 */
+
+	printk(KERN_EMERG "Fast Power Off initiated.\n");
+	fastpoweroff_prepare();
+	fastpoweroff();
+	fastpoweroff_standby();
+	return 1;
+}
+
+static struct fpo_driver fpo_default = {
+	.name = "default",
+	.policy = fsd_default_off,
+};
+
+static int __init fsd_default_init(void)
+{
+	int ret = 0;
+
+	if(( ret = fastpoweroff_register(&fpo_default)) < 0) {
+		printk(KERN_ERR "PM: Fastpoweroff: %s profile registation failed %d.\n",
+			fpo_default.name,ret);
+		goto errout;
+	}
+
+	printk(KERN_INFO "PM: Fastpoweroff, %s profile added\n",fpo_default.name);
+errout:
+	return ret;
+}
+
+module_init(fsd_default_init);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Armin Kuster <akuster@mvista.com>");
+
Index: linux-2.6_dev/kernel/power/fastoff/Kconfig
===================================================================
--- linux-2.6_dev.orig/kernel/power/fastoff/Kconfig
+++ linux-2.6_dev/kernel/power/fastoff/Kconfig
@@ -10,4 +10,12 @@ config FAST_POWER_OFF
 	---help---
 	  Say yes if you want core support for sysfs/power/fastoff
 
+config FAST_POWER_DOWN
+	tristate "Fast power of profile"
+	depends on FAST_POWER_OFF
+	default n
+	---help---
+	  Say yes if want to bypass the rc kill scripts
+	  and shut the machine down
+
 endmenu
Index: linux-2.6_dev/kernel/power/fastoff/Makefile
===================================================================
--- linux-2.6_dev.orig/kernel/power/fastoff/Makefile
+++ linux-2.6_dev/kernel/power/fastoff/Makefile
@@ -5,4 +5,4 @@
 #
 
 obj-$(CONFIG_FAST_POWER_OFF)	:= fpo.o
-
+obj-$(CONFIG_FAST_POWER_DOWN)	+= fastoffdrv.o

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] PM: fast power off - driver
  2007-01-27 20:05 [PATCH 2/2] PM: fast power off - driver akuster
@ 2007-01-28  3:20 ` Andi Kleen
  2007-01-28 18:09 ` Randy Dunlap
  1 sibling, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2007-01-28  3:20 UTC (permalink / raw)
  To: akuster; +Cc: Andrew Morton, linux-kernel

akuster <akuster@mvista.com> writes:

> My apologies, I cc'd the wrong list the first time around.
> 
> - Armin
> ---
> 
> Fastpoweroff default profile driver

Why don't you just call the existing reboot(2)? I've had a simple 
C program that does a very fast poweroff (or reboot) forever
and it works just fine. It won't kill all processes,
but if you really want to do that you can use killall -r .* first.

-Andi


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] PM: fast power off - driver
  2007-01-27 20:05 [PATCH 2/2] PM: fast power off - driver akuster
  2007-01-28  3:20 ` Andi Kleen
@ 2007-01-28 18:09 ` Randy Dunlap
  2007-01-29 17:41   ` akuster
  1 sibling, 1 reply; 4+ messages in thread
From: Randy Dunlap @ 2007-01-28 18:09 UTC (permalink / raw)
  To: akuster, linux-pm; +Cc: Andrew Morton, linux-kernel

On Sat, 27 Jan 2007 10:05:48 -1000 akuster wrote:

> My apologies, I cc'd the wrong list the first time around.


+config FAST_POWER_DOWN
+	tristate "Fast power of profile"
---------------------------> off
	What does that mean?  especially the "profile" part?

+	depends on FAST_POWER_OFF


+	printk(KERN_INFO "PM: Fastpoweroff, %s profile added\n",fpo_default.name);

Space after "," please.


OK, let me see if I understand fsd_default_off().

+static int fsd_default_off(void)
+{
+	/*
+	 * Actions taken:
+	 *
+	 *    1. Freeze all user processes.
+	 *
+	 *    2. Power off
+	 *
+	 *    3. Power off devices
+	 */
+
+	printk(KERN_EMERG "Fast Power Off initiated.\n");
+	fastpoweroff_prepare();
+	fastpoweroff();
+	fastpoweroff_standby();
+	return 1;
+}

Does this say (2) power off the system and then (3) power off devices?
How does it power off devices after calling fastpoweroff()?
Or is fastpoweroff() only setting the stage for something to
happen later?

Thanks,
---
~Randy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] PM: fast power off - driver
  2007-01-28 18:09 ` Randy Dunlap
@ 2007-01-29 17:41   ` akuster
  0 siblings, 0 replies; 4+ messages in thread
From: akuster @ 2007-01-29 17:41 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-pm, Andrew Morton, linux-kernel



Randy Dunlap wrote:
> On Sat, 27 Jan 2007 10:05:48 -1000 akuster wrote:
> 
>> My apologies, I cc'd the wrong list the first time around.
> 
> 
> +config FAST_POWER_DOWN
> +	tristate "Fast power of profile"
> ---------------------------> off
> 	What does that mean?  especially the "profile" part?
> 
> +	depends on FAST_POWER_OFF
> 
> 
> +	printk(KERN_INFO "PM: Fastpoweroff, %s profile added\n",fpo_default.name);
> 
> Space after "," please.

will correct

> 
> 
> OK, let me see if I understand fsd_default_off().
> 

<snipped.

> 
> Does this say (2) power off the system and then (3) power off devices?
yes,
> How does it power off devices after calling fastpoweroff()?

It does not, it was only a last ditch effort before losing power. I was 
on the fence whether to include that, easy to remove.

> Or is fastpoweroff() only setting the stage for something to
> happen later?

Nope.

Thanks for you time.
- Armin



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-01-31  7:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-27 20:05 [PATCH 2/2] PM: fast power off - driver akuster
2007-01-28  3:20 ` Andi Kleen
2007-01-28 18:09 ` Randy Dunlap
2007-01-29 17:41   ` akuster

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).