linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* patches for 2.6.22
@ 2007-04-27 11:25 Paul Mackerras
  2007-04-27 12:00 ` Johannes Berg
                   ` (16 more replies)
  0 siblings, 17 replies; 78+ messages in thread
From: Paul Mackerras @ 2007-04-27 11:25 UTC (permalink / raw)
  To: linuxppc-dev

I have pushed out some more patches to the for-2.6.22 branch of the
powerpc.git repository.  I intend in the next couple of days to ask
Linus to pull that branch.

If anyone has patches that I haven't picked up yet which they think
should go into 2.6.22, please send me either a pointer to the
patches if previously posted to linuxppc-dev, or post them to
linuxppc-dev.  Note that I don't read linuxppc-embedded, and I rely on
platform maintainers to forward any patches that are ready for
inclusion to me and the linuxppc-dev list.

I'm willing to take arch/ppc patches that fix bugs or generally keep
the existing platforms there working.  I don't want to put large lumps
of new code in there, though.

Due to a mistake on my part (I put in the pasemi RNG driver) I have
had to rebase some of the patches in for-2.6.22 branch, so if you have
done a pull of the for-2.6.22 or master branches in the last 5 hours,
please do a pull -f to get the new set.

Paul.

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

* Re: patches for 2.6.22
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
@ 2007-04-27 12:00 ` Johannes Berg
  2007-04-27 21:41 ` [PATCH] powerpc: fix suspend states again Johannes Berg
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-04-27 12:00 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

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

On Fri, 2007-04-27 at 21:25 +1000, Paul Mackerras wrote:

> If anyone has patches that I haven't picked up yet which they think
> should go into 2.6.22, please send me either a pointer to the
> patches if previously posted to linuxppc-dev, or post them to
> linuxppc-dev.

I'd love to have a bunch of the suspend work in 2.6.22, and even if it's
not the suspend to disk implementation for my G5 but just the suspend to
ram with /sys/power/state for pmu-based machines. However, that depends
on some patches that are still in -mm, what's the way forward with that?
Should I poke akpm to send them out?

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* [PATCH] powerpc: fix suspend states again
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
  2007-04-27 12:00 ` Johannes Berg
@ 2007-04-27 21:41 ` Johannes Berg
  2007-04-27 21:53   ` Olof Johansson
  2007-04-27 23:42 ` patches for 2.6.22 Arnd Bergmann
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-04-27 21:41 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

In commit 0fba3a1f39f8b0a50b56c8b068fa52131cbc84c2 (a very long time ago,
May 2006), I fixed a bug that caused powermacs to crash when you tried
entering standby/mem suspend states.

As I'm now getting more familiar with the suspend code I notice a few
more things:
 1. we previously misunderstood what pm_ops is for, it isn't supposed to be
    for doing platform dependent suspend/resume stuff that needs to be done
    for suspend to disk (as we currently try to use it!), it is instead for
    entering platform dependent suspend states ("standby", "mem").
 2. due to the first point, we never properly save FPU and altivec states
    when suspending to disk. It probably hasn't hurt yet because the process
    that writes the "disk" to /sys/power/state uses neither and its context
    is used.

This patch addresses these points as follows:
 1. remove all pm_ops from powermac, powermac suspend to ram isn't currently
    usable via /sys/power/state but is done via the PMU instead.
 2. move the code responsible for storing FPU/altivec state into
    save_processor_state and the set_context() call to restore_processor_state.
 3. add a call to kernel_enable_spe()

It may look like there is some code removal missing but that is actually because
the new suspend.h file overrides the ppc/suspend.h one which was previously used.

A follow-on patch will create new pm_ops for via-pmu.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
Ben's acked-by can be found at
http://thread.gmane.org/gmane.linux.ports.ppc64.devel/17441/focus=17467,
I just reworded the description slightly since then.

 arch/powerpc/kernel/Makefile            |    1 
 arch/powerpc/kernel/swsusp.c            |   42 ++++++++++++++++++++
 arch/powerpc/platforms/powermac/setup.c |   65 --------------------------------
 include/asm-powerpc/suspend.h           |    9 ++++
 4 files changed, 52 insertions(+), 65 deletions(-)

--- linux-2.6.orig/arch/powerpc/platforms/powermac/setup.c	2007-04-27 23:24:57.576021121 +0200
+++ linux-2.6/arch/powerpc/platforms/powermac/setup.c	2007-04-27 23:25:20.396021121 +0200
@@ -420,76 +420,11 @@ static void __init find_boot_device(void
 #endif
 }
 
-/* TODO: Merge the suspend-to-ram with the common code !!!
- * currently, this is a stub implementation for suspend-to-disk
- * only
- */
-
-#ifdef CONFIG_SOFTWARE_SUSPEND
-
-static int pmac_pm_prepare(suspend_state_t state)
-{
-	printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
-
-	return 0;
-}
-
-static int pmac_pm_enter(suspend_state_t state)
-{
-	printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
-
-	/* Giveup the lazy FPU & vec so we don't have to back them
-	 * up from the low level code
-	 */
-	enable_kernel_fp();
-
-#ifdef CONFIG_ALTIVEC
-	if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
-		enable_kernel_altivec();
-#endif /* CONFIG_ALTIVEC */
-
-	return 0;
-}
-
-static int pmac_pm_finish(suspend_state_t state)
-{
-	printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
-
-	/* Restore userland MMU context */
-	set_context(current->active_mm->context.id, current->active_mm->pgd);
-
-	return 0;
-}
-
-static int pmac_pm_valid(suspend_state_t state)
-{
-	switch (state) {
-	case PM_SUSPEND_DISK:
-		return 1;
-	/* can't do any other states via generic mechanism yet */
-	default:
-		return 0;
-	}
-}
-
-static struct pm_ops pmac_pm_ops = {
-	.pm_disk_mode	= PM_DISK_SHUTDOWN,
-	.prepare	= pmac_pm_prepare,
-	.enter		= pmac_pm_enter,
-	.finish		= pmac_pm_finish,
-	.valid		= pmac_pm_valid,
-};
-
-#endif /* CONFIG_SOFTWARE_SUSPEND */
-
 static int initializing = 1;
 
 static int pmac_late_init(void)
 {
 	initializing = 0;
-#ifdef CONFIG_SOFTWARE_SUSPEND
-	pm_set_ops(&pmac_pm_ops);
-#endif /* CONFIG_SOFTWARE_SUSPEND */
 	return 0;
 }
 
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/include/asm-powerpc/suspend.h	2007-04-27 23:25:20.396021121 +0200
@@ -0,0 +1,9 @@
+#ifndef __ASM_POWERPC_SUSPEND_H
+#define __ASM_POWERPC_SUSPEND_H
+
+static inline int arch_prepare_suspend(void) { return 0; }
+
+void save_processor_state(void);
+void restore_processor_state(void);
+
+#endif /* __ASM_POWERPC_SUSPEND_H */
--- linux-2.6.orig/arch/powerpc/kernel/Makefile	2007-04-27 23:24:57.616021121 +0200
+++ linux-2.6/arch/powerpc/kernel/Makefile	2007-04-27 23:25:20.406021121 +0200
@@ -36,6 +36,7 @@ obj-$(CONFIG_GENERIC_TBSYNC)	+= smp-tbsy
 obj-$(CONFIG_CRASH_DUMP)	+= crash_dump.o
 obj-$(CONFIG_6xx)		+= idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o
 obj-$(CONFIG_TAU)		+= tau_6xx.o
+obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o
 obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o
 obj32-$(CONFIG_MODULES)		+= module_32.o
 
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/arch/powerpc/kernel/swsusp.c	2007-04-27 23:25:20.406021121 +0200
@@ -0,0 +1,42 @@
+/*
+ * Common powerpc suspend code for 32 and 64 bits
+ *
+ * Copyright 2007	Johannes Berg <johannes@sipsolutions.net>
+ *
+ * GPLv2
+ */
+
+#include <linux/sched.h>
+#include <asm/suspend.h>
+#include <asm/cputable.h>
+#include <asm/system.h>
+#include <asm/current.h>
+#include <asm/mmu_context.h>
+
+#ifdef CONFIG_SPE
+extern void enable_kernel_spe(void);
+#endif
+
+void save_processor_state(void)
+{
+	/* Giveup the lazy FPU & vec so we don't have to back them
+	 * up from the low level code
+	 */
+	enable_kernel_fp();
+
+#ifdef CONFIG_ALTIVEC
+	if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
+		enable_kernel_altivec();
+#endif /* CONFIG_ALTIVEC */
+
+#ifdef CONFIG_SPE
+	enable_kernel_spe();
+#endif
+}
+
+void restore_processor_state(void)
+{
+#ifdef CONFIG_PPC32
+	set_context(current->active_mm->context.id, current->active_mm->pgd);
+#endif
+}

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

* Re: [PATCH] powerpc: fix suspend states again
  2007-04-27 21:41 ` [PATCH] powerpc: fix suspend states again Johannes Berg
@ 2007-04-27 21:53   ` Olof Johansson
  2007-04-27 21:54     ` Johannes Berg
  0 siblings, 1 reply; 78+ messages in thread
From: Olof Johansson @ 2007-04-27 21:53 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, Paul Mackerras

Hi,


On Fri, Apr 27, 2007 at 11:41:35PM +0200, Johannes Berg wrote:

> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ linux-2.6/arch/powerpc/kernel/swsusp.c	2007-04-27 23:25:20.406021121 +0200
> @@ -0,0 +1,42 @@
> +/*
> + * Common powerpc suspend code for 32 and 64 bits
> + *
> + * Copyright 2007	Johannes Berg <johannes@sipsolutions.net>
> + *
> + * GPLv2
> + */

A regular GPL copyright blurb isn't that hard to paste in. :-)

> +#include <linux/sched.h>
> +#include <asm/suspend.h>
> +#include <asm/cputable.h>
> +#include <asm/system.h>
> +#include <asm/current.h>
> +#include <asm/mmu_context.h>
> +
> +#ifdef CONFIG_SPE
> +extern void enable_kernel_spe(void);
> +#endif

This should be added to asm-powerpc/system.h instead, and that should
be included here since that has the enable_kernel_altivec() and
enable_kernel_fp() definitions.


-Olof

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

* Re: [PATCH] powerpc: fix suspend states again
  2007-04-27 21:53   ` Olof Johansson
@ 2007-04-27 21:54     ` Johannes Berg
  2007-04-27 21:57       ` Olof Johansson
                         ` (2 more replies)
  0 siblings, 3 replies; 78+ messages in thread
From: Johannes Berg @ 2007-04-27 21:54 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, Paul Mackerras

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

On Fri, 2007-04-27 at 16:53 -0500, Olof Johansson wrote:

> > + * GPLv2
> > + */
> 
> A regular GPL copyright blurb isn't that hard to paste in. :-)

Aw, I just hate cluttering all the files with it :)

> > +#ifdef CONFIG_SPE
> > +extern void enable_kernel_spe(void);
> > +#endif
> 
> This should be added to asm-powerpc/system.h instead

and it shouldn't be ifdef'ed either ;)

> , and that should
> be included here since that has the enable_kernel_altivec() and
> enable_kernel_fp() definitions.

True. Guess I get to make two new patches.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: [PATCH] powerpc: fix suspend states again
  2007-04-27 21:54     ` Johannes Berg
@ 2007-04-27 21:57       ` Olof Johansson
  2007-04-27 22:00       ` [PATCH] powerpc: put enable_kernel_spe into a header Johannes Berg
  2007-04-27 22:02       ` [PATCH v2] powerpc: fix suspend states again Johannes Berg
  2 siblings, 0 replies; 78+ messages in thread
From: Olof Johansson @ 2007-04-27 21:57 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, Paul Mackerras

On Fri, Apr 27, 2007 at 11:54:43PM +0200, Johannes Berg wrote:
> On Fri, 2007-04-27 at 16:53 -0500, Olof Johansson wrote:
> 
> > > + * GPLv2
> > > + */
> > 
> > A regular GPL copyright blurb isn't that hard to paste in. :-)
> 
> Aw, I just hate cluttering all the files with it :)
>
> > > +#ifdef CONFIG_SPE
> > > +extern void enable_kernel_spe(void);
> > > +#endif
> > 
> > This should be added to asm-powerpc/system.h instead
> 
> and it shouldn't be ifdef'ed either ;)

Nope

> > , and that should
> > be included here since that has the enable_kernel_altivec() and
> > enable_kernel_fp() definitions.
> 
> True. Guess I get to make two new patches.

It already was, I missed it. -ENEEDCOFFEE.


-Olof

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

* [PATCH] powerpc: put enable_kernel_spe into a header
  2007-04-27 21:54     ` Johannes Berg
  2007-04-27 21:57       ` Olof Johansson
@ 2007-04-27 22:00       ` Johannes Berg
  2007-04-27 22:02       ` [PATCH v2] powerpc: fix suspend states again Johannes Berg
  2 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-04-27 22:00 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, Paul Mackerras

This patch puts enable_kernel_spe into <asm-powerpc/system.h> along with
enable_kernel_altivec etc.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>

---
 include/asm-powerpc/system.h |    1 +
 1 file changed, 1 insertion(+)

--- linux-2.6.orig/include/asm-powerpc/system.h	2007-04-27 23:56:42.976021121 +0200
+++ linux-2.6/include/asm-powerpc/system.h	2007-04-27 23:59:50.826021121 +0200
@@ -131,6 +131,7 @@ extern void enable_kernel_altivec(void);
 extern void giveup_altivec(struct task_struct *);
 extern void load_up_altivec(struct task_struct *);
 extern int emulate_altivec(struct pt_regs *);
+extern void enable_kernel_spe(void);
 extern void giveup_spe(struct task_struct *);
 extern void load_up_spe(struct task_struct *);
 extern int fix_alignment(struct pt_regs *);

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

* [PATCH v2] powerpc: fix suspend states again
  2007-04-27 21:54     ` Johannes Berg
  2007-04-27 21:57       ` Olof Johansson
  2007-04-27 22:00       ` [PATCH] powerpc: put enable_kernel_spe into a header Johannes Berg
@ 2007-04-27 22:02       ` Johannes Berg
  2007-04-27 23:13         ` Olof Johansson
  2007-04-30  0:14         ` Paul Mackerras
  2 siblings, 2 replies; 78+ messages in thread
From: Johannes Berg @ 2007-04-27 22:02 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, Paul Mackerras

In commit 0fba3a1f39f8b0a50b56c8b068fa52131cbc84c2 (a very long time ago,
May 2006), I fixed a bug that caused powermacs to crash when you tried
entering standby/mem suspend states.

As I'm now getting more familiar with the suspend code I notice a few
more things:
 1. we previously misunderstood what pm_ops is for, it isn't supposed to be
    for doing platform dependent suspend/resume stuff that needs to be done
    for suspend to disk (as we currently try to use it!), it is instead for
    entering platform dependent suspend states ("standby", "mem").
 2. due to the first point, we never properly save FPU and altivec states
    when suspending to disk. It probably hasn't hurt yet because the process
    that writes the "disk" to /sys/power/state uses neither and its context
    is used.

This patch addresses these points as follows:
 1. remove all pm_ops from powermac, powermac suspend to ram isn't currently
    usable via /sys/power/state but is done via the PMU instead.
 2. move the code responsible for storing FPU/altivec state into
    save_processor_state and the set_context() call to restore_processor_state.
 3. add a call to kernel_enable_spe()

It may look like there is some code removal missing but that is actually because
the new suspend.h file overrides the ppc/suspend.h one which was previously used.

A follow-on patch will create new pm_ops for via-pmu.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
This time without the extern declaration and four new lines of license text ;)

 arch/powerpc/kernel/Makefile            |    1 
 arch/powerpc/kernel/swsusp.c            |   41 ++++++++++++++++++++
 arch/powerpc/platforms/powermac/setup.c |   65 --------------------------------
 include/asm-powerpc/suspend.h           |    9 ++++
 4 files changed, 51 insertions(+), 65 deletions(-)

--- linux-2.6.orig/arch/powerpc/platforms/powermac/setup.c	2007-04-27 23:56:21.466021121 +0200
+++ linux-2.6/arch/powerpc/platforms/powermac/setup.c	2007-04-28 00:00:08.986021121 +0200
@@ -420,76 +420,11 @@ static void __init find_boot_device(void
 #endif
 }
 
-/* TODO: Merge the suspend-to-ram with the common code !!!
- * currently, this is a stub implementation for suspend-to-disk
- * only
- */
-
-#ifdef CONFIG_SOFTWARE_SUSPEND
-
-static int pmac_pm_prepare(suspend_state_t state)
-{
-	printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
-
-	return 0;
-}
-
-static int pmac_pm_enter(suspend_state_t state)
-{
-	printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
-
-	/* Giveup the lazy FPU & vec so we don't have to back them
-	 * up from the low level code
-	 */
-	enable_kernel_fp();
-
-#ifdef CONFIG_ALTIVEC
-	if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
-		enable_kernel_altivec();
-#endif /* CONFIG_ALTIVEC */
-
-	return 0;
-}
-
-static int pmac_pm_finish(suspend_state_t state)
-{
-	printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
-
-	/* Restore userland MMU context */
-	set_context(current->active_mm->context.id, current->active_mm->pgd);
-
-	return 0;
-}
-
-static int pmac_pm_valid(suspend_state_t state)
-{
-	switch (state) {
-	case PM_SUSPEND_DISK:
-		return 1;
-	/* can't do any other states via generic mechanism yet */
-	default:
-		return 0;
-	}
-}
-
-static struct pm_ops pmac_pm_ops = {
-	.pm_disk_mode	= PM_DISK_SHUTDOWN,
-	.prepare	= pmac_pm_prepare,
-	.enter		= pmac_pm_enter,
-	.finish		= pmac_pm_finish,
-	.valid		= pmac_pm_valid,
-};
-
-#endif /* CONFIG_SOFTWARE_SUSPEND */
-
 static int initializing = 1;
 
 static int pmac_late_init(void)
 {
 	initializing = 0;
-#ifdef CONFIG_SOFTWARE_SUSPEND
-	pm_set_ops(&pmac_pm_ops);
-#endif /* CONFIG_SOFTWARE_SUSPEND */
 	return 0;
 }
 
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/include/asm-powerpc/suspend.h	2007-04-28 00:00:08.986021121 +0200
@@ -0,0 +1,9 @@
+#ifndef __ASM_POWERPC_SUSPEND_H
+#define __ASM_POWERPC_SUSPEND_H
+
+static inline int arch_prepare_suspend(void) { return 0; }
+
+void save_processor_state(void);
+void restore_processor_state(void);
+
+#endif /* __ASM_POWERPC_SUSPEND_H */
--- linux-2.6.orig/arch/powerpc/kernel/Makefile	2007-04-27 23:56:21.526021121 +0200
+++ linux-2.6/arch/powerpc/kernel/Makefile	2007-04-28 00:00:08.996021121 +0200
@@ -36,6 +36,7 @@ obj-$(CONFIG_GENERIC_TBSYNC)	+= smp-tbsy
 obj-$(CONFIG_CRASH_DUMP)	+= crash_dump.o
 obj-$(CONFIG_6xx)		+= idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o
 obj-$(CONFIG_TAU)		+= tau_6xx.o
+obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o
 obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o
 obj32-$(CONFIG_MODULES)		+= module_32.o
 
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/arch/powerpc/kernel/swsusp.c	2007-04-28 00:02:06.186021121 +0200
@@ -0,0 +1,41 @@
+/*
+ * Common powerpc suspend code for 32 and 64 bits
+ *
+ * Copyright 2007	Johannes Berg <johannes@sipsolutions.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/sched.h>
+#include <asm/suspend.h>
+#include <asm/cputable.h>
+#include <asm/system.h>
+#include <asm/current.h>
+#include <asm/mmu_context.h>
+
+void save_processor_state(void)
+{
+	/* Giveup the lazy FPU & vec so we don't have to back them
+	 * up from the low level code
+	 */
+	enable_kernel_fp();
+
+#ifdef CONFIG_ALTIVEC
+	if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
+		enable_kernel_altivec();
+#endif /* CONFIG_ALTIVEC */
+
+#ifdef CONFIG_SPE
+	enable_kernel_spe();
+#endif
+}
+
+void restore_processor_state(void)
+{
+#ifdef CONFIG_PPC32
+	set_context(current->active_mm->context.id, current->active_mm->pgd);
+#endif
+}

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

* Re: [PATCH v2] powerpc: fix suspend states again
  2007-04-27 22:02       ` [PATCH v2] powerpc: fix suspend states again Johannes Berg
@ 2007-04-27 23:13         ` Olof Johansson
  2007-04-30  0:14         ` Paul Mackerras
  1 sibling, 0 replies; 78+ messages in thread
From: Olof Johansson @ 2007-04-27 23:13 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, Paul Mackerras

On Sat, Apr 28, 2007 at 12:02:52AM +0200, Johannes Berg wrote:
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Acked-by: Olof Johansson <olof@lixom.net>

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

* Re: patches for 2.6.22
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
  2007-04-27 12:00 ` Johannes Berg
  2007-04-27 21:41 ` [PATCH] powerpc: fix suspend states again Johannes Berg
@ 2007-04-27 23:42 ` Arnd Bergmann
  2007-04-28  2:49 ` [PATCH] cell: cbe_cpufreq cleanup and crash fix Arnd Bergmann
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 78+ messages in thread
From: Arnd Bergmann @ 2007-04-27 23:42 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, jeremy

On Friday 27 April 2007, Paul Mackerras wrote:
> If anyone has patches that I haven't picked up yet which they think
> should go into 2.6.22, please send me either a pointer to the
> patches if previously posted to linuxppc-dev, or post them to
> linuxppc-dev. 

I still have around 20 patches pending. Most of them are for spufs,
and I'm waiting to get feedback about them from Jeremy.

http://kernel.org/pub/linux/kernel/people/arnd/patches/2.6.21-rc7-arnd2/2.6.21-rc7-arnd2.log
has a description of what is still pending, the patches in detail are:

#### SPE affinity
cell-be_info-2.diff
cell-spu_indexing-2.diff
cell-spu_indexing_QS20-2.diff
spufs-affinity_create-4.diff
spufs-affinity_placement-4.diff
spufs-affinity_schedulling-2.diff
cell-spu_indexing_FW_vicinity-1.diff

-> waiting for an ack

spu_base-locking-cleanup.diff

-> ok with me, but depends on above

#### SPE oprofile support
re-cell-oprofile-spu-profiling-updated-patch-4.diff
re-add-support-to-oprofile-for-profiling-cell-be-spus-update-2.diff

-> want to do a final review myself

#### spu scheduler updates
spusched-remove-wakeup-races.diff
spusched-kthread.diff
spusched-dynamic-timeslicing.diff
spusched-update-policy.diff
spusched-fix-cpubind.diff
spu-loadavg.diff

-> looks ok to me, but depends on the above

#### under discussion
axon-ram-3.diff

-> This version hasn't been reviewed yet, the author hasn't signed off.

64k-support-for-kexec.diff

-> discussion ongoing, will hopefully come to a conclusion soon

powerpc-uninline-of_iomap.diff
cell-cbe_cpufreq-cleanup-and-crash-fix.diff

-> have been submitted after the previous merge with you, should go in.

	Arnd <><

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

* [PATCH] cell: cbe_cpufreq cleanup and crash fix
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (2 preceding siblings ...)
  2007-04-27 23:42 ` patches for 2.6.22 Arnd Bergmann
@ 2007-04-28  2:49 ` Arnd Bergmann
  2007-04-28  7:49 ` [PATCH] powermac: proper sleep management Johannes Berg
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 78+ messages in thread
From: Arnd Bergmann @ 2007-04-28  2:49 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Olof Johansson, Christian Krafft, Paul Mackerras

From: Olof Johansson <olof@lixom.net>
cbe_cpufreq cleanups:

* comment format
* whitespace
* don't init on non-cell platforms

Signed-off-by: Olof Johansson <olof@lixom.net>
Acked-by: Christian Krafft <krafft@de.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
---
Index: linux-2.6/arch/powerpc/platforms/cell/cbe_cpufreq.c
===================================================================
--- linux-2.6.orig/arch/powerpc/platforms/cell/cbe_cpufreq.c
+++ linux-2.6/arch/powerpc/platforms/cell/cbe_cpufreq.c
@@ -25,6 +25,7 @@
 
 #include <asm/hw_irq.h>
 #include <asm/io.h>
+#include <asm/machdep.h>
 #include <asm/processor.h>
 #include <asm/prom.h>
 #include <asm/time.h>
@@ -155,7 +156,7 @@ static int set_pmode_reg(int cpu, unsign
 }
 
 static int set_pmode(int cpu, unsigned int slow_mode) {
-	if(pmi_dev)
+	if (pmi_dev)
 		return set_pmode_pmi(cpu, slow_mode);
 	else
 		return set_pmode_reg(cpu, slow_mode);
@@ -167,7 +168,7 @@ static void cbe_cpufreq_handle_pmi(struc
 	u8 cpu;
 	u8 cbe_pmode_new;
 
-	BUG_ON (pmi_msg.type != PMI_TYPE_FREQ_CHANGE);
+	BUG_ON(pmi_msg.type != PMI_TYPE_FREQ_CHANGE);
 
 	cpu = cbe_node_to_cpu(pmi_msg.data1);
 	cbe_pmode_new = pmi_msg.data2;
@@ -191,7 +192,7 @@ static struct pmi_handler cbe_pmi_handle
  * cpufreq functions
  */
 
-static int cbe_cpufreq_cpu_init (struct cpufreq_policy *policy)
+static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
 {
 	const u32 *max_freqp;
 	u32 max_freq;
@@ -200,7 +201,7 @@ static int cbe_cpufreq_cpu_init (struct 
 
 	cpu = of_get_cpu_node(policy->cpu, NULL);
 
-	if(!cpu)
+	if (!cpu)
 		return -ENODEV;
 
 	pr_debug("init cpufreq on CPU %d\n", policy->cpu);
@@ -210,13 +211,13 @@ static int cbe_cpufreq_cpu_init (struct 
 	if (!max_freqp)
 		return -EINVAL;
 
-	// we need the freq in kHz
+	/* we need the freq in kHz */
 	max_freq = *max_freqp / 1000;
 
 	pr_debug("max clock-frequency is at %u kHz\n", max_freq);
 	pr_debug("initializing frequency table\n");
 
-	// initialize frequency table
+	/* initialize frequency table */
 	for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) {
 		cbe_freqs[i].frequency = max_freq / cbe_freqs[i].index;
 		pr_debug("%d: %d\n", i, cbe_freqs[i].frequency);
@@ -235,10 +236,10 @@ static int cbe_cpufreq_cpu_init (struct 
 	policy->cpus = cpu_sibling_map[policy->cpu];
 #endif
 
-	cpufreq_frequency_table_get_attr (cbe_freqs, policy->cpu);
+	cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu);
 
 	/* this ensures that policy->cpuinfo_min and policy->cpuinfo_max are set correctly */
-	return cpufreq_frequency_table_cpuinfo (policy, cbe_freqs);
+	return cpufreq_frequency_table_cpuinfo(policy, cbe_freqs);
 }
 
 static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy)
@@ -270,7 +271,7 @@ static int cbe_cpufreq_target(struct cpu
 	freqs.new = cbe_freqs[cbe_pmode_new].frequency;
 	freqs.cpu = policy->cpu;
 
-	mutex_lock (&cbe_switch_mutex);
+	mutex_lock(&cbe_switch_mutex);
 	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
 
 	pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n",
@@ -303,6 +304,9 @@ static int __init cbe_cpufreq_init(void)
 {
 	struct device_node *np;
 
+	if (!machine_is(cell))
+		return -ENODEV;
+
 	np = of_find_node_by_type(NULL, "ibm,pmi");
 
 	pmi_dev = of_find_device_by_node(np);
@@ -315,7 +319,7 @@ static int __init cbe_cpufreq_init(void)
 
 static void __exit cbe_cpufreq_exit(void)
 {
-	if(pmi_dev)
+	if (pmi_dev)
 		pmi_unregister_handler(pmi_dev, &cbe_pmi_handler);
 
 	cpufreq_unregister_driver(&cbe_cpufreq_driver);

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

* [PATCH] powermac: proper sleep management
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (3 preceding siblings ...)
  2007-04-28  2:49 ` [PATCH] cell: cbe_cpufreq cleanup and crash fix Arnd Bergmann
