Skip to contentSkip to conversation

patches for 2.6.22

PATCH Superseded Paul Mackerras 10 participants 78 messages Apr 27, 2007 – Jul 17, 2007

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

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.

#1 lore raw
Quoted 4 lines · Paul Mackerras

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

#2 lore raw

PATCH 1/1 powerpc: fix suspend states again

In reply to 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.

---
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(-)
arch/powerpc/platforms/powermac/setup.c +0 -65
@@ -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;
 }
 
include/asm-powerpc/suspend.h new file +9 -0
@@ -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 */
arch/powerpc/kernel/Makefile +1 -0
@@ -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
 
arch/powerpc/kernel/swsusp.c new file +42 -0

42 lines not on this page · raw message

#3 lore raw

Re: [PATCH] powerpc: fix suspend states again

Hi,

arch/powerpc/kernel/swsusp.c line 7

Quoted 10 lines · Johannes Berg
arch/powerpc/kernel/swsusp.c new file +7 -0
@@ -0,0 +1,42 @@
+/*
+ * Common powerpc suspend code for 32 and 64 bits
+ *
+ * Copyright 2007	Johannes Berg <[email protected]>
+ *
+ * GPLv2
+ */

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

arch/powerpc/kernel/swsusp.c line 18

Quoted 10 lines
arch/powerpc/kernel/swsusp.c new file +10 -0
+#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

#4 lore raw

Re: [PATCH] powerpc: fix suspend states again

Quoted 4 lines · Olof Johansson
Quoted 2 lines

+ * GPLv2
+ */

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

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

Quoted 5 lines

arch/powerpc/kernel/swsusp.c line 18

Quoted 3 lines
arch/powerpc/kernel/swsusp.c new file +3 -0
+#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 ;)

Quoted 3 lines

, 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

#5 lore raw

Re: [PATCH] powerpc: fix suspend states again

Quoted 9 lines · Johannes Berg
Quoted 4 lines · Olof Johansson
Quoted 2 lines

+ * GPLv2
+ */

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

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

Quoted 7 lines
Quoted 5 lines

arch/powerpc/kernel/swsusp.c line 18

Quoted 3 lines
arch/powerpc/kernel/swsusp.c new file +3 -0
+#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

Quoted 5 lines
Quoted 3 lines

, 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

#6 lore raw

PATCH 1/1 powerpc: put enable_kernel_spe into a header

In reply to Johannes Berg

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

---
 include/asm-powerpc/system.h |    1 +
 1 file changed, 1 insertion(+)
include/asm-powerpc/system.h +1 -0
@@ -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 *);
#7 lore raw

PATCH v2 1/1 powerpc: fix suspend states again

In reply to Johannes Berg

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.

---
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(-)
arch/powerpc/platforms/powermac/setup.c +0 -65
@@ -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;
 }
 
include/asm-powerpc/suspend.h new file +9 -0
@@ -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 */
arch/powerpc/kernel/Makefile +1 -0
@@ -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
 
arch/powerpc/kernel/swsusp.c new file +41 -0

41 lines not on this page · raw message

#9 lore raw

Re: [PATCH v2] powerpc: fix suspend states again

In reply to Johannes Berg
Quoted 6 lines · Johannes Berg
arch/powerpc/kernel/swsusp.c new file +6 -0
+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();

arch/powerpc/kernel/swsusp.c line 34

Quoted 10 lines
arch/powerpc/kernel/swsusp.c new file +10 -0
+
+#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.

#10 lore raw

Re: [PATCH v2] powerpc: fix suspend states again

Quoted 3 lines

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

#11 lore raw

PATCH v3 1/1 powerpc: fix suspend states again

In reply to 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.

---
 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(-)
arch/powerpc/platforms/powermac/setup.c +0 -65
@@ -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;
 }
 
include/asm-powerpc/suspend.h new file +9 -0
@@ -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 */
arch/powerpc/kernel/Makefile +1 -0
@@ -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
 