@ 2007-04-28  7:49 ` Johannes Berg
  2007-04-28  8:08   ` Paul Mackerras
                     ` (3 more replies)
  2007-04-30 19:51 ` patches for 2.6.22 Kim Phillips
                   ` (11 subsequent siblings)
  16 siblings, 4 replies; 78+ messages in thread
From: Johannes Berg @ 2007-04-28  7:49 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

After having removed the power management ops from powermac completely, this
patch adds them back for PMU based machines, directly in the PMU driver.
This finally allows suspending via /sys/power/state on powerbooks.

The patch also replaces the PMU ioctl with a simple call to
pm_suspend(PM_SUSPEND_MEM) and puts the sleep-related PMU ioctls onto the
feature-removal schedule.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
This was tested on slightly older machines by David Woodhouse and by me
on my PowerBook5,6. It will apply, build and suspend-to-ram will work
against current kernels (the arch suspend hooks have been merged via
Greg KH) but it will break suspend to disk if working. This is addressed
by a patch to the generic code that Andrew Morton has and will be
sending soon under the title "rework pm_ops pm_disk_mode, kill misuse".

---
 Documentation/feature-removal-schedule.txt |   10 
 drivers/macintosh/via-pmu.c                |  329 +++++++++++++----------------
 2 files changed, 159 insertions(+), 180 deletions(-)

--- linux-2.6.orig/drivers/macintosh/via-pmu.c	2007-04-27 23:56:19.176021121 +0200
+++ linux-2.6/drivers/macintosh/via-pmu.c	2007-04-28 09:45:25.746883531 +0200
@@ -61,6 +61,10 @@
 #include <asm/cputable.h>
 #include <asm/time.h>
 #include <asm/backlight.h>
+#include <asm/suspend.h>
+
+/* remove when we don't need kernel_power_off any more */
+#include <linux/reboot.h>
 
 #include "via-pmu-event.h"
 
@@ -155,9 +159,6 @@ static int drop_interrupts;
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 static int option_lid_wakeup = 1;
 #endif /* CONFIG_PM && CONFIG_PPC32 */
-#if (defined(CONFIG_PM)&&defined(CONFIG_PPC32))||defined(CONFIG_PMAC_BACKLIGHT_LEGACY)
-static int sleep_in_progress;
-#endif
 static unsigned long async_req_locks;
 static unsigned int pmu_irq_stats[11];
 
@@ -1991,132 +1992,6 @@ restore_via_state(void)
 
 extern void pmu_backlight_set_sleep(int sleep);
 
-static int
-pmac_suspend_devices(void)
-{
-	int ret;
-
-	pm_prepare_console();
-	
-	/* Notify old-style device drivers */
-	broadcast_sleep(PBOOK_SLEEP_REQUEST);
-
-	/* Sync the disks. */
-	/* XXX It would be nice to have some way to ensure that
-	 * nobody is dirtying any new buffers while we wait. That
-	 * could be achieved using the refrigerator for processes
-	 * that swsusp uses
-	 */
-	sys_sync();
-
-	broadcast_sleep(PBOOK_SLEEP_NOW);
-
-	/* Send suspend call to devices, hold the device core's dpm_sem */
-	ret = device_suspend(PMSG_SUSPEND);
-	if (ret) {
-		broadcast_wake();
-		printk(KERN_ERR "Driver sleep failed\n");
-		return -EBUSY;
-	}
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-	/* Tell backlight code not to muck around with the chip anymore */
-	pmu_backlight_set_sleep(1);
-#endif
-
-	/* Call platform functions marked "on sleep" */
-	pmac_pfunc_i2c_suspend();
-	pmac_pfunc_base_suspend();
-
-	/* Stop preemption */
-	preempt_disable();
-
-	/* Make sure the decrementer won't interrupt us */
-	asm volatile("mtdec %0" : : "r" (0x7fffffff));
-	/* Make sure any pending DEC interrupt occurring while we did
-	 * the above didn't re-enable the DEC */
-	mb();
-	asm volatile("mtdec %0" : : "r" (0x7fffffff));
-
-	/* We can now disable MSR_EE. This code of course works properly only
-	 * on UP machines... For SMP, if we ever implement sleep, we'll have to
-	 * stop the "other" CPUs way before we do all that stuff.
-	 */
-	local_irq_disable();
-
-	/* Broadcast power down irq
-	 * This isn't that useful in most cases (only directly wired devices can
-	 * use this but still... This will take care of sysdev's as well, so
-	 * we exit from here with local irqs disabled and PIC off.
-	 */
-	ret = device_power_down(PMSG_SUSPEND);
-	if (ret) {
-		wakeup_decrementer();
-		local_irq_enable();
-		preempt_enable();
-		device_resume();
-		broadcast_wake();
-		printk(KERN_ERR "Driver powerdown failed\n");
-		return -EBUSY;
-	}
-
-	/* Wait for completion of async requests */
-	while (!batt_req.complete)
-		pmu_poll();
-
-	/* Giveup the lazy FPU & vec so we don't have to back them
-	 * up from the low level code
-	 */
-	enable_kernel_fp();
-
-#ifdef CONFIG_ALTIVEC
-	if (cpu_has_feature(CPU_FTR_ALTIVEC))
-		enable_kernel_altivec();
-#endif /* CONFIG_ALTIVEC */
-
-	return 0;
-}
-
-static int
-pmac_wakeup_devices(void)
-{
-	mdelay(100);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-	/* Tell backlight code it can use the chip again */
-	pmu_backlight_set_sleep(0);
-#endif
-
-	/* Power back up system devices (including the PIC) */
-	device_power_up();
-
-	/* Force a poll of ADB interrupts */
-	adb_int_pending = 1;
-	via_pmu_interrupt(0, NULL);
-
-	/* Restart jiffies & scheduling */
-	wakeup_decrementer();
-
-	/* Re-enable local CPU interrupts */
-	local_irq_enable();
-	mdelay(10);
-	preempt_enable();
-
-	/* Call platform functions marked "on wake" */
-	pmac_pfunc_base_resume();
-	pmac_pfunc_i2c_resume();
-
-	/* Resume devices */
-	device_resume();
-
-	/* Notify old style drivers */
-	broadcast_wake();
-
-	pm_restore_console();
-
-	return 0;
-}
-
 #define	GRACKLE_PM	(1<<7)
 #define GRACKLE_DOZE	(1<<5)
 #define	GRACKLE_NAP	(1<<4)
@@ -2127,19 +2002,12 @@ static int powerbook_sleep_grackle(void)
 	unsigned long save_l2cr;
 	unsigned short pmcr1;
 	struct adb_request req;
-	int ret;
 	struct pci_dev *grackle;
 
 	grackle = pci_find_slot(0, 0);
 	if (!grackle)
 		return -ENODEV;
 
-	ret = pmac_suspend_devices();
-	if (ret) {
-		printk(KERN_ERR "Sleep rejected by devices\n");
-		return ret;
-	}
-	
 	/* Turn off various things. Darwin does some retry tests here... */
 	pmu_request(&req, NULL, 2, PMU_POWER_CTRL0, PMU_POW0_OFF|PMU_POW0_HARD_DRIVE);
 	pmu_wait_complete(&req);
@@ -2200,8 +2068,6 @@ static int powerbook_sleep_grackle(void)
 			PMU_POW_ON|PMU_POW_BACKLIGHT|PMU_POW_CHARGER|PMU_POW_IRLED|PMU_POW_MEDIABAY);
 	pmu_wait_complete(&req);
 
-	pmac_wakeup_devices();
-
 	return 0;
 }
 
@@ -2211,7 +2077,6 @@ powerbook_sleep_Core99(void)
 	unsigned long save_l2cr;
 	unsigned long save_l3cr;
 	struct adb_request req;
-	int ret;
 	
 	if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) < 0) {
 		printk(KERN_ERR "Sleep mode not supported on this machine\n");
@@ -2221,12 +2086,6 @@ powerbook_sleep_Core99(void)
 	if (num_online_cpus() > 1 || cpu_is_offline(0))
 		return -EAGAIN;
 
-	ret = pmac_suspend_devices();
-	if (ret) {
-		printk(KERN_ERR "Sleep rejected by devices\n");
-		return ret;
-	}
-
 	/* Stop environment and ADB interrupts */
 	pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0);
 	pmu_wait_complete(&req);
@@ -2297,8 +2156,6 @@ powerbook_sleep_Core99(void)
 	/* Restore LPJ, cpufreq will adjust the cpu frequency */
 	loops_per_jiffy /= 2;
 
-	pmac_wakeup_devices();
-
 	return 0;
 }
 
@@ -2308,7 +2165,7 @@ powerbook_sleep_Core99(void)
 static int
 powerbook_sleep_3400(void)
 {
-	int ret, i, x;
+	int i, x;
 	unsigned int hid0;
 	unsigned long p;
 	struct adb_request sleep_req;
@@ -2326,13 +2183,6 @@ powerbook_sleep_3400(void)
 	/* Allocate room for PCI save */
 	pbook_alloc_pci_save();
 
-	ret = pmac_suspend_devices();
-	if (ret) {
-		pbook_free_pci_save();
-		printk(KERN_ERR "Sleep rejected by devices\n");
-		return ret;
-	}
-
 	/* Save the state of PCI config space for some slots */
 	pbook_pci_save();
 
@@ -2376,7 +2226,6 @@ powerbook_sleep_3400(void)
 	while (asleep)
 		mb();
 
-	pmac_wakeup_devices();
 	pbook_free_pci_save();
 	iounmap(mem_ctrl);
 
@@ -2558,6 +2407,142 @@ pmu_release(struct inode *inode, struct 
 	return 0;
 }
 
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+static int powerbook_prepare_sleep(suspend_state_t state)
+{
+	/* Notify old-style device drivers */
+	broadcast_sleep(PBOOK_SLEEP_REQUEST);
+	broadcast_sleep(PBOOK_SLEEP_NOW);
+
+	return 0;
+}
+
+/*
+ * overrides the weak arch_suspend_disable_irqs in kernel/power/main.c
+ */
+void arch_suspend_disable_irqs(void)
+{
+#ifdef CONFIG_PMAC_BACKLIGHT
+	/* Tell backlight code not to muck around with the chip anymore */
+	pmu_backlight_set_sleep(1);
+#endif
+
+	/* Call platform functions marked "on sleep" */
+	pmac_pfunc_i2c_suspend();
+	pmac_pfunc_base_suspend();
+
+	/* Stop preemption */
+	preempt_disable();
+
+	/* Make sure the decrementer won't interrupt us */
+	asm volatile("mtdec %0" : : "r" (0x7fffffff));
+	/* Make sure any pending DEC interrupt occurring while we did
+	 * the above didn't re-enable the DEC */
+	mb();
+	asm volatile("mtdec %0" : : "r" (0x7fffffff));
+
+	local_irq_disable();
+}
+
+static int powerbook_sleep(suspend_state_t state)
+{
+	int error = 0;
+
+	/* Wait for completion of async requests */
+	while (!batt_req.complete)
+		pmu_poll();
+
+	/* Giveup the lazy FPU & vec so we don't have to back them
+	 * up from the low level code
+	 */
+	enable_kernel_fp();
+
+#ifdef CONFIG_ALTIVEC
+	if (cpu_has_feature(CPU_FTR_ALTIVEC))
+		enable_kernel_altivec();
+#endif /* CONFIG_ALTIVEC */
+
+	switch (pmu_kind) {
+	case PMU_OHARE_BASED:
+		error = powerbook_sleep_3400();
+		break;
+	case PMU_HEATHROW_BASED:
+	case PMU_PADDINGTON_BASED:
+		error = powerbook_sleep_grackle();
+		break;
+	case PMU_KEYLARGO_BASED:
+		error = powerbook_sleep_Core99();
+		break;
+	default:
+		return -ENOSYS;
+	}
+
+	if (error)
+		return error;
+
+	mdelay(100);
+
+#ifdef CONFIG_PMAC_BACKLIGHT
+	/* Tell backlight code it can use the chip again */
+	pmu_backlight_set_sleep(0);
+#endif
+
+	return 0;
+}
+
+/*
+ * overrides the weak arch_suspend_enable_irqs in kernel/power/main.c
+ */
+void arch_suspend_enable_irqs(void)
+{
+	/* Force a poll of ADB interrupts */
+	adb_int_pending = 1;
+	via_pmu_interrupt(0, NULL);
+
+	/* Restart jiffies & scheduling */
+	wakeup_decrementer();
+
+	/* Re-enable local CPU interrupts */
+	local_irq_enable();
+	mdelay(10);
+	preempt_enable();
+
+	/* Call platform functions marked "on wake" */
+	pmac_pfunc_base_resume();
+	pmac_pfunc_i2c_resume();
+}
+
+static int powerbook_finish_sleep(suspend_state_t state)
+{
+	/* Notify old style drivers */
+	broadcast_wake();
+
+	return 0;
+}
+
+static int pmu_sleep_valid(suspend_state_t state)
+{
+	return state == PM_SUSPEND_MEM
+		&& (pmac_call_feature(PMAC_FTR_SLEEP_STATE, NULL, 0, -1) >= 0);
+}
+
+static struct pm_ops pmu_pm_ops = {
+	.prepare = powerbook_prepare_sleep,
+	.enter = powerbook_sleep,
+	.finish = powerbook_finish_sleep,
+	.valid = pmu_sleep_valid,
+};
+
+static int register_pmu_pm_ops(void)
+{
+	pm_set_ops(&pmu_pm_ops);
+
+	return 0;
+}
+
+device_initcall(register_pmu_pm_ops);
+#endif
+
 static int
 pmu_ioctl(struct inode * inode, struct file *filp,
 		     u_int cmd, u_long arg)
@@ -2567,29 +2552,19 @@ pmu_ioctl(struct inode * inode, struct f
 
 	switch (cmd) {
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+	/* just provided for compatibility */
 	case PMU_IOC_SLEEP:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
-		if (sleep_in_progress)
-			return -EBUSY;
-		sleep_in_progress = 1;
-		switch (pmu_kind) {
-		case PMU_OHARE_BASED:
-			error = powerbook_sleep_3400();
-			break;
-		case PMU_HEATHROW_BASED:
-		case PMU_PADDINGTON_BASED:
-			error = powerbook_sleep_grackle();
-			break;
-		case PMU_KEYLARGO_BASED:
-			error = powerbook_sleep_Core99();
-			break;
-		default:
-			error = -ENOSYS;
-		}
-		sleep_in_progress = 0;
+		printk(KERN_INFO "via-pmu: the PMU_IOC_SLEEP ioctl is deprecated.\n");
+		printk(KERN_INFO "via-pmu: use \"echo mem > /sys/power/state\" instead!\n");
+		printk(KERN_INFO "via-pmu: this ioctl will be removed soon.\n");
+		error = pm_suspend(PM_SUSPEND_MEM);
 		break;
 	case PMU_IOC_CAN_SLEEP:
+		printk(KERN_INFO "via-pmu: the PMU_IOC_CAN_SLEEP ioctl is deprecated.\n");
+		printk(KERN_INFO "via-pmu: use \"grep mem /sys/power/state\" instead!\n");
+		printk(KERN_INFO "via-pmu: this ioctl will be removed soon.\n");
 		if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) < 0)
 			return put_user(0, argp);
 		else
@@ -2602,9 +2577,6 @@ pmu_ioctl(struct inode * inode, struct f
 	{
 		int brightness;
 
-		if (sleep_in_progress)
-			return -EBUSY;
-
 		brightness = pmac_backlight_get_legacy_brightness();
 		if (brightness < 0)
 			return brightness;
@@ -2616,9 +2588,6 @@ pmu_ioctl(struct inode * inode, struct f
 	{
 		int brightness;
 
-		if (sleep_in_progress)
-			return -EBUSY;
-
 		error = get_user(brightness, argp);
 		if (error)
 			return error;
--- linux-2.6.orig/Documentation/feature-removal-schedule.txt	2007-04-27 23:56:19.196021121 +0200
+++ linux-2.6/Documentation/feature-removal-schedule.txt	2007-04-28 00:52:59.482010117 +0200
@@ -302,3 +302,13 @@ Why:	Code was merged, then submitter imm
 Who:	David S. Miller <davem@davemloft.net>
 
 ---------------------------
+
+What:	/dev/pmu suspend/can-suspend ioctls
+When:	2.6.24
+Files:	drivers/macintosh/via-pmu.c
+Why:	powermac supports proper generic pm_ops now and can suspend with
+	"echo mem > /sys/power/state" instead of the ioctl, checking if
+	it can suspend can be done by reading /sys/power/state.
+Who:	Johannes Berg <johannes@sipsolutions.net>
+
+---------------------------

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

* Re: [PATCH] powermac: proper sleep management
  2007-04-28  7:49 ` [PATCH] powermac: proper sleep management Johannes Berg
@ 2007-04-28  8:08   ` Paul Mackerras
  2007-04-28 12:52     ` Johannes Berg
  2007-04-28  8:38   ` Benjamin Herrenschmidt
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 78+ messages in thread
From: Paul Mackerras @ 2007-04-28  8:08 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev

Johannes Berg writes:

> +What:	/dev/pmu suspend/can-suspend ioctls
> +When:	2.6.24

No way.  You're proposing to remove a kernel/user ABI which is
actively being used by many users.  It needs to stick around for at
least 2 years before we make it non-functional.

Paul.

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

* Re: [PATCH] powermac: proper sleep management
  2007-04-28  7:49 ` [PATCH] powermac: proper sleep management Johannes Berg
  2007-04-28  8:08   ` Paul Mackerras
@ 2007-04-28  8:38   ` Benjamin Herrenschmidt
  2007-04-28 12:51     ` Johannes Berg
  2007-04-28 12:01   ` Paul Mackerras
  2007-04-30 11:44   ` [PATCH v3] " Johannes Berg
  3 siblings, 1 reply; 78+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-28  8:38 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, Paul Mackerras

On Sat, 2007-04-28 at 09:49 +0200, Johannes Berg wrote:
> After having removed the power management ops from powermac completely, this
> patch adds them back for PMU based machines, directly in the PMU driver.
> This finally allows suspending via /sys/power/state on powerbooks.
> 
> The patch also replaces the PMU ioctl with a simple call to
> pm_suspend(PM_SUSPEND_MEM) and puts the sleep-related PMU ioctls onto the
> feature-removal schedule.

What happened to moving that code out of the PMU driver ?

Cheers,
Ben.

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

* Re: [PATCH] powermac: proper sleep management
  2007-04-28  7:49 ` [PATCH] powermac: proper sleep management Johannes Berg
  2007-04-28  8:08   ` Paul Mackerras
  2007-04-28  8:38   ` Benjamin Herrenschmidt
@ 2007-04-28 12:01   ` Paul Mackerras
  2007-04-28 13:46     ` Johannes Berg
  2007-04-30 11:44   ` [PATCH v3] " Johannes Berg
  3 siblings, 1 reply; 78+ messages in thread
From: Paul Mackerras @ 2007-04-28 12:01 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev

Johannes Berg writes:

> After having removed the power management ops from powermac completely, this
> patch adds them back for PMU based machines, directly in the PMU driver.
> This finally allows suspending via /sys/power/state on powerbooks.

I would very much rather that we keep the existing code path intact
and add the code to suspend via /sys/power/state as a separate code
path.  I am not confident enough about the state of the generic
suspend/resume code to commit to using it as the only way to suspend
to RAM, given how many bugs it seems to have (as evidenced by the
number of suspend-related bugs in Adrian Bunk's regression lists, for
instance).

I don't mind code being factored out into helpers, or moved from one
file to another, as long as the control flow for the old sleep ioctl
remains essentially unchanged, for now.

Paul.

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

* Re: [PATCH] powermac: proper sleep management
  2007-04-28  8:38   ` Benjamin Herrenschmidt
@ 2007-04-28 12:51     ` Johannes Berg
  0 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-04-28 12:51 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Paul Mackerras

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

On Sat, 2007-04-28 at 18:38 +1000, Benjamin Herrenschmidt wrote:

> What happened to moving that code out of the PMU driver ?

It was a separate patch and also buggy and had feature regressions. So I
left it for now.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: [PATCH] powermac: proper sleep management
  2007-04-28  8:08   ` Paul Mackerras
@ 2007-04-28 12:52     ` Johannes Berg
  0 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-04-28 12:52 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

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

On Sat, 2007-04-28 at 18:08 +1000, Paul Mackerras wrote:
> Johannes Berg writes:
> 
> > +What:	/dev/pmu suspend/can-suspend ioctls
> > +When:	2.6.24
> 
> No way.  You're proposing to remove a kernel/user ABI which is
> actively being used by many users.  It needs to stick around for at
> least 2 years before we make it non-functional.

Heh, ok, let's push the timeline out then. Don't really care anyway
since the feature now has about 10 lines of code.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: [PATCH] powermac: proper sleep management
  2007-04-28 12:01   ` Paul Mackerras
@ 2007-04-28 13:46     ` Johannes Berg
  2007-04-30  5:31       ` Paul Mackerras
  0 siblings, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-04-28 13:46 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

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

On Sat, 2007-04-28 at 22:01 +1000, Paul Mackerras wrote:

> I would very much rather that we keep the existing code path intact
> and add the code to suspend via /sys/power/state as a separate code
> path. 

Are you serious? The only thing the generic code does here is invoke our
stuff in the right order. That shouldn't be too much of a constraint. We
don't even have multiple CPUs or anything that was recently giving
problems.

> I am not confident enough about the state of the generic
> suspend/resume code to commit to using it as the only way to suspend
> to RAM, given how many bugs it seems to have (as evidenced by the
> number of suspend-related bugs in Adrian Bunk's regression lists, for
> instance).

Of the suspend related bugs Adrian's regression list most aren't really
related to the generic code we rely on, especially since all machines
this code applies to are single-CPU. Besides, relying on it is the only
way to ensure it stays compatible.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: [PATCH v2] powerpc: fix suspend states again
  2007-04-27 22:02       ` [PATCH v2] powerpc: fix suspend states again Johannes Berg
  2007-04-27 23:13         ` Olof Johansson
@ 2007-04-30  0:14         ` Paul Mackerras
  2007-04-30 11:35           ` Johannes Berg
  2007-04-30 11:37           ` [PATCH v3] " Johannes Berg
  1 sibling, 2 replies; 78+ messages in thread
From: Paul Mackerras @ 2007-04-30  0:14 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Olof Johansson, linuxppc-dev

Johannes Berg writes:

> +void save_processor_state(void)
> +{
> +	/* Giveup the lazy FPU & vec so we don't have to back them
> +	 * up from the low level code
> +	 */
> +	enable_kernel_fp();
> +
> +#ifdef CONFIG_ALTIVEC
> +	if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
> +		enable_kernel_altivec();
> +#endif /* CONFIG_ALTIVEC */
> +
> +#ifdef CONFIG_SPE
> +	enable_kernel_spe();
> +#endif
> +}

This achieves essentially the same effect as prepare_to_copy() in
arch/powerpc/kernel/process.c, except that we don't end up with fp,
altivec and/or spe enabled - but that's OK since the following code
doesn't actually need fp/altivec/spe.

It would be good to avoid this duplication, or at least to use the
flush_* calls instead of the enable_kernel_* calls.

Paul.

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

* Re: [PATCH] powermac: proper sleep management
  2007-04-28 13:46     ` Johannes Berg
@ 2007-04-30  5:31       ` Paul Mackerras
  2007-04-30 12:08         ` Johannes Berg
  0 siblings, 1 reply; 78+ messages in thread
From: Paul Mackerras @ 2007-04-30  5:31 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev

Johannes Berg writes:

> Are you serious? The only thing the generic code does here is invoke our
> stuff in the right order. That shouldn't be too much of a constraint. We

Yes I'm serious.  At a quick look, the generic code is calling
freeze_processes and shrink_all_memory, and I don't see where it's
doing a sync.  I really don't like the process freezer; as Linus
pointed out, it has caused more deadlocks than it solved.

Also, you're now calling pbook_alloc_pci_save after interrupts are
disabled, and it does a kmalloc(..., GFP_KERNEL).  Oops.

Part of the problem is exactly what Linus pointed out: that the
generic code tries to use the same code paths for suspend to RAM and
suspend to disk, but they are two totally different things.

I have no objection to adding code to enable the generic code to do
the (mostly) right thing when you write "mem" into /sys/power/state.
I have no objection to code being refactored to eliminate
duplication.  All I ask is that the PMU ioctls continue to do
essentially the same things in the same order.

Paul.

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