arch/powerpc/kernel/swsusp.c new file +34 -0
@@ -0,0 +1,34 @@
+/*
+ * Common powerpc suspend code for 32 and 64 bits
+ *
+ * Copyright 2007	Johannes Berg <[email protected]>
+ *
+ * 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
+}
#12 lore raw

Re: [PATCH v3] powerpc: fix suspend states again

Quoted 6 lines · Johannes Berg

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

#13 lore raw
In reply to Paul Mackerras
Quoted 4 lines · Paul Mackerras

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 <><
#14 lore raw

PATCH 1/1 cell: cbe_cpufreq cleanup and crash fix

In reply to Paul Mackerras

From: Olof Johansson <[email protected]>
cbe_cpufreq cleanups:

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

---

arch/powerpc/platforms/cell/cbe_cpufreq.c +14 -10
Index: 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);
#15 lore raw

PATCH 1/1 powermac: proper sleep management

In reply to Paul Mackerras

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.

Cc Benjamin Herrenschmidt <[email protected]>

---
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(-)
drivers/macintosh/via-pmu.c +149 -180
@@ -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;
Documentation/feature-removal-schedule.txt +10 -0
@@ -302,3 +302,13 @@ Why:	Code was merged, then submitter imm
 Who:	David S. Miller <[email protected]>
 
 ---------------------------
+
+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 <[email protected]>
+
+---------------------------
#16 lore raw

Re: [PATCH] powermac: proper sleep management

Documentation/feature-removal-schedule.txt Why: Code was merged, then submitter imm · line 307

Quoted 2 lines · Johannes Berg
Documentation/feature-removal-schedule.txt +2 -0
+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.

#17 lore raw

Re: [PATCH] powermac: proper sleep management

Quoted 8 lines · Paul Mackerras

Documentation/feature-removal-schedule.txt Why: Code was merged, then submitter imm · line 307

Quoted 2 lines · Johannes Berg
Documentation/feature-removal-schedule.txt +2 -0
+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

#18 lore raw

Re: [PATCH] powermac: proper sleep management

In reply to Johannes Berg
Quoted 7 lines · Johannes Berg

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.

#19 lore raw

Re: [PATCH] powermac: proper sleep management

Quoted 1 line · Benjamin Herrenschmidt

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

#20 lore raw

Re: [PATCH] powermac: proper sleep management

In reply to Johannes Berg
Quoted 3 lines · Johannes Berg

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.

#21 lore raw

Re: [PATCH] powermac: proper sleep management

Quoted 3 lines · Paul Mackerras

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.

Quoted 5 lines

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

#22 lore raw

Re: [PATCH] powermac: proper sleep management

Quoted 2 lines · Johannes Berg

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.

#23 lore raw

Re: [PATCH] powermac: proper sleep management

Quoted 3 lines · Paul Mackerras

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.

Quoted 2 lines

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.

Quoted 3 lines

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.

Quoted 5 lines

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

#24 lore raw

Re: [PATCH] powermac: proper sleep management

Quoted 6 lines · Johannes Berg

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.

#25 lore raw

Re: [PATCH] powermac: proper sleep management

Quoted 2 lines · Paul Mackerras

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

#26 lore raw

PATCH v3 1/1 powermac: proper sleep management

In reply to Johannes Berg

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.

Cc Benjamin Herrenschmidt <[email protected]>

---
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(-)
drivers/macintosh/via-pmu.c +166 -194
@@ -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;
Documentation/feature-removal-schedule.txt +10 -0
@@ -302,3 +302,13 @@ Why:	Code was merged, then submitter imm
 Who:	David S. Miller <[email protected]>
 
 ---------------------------
+
+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 <[email protected]>
+
+---------------------------
#27 lore raw

Re: [PATCH v3] powermac: proper sleep management

Quoted 4 lines · Johannes Berg

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

#28 lore raw
In reply to Paul Mackerras
Quoted 2 lines · On Fri, 27 Apr 2007 21:25:19 +1000 Paul Mackerras <[email protected]> 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

#29 lore raw
Quoted 10 lines · Kim Phillips

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

Quoted 7 lines

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

#30 lore raw
In reply to Kim Phillips
Quoted 11 lines · Kim Phillips
Quoted 2 lines · On Fri, 27 Apr 2007 21:25:19 +1000 Paul Mackerras <[email protected]> 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.

Quoted 4 lines

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

Quoted 4 lines

[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

Quoted 5 lines

[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

#31 lore raw
Quoted 3 lines · On Wed, 2 May 2007 09:12:36 -0500 Kumar Gala <[email protected]> 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

#32 lore raw
In reply to Paul Mackerras
Quoted 2 lines · Paul Mackerras

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

#33 lore raw

PATCH 1/1 adb: replace sleep notifier with platform driver suspend/resume hooks

In reply to Paul Mackerras

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

Cc Benjamin Herrenschmidt <[email protected]>

---
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(-)
drivers/macintosh/adb.c +57 -39
@@ -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);
 }
#34 lore raw

PATCH 1/1 apm_emu: use generic apm-emulation

In reply to Paul Mackerras

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

Cc Benjamin Herrenschmidt <[email protected]>

---
Works for me.

 arch/powerpc/Kconfig        |    3 
 drivers/macintosh/Kconfig   |    4 
 drivers/macintosh/apm_emu.c |  519 +++-----------------------------------------
 3 files changed, 51 insertions(+), 475 deletions(-)
drivers/macintosh/Kconfig +3 -1
@@ -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"
drivers/macintosh/apm_emu.c +45 -474

577 lines not on this page · raw message

arch/powerpc/Kconfig +3 -0
@@ -117,6 +117,9 @@ config GENERIC_BUG
 	default y
 	depends on BUG
 
+config SYS_SUPPORTS_APM_EMULATION
+	bool
+
 config DEFAULT_UIMAGE
 	bool
 	help
#35 lore raw

PATCH 1/1 via-pmu: remove LED sleep notifier

In reply to 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.

Cc Benjamin Herrenschmidt <[email protected]>
---
 drivers/macintosh/via-pmu-led.c |   37 +++++--------------------------------
 drivers/macintosh/via-pmu.c     |    2 +-
 2 files changed, 6 insertions(+), 33 deletions(-)
drivers/macintosh/via-pmu-led.c +5 -32
@@ -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);
 }
 
drivers/macintosh/via-pmu.c +1 -1
@@ -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)
 {
#36 lore raw

Re: [PATCH] via-pmu: remove LED sleep notifier

drivers/macintosh/via-pmu-led.c static spinlock_t pmu_blink_lock; · line 35

Quoted 10 lines · On Wed, 02 May 2007 07:36:01 +0200 Johannes Berg <[email protected]>…
drivers/macintosh/via-pmu-led.c +2 -1
@@ -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 [email protected]
http://www.canb.auug.org.au/~sfr/

#37 lore raw

PATCH v2 1/1 via-pmu: remove LED sleep notifier

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.

Cc Benjamin Herrenschmidt <[email protected]>
---
 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(-)
drivers/macintosh/via-pmu-led.c +3 -32
@@ -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);
 }
 
drivers/macintosh/via-pmu.c +1 -1
@@ -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)
 {
include/linux/pmu.h +3 -0
@@ -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__ */
#38 lore raw