* Re: [PATCH v2] powerpc: fix suspend states again
  2007-04-30  0:14         ` Paul Mackerras
@ 2007-04-30 11:35           ` Johannes Berg
  2007-04-30 11:37           ` [PATCH v3] " Johannes Berg
  1 sibling, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-04-30 11:35 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Olof Johansson, linuxppc-dev

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


> It would be good to avoid this duplication, or at least to use the
> flush_* calls instead of the enable_kernel_* calls.

I don't like calling prepare_to_copy() since I doubt somebody changing
prepare_to_copy will be aware that it is called there, but using the
flush calls seems appropriate. I had it this way because the original
code used enable_kernel_* and I was mostly copying around the code,
should have looked closer.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* [PATCH v3] powerpc: fix suspend states again
  2007-04-30  0:14         ` Paul Mackerras
  2007-04-30 11:35           ` Johannes Berg
@ 2007-04-30 11:37           ` Johannes Berg
  2007-05-01 14:16             ` Johannes Berg
  1 sibling, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-04-30 11:37 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Olof Johansson, linuxppc-dev

In commit 0fba3a1f39f8b0a50b56c8b068fa52131cbc84c2 (a very long time ago,
May 2006), I fixed a bug that caused powermacs to crash when you tried
entering standby/mem suspend states.

As I'm now getting more familiar with the suspend code I notice a few
more things:
 1. we previously misunderstood what pm_ops is for, it isn't supposed to be
    for doing platform dependent suspend/resume stuff that needs to be done
    for suspend to disk (as we currently try to use it!), it is instead for
    entering platform dependent suspend states ("standby", "mem").
 2. due to the first point, we never properly save FPU and altivec states
    when suspending to disk. It probably hasn't hurt yet because the process
    that writes the "disk" to /sys/power/state uses neither and its context
    is used.

This patch addresses these points as follows:
 1. remove all pm_ops from powermac, powermac suspend to ram isn't currently
    usable via /sys/power/state but is done via the PMU instead.
 2. move the code responsible for storing FPU/altivec state into
    save_processor_state and the set_context() call to restore_processor_state.
 3. add a call to kernel_enable_spe()

It may look like there is some code removal missing but that is actually because
the new suspend.h file overrides the ppc/suspend.h one which was previously used.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>

---
 arch/powerpc/kernel/Makefile            |    1 
 arch/powerpc/kernel/swsusp.c            |   34 ++++++++++++++++
 arch/powerpc/platforms/powermac/setup.c |   65 --------------------------------
 include/asm-powerpc/suspend.h           |    9 ++++
 4 files changed, 44 insertions(+), 65 deletions(-)

--- linux-2.6.orig/arch/powerpc/platforms/powermac/setup.c	2007-04-27 23:56:21.466021121 +0200
+++ linux-2.6/arch/powerpc/platforms/powermac/setup.c	2007-04-28 00:00:08.986021121 +0200
@@ -420,76 +420,11 @@ static void __init find_boot_device(void
 #endif
 }
 
-/* TODO: Merge the suspend-to-ram with the common code !!!
- * currently, this is a stub implementation for suspend-to-disk
- * only
- */
-
-#ifdef CONFIG_SOFTWARE_SUSPEND
-
-static int pmac_pm_prepare(suspend_state_t state)
-{
-	printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
-
-	return 0;
-}
-
-static int pmac_pm_enter(suspend_state_t state)
-{
-	printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
-
-	/* Giveup the lazy FPU & vec so we don't have to back them
-	 * up from the low level code
-	 */
-	enable_kernel_fp();
-
-#ifdef CONFIG_ALTIVEC
-	if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
-		enable_kernel_altivec();
-#endif /* CONFIG_ALTIVEC */
-
-	return 0;
-}
-
-static int pmac_pm_finish(suspend_state_t state)
-{
-	printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
-
-	/* Restore userland MMU context */
-	set_context(current->active_mm->context.id, current->active_mm->pgd);
-
-	return 0;
-}
-
-static int pmac_pm_valid(suspend_state_t state)
-{
-	switch (state) {
-	case PM_SUSPEND_DISK:
-		return 1;
-	/* can't do any other states via generic mechanism yet */
-	default:
-		return 0;
-	}
-}
-
-static struct pm_ops pmac_pm_ops = {
-	.pm_disk_mode	= PM_DISK_SHUTDOWN,
-	.prepare	= pmac_pm_prepare,
-	.enter		= pmac_pm_enter,
-	.finish		= pmac_pm_finish,
-	.valid		= pmac_pm_valid,
-};
-
-#endif /* CONFIG_SOFTWARE_SUSPEND */
-
 static int initializing = 1;
 
 static int pmac_late_init(void)
 {
 	initializing = 0;
-#ifdef CONFIG_SOFTWARE_SUSPEND
-	pm_set_ops(&pmac_pm_ops);
-#endif /* CONFIG_SOFTWARE_SUSPEND */
 	return 0;
 }
 
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/include/asm-powerpc/suspend.h	2007-04-28 00:00:08.986021121 +0200
@@ -0,0 +1,9 @@
+#ifndef __ASM_POWERPC_SUSPEND_H
+#define __ASM_POWERPC_SUSPEND_H
+
+static inline int arch_prepare_suspend(void) { return 0; }
+
+void save_processor_state(void);
+void restore_processor_state(void);
+
+#endif /* __ASM_POWERPC_SUSPEND_H */
--- linux-2.6.orig/arch/powerpc/kernel/Makefile	2007-04-27 23:56:21.526021121 +0200
+++ linux-2.6/arch/powerpc/kernel/Makefile	2007-04-28 00:00:08.996021121 +0200
@@ -36,6 +36,7 @@ obj-$(CONFIG_GENERIC_TBSYNC)	+= smp-tbsy
 obj-$(CONFIG_CRASH_DUMP)	+= crash_dump.o
 obj-$(CONFIG_6xx)		+= idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o
 obj-$(CONFIG_TAU)		+= tau_6xx.o
+obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o
 obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o
 obj32-$(CONFIG_MODULES)		+= module_32.o
 
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/arch/powerpc/kernel/swsusp.c	2007-04-30 13:33:21.555655832 +0200
@@ -0,0 +1,34 @@
+/*
+ * Common powerpc suspend code for 32 and 64 bits
+ *
+ * Copyright 2007	Johannes Berg <johannes@sipsolutions.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/sched.h>
+#include <asm/suspend.h>
+#include <asm/system.h>
+#include <asm/current.h>
+#include <asm/mmu_context.h>
+
+void save_processor_state(void)
+{
+	/*
+	 * flush out all the special registers so we don't need
+	 * to save them in the snapshot
+	 */
+	flush_fp_to_thread(current);
+	flush_altivec_to_thread(current);
+	flush_spe_to_thread(current);
+}
+
+void restore_processor_state(void)
+{
+#ifdef CONFIG_PPC32
+	set_context(current->active_mm->context.id, current->active_mm->pgd);
+#endif
+}

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

* [PATCH v3] powermac: proper sleep management
  2007-04-28  7:49 ` [PATCH] powermac: proper sleep management Johannes Berg
                     ` (2 preceding siblings ...)
  2007-04-28 12:01   ` Paul Mackerras
@ 2007-04-30 11:44   ` Johannes Berg
  2007-05-01  8:55     ` Johannes Berg
  3 siblings, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-04-30 11:44 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, David Woodhouse

After having removed the power management ops from powermac completely, this
patch adds them back for PMU based machines, directly in the PMU driver.
This finally allows suspending via /sys/power/state on powerbooks.

The patch also replaces the PMU ioctl with a simple call to
pm_suspend(PM_SUSPEND_MEM) and puts the sleep-related PMU ioctls onto the
feature-removal schedule.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
This version fixes the bug with the pci save routines that Paul spotted
for powerbook 3400 and pushes the feature removal to August 2009 (based
on the assumption that .22 will be released before August that gives us
at least 2 years.)

It relies on the currently merged arch_suspend_{disable,enable}_irqs
which is changeset a53c46dc8253cc613ad66a2ca7aad6de8b7e61b9 in Linus's
tree and will break suspend to disk until
"rework-pm_ops-pm_disk_mode-kill-misuse.patch" from -mm is merged (which
should be soon, I asked akpm to send it early if possible.)

---
 Documentation/feature-removal-schedule.txt |   10 
 drivers/macintosh/via-pmu.c                |  360 +++++++++++++----------------
 2 files changed, 176 insertions(+), 194 deletions(-)

--- linux-2.6.orig/drivers/macintosh/via-pmu.c	2007-04-30 13:30:44.525655832 +0200
+++ linux-2.6/drivers/macintosh/via-pmu.c	2007-04-30 13:37:18.045655832 +0200
@@ -61,6 +61,7 @@
 #include <asm/cputable.h>
 #include <asm/time.h>
 #include <asm/backlight.h>
+#include <asm/suspend.h>
 
 #include "via-pmu-event.h"
 
@@ -155,9 +156,6 @@ static int drop_interrupts;
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 static int option_lid_wakeup = 1;
 #endif /* CONFIG_PM && CONFIG_PPC32 */
-#if (defined(CONFIG_PM)&&defined(CONFIG_PPC32))||defined(CONFIG_PMAC_BACKLIGHT_LEGACY)
-static int sleep_in_progress;
-#endif
 static unsigned long async_req_locks;
 static unsigned int pmu_irq_stats[11];
 
@@ -1991,132 +1989,6 @@ restore_via_state(void)
 
 extern void pmu_backlight_set_sleep(int sleep);
 
-static int
-pmac_suspend_devices(void)
-{
-	int ret;
-
-	pm_prepare_console();
-	
-	/* Notify old-style device drivers */
-	broadcast_sleep(PBOOK_SLEEP_REQUEST);
-
-	/* Sync the disks. */
-	/* XXX It would be nice to have some way to ensure that
-	 * nobody is dirtying any new buffers while we wait. That
-	 * could be achieved using the refrigerator for processes
-	 * that swsusp uses
-	 */
-	sys_sync();
-
-	broadcast_sleep(PBOOK_SLEEP_NOW);
-
-	/* Send suspend call to devices, hold the device core's dpm_sem */
-	ret = device_suspend(PMSG_SUSPEND);
-	if (ret) {
-		broadcast_wake();
-		printk(KERN_ERR "Driver sleep failed\n");
-		return -EBUSY;
-	}
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-	/* Tell backlight code not to muck around with the chip anymore */
-	pmu_backlight_set_sleep(1);
-#endif
-
-	/* Call platform functions marked "on sleep" */
-	pmac_pfunc_i2c_suspend();
-	pmac_pfunc_base_suspend();
-
-	/* Stop preemption */
-	preempt_disable();
-
-	/* Make sure the decrementer won't interrupt us */
-	asm volatile("mtdec %0" : : "r" (0x7fffffff));
-	/* Make sure any pending DEC interrupt occurring while we did
-	 * the above didn't re-enable the DEC */
-	mb();
-	asm volatile("mtdec %0" : : "r" (0x7fffffff));
-
-	/* We can now disable MSR_EE. This code of course works properly only
-	 * on UP machines... For SMP, if we ever implement sleep, we'll have to
-	 * stop the "other" CPUs way before we do all that stuff.
-	 */
-	local_irq_disable();
-
-	/* Broadcast power down irq
-	 * This isn't that useful in most cases (only directly wired devices can
-	 * use this but still... This will take care of sysdev's as well, so
-	 * we exit from here with local irqs disabled and PIC off.
-	 */
-	ret = device_power_down(PMSG_SUSPEND);
-	if (ret) {
-		wakeup_decrementer();
-		local_irq_enable();
-		preempt_enable();
-		device_resume();
-		broadcast_wake();
-		printk(KERN_ERR "Driver powerdown failed\n");
-		return -EBUSY;
-	}
-
-	/* Wait for completion of async requests */
-	while (!batt_req.complete)
-		pmu_poll();
-
-	/* Giveup the lazy FPU & vec so we don't have to back them
-	 * up from the low level code
-	 */
-	enable_kernel_fp();
-
-#ifdef CONFIG_ALTIVEC
-	if (cpu_has_feature(CPU_FTR_ALTIVEC))
-		enable_kernel_altivec();
-#endif /* CONFIG_ALTIVEC */
-
-	return 0;
-}
-
-static int
-pmac_wakeup_devices(void)
-{
-	mdelay(100);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-	/* Tell backlight code it can use the chip again */
-	pmu_backlight_set_sleep(0);
-#endif
-
-	/* Power back up system devices (including the PIC) */
-	device_power_up();
-
-	/* Force a poll of ADB interrupts */
-	adb_int_pending = 1;
-	via_pmu_interrupt(0, NULL);
-
-	/* Restart jiffies & scheduling */
-	wakeup_decrementer();
-
-	/* Re-enable local CPU interrupts */
-	local_irq_enable();
-	mdelay(10);
-	preempt_enable();
-
-	/* Call platform functions marked "on wake" */
-	pmac_pfunc_base_resume();
-	pmac_pfunc_i2c_resume();
-
-	/* Resume devices */
-	device_resume();
-
-	/* Notify old style drivers */
-	broadcast_wake();
-
-	pm_restore_console();
-
-	return 0;
-}
-
 #define	GRACKLE_PM	(1<<7)
 #define GRACKLE_DOZE	(1<<5)
 #define	GRACKLE_NAP	(1<<4)
@@ -2127,19 +1999,12 @@ static int powerbook_sleep_grackle(void)
 	unsigned long save_l2cr;
 	unsigned short pmcr1;
 	struct adb_request req;
-	int ret;
 	struct pci_dev *grackle;
 
 	grackle = pci_find_slot(0, 0);
 	if (!grackle)
 		return -ENODEV;
 
-	ret = pmac_suspend_devices();
-	if (ret) {
-		printk(KERN_ERR "Sleep rejected by devices\n");
-		return ret;
-	}
-	
 	/* Turn off various things. Darwin does some retry tests here... */
 	pmu_request(&req, NULL, 2, PMU_POWER_CTRL0, PMU_POW0_OFF|PMU_POW0_HARD_DRIVE);
 	pmu_wait_complete(&req);
@@ -2200,8 +2065,6 @@ static int powerbook_sleep_grackle(void)
 			PMU_POW_ON|PMU_POW_BACKLIGHT|PMU_POW_CHARGER|PMU_POW_IRLED|PMU_POW_MEDIABAY);
 	pmu_wait_complete(&req);
 
-	pmac_wakeup_devices();
-
 	return 0;
 }
 
@@ -2211,7 +2074,6 @@ powerbook_sleep_Core99(void)
 	unsigned long save_l2cr;
 	unsigned long save_l3cr;
 	struct adb_request req;
-	int ret;
 	
 	if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) < 0) {
 		printk(KERN_ERR "Sleep mode not supported on this machine\n");
@@ -2221,12 +2083,6 @@ powerbook_sleep_Core99(void)
 	if (num_online_cpus() > 1 || cpu_is_offline(0))
 		return -EAGAIN;
 
-	ret = pmac_suspend_devices();
-	if (ret) {
-		printk(KERN_ERR "Sleep rejected by devices\n");
-		return ret;
-	}
-
 	/* Stop environment and ADB interrupts */
 	pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0);
 	pmu_wait_complete(&req);
@@ -2297,41 +2153,24 @@ powerbook_sleep_Core99(void)
 	/* Restore LPJ, cpufreq will adjust the cpu frequency */
 	loops_per_jiffy /= 2;
 
-	pmac_wakeup_devices();
-
 	return 0;
 }
 
 #define PB3400_MEM_CTRL		0xf8000000
 #define PB3400_MEM_CTRL_SLEEP	0x70
 
+static void __iomem *pb3400_mem_ctrl;
+
 static int
 powerbook_sleep_3400(void)
 {
-	int ret, i, x;
+	int i, x;
 	unsigned int hid0;
 	unsigned long p;
 	struct adb_request sleep_req;
-	void __iomem *mem_ctrl;
 	unsigned int __iomem *mem_ctrl_sleep;
 
-	/* first map in the memory controller registers */
-	mem_ctrl = ioremap(PB3400_MEM_CTRL, 0x100);
-	if (mem_ctrl == NULL) {
-		printk("powerbook_sleep_3400: ioremap failed\n");
-		return -ENOMEM;
-	}
-	mem_ctrl_sleep = mem_ctrl + PB3400_MEM_CTRL_SLEEP;
-
-	/* Allocate room for PCI save */
-	pbook_alloc_pci_save();
-
-	ret = pmac_suspend_devices();
-	if (ret) {
-		pbook_free_pci_save();
-		printk(KERN_ERR "Sleep rejected by devices\n");
-		return ret;
-	}
+	mem_ctrl_sleep = pb3400_mem_ctrl + PB3400_MEM_CTRL_SLEEP;
 
 	/* Save the state of PCI config space for some slots */
 	pbook_pci_save();
@@ -2376,10 +2215,6 @@ powerbook_sleep_3400(void)
 	while (asleep)
 		mb();
 
-	pmac_wakeup_devices();
-	pbook_free_pci_save();
-	iounmap(mem_ctrl);
-
 	return 0;
 }
 
@@ -2558,6 +2393,159 @@ pmu_release(struct inode *inode, struct 
 	return 0;
 }
 
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+static int powerbook_prepare_sleep(suspend_state_t state)
+{
+	if (pmu_kind == PMU_OHARE_BASED) {
+		/* first map in the memory controller registers */
+		pb3400_mem_ctrl = ioremap(PB3400_MEM_CTRL, 0x100);
+		if (!pb3400_mem_ctrl) {
+			printk("powerbook_sleep_3400: ioremap failed\n");
+			return -ENOMEM;
+		}
+
+		/* Allocate room for PCI save */
+		pbook_alloc_pci_save();
+	}
+
+	/* Notify old-style device drivers */
+	broadcast_sleep(PBOOK_SLEEP_REQUEST);
+	broadcast_sleep(PBOOK_SLEEP_NOW);
+
+	return 0;
+}
+
+/*
+ * overrides the weak arch_suspend_disable_irqs in kernel/power/main.c
+ */
+void arch_suspend_disable_irqs(void)
+{
+#ifdef CONFIG_PMAC_BACKLIGHT
+	/* Tell backlight code not to muck around with the chip anymore */
+	pmu_backlight_set_sleep(1);
+#endif
+
+	/* Call platform functions marked "on sleep" */
+	pmac_pfunc_i2c_suspend();
+	pmac_pfunc_base_suspend();
+
+	/* Stop preemption */
+	preempt_disable();
+
+	/* Make sure the decrementer won't interrupt us */
+	asm volatile("mtdec %0" : : "r" (0x7fffffff));
+	/* Make sure any pending DEC interrupt occurring while we did
+	 * the above didn't re-enable the DEC */
+	mb();
+	asm volatile("mtdec %0" : : "r" (0x7fffffff));
+
+	local_irq_disable();
+}
+
+static int powerbook_sleep(suspend_state_t state)
+{
+	int error = 0;
+
+	/* Wait for completion of async requests */
+	while (!batt_req.complete)
+		pmu_poll();
+
+	/* Giveup the lazy FPU & vec so we don't have to back them
+	 * up from the low level code
+	 */
+	enable_kernel_fp();
+
+#ifdef CONFIG_ALTIVEC
+	if (cpu_has_feature(CPU_FTR_ALTIVEC))
+		enable_kernel_altivec();
+#endif /* CONFIG_ALTIVEC */
+
+	switch (pmu_kind) {
+	case PMU_OHARE_BASED:
+		error = powerbook_sleep_3400();
+		break;
+	case PMU_HEATHROW_BASED:
+	case PMU_PADDINGTON_BASED:
+		error = powerbook_sleep_grackle();
+		break;
+	case PMU_KEYLARGO_BASED:
+		error = powerbook_sleep_Core99();
+		break;
+	default:
+		return -ENOSYS;
+	}
+
+	if (error)
+		return error;
+
+	mdelay(100);
+
+#ifdef CONFIG_PMAC_BACKLIGHT
+	/* Tell backlight code it can use the chip again */
+	pmu_backlight_set_sleep(0);
+#endif
+
+	return 0;
+}
+
+/*
+ * overrides the weak arch_suspend_enable_irqs in kernel/power/main.c
+ */
+void arch_suspend_enable_irqs(void)
+{
+	/* Force a poll of ADB interrupts */
+	adb_int_pending = 1;
+	via_pmu_interrupt(0, NULL);
+
+	/* Restart jiffies & scheduling */
+	wakeup_decrementer();
+
+	/* Re-enable local CPU interrupts */
+	local_irq_enable();
+	mdelay(10);
+	preempt_enable();
+
+	/* Call platform functions marked "on wake" */
+	pmac_pfunc_base_resume();
+	pmac_pfunc_i2c_resume();
+}
+
+static int powerbook_finish_sleep(suspend_state_t state)
+{
+	/* Notify old style drivers */
+	broadcast_wake();
+
+	if (pmu_kind == PMU_OHARE_BASED) {
+		pbook_free_pci_save();
+		iounmap(pb3400_mem_ctrl);
+	}
+
+	return 0;
+}
+
+static int pmu_sleep_valid(suspend_state_t state)
+{
+	return state == PM_SUSPEND_MEM
+		&& (pmac_call_feature(PMAC_FTR_SLEEP_STATE, NULL, 0, -1) >= 0);
+}
+
+static struct pm_ops pmu_pm_ops = {
+	.prepare = powerbook_prepare_sleep,
+	.enter = powerbook_sleep,
+	.finish = powerbook_finish_sleep,
+	.valid = pmu_sleep_valid,
+};
+
+static int register_pmu_pm_ops(void)
+{
+	pm_set_ops(&pmu_pm_ops);
+
+	return 0;
+}
+
+device_initcall(register_pmu_pm_ops);
+#endif
+
 static int
 pmu_ioctl(struct inode * inode, struct file *filp,
 		     u_int cmd, u_long arg)
@@ -2567,29 +2555,19 @@ pmu_ioctl(struct inode * inode, struct f
 
 	switch (cmd) {
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+	/* just provided for compatibility */
 	case PMU_IOC_SLEEP:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
-		if (sleep_in_progress)
-			return -EBUSY;
-		sleep_in_progress = 1;
-		switch (pmu_kind) {
-		case PMU_OHARE_BASED:
-			error = powerbook_sleep_3400();
-			break;
-		case PMU_HEATHROW_BASED:
-		case PMU_PADDINGTON_BASED:
-			error = powerbook_sleep_grackle();
-			break;
-		case PMU_KEYLARGO_BASED:
-			error = powerbook_sleep_Core99();
-			break;
-		default:
-			error = -ENOSYS;
-		}
-		sleep_in_progress = 0;
+		printk(KERN_INFO "via-pmu: the PMU_IOC_SLEEP ioctl is deprecated.\n");
+		printk(KERN_INFO "via-pmu: use \"echo mem > /sys/power/state\" instead!\n");
+		printk(KERN_INFO "via-pmu: this ioctl will be removed soon.\n");
+		error = pm_suspend(PM_SUSPEND_MEM);
 		break;
 	case PMU_IOC_CAN_SLEEP:
+		printk(KERN_INFO "via-pmu: the PMU_IOC_CAN_SLEEP ioctl is deprecated.\n");
+		printk(KERN_INFO "via-pmu: use \"grep mem /sys/power/state\" instead!\n");
+		printk(KERN_INFO "via-pmu: this ioctl will be removed soon.\n");
 		if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) < 0)
 			return put_user(0, argp);
 		else