Re: [PATCH v2] via-pmu: remove LED sleep notifier

Quoted 4 lines · Johannes Berg

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.

#39 lore raw

Re: [PATCH v2] via-pmu: remove LED sleep notifier

Quoted 6 lines · Paul Mackerras

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

#40 lore raw

PATCH v3 1/1 via-pmu: remove LED sleep notifier

In reply to 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.

Cc Benjamin Herrenschmidt <[email protected]>

---
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(-)
drivers/macintosh/via-pmu-led.c +3 -32
@@ -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);
 }
 
drivers/macintosh/via-pmu.c +1 -1
@@ -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)
 {
include/linux/pmu.h +8 -0
@@ -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__ */
#41 lore raw

PATCH 1/1 remove awacs dmasound

In reply to Paul Mackerras

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

Cc Benjamin Herrenschmidt <[email protected]>
Cc Adrian Bunk <[email protected]>

---
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(-)
sound/oss/dmasound/Makefile +0 -6
@@ -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
sound/oss/dmasound/Kconfig +0 -14
@@ -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
#42 lore raw

PATCH 1/1 via-pmu: kill sleep notifiers completely

In reply to Paul Mackerras

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

Cc Benjamin Herrenschmidt <[email protected]>

---
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(-)
drivers/macintosh/via-pmu.c +0 -71
@@ -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;
include/linux/pmu.h +0 -36
@@ -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 */
#43 lore raw

PATCH 1/1 powermac: support G5 CPU hotplug

In reply to Paul Mackerras

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.

Cc Benjamin Herrenschmidt <[email protected]>
---
 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(-)
arch/powerpc/platforms/powermac/smp.c +10 -2
@@ -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
 };
arch/powerpc/platforms/powermac/setup.c +33 -1
@@ -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
 };
arch/powerpc/kernel/idle_power4.S +10 -4
@@ -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
include/asm-powerpc/machdep.h +2 -0
@@ -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
#44 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 5 lines · Johannes Berg

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.

#45 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 2 lines · 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?

johannes

#46 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 5 lines
Quoted 2 lines

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

#47 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

In reply to Johannes Berg
Quoted 7 lines · Johannes Berg
Quoted 2 lines · 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?

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.

#48 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 5 lines
Quoted 2 lines

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

#49 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 7 lines · Segher Boessenkool
Quoted 5 lines
Quoted 2 lines

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.

#50 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

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

#51 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 8 lines · Segher Boessenkool
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

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.

#52 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

In reply to Benjamin Herrenschmidt
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 5 lines · Johannes Berg
Quoted 2 lines · Paul Mackerras

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

Quoted 6 lines
Quoted 2 lines

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.

#53 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 11 lines · Paul Mackerras
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 7 lines · Johannes Berg
Quoted 2 lines · 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?

Quoted 6 lines
Quoted 3 lines

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.

#54 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 5 lines

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.

#55 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

In reply to Benjamin Herrenschmidt
Quoted 4 lines

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

#56 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

In reply to Paul Mackerras
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

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?

Quoted 6 lines
Quoted 3 lines

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

#57 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 6 lines

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.

Quoted 5 lines

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

Quoted 2 lines

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.

#58 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 8 lines · Benjamin Herrenschmidt
Quoted 5 lines

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.

Quoted 22 lines

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.

Quoted 5 lines

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

Quoted 2 lines

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.

#59 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

In reply to Benjamin Herrenschmidt
Quoted 7 lines
Quoted 5 lines

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.

Quoted 2 lines

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.

Quoted 4 lines

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

Quoted 7 lines
Quoted 5 lines

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.

Quoted 5 lines
Quoted 2 lines

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

#60 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 4 lines

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.

#61 lore raw

Re: [PATCH] powermac: support G5 CPU hotplug

Quoted 8 lines
Quoted 3 lines

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

#62 lore raw

PATCH v2 1/1 powermac: support G5 CPU hotplug

In reply to Paul Mackerras

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.

Cc Benjamin Herrenschmidt <[email protected]>
---
 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(-)
arch/powerpc/platforms/powermac/smp.c +10 -2
@@ -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
 };
arch/powerpc/platforms/powermac/setup.c +50 -2

69 lines not on this page · raw message

arch/powerpc/kernel/idle_power4.S +21 -0
@@ -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
include/asm-powerpc/machdep.h +1 -0
@@ -248,6 +248,7 @@ struct machdep_calls {
 };
 
 extern void power4_idle(void);
+extern void power4_cpu_offline_powersave(void);
 extern void ppc6xx_idle(void);
 
 /*
#63 lore raw

PATCH 1/1 powerpc: MPIC sys_device & suspend/resume

In reply to Paul Mackerras

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.

Cc Benjamin Herrenschmidt <[email protected]>
---
 arch/powerpc/sysdev/mpic.c |   96 ++++++++++++++++++++++++++++++++++++++++++++-
 include/asm-powerpc/mpic.h |   15 +++++++
 2 files changed, 110 insertions(+), 1 deletion(-)
arch/powerpc/sysdev/mpic.c +95 -1
@@ -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);
include/asm-powerpc/mpic.h +15 -0
@@ -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
 };
 
 /*
#64 lore raw

PATCH 1/1 powermac: fix G5-cpufreq for cpu on/offline

In reply to Paul Mackerras

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.

Cc Paul Mackeras <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
---
 arch/powerpc/platforms/powermac/cpufreq_64.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/powermac/cpufreq_64.c +4 -4
@@ -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,
#65 lore raw
In reply to Paul Mackerras

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

#66 lore raw

PATCH 1/1 powerpc: dart iommu suspend

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

Cc Paul Mackeras <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Olof Johansson <[email protected]>
---
 arch/powerpc/sysdev/dart_iommu.c |   46 +++++++++++++++++++++++++++++++++++++++
 include/asm-powerpc/iommu.h      |   14 +++++++++++
 include/asm-powerpc/machdep.h    |    5 ++++
 3 files changed, 65 insertions(+)
arch/powerpc/sysdev/dart_iommu.c +46 -0
@@ -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)
 {
include/asm-powerpc/iommu.h +14 -0
@@ -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 */
include/asm-powerpc/machdep.h +5 -0
@@ -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);
#67 lore raw