@@ -2602,9 +2580,6 @@ pmu_ioctl(struct inode * inode, struct f
 	{
 		int brightness;
 
-		if (sleep_in_progress)
-			return -EBUSY;
-
 		brightness = pmac_backlight_get_legacy_brightness();
 		if (brightness < 0)
 			return brightness;
@@ -2616,9 +2591,6 @@ pmu_ioctl(struct inode * inode, struct f
 	{
 		int brightness;
 
-		if (sleep_in_progress)
-			return -EBUSY;
-
 		error = get_user(brightness, argp);
 		if (error)
 			return error;
--- linux-2.6.orig/Documentation/feature-removal-schedule.txt	2007-04-30 13:30:44.565655832 +0200
+++ linux-2.6/Documentation/feature-removal-schedule.txt	2007-04-30 13:37:18.045655832 +0200
@@ -302,3 +302,13 @@ Why:	Code was merged, then submitter imm
 Who:	David S. Miller <davem@davemloft.net>
 
 ---------------------------
+
+What:	/dev/pmu suspend/can-suspend ioctls
+When:	August 2009
+Files:	drivers/macintosh/via-pmu.c
+Why:	powermac supports proper generic pm_ops now and can suspend with
+	"echo mem > /sys/power/state" instead of the ioctl, checking if
+	it can suspend can be done by reading /sys/power/state.
+Who:	Johannes Berg <johannes@sipsolutions.net>
+
+---------------------------

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

* Re: [PATCH] powermac: proper sleep management
  2007-04-30  5:31       ` Paul Mackerras
@ 2007-04-30 12:08         ` Johannes Berg
  2007-05-01 12:14           ` Paul Mackerras
  0 siblings, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-04-30 12:08 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

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

On Mon, 2007-04-30 at 15:31 +1000, Paul Mackerras wrote:

> At a quick look, the generic code is calling
> freeze_processes and shrink_all_memory, and I don't see where it's
> doing a sync.

The sync is done after userspace has been frozen, in freeze_processes. I
agree that shrink_all_memory is bogus, I'll talk to Rafael about it;
we're working on splitting out the hibernate and suspend code paths
anyway so it should be possible to remove this cleanly. It should also
be easy to invoke it only for suspend to disk for now.

> Also, you're now calling pbook_alloc_pci_save after interrupts are
> disabled, and it does a kmalloc(..., GFP_KERNEL).  Oops.

Oops, yes, thanks for pointing that out, it needs to go into the prepare
callback. I just sent an updated patch that moves it there and verified
that no other code was misplaced.

> Part of the problem is exactly what Linus pointed out: that the
> generic code tries to use the same code paths for suspend to RAM and
> suspend to disk, but they are two totally different things.

Actually, the stuff Linus pointed out in the recent thread was about
device drivers and the current PMU code uses the same driver/device
suspend routines that the generic code uses. No difference there.

> I have no objection to adding code to enable the generic code to do
> the (mostly) right thing when you write "mem" into /sys/power/state.
> I have no objection to code being refactored to eliminate
> duplication.  All I ask is that the PMU ioctls continue to do
> essentially the same things in the same order.

I disagree with that, it'll get us no closer to keeping the generic code
working for us. It does in fact work now, I've been using it for a long
time and a few other people have also tried on older powerbooks. It's
also very hard to convince anybody that we need changes in the generic
code if at the same time we do our own stuff because "the generic code
(you wrote) is not good enough for us anyway."

Considering the options from userspace, there are currently 3 programs
(that I know of) that actually use the ioctl:
 * hal via some helper or via pm-utils (almost all gnome/kde programs
   use it)
 * pbbuttonsd
 * pmud (?)

I know that the hal/pm-utils folks would love to get rid of the pmu
specific stuff and I think this and the battery (?) are the last things.
I don't even pretend to know what pbbuttonsd/pmud will do. Regardless of
that, however, the vast majority of users of modern desktop distros will
be using hal and hence the new code simply because that is integrated
into their desktop. If we fragment the user base into these two sets
we're making life more difficult because suddenly "sleep" or "suspend to
RAM" no longer identifies uniquely what the user did. Also, if one of
them breaks people will switch to the other one instead of helping
identify and fix the problem.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: patches for 2.6.22
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (4 preceding siblings ...)
  2007-04-28  7:49 ` [PATCH] powermac: proper sleep management Johannes Berg
@ 2007-04-30 19:51 ` Kim Phillips
  2007-05-01  3:38   ` Paul Mackerras
  2007-05-02 14:12   ` Kumar Gala
  2007-05-01  9:06 ` Johannes Berg
                   ` (10 subsequent siblings)
  16 siblings, 2 replies; 78+ messages in thread
From: Kim Phillips @ 2007-04-30 19:51 UTC (permalink / raw)
  To: Paul Mackerras, Kumar Gala; +Cc: linuxppc-dev

On Fri, 27 Apr 2007 21:25:19 +1000
Paul Mackerras <paulus@samba.org> wrote:

> If anyone has patches that I haven't picked up yet which they think
> should go into 2.6.22, please send me either a pointer to the

these were missed:

[PATCH 1/4 v5] powerpc: document phy-connection-type property
Tue Apr 24 07:26:10 EST 2007
http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034669.html

[PATCH 2/4 v4] powerpc: replace undocumented interface properties in dts files
Tue Apr 24 07:26:14 EST 2007
http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034670.html

[PATCH 3/4] powerpc: Add 'mdio' to bus scan id list for platforms with QE UEC
Wed Apr 11 07:56:49 EST 2007
http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034163.html

[PATCH 4/4] powerpc: turn on corresponding PHY drivers in QE UEC platforms defconfigs
Wed Apr 11 07:56:53 EST 2007
http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034164.html

Kim

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

* Re: patches for 2.6.22
  2007-04-30 19:51 ` patches for 2.6.22 Kim Phillips
@ 2007-05-01  3:38   ` Paul Mackerras
  2007-05-02 14:12   ` Kumar Gala
  1 sibling, 0 replies; 78+ messages in thread
From: Paul Mackerras @ 2007-05-01  3:38 UTC (permalink / raw)
  To: Kim Phillips; +Cc: linuxppc-dev

Kim Phillips writes:

> these were missed:
> 
> [PATCH 1/4 v5] powerpc: document phy-connection-type property
> Tue Apr 24 07:26:10 EST 2007
> http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034669.html
> 
> [PATCH 2/4 v4] powerpc: replace undocumented interface properties in dts files
> Tue Apr 24 07:26:14 EST 2007
> http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034670.html
> 
> [PATCH 3/4] powerpc: Add 'mdio' to bus scan id list for platforms with QE UEC
> Wed Apr 11 07:56:49 EST 2007
> http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034163.html
> 
> [PATCH 4/4] powerpc: turn on corresponding PHY drivers in QE UEC platforms defconfigs
> Wed Apr 11 07:56:53 EST 2007
> http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034164.html

I was waiting for an ack for those, but they look pretty
straightforward, so I'll put them in unless I hear a nak...

Paul.

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

* Re: [PATCH v3] powermac: proper sleep management
  2007-04-30 11:44   ` [PATCH v3] " Johannes Berg
@ 2007-05-01  8:55     ` Johannes Berg
  0 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-01  8:55 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, David Woodhouse

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

On Mon, 2007-04-30 at 13:44 +0200, Johannes Berg wrote:

>  and will break suspend to disk until
> "rework-pm_ops-pm_disk_mode-kill-misuse.patch" from -mm is merged
> (which
> should be soon, I asked akpm to send it early if possible.)

This has now happened, commit fe0c935a6cbf25d72a27c7a345df8a2151de0b74

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: patches for 2.6.22
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (5 preceding siblings ...)
  2007-04-30 19:51 ` patches for 2.6.22 Kim Phillips
@ 2007-05-01  9:06 ` Johannes Berg
  2007-05-02  5:33 ` [PATCH] adb: replace sleep notifier with platform driver suspend/resume hooks Johannes Berg
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-01  9:06 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

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

On Fri, 2007-04-27 at 21:25 +1000, Paul Mackerras wrote:

> If anyone has patches that I haven't picked up yet which they think
> should go into 2.6.22

Oh another thing is my suspend-to-disk work. Most of the patches to
drivers have been reviewed by various people around, but afaik nobody
has given the core code much of a look. It's a new feature and could be
marked EXPERIMENTAL or such, so it can't introduce regressions. I can
repost for consideration but since I never received much comments I
never bothered.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: [PATCH] powermac: proper sleep management
  2007-04-30 12:08         ` Johannes Berg
@ 2007-05-01 12:14           ` Paul Mackerras
  2007-05-01 12:24             ` Johannes Berg
  0 siblings, 1 reply; 78+ messages in thread
From: Paul Mackerras @ 2007-05-01 12:14 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev

Johannes Berg writes:

> I disagree with that, it'll get us no closer to keeping the generic code
> working for us. It does in fact work now, I've been using it for a long
> time and a few other people have also tried on older powerbooks. It's
> also very hard to convince anybody that we need changes in the generic
> code if at the same time we do our own stuff because "the generic code
> (you wrote) is not good enough for us anyway."

I think that once we have /sys/power/state working the distros will
start using it.  I want the old way to keep doing what it was doing
while the new way is tested and the bugs are shaken out.

Bottom line is I'm not going to apply a patch that makes pmu_ioctl
call pm_suspend.

Paul.

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

* Re: [PATCH] powermac: proper sleep management
  2007-05-01 12:14           ` Paul Mackerras
@ 2007-05-01 12:24             ` Johannes Berg
  0 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-01 12:24 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

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

On Tue, 2007-05-01 at 22:14 +1000, Paul Mackerras wrote:

> Bottom line is I'm not going to apply a patch that makes pmu_ioctl
> call pm_suspend.

Alright, I'll drop the patch. What about suspend to disk for G5?

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: [PATCH v3] powerpc: fix suspend states again
  2007-04-30 11:37           ` [PATCH v3] " Johannes Berg
@ 2007-05-01 14:16             ` Johannes Berg
  0 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-01 14:16 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Olof Johansson, linuxppc-dev

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

On Mon, 2007-04-30 at 13:37 +0200, Johannes Berg wrote:
> In commit 0fba3a1f39f8b0a50b56c8b068fa52131cbc84c2 (a very long time ago,
> May 2006), I fixed a bug that caused powermacs to crash when you tried
> entering standby/mem suspend states.
> 
> As I'm now getting more familiar with the suspend code I notice a few
> more things:
[...]

Regardless of the follow-up pmu pm_ops patch you should really merge
this patch since I changed the generic pm_ops infrastructure to be less
broken, and the current code in .21 may sometimes work due to the
breakage that is now no longer there; pm_ops will now not be invoked for
suspend to disk unless
 (1) the user has 'platform' in /sys/power/disk
 (2) pm_ops.pm_disk_mode is set to PM_DISK_PLATFORM

(1) can be changed by the user so even the old code was just correct in
case the user didn't change anything, and (2) isn't true in the current
tree.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* [PATCH] adb: replace sleep notifier with platform driver suspend/resume hooks
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (6 preceding siblings ...)
  2007-05-01  9:06 ` Johannes Berg
@ 2007-05-02  5:33 ` Johannes Berg
  2007-05-02  5:34 ` [PATCH] apm_emu: use generic apm-emulation Johannes Berg
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-02  5:33 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

This patch replaces the pmu sleep notifier that adb had with
suspend/resume hooks in a new platform driver/device.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
Never tested as I don't have adb. Part of my "remove pmu sleep
notifiers" exercise.

 drivers/macintosh/adb.c |   96 ++++++++++++++++++++++++++++--------------------
 1 file changed, 57 insertions(+), 39 deletions(-)

--- wireless-dev.orig/drivers/macintosh/adb.c	2007-05-01 11:35:45.924734191 +0200
+++ wireless-dev/drivers/macintosh/adb.c	2007-05-01 11:36:24.284734191 +0200
@@ -89,14 +89,6 @@ static int sleepy_trackpad;
 static int autopoll_devs;
 int __adb_probe_sync;
 
-#ifdef CONFIG_PM
-static void adb_notify_sleep(struct pmu_sleep_notifier *self, int when);
-static struct pmu_sleep_notifier adb_sleep_notifier = {
-	adb_notify_sleep,
-	SLEEP_LEVEL_ADB,
-};
-#endif
-
 static int adb_scan_bus(void);
 static int do_adb_reset_bus(void);
 static void adbdev_init(void);
@@ -287,6 +279,36 @@ adb_reset_bus(void)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+/*
+ * notify clients before sleep
+ */
+static int adb_suspend(struct platform_device *dev, pm_message_t state)
+{
+	adb_got_sleep = 1;
+	/* We need to get a lock on the probe thread */
+	down(&adb_probe_mutex);
+	/* Stop autopoll */
+	if (adb_controller->autopoll)
+		adb_controller->autopoll(0);
+	blocking_notifier_call_chain(&adb_client_list, ADB_MSG_POWERDOWN, NULL);
+
+	return 0;
+}
+
+/*
+ * reset bus after sleep
+ */
+static int adb_resume(struct platform_device *dev)
+{
+	adb_got_sleep = 0;
+	up(&adb_probe_mutex);
+	adb_reset_bus();
+
+	return 0;
+}
+#endif /* CONFIG_PM */
+
 int __init adb_init(void)
 {
 	struct adb_driver *driver;
@@ -319,14 +341,12 @@ int __init adb_init(void)
 		printk(KERN_WARNING "Warning: no ADB interface detected\n");
 		adb_controller = NULL;
 	} else {
-#ifdef CONFIG_PM
-		pmu_register_sleep_notifier(&adb_sleep_notifier);
-#endif /* CONFIG_PM */
 #ifdef CONFIG_PPC
 		if (machine_is_compatible("AAPL,PowerBook1998") ||
 			machine_is_compatible("PowerBook1,1"))
 			sleepy_trackpad = 1;
 #endif /* CONFIG_PPC */
+
 		init_completion(&adb_probe_task_comp);
 		adbdev_init();
 		adb_reset_bus();
@@ -336,33 +356,6 @@ int __init adb_init(void)
 
 __initcall(adb_init);
 
-#ifdef CONFIG_PM
-/*
- * notify clients before sleep and reset bus afterwards
- */
-void
-adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
-{
-	switch (when) {
-	case PBOOK_SLEEP_REQUEST:
-		adb_got_sleep = 1;
-		/* We need to get a lock on the probe thread */
-		down(&adb_probe_mutex);
-		/* Stop autopoll */
-		if (adb_controller->autopoll)
-			adb_controller->autopoll(0);
-		blocking_notifier_call_chain(&adb_client_list,
-			ADB_MSG_POWERDOWN, NULL);
-		break;
-	case PBOOK_WAKE:
-		adb_got_sleep = 0;
-		up(&adb_probe_mutex);
-		adb_reset_bus();
-		break;
-	}
-}
-#endif /* CONFIG_PM */
-
 static int
 do_adb_reset_bus(void)
 {
@@ -870,7 +863,29 @@ static const struct file_operations adb_
 	.release	= adb_release,
 };
 
-static void
+static struct platform_driver adb_pfdrv = {
+	.driver = {
+		.name = "adb",
+	},
+#ifdef CONFIG_PM
+	.suspend = adb_suspend,
+	.resume = adb_resume,
+#endif
+};
+
+static struct platform_device adb_pfdev = {
+	.name = "adb",
+};
+
+static int __init
+adb_dummy_probe(struct platform_device *dev)
+{
+	if (dev == &adb_pfdev)
+		return 0;
+	return -ENODEV;
+}
+
+static void __init
 adbdev_init(void)
 {
 	if (register_chrdev(ADB_MAJOR, "adb", &adb_fops)) {
@@ -882,4 +897,7 @@ adbdev_init(void)
 	if (IS_ERR(adb_dev_class))
 		return;
 	class_device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
+
+	platform_device_register(&adb_pfdev);
+	platform_driver_probe(&adb_pfdrv, adb_dummy_probe);
 }

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

* [PATCH] apm_emu: use generic apm-emulation
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (7 preceding siblings ...)
  2007-05-02  5:33 ` [PATCH] adb: replace sleep notifier with platform driver suspend/resume hooks Johannes Berg
@ 2007-05-02  5:34 ` Johannes Berg
  2007-05-02  5:36 ` [PATCH] via-pmu: remove LED sleep notifier Johannes Berg
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-02  5:34 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

This patch removes a huge amount of code that is now in common code
in drivers/char/apm-emulation.c

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
Works for me.

 arch/powerpc/Kconfig        |    3 
 drivers/macintosh/Kconfig   |    4 
 drivers/macintosh/apm_emu.c |  519 +++-----------------------------------------
 3 files changed, 51 insertions(+), 475 deletions(-)

--- wireless-dev.orig/drivers/macintosh/Kconfig	2007-05-01 11:35:45.654734191 +0200
+++ wireless-dev/drivers/macintosh/Kconfig	2007-05-01 11:36:24.814734191 +0200
@@ -109,7 +109,9 @@ config PMAC_SMU
 
 config PMAC_APM_EMU
 	tristate "APM emulation"
-	depends on PPC_PMAC && PPC32 && PM && ADB_PMU
+	select SYS_SUPPORTS_APM_EMULATION
+	select APM_EMULATION
+	depends on ADB_PMU && PM
 
 config PMAC_MEDIABAY
 	bool "Support PowerBook hotswap media bay"
--- wireless-dev.orig/drivers/macintosh/apm_emu.c	2007-05-01 11:35:45.694734191 +0200
+++ wireless-dev/drivers/macintosh/apm_emu.c	2007-05-01 11:36:24.824734191 +0200
@@ -1,9 +1,7 @@
-/* APM emulation layer for PowerMac
- * 
- * Copyright 2001 Benjamin Herrenschmidt (benh@kernel.crashing.org)
+/*
+ * APM emulation for PMU-based machines
  *
- * Lots of code inherited from apm.c, see appropriate notice in
- *  arch/i386/kernel/apm.c
+ * Copyright 2001 Benjamin Herrenschmidt (benh@kernel.crashing.org)
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -18,429 +16,40 @@
  *
  */
 
-#include <linux/module.h>
-
-#include <linux/poll.h>
-#include <linux/types.h>
-#include <linux/stddef.h>
-#include <linux/timer.h>
-#include <linux/fcntl.h>
-#include <linux/slab.h>
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-#include <linux/miscdevice.h>
-#include <linux/apm_bios.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/pm.h>
 #include <linux/kernel.h>
-#include <linux/smp_lock.h>
-
+#include <linux/module.h>
+#include <linux/apm-emulation.h>
 #include <linux/adb.h>
 #include <linux/pmu.h>
-
-#include <asm/system.h>
-#include <asm/uaccess.h>
 #include <asm/machdep.h>
 
-#undef DEBUG
-
-#ifdef DEBUG
-#define DBG(args...) printk(KERN_DEBUG args)
-//#define DBG(args...) xmon_printf(args)
-#else
-#define DBG(args...) do { } while (0)
-#endif
-
-/*
- * The apm_bios device is one of the misc char devices.
- * This is its minor number.
- */
-#define	APM_MINOR_DEV	134
-
-/*
- * Maximum number of events stored
- */
-#define APM_MAX_EVENTS		20
-
-#define FAKE_APM_BIOS_VERSION	0x0101
-
-#define APM_USER_NOTIFY_TIMEOUT	(5*HZ)
-
-/*
- * The per-file APM data
- */
-struct apm_user {
-	int		magic;
-	struct apm_user *	next;
-	int		suser: 1;
-	int		suspend_waiting: 1;
-	int		suspends_pending;
-	int		suspends_read;
-	int		event_head;
-	int		event_tail;
-	apm_event_t	events[APM_MAX_EVENTS];
-};
-
-/*
- * The magic number in apm_user
- */
-#define APM_BIOS_MAGIC		0x4101
-
-/*
- * Local variables
- */
-static int			suspends_pending;
-
-static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
-static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
-static struct apm_user *	user_list;
-
-static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when);
-static struct pmu_sleep_notifier apm_sleep_notifier = {
-	apm_notify_sleep,
-	SLEEP_LEVEL_USERLAND,
-};
-
-static const char driver_version[] = "0.5";	/* no spaces */
-
-#ifdef DEBUG
-static char *	apm_event_name[] = {
-	"system standby",
-	"system suspend",
-	"normal resume",
-	"critical resume",
-	"low battery",
-	"power status change",
-	"update time",
-	"critical suspend",
-	"user standby",
-	"user suspend",
-	"system standby resume",
-	"capabilities change"
-};
-#define NR_APM_EVENT_NAME	\
-		(sizeof(apm_event_name) / sizeof(apm_event_name[0]))
-
-#endif
-
-static int queue_empty(struct apm_user *as)
-{
-	return as->event_head == as->event_tail;
-}
-
-static apm_event_t get_queued_event(struct apm_user *as)
-{
-	as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS;
-	return as->events[as->event_tail];
-}
-
-static void queue_event(apm_event_t event, struct apm_user *sender)
-{
-	struct apm_user *	as;
-
-	DBG("apm_emu: queue_event(%s)\n", apm_event_name[event-1]);
-	if (user_list == NULL)
-		return;
-	for (as = user_list; as != NULL; as = as->next) {
-		if (as == sender)
-			continue;
-		as->event_head = (as->event_head + 1) % APM_MAX_EVENTS;
-		if (as->event_head == as->event_tail) {
-			static int notified;
-
-			if (notified++ == 0)
-			    printk(KERN_ERR "apm_emu: an event queue overflowed\n");
-			as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS;
-		}
-		as->events[as->event_head] = event;
-		if (!as->suser)
-			continue;
-		switch (event) {
-		case APM_SYS_SUSPEND:
-		case APM_USER_SUSPEND:
-			as->suspends_pending++;
-			suspends_pending++;
-			break;
-		case APM_NORMAL_RESUME:
-			as->suspend_waiting = 0;
-			break;
-		}
-	}
-	wake_up_interruptible(&apm_waitqueue);
-}
-
-static int check_apm_user(struct apm_user *as, const char *func)
-{
-	if ((as == NULL) || (as->magic != APM_BIOS_MAGIC)) {
-		printk(KERN_ERR "apm_emu: %s passed bad filp\n", func);
-		return 1;
-	}
-	return 0;
-}
-
-static ssize_t do_read(struct file *fp, char __user *buf, size_t count, loff_t *ppos)
-{
-	struct apm_user *	as;
-	size_t			i;
-	apm_event_t		event;
-	DECLARE_WAITQUEUE(wait, current);
-
-	as = fp->private_data;
-	if (check_apm_user(as, "read"))
-		return -EIO;
-	if (count < sizeof(apm_event_t))
-		return -EINVAL;
-	if (queue_empty(as)) {
-		if (fp->f_flags & O_NONBLOCK)
-			return -EAGAIN;
-		add_wait_queue(&apm_waitqueue, &wait);
-repeat:
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (queue_empty(as) && !signal_pending(current)) {
-			schedule();
-			goto repeat;
-		}
-		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&apm_waitqueue, &wait);
-	}
-	i = count;
-	while ((i >= sizeof(event)) && !queue_empty(as)) {
-		event = get_queued_event(as);
-		DBG("apm_emu: do_read, returning: %s\n", apm_event_name[event-1]);
-		if (copy_to_user(buf, &event, sizeof(event))) {
-			if (i < count)
-				break;
-			return -EFAULT;
-		}
-		switch (event) {
-		case APM_SYS_SUSPEND:
-		case APM_USER_SUSPEND:
-			as->suspends_read++;
-			break;
-		}
-		buf += sizeof(event);
-		i -= sizeof(event);
-	}
-	if (i < count)
-		return count - i;
-	if (signal_pending(current))
-		return -ERESTARTSYS;
-	return 0;
-}
-
-static unsigned int do_poll(struct file *fp, poll_table * wait)
-{
-	struct apm_user * as;
-
-	as = fp->private_data;
-	if (check_apm_user(as, "poll"))
-		return 0;
-	poll_wait(fp, &apm_waitqueue, wait);
-	if (!queue_empty(as))
-		return POLLIN | POLLRDNORM;
-	return 0;
-}
-
-static int do_ioctl(struct inode * inode, struct file *filp,
-		    u_int cmd, u_long arg)
-{
-	struct apm_user *	as;
-	DECLARE_WAITQUEUE(wait, current);
-
-	as = filp->private_data;
-	if (check_apm_user(as, "ioctl"))
-		return -EIO;
-	if (!as->suser)
-		return -EPERM;
-	switch (cmd) {
-	case APM_IOC_SUSPEND:
-		/* If a suspend message was sent to userland, we
-		 * consider this as a confirmation message
-		 */
-		if (as->suspends_read > 0) {
-			as->suspends_read--;
-			as->suspends_pending--;
-			suspends_pending--;
-		} else {
-			// Route to PMU suspend ?
-			break;
-		}
-		as->suspend_waiting = 1;
-		add_wait_queue(&apm_waitqueue, &wait);
-		DBG("apm_emu: ioctl waking up sleep waiter !\n");
-		wake_up(&apm_suspend_waitqueue);
-		mb();
-		while(as->suspend_waiting && !signal_pending(current)) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule();
-		}
-		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&apm_waitqueue, &wait);
-		break;
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static int do_release(struct inode * inode, struct file * filp)
-{
-	struct apm_user *	as;
-
-	as = filp->private_data;
-	if (check_apm_user(as, "release"))
-		return 0;
-	filp->private_data = NULL;
-	lock_kernel();
-	if (as->suspends_pending > 0) {
-		suspends_pending -= as->suspends_pending;
-		if (suspends_pending <= 0)
-			wake_up(&apm_suspend_waitqueue);
-	}
-	if (user_list == as)
-		user_list = as->next;
-	else {
-		struct apm_user *	as1;
-
-		for (as1 = user_list;
-		     (as1 != NULL) && (as1->next != as);
-		     as1 = as1->next)
-			;
-		if (as1 == NULL)
-			printk(KERN_ERR "apm: filp not in user list\n");
-		else
-			as1->next = as->next;
-	}
-	unlock_kernel();
-	kfree(as);
-	return 0;
-}
-
-static int do_open(struct inode * inode, struct file * filp)
-{
-	struct apm_user *	as;
-
-	as = kmalloc(sizeof(*as), GFP_KERNEL);
-	if (as == NULL) {
-		printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n",
-		       sizeof(*as));
-		return -ENOMEM;
-	}
-	as->magic = APM_BIOS_MAGIC;
-	as->event_tail = as->event_head = 0;
-	as->suspends_pending = 0;
-	as->suspends_read = 0;
-	/*
-	 * XXX - this is a tiny bit broken, when we consider BSD
-         * process accounting. If the device is opened by root, we
-	 * instantly flag that we used superuser privs. Who knows,
-	 * we might close the device immediately without doing a
-	 * privileged operation -- cevans
-	 */
-	as->suser = capable(CAP_SYS_ADMIN);
-	as->next = user_list;
-	user_list = as;
-	filp->private_data = as;
-
-	DBG("apm_emu: opened by %s, suser: %d\n", current->comm, (int)as->suser);
-
-	return 0;
-}
-
-/* Wait for all clients to ack the suspend request. APM API
- * doesn't provide a way to NAK, but this could be added
- * here.
- */
-static void wait_all_suspend(void)
-{
-	DECLARE_WAITQUEUE(wait, current);
-
-	add_wait_queue(&apm_suspend_waitqueue, &wait);
-	DBG("apm_emu: wait_all_suspend(), suspends_pending: %d\n", suspends_pending);
-	while(suspends_pending > 0) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule();
-	}
-	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&apm_suspend_waitqueue, &wait);
-
-	DBG("apm_emu: wait_all_suspend() - complete !\n");
-}
-
-static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when)
-{
-	switch(when) {
-		case PBOOK_SLEEP_REQUEST:
-			queue_event(APM_SYS_SUSPEND, NULL);
-			wait_all_suspend();
-			break;
-		case PBOOK_WAKE:
-			queue_event(APM_NORMAL_RESUME, NULL);
-			break;
-	}
-}
-
 #define APM_CRITICAL		10
 #define APM_LOW			30
 
-static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length)
+static void pmu_apm_get_power_status(struct apm_power_info *info)
 {
-	/* Arguments, with symbols from linux/apm_bios.h.  Information is
-	   from the Get Power Status (0x0a) call unless otherwise noted.
-
-	   0) Linux driver version (this will change if format changes)
-	   1) APM BIOS Version.  Usually 1.0, 1.1 or 1.2.
-	   2) APM flags from APM Installation Check (0x00):
-	      bit 0: APM_16_BIT_SUPPORT
-	      bit 1: APM_32_BIT_SUPPORT
-	      bit 2: APM_IDLE_SLOWS_CLOCK
-	      bit 3: APM_BIOS_DISABLED
-	      bit 4: APM_BIOS_DISENGAGED
-	   3) AC line status
-	      0x00: Off-line
-	      0x01: On-line
-	      0x02: On backup power (BIOS >= 1.1 only)
-	      0xff: Unknown
-	   4) Battery status
-	      0x00: High
-	      0x01: Low
-	      0x02: Critical
-	      0x03: Charging
-	      0x04: Selected battery not present (BIOS >= 1.2 only)
-	      0xff: Unknown
-	   5) Battery flag
-	      bit 0: High
-	      bit 1: Low
-	      bit 2: Critical
-	      bit 3: Charging
-	      bit 7: No system battery
-	      0xff: Unknown
-	   6) Remaining battery life (percentage of charge):
-	      0-100: valid
-	      -1: Unknown
-	   7) Remaining battery life (time units):
-	      Number of remaining minutes or seconds
-	      -1: Unknown
-	   8) min = minutes; sec = seconds */
-
-	unsigned short  ac_line_status;
-	unsigned short  battery_status = 0;
-	unsigned short  battery_flag   = 0xff;
-	int		percentage     = -1;
-	int             time_units     = -1;
-	int		real_count     = 0;
-	int		i;
-	char *		p = buf;
-	char		charging       = 0;
-	long		charge	       = -1;
-	long		amperage       = 0;
-	unsigned long	btype          = 0;
+	int percentage = -1;
+	int batteries = 0;
+	int time_units = -1;
+	int real_count = 0;
+	int i;
+	char charging = 0;
+	long charge = -1;
+	long amperage = 0;
+	unsigned long btype = 0;
+
+	info->battery_status = APM_BATTERY_STATUS_UNKNOWN;
+	info->battery_flag = APM_BATTERY_FLAG_UNKNOWN;
+	info->units = APM_UNITS_MINS;
+
+	if (pmu_power_flags & PMU_PWR_AC_PRESENT)
+		info->ac_line_status = APM_AC_ONLINE;
+	else
+		info->ac_line_status = APM_AC_OFFLINE;
 
-	ac_line_status = ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0);
 	for (i=0; i<pmu_battery_count; i++) {
 		if (pmu_batteries[i].flags & PMU_BATT_PRESENT) {
-			battery_status++;
+			batteries++;
 			if (percentage < 0)
 				percentage = 0;
 			if (charge < 0)
@@ -456,9 +65,9 @@ static int apm_emu_get_info(char *buf, c
 				charging++;
 		}
 	}
-	if (0 == battery_status)
-		ac_line_status = 1;
-	battery_status = 0xff;
+	if (batteries == 0)
+		info->ac_line_status = APM_AC_ONLINE;
+
 	if (real_count) {
 		if (amperage < 0) {
 			if (btype == PMU_BATT_TYPE_SMART)
@@ -468,85 +77,47 @@ static int apm_emu_get_info(char *buf, c
 		}
 		percentage /= real_count;
 		if (charging > 0) {
-			battery_status = 0x03;
-			battery_flag = 0x08;
+			info->battery_status = APM_BATTERY_STATUS_CHARGING;
+			info->battery_flag = APM_BATTERY_FLAG_CHARGING;
 		} else if (percentage <= APM_CRITICAL) {
-			battery_status = 0x02;
-			battery_flag = 0x04;
+			info->battery_status = APM_BATTERY_STATUS_CRITICAL;
+			info->battery_flag = APM_BATTERY_FLAG_CRITICAL;
 		} else if (percentage <= APM_LOW) {
-			battery_status = 0x01;
-			battery_flag = 0x02;
+			info->battery_status = APM_BATTERY_STATUS_LOW;
+			info->battery_flag = APM_BATTERY_FLAG_LOW;
 		} else {
-			battery_status = 0x00;
-			battery_flag = 0x01;
+			info->battery_status = APM_BATTERY_STATUS_HIGH;
+			info->battery_flag = APM_BATTERY_FLAG_HIGH;
 		}
 	}
-	p += sprintf(p, "%s %d.%d 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
-		     driver_version,
-		     (FAKE_APM_BIOS_VERSION >> 8) & 0xff,
-		     FAKE_APM_BIOS_VERSION & 0xff,
-		     0,
-		     ac_line_status,
-		     battery_status,
-		     battery_flag,
-		     percentage,
-		     time_units,
-		     "min");
 
-	return p - buf;
+	info->battery_life = percentage;
+	info->time = time_units;
 }
 
-static const struct file_operations apm_bios_fops = {
-	.owner		= THIS_MODULE,
-	.read		= do_read,
-	.poll		= do_poll,
-	.ioctl		= do_ioctl,
-	.open		= do_open,
-	.release	= do_release,
-};
-
-static struct miscdevice apm_device = {
-	APM_MINOR_DEV,
-	"apm_bios",
-	&apm_bios_fops
-};
-
 static int __init apm_emu_init(void)
 {
-	struct proc_dir_entry *apm_proc;
-
-	if (sys_ctrler != SYS_CTRLER_PMU) {
-		printk(KERN_INFO "apm_emu: Requires a machine with a PMU.\n");
+	if (sys_ctrler != SYS_CTRLER_PMU)
 		return -ENODEV;
-	}
-		
-	apm_proc = create_proc_info_entry("apm", 0, NULL, apm_emu_get_info);
-	if (apm_proc)
-		apm_proc->owner = THIS_MODULE;
-
-	if (misc_register(&apm_device) != 0)
-		printk(KERN_INFO "Could not create misc. device for apm\n");
 
-	pmu_register_sleep_notifier(&apm_sleep_notifier);
+	apm_get_power_status = pmu_apm_get_power_status;
 
-	printk(KERN_INFO "apm_emu: APM Emulation %s initialized.\n", driver_version);
+	printk(KERN_INFO "apm_emu: PMU APM Emulation initialized.\n");
 
 	return 0;
 }
 
 static void __exit apm_emu_exit(void)
 {
-	pmu_unregister_sleep_notifier(&apm_sleep_notifier);
-	misc_deregister(&apm_device);
-	remove_proc_entry("apm", NULL);
+	if (apm_get_power_status == pmu_apm_get_power_status)
+		apm_get_power_status = NULL;
 
-	printk(KERN_INFO "apm_emu: APM Emulation removed.\n");
+	printk(KERN_INFO "apm_emu: PMU APM Emulation removed.\n");
 }
 
 module_init(apm_emu_init);
 module_exit(apm_emu_exit);
 
 MODULE_AUTHOR("Benjamin Herrenschmidt");
-MODULE_DESCRIPTION("APM emulation layer for PowerMac");
+MODULE_DESCRIPTION("APM emulation for PowerMac");
 MODULE_LICENSE("GPL");
-
--- wireless-dev.orig/arch/powerpc/Kconfig	2007-05-01 11:35:45.774734191 +0200
+++ wireless-dev/arch/powerpc/Kconfig	2007-05-01 11:36:24.824734191 +0200
@@ -117,6 +117,9 @@ config GENERIC_BUG
 	default y
 	depends on BUG
 
+config SYS_SUPPORTS_APM_EMULATION
+	bool
+
 config DEFAULT_UIMAGE
 	bool
 	help

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

* [PATCH] via-pmu: remove LED sleep notifier
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (8 preceding siblings ...)
  2007-05-02  5:34 ` [PATCH] apm_emu: use generic apm-emulation Johannes Berg
@ 2007-05-02  5:36 ` Johannes Berg
  2007-05-02 10:57   ` Stephen Rothwell
  2007-05-02  5:39 ` [PATCH] remove awacs dmasound Johannes Berg
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-05-02  5:36 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

The generic LED code now makes sure that suspended devices don't blink,
so we no longer need to do it ourselves. For the suspend to disk case,
however, we need to make sure that we don't blink if the PMU sysdev
was suspended before the LED device.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
 drivers/macintosh/via-pmu-led.c |   37 +++++--------------------------------
 drivers/macintosh/via-pmu.c     |    2 +-
 2 files changed, 6 insertions(+), 33 deletions(-)

--- wireless-dev.orig/drivers/macintosh/via-pmu-led.c	2007-05-01 11:35:45.354734191 +0200
+++ wireless-dev/drivers/macintosh/via-pmu-led.c	2007-05-01 11:36:25.454734191 +0200
@@ -31,7 +31,8 @@ static spinlock_t pmu_blink_lock;
 static struct adb_request pmu_blink_req;
 /* -1: no change, 0: request off, 1: request on */
 static int requested_change;
-static int sleeping;
+
+extern int pmu_sys_suspended;
 
 static void pmu_req_done(struct adb_request * req)
 {
@@ -41,7 +42,7 @@ static void pmu_req_done(struct adb_requ
 	/* if someone requested a change in the meantime
 	 * (we only see the last one which is fine)
 	 * then apply it now */
-	if (requested_change != -1 && !sleeping)
+	if (requested_change != -1 && !pmu_sys_suspended)
 		pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
 	/* reset requested change */
 	requested_change = -1;
@@ -66,7 +67,7 @@ static void pmu_led_set(struct led_class
 		break;
 	}
 	/* if request isn't done, then don't do anything */
-	if (pmu_blink_req.complete && !sleeping)
+	if (pmu_blink_req.complete && !pmu_sys_suspended)
 		pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
  out:
  	spin_unlock_irqrestore(&pmu_blink_lock, flags);
@@ -80,32 +81,6 @@ static struct led_classdev pmu_led = {
 	.brightness_set = pmu_led_set,
 };
 
-#ifdef CONFIG_PM
-static void pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&pmu_blink_lock, flags);
-
-	switch (when) {
-	case PBOOK_SLEEP_REQUEST:
-		sleeping = 1;
-		break;
-	case PBOOK_WAKE:
-		sleeping = 0;
-		break;
-	default:
-		/* do nothing */
-		break;
-	}
-	spin_unlock_irqrestore(&pmu_blink_lock, flags);
-}
-
-static struct pmu_sleep_notifier via_pmu_led_sleep_notif = {
-	.notifier_call = pmu_led_sleep_call,
-};
-#endif
-
 static int __init via_pmu_led_init(void)
 {
 	struct device_node *dt;
@@ -135,9 +110,7 @@ static int __init via_pmu_led_init(void)
 	/* no outstanding req */
 	pmu_blink_req.complete = 1;
 	pmu_blink_req.done = pmu_req_done;
-#ifdef CONFIG_PM
-	pmu_register_sleep_notifier(&via_pmu_led_sleep_notif);
-#endif
+
 	return led_classdev_register(NULL, &pmu_led);
 }
 
--- wireless-dev.orig/drivers/macintosh/via-pmu.c	2007-05-01 11:36:23.184734191 +0200
+++ wireless-dev/drivers/macintosh/via-pmu.c	2007-05-01 11:36:25.464734191 +0200
@@ -2731,7 +2731,7 @@ pmu_polled_request(struct adb_request *r
 
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 
-static int pmu_sys_suspended;
+int pmu_sys_suspended;
 
 static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
 {

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

* [PATCH] remove awacs dmasound
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (9 preceding siblings ...)
  2007-05-02  5:36 ` [PATCH] via-pmu: remove LED sleep notifier Johannes Berg
@ 2007-05-02  5:39 ` Johannes Berg
  2007-05-02  6:18 ` [PATCH] via-pmu: kill sleep notifiers completely Johannes Berg
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-02  5:39 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, Adrian Bunk

This patch kills the obsolete awacs dmasound because it is in
the way of doing power management improvements since it uses
ancient API.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Adrian Bunk <bunk@stusta.de>

---
This patch contains only the patch for the first two files here, please
remove the other ones manually:

git rm -- sound/oss/dmasound/awacs_defs.h
git rm -- sound/oss/dmasound/dac3550a.c
git rm -- sound/oss/dmasound/dmasound_awacs.c
git rm -- sound/oss/dmasound/tas3001c.c
git rm -- sound/oss/dmasound/tas3001c.h
git rm -- sound/oss/dmasound/tas3001c_tables.c
git rm -- sound/oss/dmasound/tas3004.c
git rm -- sound/oss/dmasound/tas3004.h
git rm -- sound/oss/dmasound/tas3004_tables.c
git rm -- sound/oss/dmasound/tas_common.c
git rm -- sound/oss/dmasound/tas_common.h
git rm -- sound/oss/dmasound/tas_eq_prefs.h
git rm -- sound/oss/dmasound/tas_ioctl.h
git rm -- sound/oss/dmasound/trans_16.c

 sound/oss/dmasound/Kconfig           |   14 
 sound/oss/dmasound/Makefile          |    6 
 sound/oss/dmasound/awacs_defs.h      |  251 --
 sound/oss/dmasound/dac3550a.c        |  209 --
 sound/oss/dmasound/dmasound_awacs.c  | 3215 -----------------------------------
 sound/oss/dmasound/tas3001c.c        |  849 ---------
 sound/oss/dmasound/tas3001c.h        |   64 
 sound/oss/dmasound/tas3001c_tables.c |  375 ----
 sound/oss/dmasound/tas3004.c         | 1138 ------------
 sound/oss/dmasound/tas3004.h         |   77 
 sound/oss/dmasound/tas3004_tables.c  |  301 ---
 sound/oss/dmasound/tas_common.c      |  214 --
 sound/oss/dmasound/tas_common.h      |  284 ---
 sound/oss/dmasound/tas_eq_prefs.h    |   24 
 sound/oss/dmasound/tas_ioctl.h       |   24 
 sound/oss/dmasound/trans_16.c        |  898 ---------
 16 files changed, 7943 deletions(-)


--- wireless-dev.orig/sound/oss/dmasound/Makefile	2007-05-01 11:35:44.664734191 +0200
+++ wireless-dev/sound/oss/dmasound/Makefile	2007-05-01 11:36:26.054734191 +0200
@@ -2,12 +2,6 @@
 # Makefile for the DMA sound driver
 #
 
-dmasound_pmac-y			+= dmasound_awacs.o \
-				   trans_16.o dac3550a.o tas_common.o \
-				   tas3001c.o tas3001c_tables.o \
-				   tas3004.o tas3004_tables.o
-
 obj-$(CONFIG_DMASOUND_ATARI)	+= dmasound_core.o dmasound_atari.o
-obj-$(CONFIG_DMASOUND_PMAC)	+= dmasound_core.o dmasound_pmac.o
 obj-$(CONFIG_DMASOUND_PAULA)	+= dmasound_core.o dmasound_paula.o
 obj-$(CONFIG_DMASOUND_Q40)	+= dmasound_core.o dmasound_q40.o
--- wireless-dev.orig/sound/oss/dmasound/Kconfig	2007-05-01 11:35:45.144734191 +0200
+++ wireless-dev/sound/oss/dmasound/Kconfig	2007-05-01 11:36:26.094734191 +0200
@@ -12,20 +12,6 @@ config DMASOUND_ATARI
 	  want). If you want to compile it as a module, say M here and read
 	  <file:Documentation/kbuild/modules.txt>.
 
-config DMASOUND_PMAC
-	tristate "PowerMac DMA sound support"
-	depends on PPC32 && PPC_PMAC && SOUND && I2C && OBSOLETE_OSS
- 	select DMASOUND
-	help
-	  If you want to use the internal audio of your PowerMac in Linux,
-	  answer Y to this question. This will provide a Sun-like /dev/audio,
-	  compatible with the Linux/i386 sound system. Otherwise, say N.
-
-	  This driver is also available as a module ( = code which can be
-	  inserted in and removed from the running kernel whenever you
-	  want). If you want to compile it as a module, say M here and read
-	  <file:Documentation/kbuild/modules.txt>.
-
 config DMASOUND_PAULA
 	tristate "Amiga DMA sound support"
 	depends on (AMIGA || APUS) && SOUND

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

* [PATCH] via-pmu: kill sleep notifiers completely
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (10 preceding siblings ...)
  2007-05-02  5:39 ` [PATCH] remove awacs dmasound Johannes Berg
@ 2007-05-02  6:18 ` Johannes Berg
  2007-05-02  6:21 ` [PATCH] powermac: support G5 CPU hotplug Johannes Berg
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-02  6:18 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

This patch kills off the remnants of the ancient sleep notifiers.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
Obviously depends on the previous patches that remove all the users.

 drivers/macintosh/via-pmu.c |   71 --------------------------------------------
 include/linux/pmu.h         |   36 ----------------------
 2 files changed, 107 deletions(-)

--- wireless-dev.orig/drivers/macintosh/via-pmu.c	2007-05-02 07:24:43.429196053 +0200
+++ wireless-dev/drivers/macintosh/via-pmu.c	2007-05-02 08:15:04.959192713 +0200
@@ -177,7 +177,6 @@ static struct proc_dir_entry *proc_pmu_b
 
 int __fake_sleep;
 int asleep;
-BLOCKING_NOTIFIER_HEAD(sleep_notifier_list);
 
 #ifdef CONFIG_ADB
 static int adb_dev_map;
@@ -1738,67 +1737,7 @@ pmu_present(void)
 	return via != 0;
 }
 
-#ifdef CONFIG_PM
-
-static LIST_HEAD(sleep_notifiers);
-
-int
-pmu_register_sleep_notifier(struct pmu_sleep_notifier *n)
-{
-	struct list_head *list;
-	struct pmu_sleep_notifier *notifier;
-
-	for (list = sleep_notifiers.next; list != &sleep_notifiers;
-	     list = list->next) {
-		notifier = list_entry(list, struct pmu_sleep_notifier, list);
-		if (n->priority > notifier->priority)
-			break;
-	}
-	__list_add(&n->list, list->prev, list);
-	return 0;
-}
-EXPORT_SYMBOL(pmu_register_sleep_notifier);
-
-int
-pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n)
-{
-	if (n->list.next == 0)
-		return -ENOENT;
-	list_del(&n->list);
-	n->list.next = NULL;
-	return 0;
-}
-EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
-#endif /* CONFIG_PM */
-
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
-
-/* Sleep is broadcast last-to-first */
-static void broadcast_sleep(int when)
-{
-	struct list_head *list;
-	struct pmu_sleep_notifier *notifier;
-
-	for (list = sleep_notifiers.prev; list != &sleep_notifiers;
-	     list = list->prev) {
-		notifier = list_entry(list, struct pmu_sleep_notifier, list);
-		notifier->notifier_call(notifier, when);
-	}
-}
-
-/* Wake is broadcast first-to-last */
-static void broadcast_wake(void)
-{
-	struct list_head *list;
-	struct pmu_sleep_notifier *notifier;
-
-	for (list = sleep_notifiers.next; list != &sleep_notifiers;
-	     list = list->next) {
-		notifier = list_entry(list, struct pmu_sleep_notifier, list);
-		notifier->notifier_call(notifier, PBOOK_WAKE);
-	}
-}
-
 /*
  * This struct is used to store config register values for
  * PCI devices which may get powered off when we sleep.
@@ -2003,9 +1942,6 @@ pmac_suspend_devices(void)
 
 	pm_prepare_console();
 	
-	/* Notify old-style device drivers */
-	broadcast_sleep(PBOOK_SLEEP_REQUEST);
-
 	/* Sync the disks. */
 	/* XXX It would be nice to have some way to ensure that
 	 * nobody is dirtying any new buffers while we wait. That
@@ -2014,12 +1950,9 @@ pmac_suspend_devices(void)
 	 */
 	sys_sync();
 
-	broadcast_sleep(PBOOK_SLEEP_NOW);
-
 	/* Send suspend call to devices, hold the device core's dpm_sem */
 	ret = device_suspend(PMSG_SUSPEND);
 	if (ret) {
-		broadcast_wake();
 		printk(KERN_ERR "Driver sleep failed\n");
 		return -EBUSY;
 	}
@@ -2060,7 +1993,6 @@ pmac_suspend_devices(void)
 		local_irq_enable();
 		preempt_enable();
 		device_resume();
-		broadcast_wake();
 		printk(KERN_ERR "Driver powerdown failed\n");
 		return -EBUSY;
 	}
@@ -2114,9 +2046,6 @@ pmac_wakeup_devices(void)
 	/* Resume devices */
 	device_resume();
 
-	/* Notify old style drivers */
-	broadcast_wake();
-
 	pm_restore_console();
 
 	return 0;
--- wireless-dev.orig/include/linux/pmu.h	2007-05-02 07:24:24.169196053 +0200
+++ wireless-dev/include/linux/pmu.h	2007-05-02 07:24:43.569196053 +0200
@@ -159,42 +159,6 @@ extern void pmu_unlock(void);
 extern int pmu_present(void);
 extern int pmu_get_model(void);
 
-#ifdef CONFIG_PM
-/*
- * Stuff for putting the powerbook to sleep and waking it again.
- *
- */
-#include <linux/list.h>
-
-struct pmu_sleep_notifier
-{
-	void (*notifier_call)(struct pmu_sleep_notifier *self, int when);
-	int priority;
-	struct list_head list;
-};
-
-/* Code values for calling sleep/wakeup handlers
- */
-#define PBOOK_SLEEP_REQUEST	1
-#define PBOOK_SLEEP_NOW		2
-#define PBOOK_WAKE		3
-
-/* priority levels in notifiers */
-#define SLEEP_LEVEL_VIDEO	100	/* Video driver (first wake) */
-#define SLEEP_LEVEL_MEDIABAY	90	/* Media bay driver */
-#define SLEEP_LEVEL_BLOCK	80	/* IDE, SCSI */
-#define SLEEP_LEVEL_NET		70	/* bmac, gmac */
-#define SLEEP_LEVEL_MISC	60	/* Anything else */
-#define SLEEP_LEVEL_USERLAND	55	/* Reserved for apm_emu */
-#define SLEEP_LEVEL_ADB		50	/* ADB (async) */
-#define SLEEP_LEVEL_SOUND	40	/* Sound driver (blocking) */
-
-/* special register notifier functions */
-int pmu_register_sleep_notifier(struct pmu_sleep_notifier* notifier);
-int pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* notifier);
-
-#endif /* CONFIG_PM */
-
 #define PMU_MAX_BATTERIES	2
 
 /* values for pmu_power_flags */

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

* [PATCH] powermac: support G5 CPU hotplug
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (11 preceding siblings ...)
  2007-05-02  6:18 ` [PATCH] via-pmu: kill sleep notifiers completely Johannes Berg
@ 2007-05-02  6:21 ` Johannes Berg
  2007-05-02 10:55   ` Paul Mackerras
  2007-05-02  6:33 ` [PATCH] powerpc: MPIC sys_device & suspend/resume Johannes Berg
                   ` (3 subsequent siblings)
  16 siblings, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-05-02  6:21 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

This patch allows "hotplugging" of CPUs on G5 machines. CPUs that are
disabled are put into an idle loop with the decrementer frequency set
to minimum. To wake them up again we kick them just like when bringing
them up. To stop those CPUs from messing with any global state we stop
them from entering the timer interrupt.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
 arch/powerpc/kernel/idle_power4.S       |   14 +++++++++----
 arch/powerpc/platforms/powermac/setup.c |   34 +++++++++++++++++++++++++++++++-
 arch/powerpc/platforms/powermac/smp.c   |   12 +++++++++--
 include/asm-powerpc/machdep.h           |    2 +
 4 files changed, 55 insertions(+), 7 deletions(-)

--- wireless-dev.orig/arch/powerpc/platforms/powermac/smp.c	2007-05-02 08:14:47.179192713 +0200
+++ wireless-dev/arch/powerpc/platforms/powermac/smp.c	2007-05-02 08:15:08.619192713 +0200
@@ -900,7 +900,7 @@ void smp_core99_cpu_die(unsigned int cpu
 	cpu_dead[cpu] = 0;
 }
 
-#endif
+#endif /* CONFIG_HOTPLUG_CPU && CONFIG_PP32 */
 
 /* Core99 Macs (dual G4s and G5s) */
 struct smp_ops_t core99_smp_ops = {
@@ -910,8 +910,16 @@ struct smp_ops_t core99_smp_ops = {
 	.setup_cpu	= smp_core99_setup_cpu,
 	.give_timebase	= smp_core99_give_timebase,
 	.take_timebase	= smp_core99_take_timebase,
-#if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PPC32)
+#if defined(CONFIG_HOTPLUG_CPU)
+# if defined(CONFIG_PPC32)
 	.cpu_disable	= smp_core99_cpu_disable,
 	.cpu_die	= smp_core99_cpu_die,
+# endif
+# if defined(CONFIG_PPC64)
+	.cpu_disable	= generic_cpu_disable,
+	.cpu_die	= generic_cpu_die,
+	/* intentionally do *NOT* assign cpu_enable,
+	 * the generic code will use kick_cpu then! */
+# endif
 #endif
 };
--- wireless-dev.orig/arch/powerpc/platforms/powermac/setup.c	2007-05-02 08:14:47.229192713 +0200
+++ wireless-dev/arch/powerpc/platforms/powermac/setup.c	2007-05-02 08:20:25.049192713 +0200
@@ -444,6 +444,9 @@ static int initializing = 1;
 static int pmac_late_init(void)
 {
 	initializing = 0;
+	/* this is udbg (which is __init) and we can later use it during
+	 * cpu hotplug (in smp_core99_kick_cpu) */
+	ppc_md.progress = NULL;
 	return 0;
 }
 
@@ -661,6 +664,35 @@ static int pmac_pci_probe_mode(struct pc
 		return PCI_PROBE_NORMAL;
 	return PCI_PROBE_DEVTREE;
 }
+
+#ifdef CONFIG_HOTPLUG_CPU
+/* access per cpu vars from generic smp.c */
+DECLARE_PER_CPU(int, cpu_state);
+
+static void pmac_cpu_die(void)
+{
+	/* turn off as much as possible, we'll be
+	 * kicked out as this will only be invoked
+	 * on core99 platforms for now ... */
+
+	printk(KERN_INFO "CPU#%d offline\n", smp_processor_id());
+	__get_cpu_var(cpu_state) = CPU_DEAD;
+	smp_wmb();
+
+	/* during the path that leads here preemption is disabled,
+	 * reenable it now so that when coming up preempt count is
+	 * zero correctly */
+	preempt_enable();
+
+	while (1) {
+		/* let's not take timer interrupts too often ... */
+		set_dec(0x7fffffff);
+
+		power4_idle_irqs_softdisabled();
+	}
+}
+#endif
+
 #endif
 
 define_machine(powermac) {
@@ -698,6 +730,6 @@ define_machine(powermac) {
 	.phys_mem_access_prot	= pci_phys_mem_access_prot,
 #endif
 #if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PPC64)
-	.cpu_die		= generic_mach_cpu_die,
+	.cpu_die		= pmac_cpu_die,
 #endif
 };
--- wireless-dev.orig/arch/powerpc/kernel/idle_power4.S	2007-05-02 08:14:47.259192713 +0200
+++ wireless-dev/arch/powerpc/kernel/idle_power4.S	2007-05-02 08:15:08.619192713 +0200
@@ -19,7 +19,12 @@
 
 	.text
 
+_GLOBAL(power4_idle_irqs_softdisabled)
+	li	r6,0
+	b	0f
 _GLOBAL(power4_idle)
+	li	r6,1
+0:
 BEGIN_FTR_SECTION
 	blr
 END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP)
@@ -35,8 +40,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP)
 	rotldi	r0,r0,16
 	mtmsrd	r0,1			/* hard-disable interrupts */
 	li	r0,1
-	stb	r0,PACASOFTIRQEN(r13)	/* we'll hard-enable shortly */
-	stb	r0,PACAHARDIRQEN(r13)
+	stb	r0,PACAHARDIRQEN(r13)	/* we'll hard-enable shortly */
+	stb	r6,PACASOFTIRQEN(r13)	/* set softirqs enabled bit */
 BEGIN_FTR_SECTION
 	DSSALL
 	sync
@@ -51,5 +56,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 	isync
 	mtmsrd	r7
 	isync
-	b	1b
-
+	cmpdi	0,r6,0
+	bne+	1b			/* return for softirq-disabled case */
+	blr
--- wireless-dev.orig/include/asm-powerpc/machdep.h	2007-05-02 08:14:47.329192713 +0200
+++ wireless-dev/include/asm-powerpc/machdep.h	2007-05-02 08:20:02.179192713 +0200
@@ -249,6 +249,8 @@ struct machdep_calls {
 
 extern void power4_idle(void);
 extern void ppc6xx_idle(void);
+/* this one is for CPU hotplug (e.g. powermac) */
+extern void power4_idle_irqs_softdisabled(void);
 
 /*
  * ppc_md contains a copy of the machine description structure for the

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

* [PATCH] powerpc: MPIC sys_device & suspend/resume
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (12 preceding siblings ...)
  2007-05-02  6:21 ` [PATCH] powermac: support G5 CPU hotplug Johannes Berg
@ 2007-05-02  6:33 ` Johannes Berg
  2007-05-02  6:35 ` [PATCH] powermac: fix G5-cpufreq for cpu on/offline Johannes Berg
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-02  6:33 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

This adds mpic to the system devices and implements suspend
and resume for them. This is necessary to get interrupts for
modules back to where they were before a suspend to disk.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
 arch/powerpc/sysdev/mpic.c |   96 ++++++++++++++++++++++++++++++++++++++++++++-
 include/asm-powerpc/mpic.h |   15 +++++++
 2 files changed, 110 insertions(+), 1 deletion(-)

--- wireless-dev.orig/arch/powerpc/sysdev/mpic.c	2007-05-02 08:20:02.339192713 +0200
+++ wireless-dev/arch/powerpc/sysdev/mpic.c	2007-05-02 08:24:15.669192713 +0200
@@ -354,6 +354,12 @@ static void mpic_startup_ht_interrupt(st
 		tmp |= 0x22;
 	writel(tmp, fixup->base + 4);
 	spin_unlock_irqrestore(&mpic->fixup_lock, flags);
+
+#ifdef CONFIG_PM
+	/* use the lowest bit inverted to the actual HW,
+	 * set if this fixup was enabled, clear otherwise */
+	mpic->save_data[source].fixup_data = tmp | 1;
+#endif
 }
 
 static void mpic_shutdown_ht_interrupt(struct mpic *mpic, unsigned int source,
@@ -375,6 +381,12 @@ static void mpic_shutdown_ht_interrupt(s
 	tmp |= 1;
 	writel(tmp, fixup->base + 4);
 	spin_unlock_irqrestore(&mpic->fixup_lock, flags);
+
+#ifdef CONFIG_PM
+	/* use the lowest bit inverted to the actual HW,
+	 * set if this fixup was enabled, clear otherwise */
+	mpic->save_data[source].fixup_data = tmp & ~1;
+#endif
 }
 
 static void __init mpic_scan_ht_pic(struct mpic *mpic, u8 __iomem *devbase,
@@ -1143,7 +1155,7 @@ void __init mpic_init(struct mpic *mpic)
 	/* Do the HT PIC fixups on U3 broken mpic */
 	DBG("MPIC flags: %x\n", mpic->flags);
 	if ((mpic->flags & MPIC_U3_HT_IRQS) && (mpic->flags & MPIC_PRIMARY))
- 		mpic_scan_ht_pics(mpic);
+		mpic_scan_ht_pics(mpic);
 
 	for (i = 0; i < mpic->num_sources; i++) {
 		/* start with vector = source number, and masked */
@@ -1167,6 +1179,12 @@ void __init mpic_init(struct mpic *mpic)
 
 	/* Set current processor priority to 0 */
 	mpic_cpu_write(MPIC_INFO(CPU_CURRENT_TASK_PRI), 0);
+
+#ifdef CONFIG_PM
+	/* allocate memory to save mpic state */
+	mpic->save_data = alloc_bootmem(mpic->num_sources * sizeof(struct mpic_irq_save));
+	BUG_ON(mpic->save_data == NULL);
+#endif
 }
 
 void __init mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio)
@@ -1417,3 +1435,79 @@ void __devinit smp_mpic_setup_cpu(int cp
 	mpic_setup_this_cpu();
 }
 #endif /* CONFIG_SMP */
+
+#ifdef CONFIG_PM
+static int mpic_suspend(struct sys_device *dev, pm_message_t state)
+{
+	struct mpic *mpic = container_of(dev, struct mpic, sysdev);
+	int i;
+
+	for (i = 0; i < mpic->num_sources; i++) {
+		mpic->save_data[i].vecprio =
+			mpic_irq_read(i, MPIC_INFO(IRQ_VECTOR_PRI));
+		mpic->save_data[i].dest =
+			mpic_irq_read(i, MPIC_INFO(IRQ_DESTINATION));
+	}
+
+	return 0;
+}
+
+static int mpic_resume(struct sys_device *dev)
+{
+	struct mpic *mpic = container_of(dev, struct mpic, sysdev);
+	int i;
+
+	for (i = 0; i < mpic->num_sources; i++) {
+		mpic_irq_write(i, MPIC_INFO(IRQ_VECTOR_PRI),
+			       mpic->save_data[i].vecprio);
+		mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION),
+			       mpic->save_data[i].dest);
+
+#ifdef CONFIG_MPIC_U3_HT_IRQS
+	{
+		struct mpic_irq_fixup *fixup = &mpic->fixups[i];
+
+		if (fixup->base) {
+			/* we use the lowest bit in an inverted meaning */
+			if ((mpic->save_data[i].fixup_data & 1) == 0)
+				continue;
+
+			/* Enable and configure */
+			writeb(0x10 + 2 * fixup->index, fixup->base + 2);
+
+			writel(mpic->save_data[i].fixup_data & ~1,
+			       fixup->base + 4);
+		}
+	}
+#endif
+	} /* end for loop */
+
+	return 0;
+}
+#endif
+
+static struct sysdev_class mpic_sysclass = {
+#ifdef CONFIG_PM
+	.resume = mpic_resume,
+	.suspend = mpic_suspend,
+#endif
+	set_kset_name("mpic"),
+};
+
+static int mpic_init_sys(void)
+{
+	struct mpic *mpic = mpics;
+	int error, id = 0;
+
+	error = sysdev_class_register(&mpic_sysclass);
+
+	while (mpic && !error) {
+		mpic->sysdev.cls = &mpic_sysclass;
+		mpic->sysdev.id = id++;
+		error = sysdev_register(&mpic->sysdev);
+		mpic = mpic->next;
+	}
+	return error;
+}
+
+device_initcall(mpic_init_sys);
--- wireless-dev.orig/include/asm-powerpc/mpic.h	2007-05-02 08:20:02.369192713 +0200
+++ wireless-dev/include/asm-powerpc/mpic.h	2007-05-02 08:24:28.479192713 +0200
@@ -3,6 +3,7 @@
 #ifdef __KERNEL__
 
 #include <linux/irq.h>