Re: [PATCH] powerpc: dart iommu suspend

Quoted 2 lines · Johannes Berg

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.

#68 lore raw

Re: [PATCH] powerpc: dart iommu suspend

Quoted 3 lines · Benjamin Herrenschmidt

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

#69 lore raw

Re: [PATCH] powerpc: dart iommu suspend

Quoted 9 lines · Johannes Berg
Quoted 3 lines · Benjamin Herrenschmidt

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.

#70 lore raw

Re: [PATCH] powerpc: dart iommu suspend

In reply to Benjamin Herrenschmidt
Quoted 1 line · Benjamin Herrenschmidt

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

#71 lore raw

Re: [PATCH] powerpc: dart iommu suspend

Quoted 9 lines · Johannes Berg
Quoted 1 line · Benjamin Herrenschmidt

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

#72 lore raw

Re: [PATCH] powerpc: dart iommu suspend

Quoted 3 lines · Olof Johansson
Quoted 1 line

Maybe somebody can offer opinions on other iommus?

The PWRficient iommu

[...]

Quoted 1 line

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

#73 lore raw

PATCH 1/1 powerpc: mark pages that don't exist as nosave

In reply to Johannes Berg

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

Cc Benjamin Herrenschmidt <[email protected]>
Cc Rafael J. Wysocki <[email protected]>

---
Tested on powerbook and G5 powermac.

---
 arch/powerpc/mm/mem.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/powerpc/mm/mem.c +25 -0
@@ -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 */
 
#74 lore raw

PATCH 1/1 powermac: suspend to disk on G5

In reply to Johannes Berg

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.

Cc Benjamin Herrenschmidt <[email protected]>

---
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(-)
arch/powerpc/kernel/Makefile +1 -0
@@ -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)
kernel/power/Kconfig +2 -2
@@ -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
include/linux/suspend.h +1 -1
@@ -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>
arch/powerpc/kernel/swsusp_64.c new file +24 -0
@@ -0,0 +1,24 @@
+/*
+ * PowerPC 64-bit swsusp implementation
+ *
+ * Copyright 2006 Johannes Berg <[email protected]>
+ *
+ * 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();
+}
arch/powerpc/kernel/swsusp_asm64.S new file +228 -0

228 lines not on this page · raw message

arch/powerpc/kernel/asm-offsets.c +2 -2
@@ -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 */
arch/powerpc/kernel/idle.c +4 -1
@@ -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
arch/powerpc/kernel/swsusp.c +9 -0
@@ -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
 }
arch/powerpc/Kconfig +5 -0
@@ -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"
#75 lore raw

PATCH 1/1 remove awacs dmasound

In reply to Paul Mackerras

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

Cc Benjamin Herrenschmidt <[email protected]>
Cc Adrian Bunk <[email protected]>

---
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(-)
sound/oss/dmasound/Makefile +0 -6
@@ -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
#76 lore raw

Re: [PATCH] remove awacs dmasound

Quoted 27 lines · Johannes Berg

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

Cc Benjamin Herrenschmidt <[email protected]>
Cc Adrian Bunk <[email protected]>

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

Quoted 1 line
 sound/oss/dmasound/Kconfig           |   14 

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

Quoted 16 lines
 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(-)
Quoted 1 line

...

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

Signature · 4 lines
       "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
#77 lore raw

Re: [PATCH] remove awacs dmasound

Quoted 4 lines · Adrian Bunk
Quoted 1 line
 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.

Quoted 3 lines

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