+#include <linux/sysdev.h>
 #include <asm/dcr.h>
 
 /*
@@ -228,6 +229,14 @@ struct mpic_reg_bank {
 #endif /* CONFIG_PPC_DCR */
 };
 
+struct mpic_irq_save {
+	u32		vecprio,
+			dest;
+#ifdef CONFIG_MPIC_U3_HT_IRQS
+	u32		fixup_data;
+#endif
+};
+
 /* The instance data of a given MPIC */
 struct mpic
 {
@@ -294,6 +303,12 @@ struct mpic
 
 	/* link */
 	struct mpic		*next;
+
+	struct sys_device	sysdev;
+
+#ifdef CONFIG_PM
+	struct mpic_irq_save	*save_data;
+#endif
 };
 
 /*

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

* [PATCH] powermac: fix G5-cpufreq for cpu on/offline
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (13 preceding siblings ...)
  2007-05-02  6:33 ` [PATCH] powerpc: MPIC sys_device & suspend/resume Johannes Berg
@ 2007-05-02  6:35 ` Johannes Berg
  2007-05-03 12:25 ` patches for 2.6.22 Johannes Berg
  2007-07-17 13:28 ` [PATCH] remove awacs dmasound Johannes Berg
  16 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-02  6:35 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

The original code here is wrong, it applies "previous" knowledge.
The way the cpufreq core is designed is that the policy for the
secondary CPU that comes online says that it must in fact not
use this policy but use the same as the other CPUs that are
listed, which in fact is CPU#0.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Paul Mackeras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
 arch/powerpc/platforms/powermac/cpufreq_64.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- wireless-dev.orig/arch/powerpc/platforms/powermac/cpufreq_64.c	2007-05-01 11:35:43.084734191 +0200
+++ wireless-dev/arch/powerpc/platforms/powermac/cpufreq_64.c	2007-05-01 11:36:31.154734191 +0200
@@ -357,13 +357,13 @@ static unsigned int g5_cpufreq_get_speed
 
 static int g5_cpufreq_cpu_init(struct cpufreq_policy *policy)
 {
-	if (policy->cpu != 0)
-		return -ENODEV;
-
 	policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
 	policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
 	policy->cur = g5_cpu_freqs[g5_query_freq()].frequency;
-	policy->cpus = cpu_possible_map;
+	/* secondary CPUs are tied to the primary one by the
+	 * cpufreq core if in the secondary policy we tell it that
+	 * it actually must be one policy together with all others. */
+	policy->cpus = cpu_online_map;
 	cpufreq_frequency_table_get_attr(g5_cpu_freqs, policy->cpu);
 
 	return cpufreq_frequency_table_cpuinfo(policy,

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-02  6:21 ` [PATCH] powermac: support G5 CPU hotplug Johannes Berg
@ 2007-05-02 10:55   ` Paul Mackerras
  2007-05-02 14:33     ` Johannes Berg
  2007-05-02 20:33     ` [PATCH v2] " Johannes Berg
  0 siblings, 2 replies; 78+ messages in thread
From: Paul Mackerras @ 2007-05-02 10:55 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev

Johannes Berg writes:

> This patch allows "hotplugging" of CPUs on G5 machines. CPUs that are
> disabled are put into an idle loop with the decrementer frequency set
> to minimum. To wake them up again we kick them just like when bringing
> them up. To stop those CPUs from messing with any global state we stop
> them from entering the timer interrupt.

Ultimately we want to put the disabled cpus in sleep mode, but that
will require a suitable cache flush routine.

For now, the patch mostly looks OK, except that I would prefer that
you make power4_idle_irqs_softdisabled a separate function from
power4_idle (and choose a better name while you're there :).  There
are enough differences between power4_idle and your new routine that
it would be clearer if they're separate.  For one thing your new
routine wouldn't need to set _TLF_NAPPING, for another, it wouldn't
need the conditional branch at the end.  Also you could do the test
for the nap capability in the caller.

Paul.

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

* Re: [PATCH] via-pmu: remove LED sleep notifier
  2007-05-02  5:36 ` [PATCH] via-pmu: remove LED sleep notifier Johannes Berg
@ 2007-05-02 10:57   ` Stephen Rothwell
  2007-05-02 14:32     ` [PATCH v2] " Johannes Berg
  0 siblings, 1 reply; 78+ messages in thread
From: Stephen Rothwell @ 2007-05-02 10:57 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, Paul Mackerras

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

On Wed, 02 May 2007 07:36:01 +0200 Johannes Berg <johannes@sipsolutions.net> wrote:
>
> --- wireless-dev.orig/drivers/macintosh/via-pmu-led.c	2007-05-01 11:35:45.354734191 +0200
> +++ wireless-dev/drivers/macintosh/via-pmu-led.c	2007-05-01 11:36:25.454734191 +0200
> @@ -31,7 +31,8 @@ static spinlock_t pmu_blink_lock;
>  static struct adb_request pmu_blink_req;
>  /* -1: no change, 0: request off, 1: request on */
>  static int requested_change;
> -static int sleeping;
> +
> +extern int pmu_sys_suspended;

Extern declarations should be in include files.
--
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: patches for 2.6.22
  2007-04-30 19:51 ` patches for 2.6.22 Kim Phillips
  2007-05-01  3:38   ` Paul Mackerras
@ 2007-05-02 14:12   ` Kumar Gala
  2007-05-02 14:19     ` Kim Phillips
  1 sibling, 1 reply; 78+ messages in thread
From: Kumar Gala @ 2007-05-02 14:12 UTC (permalink / raw)
  To: Kim Phillips; +Cc: linuxppc-dev list, Paul Mackerras, jeff Garzik, netdev


On Apr 30, 2007, at 2:51 PM, Kim Phillips wrote:

> On Fri, 27 Apr 2007 21:25:19 +1000
> Paul Mackerras <paulus@samba.org> wrote:
>
>> If anyone has patches that I haven't picked up yet which they think
>> should go into 2.6.22, please send me either a pointer to the
>
> these were missed:
>
> [PATCH 1/4 v5] powerpc: document phy-connection-type property
> Tue Apr 24 07:26:10 EST 2007
> http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034669.html

ok.

> [PATCH 2/4 v4] powerpc: replace undocumented interface properties  
> in dts files
> Tue Apr 24 07:26:14 EST 2007
> http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034670.html

I have issues with this since it looks like the current ucc driver in  
linus's tree is using a previous rev of your patch and thus using  
interface-type and max-speed still.

> [PATCH 3/4] powerpc: Add 'mdio' to bus scan id list for platforms  
> with QE UEC
> Wed Apr 11 07:56:49 EST 2007
> http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034163.html

ok

>
> [PATCH 4/4] powerpc: turn on corresponding PHY drivers in QE UEC  
> platforms defconfigs
> Wed Apr 11 07:56:53 EST 2007
> http://ozlabs.org/pipermail/linuxppc-dev/2007-April/034164.html

ok

I'll pull patches 1, 3, 4 and wait on the dts changes until you sort  
of the ucc driver issues with Jeff.

- k

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

* Re: patches for 2.6.22
  2007-05-02 14:12   ` Kumar Gala
@ 2007-05-02 14:19     ` Kim Phillips
  0 siblings, 0 replies; 78+ messages in thread
From: Kim Phillips @ 2007-05-02 14:19 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, paulus, jeff, netdev

On Wed, 2 May 2007 09:12:36 -0500
Kumar Gala <galak@kernel.crashing.org> wrote:

> 
> I'll pull patches 1, 3, 4 and wait on the dts changes until you sort  
> of the ucc driver issues with Jeff.

sounds good.  I was waiting for the get_property -> of_get_propery
patches for ucc_geth before I submitted the follow-on patch to change
interface-type and remove max-speed.  It's out now, so I can proceed.

Kim

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

* [PATCH v2] via-pmu: remove LED sleep notifier
  2007-05-02 10:57   ` Stephen Rothwell
@ 2007-05-02 14:32     ` Johannes Berg
  2007-05-07  8:47       ` Paul Mackerras
  0 siblings, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-05-02 14:32 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linuxppc-dev, Paul Mackerras

The generic LED code now makes sure that suspended devices don't blink,
so we no longer need to do it ourselves. For the suspend to disk case,
however, we need to make sure that we don't blink if the PMU sysdev
was suspended before the LED device.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
 drivers/macintosh/via-pmu-led.c |   35 +++--------------------------------
 drivers/macintosh/via-pmu.c     |    2 +-
 include/linux/pmu.h             |    3 +++
 3 files changed, 7 insertions(+), 33 deletions(-)

--- wireless-dev.orig/drivers/macintosh/via-pmu-led.c	2007-05-02 10:46:52.289190072 +0200
+++ wireless-dev/drivers/macintosh/via-pmu-led.c	2007-05-02 16:31:37.019177080 +0200
@@ -31,7 +31,6 @@ static spinlock_t pmu_blink_lock;
 static struct adb_request pmu_blink_req;
 /* -1: no change, 0: request off, 1: request on */
 static int requested_change;
-static int sleeping;
 
 static void pmu_req_done(struct adb_request * req)
 {
@@ -41,7 +40,7 @@ static void pmu_req_done(struct adb_requ
 	/* if someone requested a change in the meantime
 	 * (we only see the last one which is fine)
 	 * then apply it now */
-	if (requested_change != -1 && !sleeping)
+	if (requested_change != -1 && !pmu_sys_suspended)
 		pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
 	/* reset requested change */
 	requested_change = -1;
@@ -66,7 +65,7 @@ static void pmu_led_set(struct led_class
 		break;
 	}
 	/* if request isn't done, then don't do anything */
-	if (pmu_blink_req.complete && !sleeping)
+	if (pmu_blink_req.complete && !pmu_sys_suspended)
 		pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
  out:
  	spin_unlock_irqrestore(&pmu_blink_lock, flags);
@@ -80,32 +79,6 @@ static struct led_classdev pmu_led = {
 	.brightness_set = pmu_led_set,
 };
 
-#ifdef CONFIG_PM
-static void pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&pmu_blink_lock, flags);
-
-	switch (when) {
-	case PBOOK_SLEEP_REQUEST:
-		sleeping = 1;
-		break;
-	case PBOOK_WAKE:
-		sleeping = 0;
-		break;
-	default:
-		/* do nothing */
-		break;
-	}
-	spin_unlock_irqrestore(&pmu_blink_lock, flags);
-}
-
-static struct pmu_sleep_notifier via_pmu_led_sleep_notif = {
-	.notifier_call = pmu_led_sleep_call,
-};
-#endif
-
 static int __init via_pmu_led_init(void)
 {
 	struct device_node *dt;
@@ -135,9 +108,7 @@ static int __init via_pmu_led_init(void)
 	/* no outstanding req */
 	pmu_blink_req.complete = 1;
 	pmu_blink_req.done = pmu_req_done;
-#ifdef CONFIG_PM
-	pmu_register_sleep_notifier(&via_pmu_led_sleep_notif);
-#endif
+
 	return led_classdev_register(NULL, &pmu_led);
 }
 
--- wireless-dev.orig/drivers/macintosh/via-pmu.c	2007-05-02 10:46:52.319190072 +0200
+++ wireless-dev/drivers/macintosh/via-pmu.c	2007-05-02 16:30:42.849177080 +0200
@@ -2759,7 +2759,7 @@ pmu_polled_request(struct adb_request *r
 
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 
-static int pmu_sys_suspended;
+int pmu_sys_suspended;
 
 static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
 {
--- wireless-dev.orig/include/linux/pmu.h	2007-05-02 16:30:48.519177080 +0200
+++ wireless-dev/include/linux/pmu.h	2007-05-02 16:31:29.619177080 +0200
@@ -225,4 +225,7 @@ extern unsigned int pmu_power_flags;
 /* Backlight */
 extern void pmu_backlight_init(void);
 
+/* some code needs to know if the PMU was suspended for hibernation */
+extern int pmu_sys_suspended;
+
 #endif	/* __KERNEL__ */

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-02 10:55   ` Paul Mackerras
@ 2007-05-02 14:33     ` Johannes Berg
  2007-05-02 17:57       ` Segher Boessenkool
  2007-05-02 22:03       ` Benjamin Herrenschmidt
  2007-05-02 20:33     ` [PATCH v2] " Johannes Berg
  1 sibling, 2 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-02 14:33 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

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

On Wed, 2007-05-02 at 20:55 +1000, Paul Mackerras wrote:

> Ultimately we want to put the disabled cpus in sleep mode, but that
> will require a suitable cache flush routine.

I don't have any docs for the particular processors the G5s have, do
they have a sleep mode?

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-02 14:33     ` Johannes Berg
@ 2007-05-02 17:57       ` Segher Boessenkool
  2007-05-02 22:03       ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 78+ messages in thread
From: Segher Boessenkool @ 2007-05-02 17:57 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, Paul Mackerras

>> Ultimately we want to put the disabled cpus in sleep mode, but that
>> will require a suitable cache flush routine.
>
> I don't have any docs for the particular processors the G5s have, do
> they have a sleep mode?

Yes; they have many different power saving modes
(doze, nap, deep nap, sleep), and the clock can
be scaled down, too.  The details are different
for each of 970, 970FX, 970MP.

Documentation for 970FX and 970MP is here:
<http://www-306.ibm.com/chips/techlib/techlib.nsf/products/ 
PowerPC_9XX_Microprocessors>


Segher

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

* [PATCH v2] powermac: support G5 CPU hotplug
  2007-05-02 10:55   ` Paul Mackerras
  2007-05-02 14:33     ` Johannes Berg
@ 2007-05-02 20:33     ` Johannes Berg
  1 sibling, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-02 20:33 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

This patch allows "hotplugging" of CPUs on G5 machines. CPUs that are
disabled are put into an idle loop with the decrementer frequency set
to minimum. To wake them up again we kick them just like when bringing
them up. To stop those CPUs from messing with any global state we stop
them from entering the timer interrupt.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
 arch/powerpc/kernel/idle_power4.S       |   21 ++++++++++++
 arch/powerpc/platforms/powermac/setup.c |   52 ++++++++++++++++++++++++++++++--
 arch/powerpc/platforms/powermac/smp.c   |   12 ++++++-
 include/asm-powerpc/machdep.h           |    1 
 4 files changed, 82 insertions(+), 4 deletions(-)

--- wireless-dev.orig/arch/powerpc/platforms/powermac/smp.c	2007-05-02 16:30:42.149177080 +0200
+++ wireless-dev/arch/powerpc/platforms/powermac/smp.c	2007-05-02 16:32:07.629177080 +0200
@@ -900,7 +900,7 @@ void smp_core99_cpu_die(unsigned int cpu
 	cpu_dead[cpu] = 0;
 }
 
-#endif
+#endif /* CONFIG_HOTPLUG_CPU && CONFIG_PP32 */
 
 /* Core99 Macs (dual G4s and G5s) */
 struct smp_ops_t core99_smp_ops = {
@@ -910,8 +910,16 @@ struct smp_ops_t core99_smp_ops = {
 	.setup_cpu	= smp_core99_setup_cpu,
 	.give_timebase	= smp_core99_give_timebase,
 	.take_timebase	= smp_core99_take_timebase,
-#if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PPC32)
+#if defined(CONFIG_HOTPLUG_CPU)
+# if defined(CONFIG_PPC32)
 	.cpu_disable	= smp_core99_cpu_disable,
 	.cpu_die	= smp_core99_cpu_die,
+# endif
+# if defined(CONFIG_PPC64)
+	.cpu_disable	= generic_cpu_disable,
+	.cpu_die	= generic_cpu_die,
+	/* intentionally do *NOT* assign cpu_enable,
+	 * the generic code will use kick_cpu then! */
+# endif
 #endif
 };
--- wireless-dev.orig/arch/powerpc/platforms/powermac/setup.c	2007-05-02 16:30:42.199177080 +0200
+++ wireless-dev/arch/powerpc/platforms/powermac/setup.c	2007-05-02 21:20:43.239175543 +0200
@@ -444,6 +444,9 @@ static int initializing = 1;
 static int pmac_late_init(void)
 {
 	initializing = 0;
+	/* this is udbg (which is __init) and we can later use it during
+	 * cpu hotplug (in smp_core99_kick_cpu) */
+	ppc_md.progress = NULL;
 	return 0;
 }
 
@@ -661,7 +664,52 @@ static int pmac_pci_probe_mode(struct pc
 		return PCI_PROBE_NORMAL;
 	return PCI_PROBE_DEVTREE;
 }
-#endif
+
+#ifdef CONFIG_HOTPLUG_CPU
+/* access per cpu vars from generic smp.c */
+DECLARE_PER_CPU(int, cpu_state);
+
+static void pmac_cpu_die(void)
+{
+	/*
+	 * turn off as much as possible, we'll be
+	 * kicked out as this will only be invoked
+	 * on core99 platforms for now ...
+	 */
+
+	printk(KERN_INFO "CPU#%d offline\n", smp_processor_id());
+	__get_cpu_var(cpu_state) = CPU_DEAD;
+	smp_wmb();
+
+	/*
+	 * during the path that leads here preemption is disabled,
+	 * reenable it now so that when coming up preempt count is
+	 * zero correctly
+	 */
+	preempt_enable();
+
+	/*
+	 * hard-disable interrupts for the non-NAP case, the NAP code
+	 * needs to re-enable interrupts (but soft-disables them)
+	 */
+	hard_irq_disable();
+
+	while (1) {
+		/* let's not take timer interrupts too often ... */
+		set_dec(0x7fffffff);
+
+		/* should always be true at this point */
+		if (cpu_has_feature(CPU_FTR_CAN_NAP))
+			power4_cpu_offline_powersave();
+		else {
+			HMT_low();
+			HMT_very_low();
+		}
+	}
+}
+#endif /* CONFIG_HOTPLUG_CPU */
+
+#endif /* CONFIG_PPC64 */
 
 define_machine(powermac) {
 	.name			= "PowerMac",
@@ -698,6 +746,6 @@ define_machine(powermac) {
 	.phys_mem_access_prot	= pci_phys_mem_access_prot,
 #endif
 #if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PPC64)
-	.cpu_die		= generic_mach_cpu_die,
+	.cpu_die		= pmac_cpu_die,
 #endif
 };
--- wireless-dev.orig/arch/powerpc/kernel/idle_power4.S	2007-05-02 16:30:42.229177080 +0200
+++ wireless-dev/arch/powerpc/kernel/idle_power4.S	2007-05-02 16:47:02.219177080 +0200
@@ -53,3 +53,24 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 	isync
 	b	1b
 
+_GLOBAL(power4_cpu_offline_powersave)
+	/* Go to NAP now */
+	mfmsr	r7
+	rldicl	r0,r7,48,1
+	rotldi	r0,r0,16
+	mtmsrd	r0,1			/* hard-disable interrupts */
+	li	r0,1
+	li	r6,0
+	stb	r0,PACAHARDIRQEN(r13)	/* we'll hard-enable shortly */
+	stb	r6,PACASOFTIRQEN(r13)	/* soft-disable irqs */
+BEGIN_FTR_SECTION
+	DSSALL
+	sync
+END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
+	ori	r7,r7,MSR_EE
+	oris	r7,r7,MSR_POW@h
+	sync
+	isync
+	mtmsrd	r7
+	isync
+	blr
--- wireless-dev.orig/include/asm-powerpc/machdep.h	2007-05-02 16:30:42.299177080 +0200
+++ wireless-dev/include/asm-powerpc/machdep.h	2007-05-02 21:20:10.449175543 +0200
@@ -248,6 +248,7 @@ struct machdep_calls {
 };
 
 extern void power4_idle(void);
+extern void power4_cpu_offline_powersave(void);
 extern void ppc6xx_idle(void);
 
 /*

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-02 14:33     ` Johannes Berg
  2007-05-02 17:57       ` Segher Boessenkool
@ 2007-05-02 22:03       ` Benjamin Herrenschmidt
  2007-05-02 23:47         ` Segher Boessenkool
  2007-05-03  0:01         ` Paul Mackerras
  1 sibling, 2 replies; 78+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-02 22:03 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, Paul Mackerras

On Wed, 2007-05-02 at 16:33 +0200, Johannes Berg wrote:
> On Wed, 2007-05-02 at 20:55 +1000, Paul Mackerras wrote:
> 
> > Ultimately we want to put the disabled cpus in sleep mode, but that
> > will require a suitable cache flush routine.
> 
> I don't have any docs for the particular processors the G5s have, do
> they have a sleep mode?

They have, but the cache flush is not trivial to do (and might imply
access to non documented bits). So let's put that on the to-do list and
stick to NAP for now while I dig something.

Ben.

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-02 22:03       ` Benjamin Herrenschmidt
@ 2007-05-02 23:47         ` Segher Boessenkool
  2007-05-02 23:59           ` Benjamin Herrenschmidt
  2007-05-03  0:01         ` Paul Mackerras
  1 sibling, 1 reply; 78+ messages in thread
From: Segher Boessenkool @ 2007-05-02 23:47 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Johannes Berg, Paul Mackerras

>> I don't have any docs for the particular processors the G5s have, do
>> they have a sleep mode?
>
> They have, but the cache flush is not trivial to do (and might imply
> access to non documented bits).

It is (publicly) documented just fine :-)


Segher

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-02 23:47         ` Segher Boessenkool
@ 2007-05-02 23:59           ` Benjamin Herrenschmidt
  2007-05-03  0:05             ` Segher Boessenkool
  0 siblings, 1 reply; 78+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-02 23:59 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev, Johannes Berg, Paul Mackerras

On Thu, 2007-05-03 at 01:47 +0200, Segher Boessenkool wrote:
> >> I don't have any docs for the particular processors the G5s have, do
> >> they have a sleep mode?
> >
> > They have, but the cache flush is not trivial to do (and might imply
> > access to non documented bits).
> 
> It is (publicly) documented just fine :-)

Ah good... you happen to have a pointer ? Last I looked, it wasn't ...

Ben.

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-02 22:03       ` Benjamin Herrenschmidt
  2007-05-02 23:47         ` Segher Boessenkool
@ 2007-05-03  0:01         ` Paul Mackerras
  2007-05-03  0:08           ` Benjamin Herrenschmidt
  2007-05-03  0:17           ` Segher Boessenkool
  1 sibling, 2 replies; 78+ messages in thread
From: Paul Mackerras @ 2007-05-03  0:01 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Johannes Berg

Benjamin Herrenschmidt writes:

> On Wed, 2007-05-02 at 16:33 +0200, Johannes Berg wrote:
> > On Wed, 2007-05-02 at 20:55 +1000, Paul Mackerras wrote:
> > 
> > > Ultimately we want to put the disabled cpus in sleep mode, but that
> > > will require a suitable cache flush routine.
> > 
> > I don't have any docs for the particular processors the G5s have, do
> > they have a sleep mode?
> 
> They have, but the cache flush is not trivial to do (and might imply
> access to non documented bits). So let's put that on the to-do list and
> stick to NAP for now while I dig something.

Hmmm, I went looking in the 970FX manual for sleep mode and didn't
find it, only nap and doze...

Paul.

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-02 23:59           ` Benjamin Herrenschmidt
@ 2007-05-03  0:05             ` Segher Boessenkool
  2007-05-03  0:18               ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 78+ messages in thread
From: Segher Boessenkool @ 2007-05-03  0:05 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Johannes Berg, Paul Mackerras

>>> They have, but the cache flush is not trivial to do (and might imply
>>> access to non documented bits).
>>
>> It is (publicly) documented just fine :-)
>
> Ah good... you happen to have a pointer ? Last I looked, it wasn't ...

It's in the UM, search for "L2 cache flush".


Segher

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-03  0:01         ` Paul Mackerras
@ 2007-05-03  0:08           ` Benjamin Herrenschmidt
  2007-05-03  0:10             ` Benjamin Herrenschmidt
  2007-05-03  0:19             ` Segher Boessenkool
  2007-05-03  0:17           ` Segher Boessenkool
  1 sibling, 2 replies; 78+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-03  0:08 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, Johannes Berg

On Thu, 2007-05-03 at 10:01 +1000, Paul Mackerras wrote:
> Benjamin Herrenschmidt writes:
> 
> > On Wed, 2007-05-02 at 16:33 +0200, Johannes Berg wrote:
> > > On Wed, 2007-05-02 at 20:55 +1000, Paul Mackerras wrote:
> > > 
> > > > Ultimately we want to put the disabled cpus in sleep mode, but that
> > > > will require a suitable cache flush routine.
> > > 
> > > I don't have any docs for the particular processors the G5s have, do
> > > they have a sleep mode?
> > 
> > They have, but the cache flush is not trivial to do (and might imply
> > access to non documented bits). So let's put that on the to-do list and
> > stick to NAP for now while I dig something.
> 
> Hmmm, I went looking in the 970FX manual for sleep mode and didn't
> find it, only nap and doze...

Ah... hrm... so it's possible that Darwin goes NAP but flushes the cache
before suspend-to-ram bcs the CPU is going down... let me check.

Nah, darwin uses HID0:sleep

Ben.

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-03  0:08           ` Benjamin Herrenschmidt
@ 2007-05-03  0:10             ` Benjamin Herrenschmidt
  2007-05-03  0:19             ` Segher Boessenkool
  1 sibling, 0 replies; 78+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-03  0:10 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, Johannes Berg


> Ah... hrm... so it's possible that Darwin goes NAP but flushes the cache
> before suspend-to-ram bcs the CPU is going down... let me check.
> 
> Nah, darwin uses HID0:sleep

Ahhh nooo .... there's a special code path for 64 bits CPUs and indeed,
it uses NAP.

Ben.

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-03  0:01         ` Paul Mackerras
  2007-05-03  0:08           ` Benjamin Herrenschmidt
@ 2007-05-03  0:17           ` Segher Boessenkool
  2007-05-03  0:21             ` Benjamin Herrenschmidt
  1 sibling, 1 reply; 78+ messages in thread
From: Segher Boessenkool @ 2007-05-03  0:17 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, Johannes Berg

>>>> Ultimately we want to put the disabled cpus in sleep mode, but that
>>>> will require a suitable cache flush routine.
>>>
>>> I don't have any docs for the particular processors the G5s have, do
>>> they have a sleep mode?
>>
>> They have, but the cache flush is not trivial to do (and might imply
>> access to non documented bits). So let's put that on the to-do list 
>> and
>> stick to NAP for now while I dig something.
>
> Hmmm, I went looking in the 970FX manual for sleep mode and didn't
> find it, only nap and doze...

"Sleep" is a generic term for both "doze" and "nap", heh.

The difference between doze and nap is that in nap mode
the bus interface unit is switched off; on the 970 and
970FX this means that the L2 cache has to be flushed
before entering nap mode (or otherwise snoops will go
missing in action); the 970MP automatically transitions
from nap to doze mode if snoops are requested (and back
to nap again), so no L2 flush is required.  The 970MP
also has a "deep nap" mode which saves more power by
automatically clocking the CPU down.

One more thing -- perhaps keeping the CPU in reset
state saves even more power?


Segher

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-03  0:05             ` Segher Boessenkool
@ 2007-05-03  0:18               ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 78+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-03  0:18 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev, Johannes Berg, Paul Mackerras

On Thu, 2007-05-03 at 02:05 +0200, Segher Boessenkool wrote:
> >>> They have, but the cache flush is not trivial to do (and might imply
> >>> access to non documented bits).
> >>
> >> It is (publicly) documented just fine :-)
> >
> > Ah good... you happen to have a pointer ? Last I looked, it wasn't ...
> 
> It's in the UM, search for "L2 cache flush".

Ah yes, it's there for recent UM.

So, to summarize:

 - 970 only does NAP, not SLEEP

 - We should probably still flush the cache when bringing a CPU down
   because we might implement STR in which case the machine will go
   down and we won't get a chance to flush that CPU cache then.

Also, I always wondered what happened if you entered NAP without MSR:EE,
and so I checked the 970 UM and it's clearly undefined behaviour. Thus
we must make sure we always set EE, and we can "use" the trick of having
soft-disable to just return where we came from and re-enter NAP if we
got woken up by the DEC. I agree with Paulus, Johannes, we should just
do a separate routine for the CPU going down vs. Idle. Among others,
we'll also add the cache flush there.

Cheers,
Ben.

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-03  0:08           ` Benjamin Herrenschmidt
  2007-05-03  0:10             ` Benjamin Herrenschmidt
@ 2007-05-03  0:19             ` Segher Boessenkool
  1 sibling, 0 replies; 78+ messages in thread
From: Segher Boessenkool @ 2007-05-03  0:19 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Johannes Berg, Paul Mackerras

> Ah... hrm... so it's possible that Darwin goes NAP but flushes the 
> cache
> before suspend-to-ram bcs the CPU is going down... let me check.
>
> Nah, darwin uses HID0:sleep

Which bit # is that?  I cannot find it :-)


Segher

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-03  0:17           ` Segher Boessenkool
@ 2007-05-03  0:21             ` Benjamin Herrenschmidt
  2007-05-03  0:24               ` Benjamin Herrenschmidt
  2007-05-03  1:01               ` Segher Boessenkool
  0 siblings, 2 replies; 78+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-03  0:21 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev, Johannes Berg, Paul Mackerras


> The difference between doze and nap is that in nap mode
> the bus interface unit is switched off; on the 970 and
> 970FX this means that the L2 cache has to be flushed
> before entering nap mode (or otherwise snoops will go
> missing in action); 

BZZZT... incorrect... the 970FX and MP behave the same here. There is
only one state you can "manually" enter and it's NAP. Transitions
between DOZE and NAP are automatic to handle snooping in both cases.
Cache flushing is never needed ... unless in our case the CPU gets
actually powered down for suspend-to-ram.

> the 970MP automatically transitions
> from nap to doze mode if snoops are requested (and back
> to nap again), so no L2 flush is required.  The 970MP
> also has a "deep nap" mode which saves more power by
> automatically clocking the CPU down.

Also deep nap only really works on 970MP DD3 and later I think

> One more thing -- perhaps keeping the CPU in reset
> state saves even more power?

Dunno... Somebody can try... but I don't think we have access to the
reset line on 970's..

Ben.

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-03  0:21             ` Benjamin Herrenschmidt
@ 2007-05-03  0:24               ` Benjamin Herrenschmidt
  2007-05-03  1:01               ` Segher Boessenkool
  1 sibling, 0 replies; 78+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-03  0:24 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev, Johannes Berg, Paul Mackerras

On Thu, 2007-05-03 at 10:21 +1000, Benjamin Herrenschmidt wrote:
> > The difference between doze and nap is that in nap mode
> > the bus interface unit is switched off; on the 970 and
> > 970FX this means that the L2 cache has to be flushed
> > before entering nap mode (or otherwise snoops will go
> > missing in action); 
> 
> BZZZT... incorrect... the 970FX and MP behave the same here. There is
> only one state you can "manually" enter and it's NAP. 

Actually, I'm not totally correct here neither, that's what 745x does...
the 970 _do_ give manual access to DOZE. But the rest is still true, it
will transition automatically to do snoops.

> Transitions
> between DOZE and NAP are automatic to handle snooping in both cases.
> Cache flushing is never needed ... unless in our case the CPU gets
> actually powered down for suspend-to-ram.
> 
> > the 970MP automatically transitions
> > from nap to doze mode if snoops are requested (and back
> > to nap again), so no L2 flush is required.  The 970MP
> > also has a "deep nap" mode which saves more power by
> > automatically clocking the CPU down.
> 
> Also deep nap only really works on 970MP DD3 and later I think
> 
> > One more thing -- perhaps keeping the CPU in reset
> > state saves even more power?
> 
> Dunno... Somebody can try... but I don't think we have access to the
> reset line on 970's..
> 
> Ben.
> 
> 

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-03  0:21             ` Benjamin Herrenschmidt
  2007-05-03  0:24               ` Benjamin Herrenschmidt
@ 2007-05-03  1:01               ` Segher Boessenkool
  2007-05-03  2:11                 ` Benjamin Herrenschmidt
  1 sibling, 1 reply; 78+ messages in thread
From: Segher Boessenkool @ 2007-05-03  1:01 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Johannes Berg, Paul Mackerras

>> The difference between doze and nap is that in nap mode
>> the bus interface unit is switched off; on the 970 and
>> 970FX this means that the L2 cache has to be flushed
>> before entering nap mode (or otherwise snoops will go
>> missing in action);
>
> BZZZT... incorrect... the 970FX and MP behave the same here.

Yeah I goofed here -- cache flush is only required if
you take a CPU offline.

> There is
> only one state you can "manually" enter and it's NAP.

BZZZT... incorrect... you can "manually" switch to
all of doze, nap, and deep nap.

> Transitions
> between DOZE and NAP are automatic to handle snooping in both cases.
> Cache flushing is never needed ... unless in our case the CPU gets
> actually powered down for suspend-to-ram.

Yeah.  Or to hot-unplug it ;-)

>> the 970MP automatically transitions
>> from nap to doze mode if snoops are requested (and back
>> to nap again), so no L2 flush is required.  The 970MP
>> also has a "deep nap" mode which saves more power by
>> automatically clocking the CPU down.
>
> Also deep nap only really works on 970MP DD3 and later I think

Yes, we put that knowledge into the kernel already.

>> One more thing -- perhaps keeping the CPU in reset
>> state saves even more power?
>
> Dunno... Somebody can try... but I don't think we have access to the
> reset line on 970's..

Isn't it just a GPIO, like on older Macs?  Of course, we
cannot bring a CPU back online after doing that so it's
pretty useless I suppose.


Segher

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-03  1:01               ` Segher Boessenkool
@ 2007-05-03  2:11                 ` Benjamin Herrenschmidt
  2007-05-03 16:49                   ` Segher Boessenkool
  0 siblings, 1 reply; 78+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-03  2:11 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev, Johannes Berg, Paul Mackerras


> Isn't it just a GPIO, like on older Macs?  Of course, we
> cannot bring a CPU back online after doing that so it's
> pretty useless I suppose.

We don't know for sure what the gpio does... wether it does a CPU soft
reset or tickles the SPU to make it do special things that cause us to
branch at 0x100. We do get the CPU back after that though. We use that
to bring them in after boot.

Ben.

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

* Re: patches for 2.6.22
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (14 preceding siblings ...)
  2007-05-02  6:35 ` [PATCH] powermac: fix G5-cpufreq for cpu on/offline Johannes Berg
@ 2007-05-03 12:25 ` Johannes Berg
  2007-05-03 12:28   ` [PATCH] powerpc: dart iommu suspend Johannes Berg
                     ` (2 more replies)
  2007-07-17 13:28 ` [PATCH] remove awacs dmasound Johannes Berg
  16 siblings, 3 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-03 12:25 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

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

Hi,

I'll reply to this message with 3 more patches that I will send as soon
as akpm sends Rafael's swsusp patches from -mm to Linus. Please take a
look anyway, only some register_nosave_region{_late,}() calls are in
these patches that are not possible yet.

I'd love to have the G5 suspend merged even though nvidiafb still breaks
it, I do think it's a bug in nvidiafb and not the generic code.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* [PATCH] powerpc: dart iommu suspend
  2007-05-03 12:25 ` patches for 2.6.22 Johannes Berg
@ 2007-05-03 12:28   ` Johannes Berg
  2007-05-03 12:30     ` Benjamin Herrenschmidt
  2007-05-03 12:29   ` [PATCH] powerpc: mark pages that don't exist as nosave Johannes Berg
  2007-05-03 12:31   ` [PATCH] powermac: suspend to disk on G5 Johannes Berg
  2 siblings, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-05-03 12:28 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Olof Johansson, linuxppc-dev

This implements save and restore hooks for IOMMUs and implements
it the dart iommu.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Paul Mackeras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Olof Johansson <olof@lixom.net>

---
 arch/powerpc/sysdev/dart_iommu.c |   46 +++++++++++++++++++++++++++++++++++++++
 include/asm-powerpc/iommu.h      |   14 +++++++++++
 include/asm-powerpc/machdep.h    |    5 ++++
 3 files changed, 65 insertions(+)

--- wireless-dev.orig/arch/powerpc/sysdev/dart_iommu.c	2007-05-03 14:20:26.089165535 +0200
+++ wireless-dev/arch/powerpc/sysdev/dart_iommu.c	2007-05-03 14:21:08.889165535 +0200
@@ -36,6 +36,7 @@
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
 #include <linux/vmalloc.h>
+#include <linux/suspend.h>
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/iommu.h>
@@ -54,6 +55,9 @@ static unsigned long dart_tablesize;
 
 /* Virtual base address of the DART table */
 static u32 *dart_vbase;
+#ifdef CONFIG_PM
+static u32 *dart_copy;
+#endif
 
 /* Mapped base address for the dart */
 static unsigned int __iomem *dart;
@@ -346,6 +350,48 @@ void iommu_init_early_dart(void)
 	set_pci_dma_ops(&dma_direct_ops);
 }
 
+#ifdef CONFIG_PM
+static void iommu_dart_save(void)
+{
+	memcpy(dart_copy, dart_vbase, 2*1024*1024);
+}
+
+static void iommu_dart_restore(void)
+{
+	memcpy(dart_vbase, dart_copy, 2*1024*1024);
+	dart_tlb_invalidate_all();
+}
+
+static int __init iommu_init_late_dart(void)
+{
+	unsigned long tbasepfn;
+	struct page *p;
+
+	/* if no dart table exists then we won't need to save it
+	 * and the area has also not been reserved */
+	if (!dart_tablebase)
+		return 0;
+
+	tbasepfn = __pa(dart_tablebase) >> PAGE_SHIFT;
+	register_nosave_region_late(tbasepfn,
+				    tbasepfn + ((1<<24) >> PAGE_SHIFT));
+
+	/* For suspend we need to copy the dart contents because
+	 * it is not part of the regular mapping (see above) and
+	 * thus not saved automatically. The memory for this copy
+	 * must be allocated early because we need 2 MB. */
+	p = alloc_pages(GFP_KERNEL, 21 - PAGE_SHIFT);
+	BUG_ON(!p);
+	dart_copy = page_address(p);
+
+	ppc_md.iommu_save = iommu_dart_save;
+	ppc_md.iommu_restore = iommu_dart_restore;
+
+	return 0;
+}
+
+late_initcall(iommu_init_late_dart);
+#endif
 
 void __init alloc_dart_table(void)
 {
--- wireless-dev.orig/include/asm-powerpc/iommu.h	2007-05-03 14:20:26.109165535 +0200
+++ wireless-dev/include/asm-powerpc/iommu.h	2007-05-03 14:21:08.889165535 +0200
@@ -26,6 +26,7 @@
 #include <linux/spinlock.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
+#include <asm/machdep.h>
 #include <asm/types.h>
 #include <asm/bitops.h>
 
@@ -109,6 +110,19 @@ static inline void pci_iommu_init(void) 
 #endif
 
 extern void alloc_dart_table(void);
+#if defined(CONFIG_PPC64) && defined(CONFIG_PM)
+static inline void iommu_save(void)
+{
+	if (ppc_md.iommu_save)
+		ppc_md.iommu_save();
+}
+
+static inline void iommu_restore(void)
+{
+	if (ppc_md.iommu_restore)
+		ppc_md.iommu_restore();
+}
+#endif
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_IOMMU_H */
--- wireless-dev.orig/include/asm-powerpc/machdep.h	2007-05-03 14:21:07.569165535 +0200
+++ wireless-dev/include/asm-powerpc/machdep.h	2007-05-03 14:21:08.899165535 +0200
@@ -91,6 +91,11 @@ struct machdep_calls {
 	void __iomem *	(*ioremap)(phys_addr_t addr, unsigned long size,
 				   unsigned long flags);
 	void		(*iounmap)(volatile void __iomem *token);
+
+#ifdef CONFIG_PM
+	void		(*iommu_save)(void);
+	void		(*iommu_restore)(void);
+#endif
 #endif /* CONFIG_PPC64 */
 
 	int		(*probe)(void);

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

* [PATCH] powerpc: mark pages that don't exist as nosave
  2007-05-03 12:25 ` patches for 2.6.22 Johannes Berg
  2007-05-03 12:28   ` [PATCH] powerpc: dart iommu suspend Johannes Berg
@ 2007-05-03 12:29   ` Johannes Berg
  2007-05-03 12:31   ` [PATCH] powermac: suspend to disk on G5 Johannes Berg
  2 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-03 12:29 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

On some powerpc architectures (notably 64-bit powermac) there is a memory
hole, for example on powermacs between 2G and 4G. Since we use the flat
memory model regardless, these pages must be marked as nosave (for suspend
to disk.)

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Rafael J. Wysocki <rjw@sisk.pl>

---
Tested on powerbook and G5 powermac.

---
 arch/powerpc/mm/mem.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

--- wireless-dev.orig/arch/powerpc/mm/mem.c	2007-05-03 14:20:25.959165535 +0200
+++ wireless-dev/arch/powerpc/mm/mem.c	2007-05-03 14:21:09.659165535 +0200
@@ -31,6 +31,7 @@
 #include <linux/highmem.h>
 #include <linux/initrd.h>
 #include <linux/pagemap.h>
+#include <linux/suspend.h>
 
 #include <asm/pgalloc.h>
 #include <asm/prom.h>
@@ -277,6 +278,28 @@ void __init do_init_bootmem(void)
 	init_bootmem_done = 1;
 }
 
+/* mark pages that don't exist as nosave */
+static int __init mark_nonram_nosave(void)
+{
+	unsigned long lmb_next_region_start_pfn,
+		      lmb_region_max_pfn;
+	int i;
+
+	for (i = 0; i < lmb.memory.cnt - 1; i++) {
+		lmb_region_max_pfn =
+			(lmb.memory.region[i].base >> PAGE_SHIFT) +
+			(lmb.memory.region[i].size >> PAGE_SHIFT);
+		lmb_next_region_start_pfn =
+			lmb.memory.region[i+1].base >> PAGE_SHIFT;
+
+		if (lmb_region_max_pfn < lmb_next_region_start_pfn)
+			register_nosave_region(lmb_region_max_pfn,
+					       lmb_next_region_start_pfn);
+	}
+
+	return 0;
+}
+
 /*
  * paging_init() sets up the page tables - in fact we've already done this.
  */
@@ -308,6 +331,8 @@ void __init paging_init(void)
 	max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
 #endif
 	free_area_init_nodes(max_zone_pfns);
+
+	mark_nonram_nosave();
 }
 #endif /* ! CONFIG_NEED_MULTIPLE_NODES */
 

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

* Re: [PATCH] powerpc: dart iommu suspend
  2007-05-03 12:28   ` [PATCH] powerpc: dart iommu suspend Johannes Berg
@ 2007-05-03 12:30     ` Benjamin Herrenschmidt
  2007-05-03 12:34       ` Johannes Berg
  2007-05-03 12:48       ` Johannes Berg
  0 siblings, 2 replies; 78+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-03 12:30 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Olof Johansson, linuxppc-dev, Paul Mackerras

On Thu, 2007-05-03 at 14:28 +0200, Johannes Berg wrote:
> This implements save and restore hooks for IOMMUs and implements
> it the dart iommu.

Paul and I have been discussing a possible better way to handle that ...

We could just make the DART pages CI in the linear mapping rather than
not mapping it. That would make it "just work" with the normal code
path.

Ben.

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

* [PATCH] powermac: suspend to disk on G5
  2007-05-03 12:25 ` patches for 2.6.22 Johannes Berg
  2007-05-03 12:28   ` [PATCH] powerpc: dart iommu suspend Johannes Berg
  2007-05-03 12:29   ` [PATCH] powerpc: mark pages that don't exist as nosave Johannes Berg
@ 2007-05-03 12:31   ` Johannes Berg
  2 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-03 12:31 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

Powermac G5 suspend to disk implementation. The code is platform
agnostic but only tested on powermac, no other 64-bit powerpc
machines.

Because nvidiafb still breaks suspend I have marked it EXPERIMENTAL on
powermac and because I can't test it and some lowlevel code will need
changes it is BROKEN on all other 64-bit platforms.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
WARNING: nvidiafb breaks suspend. I don't know why yet, but if it is
compiled and you try to suspend from X it all just freezes. The nvidiafb
suspend code looks a bit fishy but I shall have to understand first what
it's trying to achieve.

Other than that I'm really happy with this, it's good to finally be able to
hibernate the machine instead of keeping it up or shutting it down.

Tested on my powermac with forced preemption enabled.

---
 arch/powerpc/Kconfig               |    5 
 arch/powerpc/kernel/Makefile       |    1 
 arch/powerpc/kernel/asm-offsets.c  |    4 
 arch/powerpc/kernel/idle.c         |    5 
 arch/powerpc/kernel/swsusp.c       |    9 +
 arch/powerpc/kernel/swsusp_64.c    |   24 +++
 arch/powerpc/kernel/swsusp_asm64.S |  228 +++++++++++++++++++++++++++++++++++++
 include/linux/suspend.h            |    2 
 kernel/power/Kconfig               |    4 
 9 files changed, 276 insertions(+), 6 deletions(-)

--- wireless-dev.orig/arch/powerpc/kernel/Makefile	2007-05-03 14:21:02.139165535 +0200
+++ wireless-dev/arch/powerpc/kernel/Makefile	2007-05-03 14:21:10.859165535 +0200
@@ -38,6 +38,7 @@ obj-$(CONFIG_6xx)		+= idle_6xx.o l2cr_6x
 obj-$(CONFIG_TAU)		+= tau_6xx.o
 obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o
 obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o
+obj64-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_64.o swsusp_asm64.o
 obj32-$(CONFIG_MODULES)		+= module_32.o
 
 ifeq ($(CONFIG_PPC_MERGE),y)
--- wireless-dev.orig/kernel/power/Kconfig	2007-05-03 14:20:25.629165535 +0200
+++ wireless-dev/kernel/power/Kconfig	2007-05-03 14:21:10.869165535 +0200
@@ -79,7 +79,7 @@ config PM_SYSFS_DEPRECATED
 
 config SOFTWARE_SUSPEND
 	bool "Software Suspend"
-	depends on PM && SWAP && ((X86 && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP))
+	depends on PM && SWAP && (((X86 || PPC64_SWSUSP) && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP))
 	---help---
 	  Enable the suspend to disk (STD) functionality.
 
@@ -134,7 +134,7 @@ config PM_STD_PARTITION
 
 config SUSPEND_SMP
 	bool
-	depends on HOTPLUG_CPU && X86 && PM
+	depends on HOTPLUG_CPU && (X86 || PPC64) && PM
 	default y
 
 config APM_EMULATION
--- wireless-dev.orig/include/linux/suspend.h	2007-05-03 14:21:06.929165535 +0200
+++ wireless-dev/include/linux/suspend.h	2007-05-03 14:21:10.869165535 +0200
@@ -1,7 +1,7 @@
 #ifndef _LINUX_SWSUSP_H
 #define _LINUX_SWSUSP_H
 
-#if defined(CONFIG_X86) || defined(CONFIG_FRV) || defined(CONFIG_PPC32)
+#if defined(CONFIG_X86) || defined(CONFIG_FRV) || defined(CONFIG_PPC32) || defined(CONFIG_PPC64)
 #include <asm/suspend.h>
 #endif
 #include <linux/swap.h>
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/arch/powerpc/kernel/swsusp_64.c	2007-05-03 14:21:10.869165535 +0200
@@ -0,0 +1,24 @@
+/*
+ * PowerPC 64-bit swsusp implementation
+ *
+ * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * GPLv2
+ */
+
+#include <asm/system.h>
+#include <asm/iommu.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+
+void do_after_copyback(void)
+{
+	iommu_restore();
+	touch_softlockup_watchdog();
+	mb();
+}
+
+void _iommu_save(void)
+{
+	iommu_save();
+}
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/arch/powerpc/kernel/swsusp_asm64.S	2007-05-03 14:21:10.869165535 +0200
@@ -0,0 +1,228 @@
+/*
+ * PowerPC 64-bit swsusp implementation
+ *
+ * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * GPLv2
+ */
+
+#include <linux/threads.h>
+#include <asm/processor.h>
+#include <asm/page.h>
+#include <asm/cputable.h>
+#include <asm/thread_info.h>
+#include <asm/ppc_asm.h>
+#include <asm/asm-offsets.h>
+
+/*
+ * Structure for storing CPU registers on the save area.
+ */
+#define SL_r1		0x00	/* stack pointer */
+#define SL_PC		0x08
+#define SL_MSR		0x10
+#define SL_SDR1		0x18
+#define SL_XER		0x20
+#define SL_TB		0x40
+#define SL_r2		0x48
+#define SL_CR		0x50
+#define SL_LR		0x58
+#define SL_r12		0x60
+#define SL_r13		0x68
+#define SL_r14		0x70
+#define SL_r15		0x78
+#define SL_r16		0x80
+#define SL_r17		0x88
+#define SL_r18		0x90
+#define SL_r19		0x98
+#define SL_r20		0xa0
+#define SL_r21		0xa8
+#define SL_r22		0xb0
+#define SL_r23		0xb8
+#define SL_r24		0xc0
+#define SL_r25		0xc8
+#define SL_r26		0xd0
+#define SL_r27		0xd8
+#define SL_r28		0xe0
+#define SL_r29		0xe8
+#define SL_r30		0xf0
+#define SL_r31		0xf8
+#define SL_SIZE		SL_r31+8
+
+/* these macros rely on the save area being
+ * pointed to by r11 */
+#define SAVE_SPECIAL(special)		\
+	mf##special	r0		;\
+	std	r0, SL_##special(r11)
+#define RESTORE_SPECIAL(special)	\
+	ld	r0, SL_##special(r11)	;\
+	mt##special	r0
+#define SAVE_REGISTER(reg)		\
+	std	reg, SL_##reg(r11)
+#define RESTORE_REGISTER(reg)		\
+	ld	reg, SL_##reg(r11)
+
+/* space for storing cpu state */
+	.section .data
+	.align  5
+swsusp_save_area:
+	.space SL_SIZE
+
+	.section ".toc","aw"
+swsusp_save_area_ptr:
+	.tc	swsusp_save_area[TC],swsusp_save_area
+restore_pblist_ptr:
+	.tc	restore_pblist[TC],restore_pblist
+
+	.section .text
+	.align  5
+_GLOBAL(swsusp_arch_suspend)
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+	SAVE_SPECIAL(LR)
+	SAVE_REGISTER(r1)
+	SAVE_SPECIAL(CR)
+	SAVE_SPECIAL(TB)
+	SAVE_REGISTER(r2)
+	SAVE_REGISTER(r12)
+	SAVE_REGISTER(r13)
+	SAVE_REGISTER(r14)
+	SAVE_REGISTER(r15)
+	SAVE_REGISTER(r16)
+	SAVE_REGISTER(r17)
+	SAVE_REGISTER(r18)
+	SAVE_REGISTER(r19)
+	SAVE_REGISTER(r20)
+	SAVE_REGISTER(r21)
+	SAVE_REGISTER(r22)
+	SAVE_REGISTER(r23)
+	SAVE_REGISTER(r24)
+	SAVE_REGISTER(r25)
+	SAVE_REGISTER(r26)
+	SAVE_REGISTER(r27)
+	SAVE_REGISTER(r28)
+	SAVE_REGISTER(r29)
+	SAVE_REGISTER(r30)
+	SAVE_REGISTER(r31)
+	SAVE_SPECIAL(MSR)
+	SAVE_SPECIAL(SDR1)
+	SAVE_SPECIAL(XER)
+
+	/* we push the stack up 128 bytes but don't store the
+	 * stack pointer on the stack like a real stackframe */
+	addi	r1,r1,-128
+
+	bl _iommu_save
+	bl swsusp_save
+
+	/* restore LR */
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+	RESTORE_SPECIAL(LR)
+	addi	r1,r1,128
+
+	blr
+
+/* Resume code */
+_GLOBAL(swsusp_arch_resume)
+	/* Stop pending alitvec streams and memory accesses */
+BEGIN_FTR_SECTION
+	DSSALL
+END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
+	sync
+
+	ld	r12,restore_pblist_ptr@toc(r2)
+	ld	r12,0(r12)
+
+	cmpdi	r12,0
+	beq-	nothing_to_copy
+	li	r15,512
+copyloop:
+	ld	r13,pbe_address(r12)
+	ld	r14,pbe_orig_address(r12)
+
+	mtctr	r15
+	li	r10,0
+copy_page_loop:
+	ldx	r0,r10,r13
+	stdx	r0,r10,r14
+	addi	r10,r10,8
+	bdnz copy_page_loop
+
+	ld	r12,pbe_next(r12)
+	cmpdi	r12,0
+	bne+	copyloop
+nothing_to_copy:
+
+	/* flush caches */
+	lis	r3, 0x10
+	mtctr	r3
+	li	r3, 0
+	ori	r3, r3, CONFIG_KERNEL_START>>48
+	li	r0, 48
+	sld	r3, r3, r0
+	li	r0, 0
+1:
+	dcbf	r0,r3
+	addi	r3,r3,0x20
+	bdnz	1b
+
+	sync
+
+	tlbia
+
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+
+	RESTORE_SPECIAL(CR)
+
+	/* restore timebase */
+	/* load saved tb */
+	ld	r1, SL_TB(r11)
+	/* get upper 32 bits of it */
+	srdi	r2, r1, 32
+	/* clear tb lower to avoid wrap */
+	li	r0, 0
+	mttbl	r0
+	/* set tb upper */
+	mttbu	r2
+	/* set tb lower */
+	mttbl	r1
+
+	/* restore registers */
+	RESTORE_REGISTER(r1)
+	RESTORE_REGISTER(r2)
+	RESTORE_REGISTER(r12)
+	RESTORE_REGISTER(r13)
+	RESTORE_REGISTER(r14)
+	RESTORE_REGISTER(r15)
+	RESTORE_REGISTER(r16)
+	RESTORE_REGISTER(r17)
+	RESTORE_REGISTER(r18)
+	RESTORE_REGISTER(r19)
+	RESTORE_REGISTER(r20)
+	RESTORE_REGISTER(r21)
+	RESTORE_REGISTER(r22)
+	RESTORE_REGISTER(r23)
+	RESTORE_REGISTER(r24)
+	RESTORE_REGISTER(r25)
+	RESTORE_REGISTER(r26)
+	RESTORE_REGISTER(r27)
+	RESTORE_REGISTER(r28)
+	RESTORE_REGISTER(r29)
+	RESTORE_REGISTER(r30)
+	RESTORE_REGISTER(r31)
+	/* can't use RESTORE_SPECIAL(MSR) */
+	ld	r0, SL_MSR(r11)
+	mtmsrd	r0, 0
+	RESTORE_SPECIAL(SDR1)
+	RESTORE_SPECIAL(XER)
+
+	sync
+
+	addi	r1,r1,-128
+	bl	slb_flush_and_rebolt
+	bl	do_after_copyback
+	addi	r1,r1,128
+
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+	RESTORE_SPECIAL(LR)
+
+	li	r3, 0
+	blr
--- wireless-dev.orig/arch/powerpc/kernel/asm-offsets.c	2007-05-03 14:20:25.519165535 +0200
+++ wireless-dev/arch/powerpc/kernel/asm-offsets.c	2007-05-03 14:21:10.869165535 +0200
@@ -21,12 +21,12 @@
 #include <linux/types.h>
 #include <linux/mman.h>
 #include <linux/mm.h>
+#include <linux/suspend.h>
 #ifdef CONFIG_PPC64
 #include <linux/time.h>
 #include <linux/hardirq.h>
 #else
 #include <linux/ptrace.h>
-#include <linux/suspend.h>
 #endif
 
 #include <asm/io.h>
@@ -257,11 +257,11 @@ int main(void)
 	DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup));
 	DEFINE(CPU_SPEC_RESTORE, offsetof(struct cpu_spec, cpu_restore));
 
-#ifndef CONFIG_PPC64
 	DEFINE(pbe_address, offsetof(struct pbe, address));
 	DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
 	DEFINE(pbe_next, offsetof(struct pbe, next));
 
+#ifndef CONFIG_PPC64
 	DEFINE(TASK_SIZE, TASK_SIZE);
 	DEFINE(NUM_USER_SEGMENTS, TASK_SIZE>>28);
 #endif /* ! CONFIG_PPC64 */
--- wireless-dev.orig/arch/powerpc/kernel/idle.c	2007-05-03 14:20:25.539165535 +0200
+++ wireless-dev/arch/powerpc/kernel/idle.c	2007-05-03 14:21:10.869165535 +0200
@@ -33,8 +33,11 @@
 #include <asm/smp.h>
 
 #ifdef CONFIG_HOTPLUG_CPU
+/* this is used for software suspend, and that shuts down
+ * CPUs even while the system is still booting... */
 #define cpu_should_die()	(cpu_is_offline(smp_processor_id()) && \
-				 system_state == SYSTEM_RUNNING)
+				   (system_state == SYSTEM_RUNNING     \
+				 || system_state == SYSTEM_BOOTING))
 #else
 #define cpu_should_die()	0
 #endif
--- wireless-dev.orig/arch/powerpc/kernel/swsusp.c	2007-05-03 14:21:02.139165535 +0200
+++ wireless-dev/arch/powerpc/kernel/swsusp.c	2007-05-03 14:21:10.869165535 +0200
@@ -32,6 +32,11 @@ void save_processor_state(void)
 #ifdef CONFIG_SPE
 	enable_kernel_spe();
 #endif
+
+#ifdef CONFIG_PPC64
+	hard_irq_disable();
+#endif
+
 }
 
 void restore_processor_state(void)
@@ -39,4 +44,8 @@ void restore_processor_state(void)
 #ifdef CONFIG_PPC32
 	set_context(current->active_mm->context.id, current->active_mm->pgd);
 #endif
+
+#ifdef CONFIG_PPC64
+	hard_irq_enable();
+#endif
 }
--- wireless-dev.orig/arch/powerpc/Kconfig	2007-05-03 14:21:03.969165535 +0200
+++ wireless-dev/arch/powerpc/Kconfig	2007-05-03 14:21:10.869165535 +0200
@@ -126,6 +126,11 @@ config DEFAULT_UIMAGE
 	  Used to allow a board to specify it wants a uImage built by default
 	default n
 
+config PPC64_SWSUSP
+	bool
+	depends on PPC64 && (BROKEN || (PPC_PMAC64 && EXPERIMENTAL))
+	default y
+
 menu "Processor support"
 choice
 	prompt "Processor Type"

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

* Re: [PATCH] powerpc: dart iommu suspend
  2007-05-03 12:30     ` Benjamin Herrenschmidt
@ 2007-05-03 12:34       ` Johannes Berg
  2007-05-03 12:34         ` Benjamin Herrenschmidt
  2007-05-03 12:48       ` Johannes Berg
  1 sibling, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-05-03 12:34 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Olof Johansson, linuxppc-dev, Paul Mackerras

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

On Thu, 2007-05-03 at 22:30 +1000, Benjamin Herrenschmidt wrote:

> We could just make the DART pages CI in the linear mapping rather than
> not mapping it. That would make it "just work" with the normal code
> path.

I didn't think that was even possible because it's mapped in larger
blocks than that. If it is then all this hackery can go, I'm not
attached to it...

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: [PATCH] powerpc: dart iommu suspend
  2007-05-03 12:34       ` Johannes Berg
@ 2007-05-03 12:34         ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 78+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-03 12:34 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Olof Johansson, linuxppc-dev, Paul Mackerras

On Thu, 2007-05-03 at 14:34 +0200, Johannes Berg wrote:
> On Thu, 2007-05-03 at 22:30 +1000, Benjamin Herrenschmidt wrote:
> 
> > We could just make the DART pages CI in the linear mapping rather than
> > not mapping it. That would make it "just work" with the normal code
> > path.
> 
> I didn't think that was even possible because it's mapped in larger
> blocks than that. If it is then all this hackery can go, I'm not
> attached to it...

Well.. the linear mapping is mapped with 16M pages. The DART only uses a
couple of MB but we blast an entire 16M page for it because of that ...

We could probably just map that 16MB page CI rather than not mapping it
and later on ioremapping the DART.

Ben.

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

* Re: [PATCH] powerpc: dart iommu suspend
  2007-05-03 12:30     ` Benjamin Herrenschmidt
  2007-05-03 12:34       ` Johannes Berg
@ 2007-05-03 12:48       ` Johannes Berg
  2007-05-03 14:24         ` Olof Johansson
  1 sibling, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-05-03 12:48 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Olof Johansson, linuxppc-dev, Paul Mackerras

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

On Thu, 2007-05-03 at 22:30 +1000, Benjamin Herrenschmidt wrote:
> That would make it "just work" with the normal code path.

We still need the iommu restore hook to invalidate the entries, so that
API I add there is needed anyway. Who actually saves the code doesn't
really matter at that point. The save hook isn't strictly necessary then
but I guess it should be there for symmetry anyway.

Maybe somebody can offer opinions on other iommus?

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: [PATCH] powerpc: dart iommu suspend
  2007-05-03 12:48       ` Johannes Berg
@ 2007-05-03 14:24         ` Olof Johansson
  2007-05-04 10:51           ` Johannes Berg
  0 siblings, 1 reply; 78+ messages in thread
From: Olof Johansson @ 2007-05-03 14:24 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Paul Mackerras, linuxppc-dev

On Thu, May 03, 2007 at 02:48:11PM +0200, Johannes Berg wrote:
> On Thu, 2007-05-03 at 22:30 +1000, Benjamin Herrenschmidt wrote:
> > That would make it "just work" with the normal code path.
> 
> We still need the iommu restore hook to invalidate the entries, so that
> API I add there is needed anyway. Who actually saves the code doesn't
> really matter at that point. The save hook isn't strictly necessary then
> but I guess it should be there for symmetry anyway.
> 
> Maybe somebody can offer opinions on other iommus?

The PWRficient iommu shouldn't need any special considerations here, our
in-memory table is kept in regular coherent memory, so as long as that
is saved and restored (and hooks to clear out old cached TLB entries, etc
are called), everything should just work. No need to copy things around.

So yes, we'd still need the hooks, at least the restore one. And as you
say, keeping the save one there for symmetry makes sense.

I don't know what's happened to the IBM bloa^WPAPR platforms the last
year and a half, but last I looked at them you would essentially need
to scan out all entries from firmware by hand and save them away. So
they'd need both save and restore hooks.


-Olof

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

* Re: [PATCH] powermac: support G5 CPU hotplug
  2007-05-03  2:11                 ` Benjamin Herrenschmidt
@ 2007-05-03 16:49                   ` Segher Boessenkool
  0 siblings, 0 replies; 78+ messages in thread
From: Segher Boessenkool @ 2007-05-03 16:49 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Johannes Berg, Paul Mackerras

>> Isn't it just a GPIO, like on older Macs?  Of course, we
>> cannot bring a CPU back online after doing that so it's
>> pretty useless I suppose.
>
> We don't know for sure what the gpio does... wether it does a CPU soft
> reset or tickles the SPU to make it do special things that cause us to
> branch at 0x100. We do get the CPU back after that though. We use that
> to bring them in after boot.

Yeah.  It's probably the SRESET pin, come to think of it.

It doesn't seem logical that this would save more power
than (deep) NAP mode, so forget the whole idea.  Or
someone could measure it if they think it might help
still.


Segher

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

* Re: [PATCH] powerpc: dart iommu suspend
  2007-05-03 14:24         ` Olof Johansson
@ 2007-05-04 10:51           ` Johannes Berg
  0 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-04 10:51 UTC (permalink / raw)
  To: Olof Johansson; +Cc: Paul Mackerras, linuxppc-dev

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

On Thu, 2007-05-03 at 09:24 -0500, Olof Johansson wrote:

> > Maybe somebody can offer opinions on other iommus?
> 
> The PWRficient iommu

[...]

> I don't know what's happened to the IBM bloa^WPAPR platforms

[...]

Thanks for this analysis. I guess that we really want the save/restore
hooks there, and then it doesn't matter if the dart code right now
actually does the copy or if we manage to map it CI up front, we can fix
that later.

johannes


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* Re: [PATCH v2] via-pmu: remove LED sleep notifier
  2007-05-02 14:32     ` [PATCH v2] " Johannes Berg
@ 2007-05-07  8:47       ` Paul Mackerras
  2007-05-07  8:58         ` Johannes Berg
  2007-05-07 15:08         ` [PATCH v3] " Johannes Berg
  0 siblings, 2 replies; 78+ messages in thread
From: Paul Mackerras @ 2007-05-07  8:47 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Stephen Rothwell, linuxppc-dev

Johannes Berg writes:

> The generic LED code now makes sure that suspended devices don't blink,
> so we no longer need to do it ourselves. For the suspend to disk case,
> however, we need to make sure that we don't blink if the PMU sysdev
> was suspended before the LED device.

With this patch I get:

  LD      .tmp_vmlinux1
drivers/built-in.o:(.toc1+0x71d8): undefined reference to `pmu_sys_suspended'

with a 64-bit config that has CONFIG_PPC_PMAC=y and CONFIG_PM=n.

Paul.

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

* Re: [PATCH v2] via-pmu: remove LED sleep notifier
  2007-05-07  8:47       ` Paul Mackerras
@ 2007-05-07  8:58         ` Johannes Berg
  2007-05-07 15:08         ` [PATCH v3] " Johannes Berg
  1 sibling, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-07  8:58 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Stephen Rothwell, linuxppc-dev

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

On Mon, 2007-05-07 at 18:47 +1000, Paul Mackerras wrote:

> With this patch I get:
> 
>   LD      .tmp_vmlinux1
> drivers/built-in.o:(.toc1+0x71d8): undefined reference to `pmu_sys_suspended'
> 
> with a 64-bit config that has CONFIG_PPC_PMAC=y and CONFIG_PM=n.

Ouch, sorry about that. I suppose I should make it

#ifdef CONFIG_PM
extern int pmu_sys_suspended;
#else
#define pmu_sys_suspended 0
#endif

in the header file. Will look at it again and send an updated patch
later.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

* [PATCH v3] via-pmu: remove LED sleep notifier
  2007-05-07  8:47       ` Paul Mackerras
  2007-05-07  8:58         ` Johannes Berg
@ 2007-05-07 15:08         ` Johannes Berg
  1 sibling, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-05-07 15:08 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Stephen Rothwell, linuxppc-dev

The generic LED code now makes sure that suspended devices don't blink,
so we no longer need to do it ourselves. For the suspend to disk case,
however, we need to make sure that we don't blink if the PMU sysdev
was suspended before the LED device.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
Third version fixing the build failure with !CONFIG_PM. Sorry about
that.

 drivers/macintosh/via-pmu-led.c |   35 +++--------------------------------
 drivers/macintosh/via-pmu.c     |    2 +-
 include/linux/pmu.h             |    8 ++++++++
 3 files changed, 12 insertions(+), 33 deletions(-)

--- wireless-dev.orig/drivers/macintosh/via-pmu-led.c	2007-05-05 01:37:47.149136942 +0200
+++ wireless-dev/drivers/macintosh/via-pmu-led.c	2007-05-05 10:21:03.879134340 +0200
@@ -31,7 +31,6 @@ static spinlock_t pmu_blink_lock;
 static struct adb_request pmu_blink_req;
 /* -1: no change, 0: request off, 1: request on */
 static int requested_change;
-static int sleeping;
 
 static void pmu_req_done(struct adb_request * req)
 {
@@ -41,7 +40,7 @@ static void pmu_req_done(struct adb_requ
 	/* if someone requested a change in the meantime
 	 * (we only see the last one which is fine)
 	 * then apply it now */
-	if (requested_change != -1 && !sleeping)
+	if (requested_change != -1 && !pmu_sys_suspended)
 		pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
 	/* reset requested change */
 	requested_change = -1;
@@ -66,7 +65,7 @@ static void pmu_led_set(struct led_class
 		break;
 	}
 	/* if request isn't done, then don't do anything */
-	if (pmu_blink_req.complete && !sleeping)
+	if (pmu_blink_req.complete && !pmu_sys_suspended)
 		pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
  out:
  	spin_unlock_irqrestore(&pmu_blink_lock, flags);
@@ -80,32 +79,6 @@ static struct led_classdev pmu_led = {
 	.brightness_set = pmu_led_set,
 };
 
-#ifdef CONFIG_PM
-static void pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&pmu_blink_lock, flags);
-
-	switch (when) {
-	case PBOOK_SLEEP_REQUEST:
-		sleeping = 1;
-		break;
-	case PBOOK_WAKE:
-		sleeping = 0;
-		break;
-	default:
-		/* do nothing */
-		break;
-	}
-	spin_unlock_irqrestore(&pmu_blink_lock, flags);
-}
-
-static struct pmu_sleep_notifier via_pmu_led_sleep_notif = {
-	.notifier_call = pmu_led_sleep_call,
-};
-#endif
-
 static int __init via_pmu_led_init(void)
 {
 	struct device_node *dt;
@@ -135,9 +108,7 @@ static int __init via_pmu_led_init(void)
 	/* no outstanding req */
 	pmu_blink_req.complete = 1;
 	pmu_blink_req.done = pmu_req_done;
-#ifdef CONFIG_PM
-	pmu_register_sleep_notifier(&via_pmu_led_sleep_notif);
-#endif
+
 	return led_classdev_register(NULL, &pmu_led);
 }
 
--- wireless-dev.orig/drivers/macintosh/via-pmu.c	2007-05-05 01:37:47.179136942 +0200
+++ wireless-dev/drivers/macintosh/via-pmu.c	2007-05-07 17:05:02.069099919 +0200
@@ -2759,7 +2759,7 @@ pmu_polled_request(struct adb_request *r
 
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 
-static int pmu_sys_suspended;
+int pmu_sys_suspended;
 
 static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
 {
--- wireless-dev.orig/include/linux/pmu.h	2007-05-05 01:37:47.219136942 +0200
+++ wireless-dev/include/linux/pmu.h	2007-05-07 17:05:48.339099919 +0200
@@ -225,4 +225,12 @@ extern unsigned int pmu_power_flags;
 /* Backlight */
 extern void pmu_backlight_init(void);
 
+/* some code needs to know if the PMU was suspended for hibernation */
+#ifdef CONFIG_PM
+extern int pmu_sys_suspended;
+#else
+/* if power management is not configured it can't be suspended */
+#define pmu_sys_suspended	0
+#endif
+
 #endif	/* __KERNEL__ */

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

* [PATCH] remove awacs dmasound
  2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
                   ` (15 preceding siblings ...)
  2007-05-03 12:25 ` patches for 2.6.22 Johannes Berg
@ 2007-07-17 13:28 ` Johannes Berg
  2007-07-17 13:37   ` Adrian Bunk
  16 siblings, 1 reply; 78+ messages in thread
From: Johannes Berg @ 2007-07-17 13:28 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, Adrian Bunk

This patch kills the obsolete awacs dmasound because it is in
the way of doing power management improvements since it uses
ancient API.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Adrian Bunk <bunk@stusta.de>

---
This patch contains only the patch for the first two files here, please
remove the other ones manually:

git rm -- sound/oss/dmasound/awacs_defs.h
git rm -- sound/oss/dmasound/dac3550a.c
git rm -- sound/oss/dmasound/dmasound_awacs.c
git rm -- sound/oss/dmasound/tas3001c.c
git rm -- sound/oss/dmasound/tas3001c.h
git rm -- sound/oss/dmasound/tas3001c_tables.c
git rm -- sound/oss/dmasound/tas3004.c
git rm -- sound/oss/dmasound/tas3004.h
git rm -- sound/oss/dmasound/tas3004_tables.c
git rm -- sound/oss/dmasound/tas_common.c
git rm -- sound/oss/dmasound/tas_common.h
git rm -- sound/oss/dmasound/tas_eq_prefs.h
git rm -- sound/oss/dmasound/tas_ioctl.h
git rm -- sound/oss/dmasound/trans_16.c

 sound/oss/dmasound/Kconfig           |   14 
 sound/oss/dmasound/Makefile          |    6 
 sound/oss/dmasound/awacs_defs.h      |  251 --
 sound/oss/dmasound/dac3550a.c        |  209 --
 sound/oss/dmasound/dmasound_awacs.c  | 3215 -----------------------------------
 sound/oss/dmasound/tas3001c.c        |  849 ---------
 sound/oss/dmasound/tas3001c.h        |   64 
 sound/oss/dmasound/tas3001c_tables.c |  375 ----
 sound/oss/dmasound/tas3004.c         | 1138 ------------
 sound/oss/dmasound/tas3004.h         |   77 
 sound/oss/dmasound/tas3004_tables.c  |  301 ---
 sound/oss/dmasound/tas_common.c      |  214 --
 sound/oss/dmasound/tas_common.h      |  284 ---
 sound/oss/dmasound/tas_eq_prefs.h    |   24 
 sound/oss/dmasound/tas_ioctl.h       |   24 
 sound/oss/dmasound/trans_16.c        |  898 ---------
 16 files changed, 7943 deletions(-)


--- wireless-dev.orig/sound/oss/dmasound/Makefile	2007-05-01 11:35:44.664734191 +0200
+++ wireless-dev/sound/oss/dmasound/Makefile	2007-05-01 11:36:26.054734191 +0200
@@ -2,12 +2,6 @@
 # Makefile for the DMA sound driver
 #
 
-dmasound_pmac-y			+= dmasound_awacs.o \
-				   trans_16.o dac3550a.o tas_common.o \
-				   tas3001c.o tas3001c_tables.o \
-				   tas3004.o tas3004_tables.o
-
 obj-$(CONFIG_DMASOUND_ATARI)	+= dmasound_core.o dmasound_atari.o
-obj-$(CONFIG_DMASOUND_PMAC)	+= dmasound_core.o dmasound_pmac.o
 obj-$(CONFIG_DMASOUND_PAULA)	+= dmasound_core.o dmasound_paula.o
 obj-$(CONFIG_DMASOUND_Q40)	+= dmasound_core.o dmasound_q40.o

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

* Re: [PATCH] remove awacs dmasound
  2007-07-17 13:28 ` [PATCH] remove awacs dmasound Johannes Berg
@ 2007-07-17 13:37   ` Adrian Bunk
  2007-07-17 13:43     ` Johannes Berg
  0 siblings, 1 reply; 78+ messages in thread
From: Adrian Bunk @ 2007-07-17 13:37 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, Paul Mackerras

On Tue, Jul 17, 2007 at 03:28:31PM +0200, Johannes Berg wrote:
> This patch kills the obsolete awacs dmasound because it is in
> the way of doing power management improvements since it uses
> ancient API.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Adrian Bunk <bunk@stusta.de>
> 
> ---
> This patch contains only the patch for the first two files here, please
> remove the other ones manually:
> 
> git rm -- sound/oss/dmasound/awacs_defs.h
> git rm -- sound/oss/dmasound/dac3550a.c
> git rm -- sound/oss/dmasound/dmasound_awacs.c
> git rm -- sound/oss/dmasound/tas3001c.c
> git rm -- sound/oss/dmasound/tas3001c.h
> git rm -- sound/oss/dmasound/tas3001c_tables.c
> git rm -- sound/oss/dmasound/tas3004.c
> git rm -- sound/oss/dmasound/tas3004.h
> git rm -- sound/oss/dmasound/tas3004_tables.c
> git rm -- sound/oss/dmasound/tas_common.c
> git rm -- sound/oss/dmasound/tas_common.h
> git rm -- sound/oss/dmasound/tas_eq_prefs.h
> git rm -- sound/oss/dmasound/tas_ioctl.h
> git rm -- sound/oss/dmasound/trans_16.c
> 
>  sound/oss/dmasound/Kconfig           |   14 

That's not in your patch, most likely because it's already removed as 
scheduled.

>  sound/oss/dmasound/Makefile          |    6 
>  sound/oss/dmasound/awacs_defs.h      |  251 --
>  sound/oss/dmasound/dac3550a.c        |  209 --
>  sound/oss/dmasound/dmasound_awacs.c  | 3215 -----------------------------------
>  sound/oss/dmasound/tas3001c.c        |  849 ---------
>  sound/oss/dmasound/tas3001c.h        |   64 
>  sound/oss/dmasound/tas3001c_tables.c |  375 ----
>  sound/oss/dmasound/tas3004.c         | 1138 ------------
>  sound/oss/dmasound/tas3004.h         |   77 
>  sound/oss/dmasound/tas3004_tables.c  |  301 ---
>  sound/oss/dmasound/tas_common.c      |  214 --
>  sound/oss/dmasound/tas_common.h      |  284 ---
>  sound/oss/dmasound/tas_eq_prefs.h    |   24 
>  sound/oss/dmasound/tas_ioctl.h       |   24 
>  sound/oss/dmasound/trans_16.c        |  898 ---------
>  16 files changed, 7943 deletions(-)
>...

The option is already removed from the Kconfig file, and the code 
removal is scheduled for 2.6.24. I'll take care of this (I'll send
a patch through Andrew).

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

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

* Re: [PATCH] remove awacs dmasound
  2007-07-17 13:37   ` Adrian Bunk
@ 2007-07-17 13:43     ` Johannes Berg
  0 siblings, 0 replies; 78+ messages in thread
From: Johannes Berg @ 2007-07-17 13:43 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linuxppc-dev, Paul Mackerras

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

On Tue, 2007-07-17 at 15:37 +0200, Adrian Bunk wrote:

> >  sound/oss/dmasound/Kconfig           |   14 
> 
> That's not in your patch, most likely because it's already removed as 
> scheduled.

Ah, good point, I just removed it manually from the patch knowing that
it was gone from the config.

> The option is already removed from the Kconfig file, and the code 
> removal is scheduled for 2.6.24. I'll take care of this (I'll send
> a patch through Andrew).

Alright. It uses the sleep notifiers I wanted to remove so I didn't want
to leave it even if it's not selectable.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

end of thread, other threads:[~2007-07-17 13:44 UTC | newest]

Thread overview: 78+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-27 11:25 patches for 2.6.22 Paul Mackerras
2007-04-27 12:00 ` Johannes Berg
2007-04-27 21:41 ` [PATCH] powerpc: fix suspend states again Johannes Berg
2007-04-27 21:53   ` Olof Johansson
2007-04-27 21:54     ` Johannes Berg
2007-04-27 21:57       ` Olof Johansson
2007-04-27 22:00       ` [PATCH] powerpc: put enable_kernel_spe into a header Johannes Berg
2007-04-27 22:02       ` [PATCH v2] powerpc: fix suspend states again Johannes Berg
2007-04-27 23:13         ` Olof Johansson
2007-04-30  0:14         ` Paul Mackerras
2007-04-30 11:35           ` Johannes Berg
2007-04-30 11:37           ` [PATCH v3] " Johannes Berg
2007-05-01 14:16             ` Johannes Berg
2007-04-27 23:42 ` patches for 2.6.22 Arnd Bergmann
2007-04-28  2:49 ` [PATCH] cell: cbe_cpufreq cleanup and crash fix Arnd Bergmann
2007-04-28  7:49 ` [PATCH] powermac: proper sleep management Johannes Berg
2007-04-28  8:08   ` Paul Mackerras
2007-04-28 12:52     ` Johannes Berg
2007-04-28  8:38   ` Benjamin Herrenschmidt
2007-04-28 12:51     ` Johannes Berg
2007-04-28 12:01   ` Paul Mackerras
2007-04-28 13:46     ` Johannes Berg
2007-04-30  5:31       ` Paul Mackerras
2007-04-30 12:08         ` Johannes Berg
2007-05-01 12:14           ` Paul Mackerras
2007-05-01 12:24             ` Johannes Berg
2007-04-30 11:44   ` [PATCH v3] " Johannes Berg
2007-05-01  8:55     ` Johannes Berg
2007-04-30 19:51 ` patches for 2.6.22 Kim Phillips
2007-05-01  3:38   ` Paul Mackerras
2007-05-02 14:12   ` Kumar Gala
2007-05-02 14:19     ` Kim Phillips
2007-05-01  9:06 ` Johannes Berg
2007-05-02  5:33 ` [PATCH] adb: replace sleep notifier with platform driver suspend/resume hooks Johannes Berg
2007-05-02  5:34 ` [PATCH] apm_emu: use generic apm-emulation Johannes Berg
2007-05-02  5:36 ` [PATCH] via-pmu: remove LED sleep notifier Johannes Berg
2007-05-02 10:57   ` Stephen Rothwell
2007-05-02 14:32     ` [PATCH v2] " Johannes Berg
2007-05-07  8:47       ` Paul Mackerras
2007-05-07  8:58         ` Johannes Berg
2007-05-07 15:08         ` [PATCH v3] " Johannes Berg
2007-05-02  5:39 ` [PATCH] remove awacs dmasound Johannes Berg
2007-05-02  6:18 ` [PATCH] via-pmu: kill sleep notifiers completely Johannes Berg
2007-05-02  6:21 ` [PATCH] powermac: support G5 CPU hotplug Johannes Berg
2007-05-02 10:55   ` Paul Mackerras
2007-05-02 14:33     ` Johannes Berg
2007-05-02 17:57       ` Segher Boessenkool
2007-05-02 22:03       ` Benjamin Herrenschmidt
2007-05-02 23:47         ` Segher Boessenkool
2007-05-02 23:59           ` Benjamin Herrenschmidt
2007-05-03  0:05             ` Segher Boessenkool
2007-05-03  0:18               ` Benjamin Herrenschmidt
2007-05-03  0:01         ` Paul Mackerras
2007-05-03  0:08           ` Benjamin Herrenschmidt
2007-05-03  0:10             ` Benjamin Herrenschmidt
2007-05-03  0:19             ` Segher Boessenkool
2007-05-03  0:17           ` Segher Boessenkool
2007-05-03  0:21             ` Benjamin Herrenschmidt
2007-05-03  0:24               ` Benjamin Herrenschmidt
2007-05-03  1:01               ` Segher Boessenkool
2007-05-03  2:11                 ` Benjamin Herrenschmidt
2007-05-03 16:49                   ` Segher Boessenkool
2007-05-02 20:33     ` [PATCH v2] " Johannes Berg
2007-05-02  6:33 ` [PATCH] powerpc: MPIC sys_device & suspend/resume Johannes Berg
2007-05-02  6:35 ` [PATCH] powermac: fix G5-cpufreq for cpu on/offline Johannes Berg
2007-05-03 12:25 ` patches for 2.6.22 Johannes Berg
2007-05-03 12:28   ` [PATCH] powerpc: dart iommu suspend Johannes Berg
2007-05-03 12:30     ` Benjamin Herrenschmidt
2007-05-03 12:34       ` Johannes Berg
2007-05-03 12:34         ` Benjamin Herrenschmidt
2007-05-03 12:48       ` Johannes Berg
2007-05-03 14:24         ` Olof Johansson
2007-05-04 10:51           ` Johannes Berg
2007-05-03 12:29   ` [PATCH] powerpc: mark pages that don't exist as nosave Johannes Berg
2007-05-03 12:31   ` [PATCH] powermac: suspend to disk on G5 Johannes Berg
2007-07-17 13:28 ` [PATCH] remove awacs dmasound Johannes Berg
2007-07-17 13:37   ` Adrian Bunk
2007-07-17 13:43     ` Johannes Berg

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