All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC 00/10] suspend to disk for powermac G5
@ 2007-02-05 18:30 Johannes Berg
  2007-02-05 18:30   ` Johannes Berg
                   ` (9 more replies)
  0 siblings, 10 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-pm, Torrance

Hi!

Here's my latest patchset for suspend to disk on powermac. It also contains
a whole bunch of cleanups and fixes in various other places some of which
are CCed to Andrew (who will hopefully put them into -mm).

Other than that, thanks to the mpic resume/suspend code it appears to work
quite well. Thanks to Michael Buesch for testing with PREEMPT enabled which
uncovered another bug with cpu "hotplug" (where I still don't understand why
the preempt_count is messed up on resume but not when I put a CPU off- and
online via sysfs.)

To actually get proper suspend for a G5 powermac with an Onyx codec you need
to apply the patch at http://patchwork.ozlabs.org/linuxppc/patch?id=8683

Any comments are appreciated, especially on the patch that actually
implements the snapshot code ("powermac: suspend to disk on G5.")

johannes

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

* [PATCH 01/10] dont copy pages that arent RAM
  2007-02-05 18:30 [PATCH/RFC 00/10] suspend to disk for powermac G5 Johannes Berg
@ 2007-02-05 18:30   ` Johannes Berg
  2007-02-05 18:30   ` Johannes Berg
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Andrew Morton, linux-pm, Torrance

[-- Attachment #1: dont-copy-non-ram-pages.patch --]
[-- Type: text/plain, Size: 708 bytes --]

Pages that aren't RAM obviously cannot be saved during suspend-to-disk
so skip them.

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

---
Pavel Machek requested this be put into -mm for some more
testing although he says it seems fine.

--- mb-wireless.orig/kernel/power/snapshot.c	2007-02-05 14:24:06.894526864 +0100
+++ mb-wireless/kernel/power/snapshot.c	2007-02-05 14:24:36.544526864 +0100
@@ -686,6 +686,8 @@ static struct page *saveable_page(unsign
 
 	if (PageReserved(page) && pfn_is_nosave(pfn))
 		return NULL;
+	if (!page_is_ram(pfn))
+		return NULL;
 
 	return page;
 }

--

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

* [PATCH 01/10] dont copy pages that arent RAM
@ 2007-02-05 18:30   ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Andrew Morton, linux-pm, Torrance

Pages that aren't RAM obviously cannot be saved during suspend-to-disk
so skip them.

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

---
Pavel Machek requested this be put into -mm for some more
testing although he says it seems fine.

--- mb-wireless.orig/kernel/power/snapshot.c	2007-02-05 14:24:06.894526864 +0100
+++ mb-wireless/kernel/power/snapshot.c	2007-02-05 14:24:36.544526864 +0100
@@ -686,6 +686,8 @@ static struct page *saveable_page(unsign
 
 	if (PageReserved(page) && pfn_is_nosave(pfn))
 		return NULL;
+	if (!page_is_ram(pfn))
+		return NULL;
 
 	return page;
 }

--

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

* [PATCH 02/10] windfarm: dont die on suspend thread signal
  2007-02-05 18:30 [PATCH/RFC 00/10] suspend to disk for powermac G5 Johannes Berg
@ 2007-02-05 18:30   ` Johannes Berg
  2007-02-05 18:30   ` Johannes Berg
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Andrew Morton, linux-pm, Torrance

[-- Attachment #1: windfarm-dont-die-on-signals.patch --]
[-- Type: text/plain, Size: 1085 bytes --]

When the windfarm thread gets a suspend signal it will die instead of
freezing. This fixes it.

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

---
Please apply to -mm.

--- mb-wireless.orig/drivers/macintosh/windfarm_core.c	2007-02-05 14:24:06.344526864 +0100
+++ mb-wireless/drivers/macintosh/windfarm_core.c	2007-02-05 14:24:38.264526864 +0100
@@ -94,8 +94,6 @@ static int wf_thread_func(void *data)
 	DBG("wf: thread started\n");
 
 	while(!kthread_should_stop()) {
-		try_to_freeze();
-
 		if (time_after_eq(jiffies, next)) {
 			wf_notify(WF_EVENT_TICK, NULL);
 			if (wf_overtemp) {
@@ -118,8 +116,8 @@ static int wf_thread_func(void *data)
 		if (delay <= HZ)
 			schedule_timeout_interruptible(delay);
 
-		/* there should be no signal, but oh well */
-		if (signal_pending(current)) {
+		/* there should be no non-suspend signal, but oh well */
+		if (signal_pending(current) && !try_to_freeze()) {
 			printk(KERN_WARNING "windfarm: thread got sigl !\n");
 			break;
 		}

--

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

* [PATCH 02/10] windfarm: dont die on suspend thread signal
@ 2007-02-05 18:30   ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Andrew Morton, linux-pm, Torrance

When the windfarm thread gets a suspend signal it will die instead of
freezing. This fixes it.

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

---
Please apply to -mm.

--- mb-wireless.orig/drivers/macintosh/windfarm_core.c	2007-02-05 14:24:06.344526864 +0100
+++ mb-wireless/drivers/macintosh/windfarm_core.c	2007-02-05 14:24:38.264526864 +0100
@@ -94,8 +94,6 @@ static int wf_thread_func(void *data)
 	DBG("wf: thread started\n");
 
 	while(!kthread_should_stop()) {
-		try_to_freeze();
-
 		if (time_after_eq(jiffies, next)) {
 			wf_notify(WF_EVENT_TICK, NULL);
 			if (wf_overtemp) {
@@ -118,8 +116,8 @@ static int wf_thread_func(void *data)
 		if (delay <= HZ)
 			schedule_timeout_interruptible(delay);
 
-		/* there should be no signal, but oh well */
-		if (signal_pending(current)) {
+		/* there should be no non-suspend signal, but oh well */
+		if (signal_pending(current) && !try_to_freeze()) {
 			printk(KERN_WARNING "windfarm: thread got sigl !\n");
 			break;
 		}

--

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

* [PATCH 03/10] powerpc: fix comment in kernel/irq.c
  2007-02-05 18:30 [PATCH/RFC 00/10] suspend to disk for powermac G5 Johannes Berg
@ 2007-02-05 18:30   ` Johannes Berg
  2007-02-05 18:30   ` Johannes Berg
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Andrew Morton, linux-pm, Torrance

[-- Attachment #1: irq-comment.patch --]
[-- Type: text/plain, Size: 938 bytes --]

kernel/irq.c contains a comment that speaks of -1 and -2 as interrupt
numbers. Replace by NO_IRQ and NO_IRQ_IGNORE.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Andrew Morton <akpm@osdl.org>

--- mb-wireless.orig/arch/powerpc/kernel/irq.c	2007-02-05 14:24:06.694526864 +0100
+++ mb-wireless/arch/powerpc/kernel/irq.c	2007-02-05 14:24:37.084526864 +0100
@@ -281,10 +281,10 @@ void do_IRQ(struct pt_regs *regs)
 
 	/*
 	 * Every platform is required to implement ppc_md.get_irq.
-	 * This function will either return an irq number or -1 to
+	 * This function will either return an irq number or NO_IRQ to
 	 * indicate there are no more pending.
-	 * The value -2 is for buggy hardware and means that this IRQ
-	 * has already been handled. -- Tom
+	 * The value NO_IRQ_IGNORE is for buggy hardware and means that this
+	 * IRQ has already been handled. -- Tom
 	 */
 	irq = ppc_md.get_irq();
 

--

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

* [PATCH 03/10] powerpc: fix comment in kernel/irq.c
@ 2007-02-05 18:30   ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Andrew Morton, linux-pm, Torrance

kernel/irq.c contains a comment that speaks of -1 and -2 as interrupt
numbers. Replace by NO_IRQ and NO_IRQ_IGNORE.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Andrew Morton <akpm@osdl.org>

--- mb-wireless.orig/arch/powerpc/kernel/irq.c	2007-02-05 14:24:06.694526864 +0100
+++ mb-wireless/arch/powerpc/kernel/irq.c	2007-02-05 14:24:37.084526864 +0100
@@ -281,10 +281,10 @@ void do_IRQ(struct pt_regs *regs)
 
 	/*
 	 * Every platform is required to implement ppc_md.get_irq.
-	 * This function will either return an irq number or -1 to
+	 * This function will either return an irq number or NO_IRQ to
 	 * indicate there are no more pending.
-	 * The value -2 is for buggy hardware and means that this IRQ
-	 * has already been handled. -- Tom
+	 * The value NO_IRQ_IGNORE is for buggy hardware and means that this
+	 * IRQ has already been handled. -- Tom
 	 */
 	irq = ppc_md.get_irq();
 

--

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

* [PATCH 04/10] powermac: clean up PIC initialisation code
  2007-02-05 18:30 [PATCH/RFC 00/10] suspend to disk for powermac G5 Johannes Berg
@ 2007-02-05 18:30   ` Johannes Berg
  2007-02-05 18:30   ` Johannes Berg
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Andrew Morton, linux-pm, Torrance

[-- Attachment #1: pic-cleanup.patch --]
[-- Type: text/plain, Size: 12590 bytes --]

This patch cleans up the powermac PIC initialisation code so that for G5
powermacs we don't even compile the old pmac pic file.

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

---
Tested on powerbook and powermac, please apply to -mm.

--- mb-wireless.orig/arch/powerpc/platforms/powermac/Makefile	2007-02-05 14:24:06.054526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/Makefile	2007-02-05 14:24:38.804526864 +0100
@@ -1,6 +1,6 @@
 CFLAGS_bootx_init.o  		+= -fPIC
 
-obj-y				+= pic.o setup.o time.o feature.o pci.o \
+obj-y				+= setup.o time.o feature.o pci.o \
 				   sleep.o low_i2c.o cache.o pfunc_core.o \
 				   pfunc_base.o
 obj-$(CONFIG_PMAC_BACKLIGHT)	+= backlight.o
@@ -8,7 +8,7 @@ obj-$(CONFIG_CPU_FREQ_PMAC)	+= cpufreq_3
 obj-$(CONFIG_CPU_FREQ_PMAC64)	+= cpufreq_64.o
 obj-$(CONFIG_NVRAM)		+= nvram.o
 # ppc64 pmac doesn't define CONFIG_NVRAM but needs nvram stuff
-obj-$(CONFIG_PPC64)		+= nvram.o
-obj-$(CONFIG_PPC32)		+= bootx_init.o
+obj-$(CONFIG_PPC64)		+= nvram.o mpic.o
+obj-$(CONFIG_PPC32)		+= bootx_init.o pic.o mpic.o
 obj-$(CONFIG_SMP)		+= smp.o
 obj-$(CONFIG_PPC_MERGE)		+= udbg_scc.o udbg_adb.o
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ mb-wireless/arch/powerpc/platforms/powermac/mpic.c	2007-02-05 14:24:38.804526864 +0100
@@ -0,0 +1,143 @@
+/*
+ *  OpenPIC initialisation for PowerMacs.
+ *
+ *  Copyright (C) 1997 Paul Mackerras (paulus@samba.org)
+ *  Copyright (C) 2005 Benjamin Herrenschmidt (benh@kernel.crashing.org)
+ *                     IBM, Corp.
+ *
+ *  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 <asm/prom.h>
+#include <asm/pmac_feature.h>
+#include <asm/mpic.h>
+
+static void pmac_u3_cascade(unsigned int irq, struct irq_desc *desc)
+{
+	struct mpic *mpic = desc->handler_data;
+
+	unsigned int cascade_irq = mpic_get_one_irq(mpic);
+	if (cascade_irq != NO_IRQ)
+		generic_handle_irq(cascade_irq);
+	desc->chip->eoi(irq);
+}
+
+static void __init pmac_pic_setup_mpic_nmi(struct mpic *mpic)
+{
+#if defined(CONFIG_XMON) && defined(CONFIG_PPC32)
+	struct device_node* pswitch;
+	int nmi_irq;
+
+	pswitch = of_find_node_by_name(NULL, "programmer-switch");
+	if (pswitch) {
+		nmi_irq = irq_of_parse_and_map(pswitch, 0);
+		if (nmi_irq != NO_IRQ) {
+			mpic_irq_set_priority(nmi_irq, 9);
+			setup_irq(nmi_irq, &xmon_action);
+		}
+		of_node_put(pswitch);
+	}
+#endif	/* defined(CONFIG_XMON) && defined(CONFIG_PPC32) */
+}
+
+static struct mpic * __init pmac_setup_one_mpic(struct device_node *np,
+						int master)
+{
+	const char *name = master ? " MPIC 1   " : " MPIC 2   ";
+	struct resource r;
+	struct mpic *mpic;
+	unsigned int flags = master ? MPIC_PRIMARY : 0;
+	int rc;
+
+	rc = of_address_to_resource(np, 0, &r);
+	if (rc)
+		return NULL;
+
+	pmac_call_feature(PMAC_FTR_ENABLE_MPIC, np, 0, 0);
+
+	flags |= MPIC_WANTS_RESET;
+	if (get_property(np, "big-endian", NULL))
+		flags |= MPIC_BIG_ENDIAN;
+
+	/* Primary Big Endian means HT interrupts. This is quite dodgy
+	 * but works until I find a better way
+	 */
+	if (master && (flags & MPIC_BIG_ENDIAN))
+		flags |= MPIC_BROKEN_U3;
+
+	mpic = mpic_alloc(np, r.start, flags, 0, 0, name);
+	if (mpic == NULL)
+		return NULL;
+
+	mpic_init(mpic);
+
+	return mpic;
+ }
+
+int __init pmac_pic_probe_mpic(void)
+{
+	struct mpic *mpic1, *mpic2;
+	struct device_node *np, *master = NULL, *slave = NULL;
+	unsigned int cascade;
+
+	/* We can have up to 2 MPICs cascaded */
+	for (np = NULL; (np = of_find_node_by_type(np, "open-pic"))
+		     != NULL;) {
+		if (master == NULL &&
+		    get_property(np, "interrupts", NULL) == NULL)
+			master = of_node_get(np);
+		else if (slave == NULL)
+			slave = of_node_get(np);
+		if (master && slave)
+			break;
+	}
+
+	/* Check for bogus setups */
+	if (master == NULL && slave != NULL) {
+		master = slave;
+		slave = NULL;
+	}
+
+	/* Not found, default to good old pmac pic */
+	if (master == NULL)
+		return -ENODEV;
+
+	/* Set master handler */
+	ppc_md.get_irq = mpic_get_irq;
+
+	/* Setup master */
+	mpic1 = pmac_setup_one_mpic(master, 1);
+	BUG_ON(mpic1 == NULL);
+
+	/* Install NMI if any */
+	pmac_pic_setup_mpic_nmi(mpic1);
+
+	of_node_put(master);
+
+	/* No slave, let's go out */
+	if (slave == NULL)
+		return 0;
+
+	/* Get/Map slave interrupt */
+	cascade = irq_of_parse_and_map(slave, 0);
+	if (cascade == NO_IRQ) {
+		printk(KERN_ERR "Failed to map cascade IRQ\n");
+		return 0;
+	}
+
+	mpic2 = pmac_setup_one_mpic(slave, 0);
+	if (mpic2 == NULL) {
+		printk(KERN_ERR "Failed to setup slave MPIC\n");
+		of_node_put(slave);
+		return 0;
+	}
+	set_irq_data(cascade, mpic2);
+	set_irq_chained_handler(cascade, pmac_u3_cascade);
+
+	of_node_put(slave);
+	return 0;
+}
--- mb-wireless.orig/arch/powerpc/platforms/powermac/pic.c	2007-02-05 14:24:06.144526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/pic.c	2007-02-05 14:24:38.804526864 +0100
@@ -15,25 +15,14 @@
  *
  */
 
-#include <linux/stddef.h>
 #include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/sysdev.h>
 #include <linux/adb.h>
 #include <linux/pmu.h>
-#include <linux/module.h>
 
-#include <asm/sections.h>
-#include <asm/io.h>
 #include <asm/smp.h>
 #include <asm/prom.h>
-#include <asm/pci-bridge.h>
 #include <asm/time.h>
 #include <asm/pmac_feature.h>
-#include <asm/mpic.h>
 
 #include "pmac.h"
 
@@ -44,7 +33,6 @@
  */
 extern irqreturn_t xmon_irq(int, void *);
 
-#ifdef CONFIG_PPC32
 struct pmac_irq_hw {
         unsigned int    event;
         unsigned int    enable;
@@ -438,134 +426,6 @@ static void __init pmac_pic_probe_oldsty
 	setup_irq(irq_create_mapping(NULL, 20), &xmon_action);
 #endif
 }
-#endif /* CONFIG_PPC32 */
-
-static void pmac_u3_cascade(unsigned int irq, struct irq_desc *desc)
-{
-	struct mpic *mpic = desc->handler_data;
-
-	unsigned int cascade_irq = mpic_get_one_irq(mpic);
-	if (cascade_irq != NO_IRQ)
-		generic_handle_irq(cascade_irq);
-	desc->chip->eoi(irq);
-}
-
-static void __init pmac_pic_setup_mpic_nmi(struct mpic *mpic)
-{
-#if defined(CONFIG_XMON) && defined(CONFIG_PPC32)
-	struct device_node* pswitch;
-	int nmi_irq;
-
-	pswitch = of_find_node_by_name(NULL, "programmer-switch");
-	if (pswitch) {
-		nmi_irq = irq_of_parse_and_map(pswitch, 0);
-		if (nmi_irq != NO_IRQ) {
-			mpic_irq_set_priority(nmi_irq, 9);
-			setup_irq(nmi_irq, &xmon_action);
-		}
-		of_node_put(pswitch);
-	}
-#endif	/* defined(CONFIG_XMON) && defined(CONFIG_PPC32) */
-}
-
-static struct mpic * __init pmac_setup_one_mpic(struct device_node *np,
-						int master)
-{
-	const char *name = master ? " MPIC 1   " : " MPIC 2   ";
-	struct resource r;
-	struct mpic *mpic;
-	unsigned int flags = master ? MPIC_PRIMARY : 0;
-	int rc;
-
-	rc = of_address_to_resource(np, 0, &r);
-	if (rc)
-		return NULL;
-
-	pmac_call_feature(PMAC_FTR_ENABLE_MPIC, np, 0, 0);
-
-	flags |= MPIC_WANTS_RESET;
-	if (get_property(np, "big-endian", NULL))
-		flags |= MPIC_BIG_ENDIAN;
-
-	/* Primary Big Endian means HT interrupts. This is quite dodgy
-	 * but works until I find a better way
-	 */
-	if (master && (flags & MPIC_BIG_ENDIAN))
-		flags |= MPIC_BROKEN_U3;
-
-	mpic = mpic_alloc(np, r.start, flags, 0, 0, name);
-	if (mpic == NULL)
-		return NULL;
-
-	mpic_init(mpic);
-
-	return mpic;
- }
-
-static int __init pmac_pic_probe_mpic(void)
-{
-	struct mpic *mpic1, *mpic2;
-	struct device_node *np, *master = NULL, *slave = NULL;
-	unsigned int cascade;
-
-	/* We can have up to 2 MPICs cascaded */
-	for (np = NULL; (np = of_find_node_by_type(np, "open-pic"))
-		     != NULL;) {
-		if (master == NULL &&
-		    get_property(np, "interrupts", NULL) == NULL)
-			master = of_node_get(np);
-		else if (slave == NULL)
-			slave = of_node_get(np);
-		if (master && slave)
-			break;
-	}
-
-	/* Check for bogus setups */
-	if (master == NULL && slave != NULL) {
-		master = slave;
-		slave = NULL;
-	}
-
-	/* Not found, default to good old pmac pic */
-	if (master == NULL)
-		return -ENODEV;
-
-	/* Set master handler */
-	ppc_md.get_irq = mpic_get_irq;
-
-	/* Setup master */
-	mpic1 = pmac_setup_one_mpic(master, 1);
-	BUG_ON(mpic1 == NULL);
-
-	/* Install NMI if any */
-	pmac_pic_setup_mpic_nmi(mpic1);
-
-	of_node_put(master);
-
-	/* No slave, let's go out */
-	if (slave == NULL)
-		return 0;
-
-	/* Get/Map slave interrupt */
-	cascade = irq_of_parse_and_map(slave, 0);
-	if (cascade == NO_IRQ) {
-		printk(KERN_ERR "Failed to map cascade IRQ\n");
-		return 0;
-	}
-
-	mpic2 = pmac_setup_one_mpic(slave, 0);
-	if (mpic2 == NULL) {
-		printk(KERN_ERR "Failed to setup slave MPIC\n");
-		of_node_put(slave);
-		return 0;
-	}
-	set_irq_data(cascade, mpic2);
-	set_irq_chained_handler(cascade, pmac_u3_cascade);
-
-	of_node_put(slave);
-	return 0;
-}
-
 
 void __init pmac_pic_init(void)
 {
@@ -574,27 +434,17 @@ void __init pmac_pic_init(void)
 	/* We configure the OF parsing based on our oldworld vs. newworld
 	 * platform type and wether we were booted by BootX.
 	 */
-#ifdef CONFIG_PPC32
 	if (!pmac_newworld)
 		flags |= OF_IMAP_OLDWORLD_MAC;
 	if (get_property(of_chosen, "linux,bootx", NULL) != NULL)
 		flags |= OF_IMAP_NO_PHANDLE;
-#endif /* CONFIG_PPC_32 */
 
 	of_irq_map_init(flags);
 
-	/* We first try to detect Apple's new Core99 chipset, since mac-io
-	 * is quite different on those machines and contains an IBM MPIC2.
-	 */
-	if (pmac_pic_probe_mpic() == 0)
-		return;
-
-#ifdef CONFIG_PPC32
 	pmac_pic_probe_oldstyle();
-#endif
 }
 
-#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+#ifdef CONFIG_PM
 /*
  * These procedures are used in implementing sleep on the powerbooks.
  * sleep_save_intrs() saves the states of all interrupt enables
@@ -662,7 +512,7 @@ static int pmacpic_resume(struct sys_dev
 	return 0;
 }
 
-#endif /* CONFIG_PM && CONFIG_PPC32 */
+#endif /* CONFIG_PM */
 
 static struct sysdev_class pmacpic_sysclass = {
 	set_kset_name("pmac_pic"),
@@ -674,18 +524,17 @@ static struct sys_device device_pmacpic 
 };
 
 static struct sysdev_driver driver_pmacpic = {
-#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+#ifdef CONFIG_PM
 	.suspend	= &pmacpic_suspend,
 	.resume		= &pmacpic_resume,
-#endif /* CONFIG_PM && CONFIG_PPC32 */
+#endif /* CONFIG_PM */
 };
 
 static int __init init_pmacpic_sysfs(void)
 {
-#ifdef CONFIG_PPC32
 	if (max_irqs == 0)
 		return -ENODEV;
-#endif
+
 	printk(KERN_DEBUG "Registering pmac pic with sysfs...\n");
 	sysdev_class_register(&pmacpic_sysclass);
 	sysdev_register(&device_pmacpic);
--- mb-wireless.orig/arch/powerpc/platforms/powermac/pmac.h	2007-02-05 14:24:06.164526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/pmac.h	2007-02-05 14:24:38.804526864 +0100
@@ -44,6 +44,9 @@ extern void pmac_ide_init_hwif_ports(hw_
 	unsigned long data_port, unsigned long ctrl_port, int *irq);
 
 extern int pmac_nvram_init(void);
+#ifdef CONFIG_PPC32
 extern void pmac_pic_init(void);
+#endif
+extern int pmac_pic_probe_mpic(void);
 
 #endif /* __PMAC_H__ */
--- mb-wireless.orig/arch/powerpc/platforms/powermac/setup.c	2007-02-05 14:24:06.194526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/setup.c	2007-02-05 14:24:38.814526864 +0100
@@ -718,13 +718,28 @@ static int pmac_pci_probe_mode(struct pc
 }
 #endif
 
+static void __init pmac_init_irq(void)
+{
+	int ret;
+
+	/* We first try to detect Apple's new Core99 chipset, since mac-io
+	 * is quite different on those machines and contains an IBM MPIC2.
+	 */
+	ret = pmac_pic_probe_mpic();
+
+#ifdef CONFIG_PPC32
+	if (ret != 0)
+		pmac_pic_init();
+#endif
+}
+
 define_machine(powermac) {
 	.name			= "PowerMac",
 	.probe			= pmac_probe,
 	.setup_arch		= pmac_setup_arch,
 	.init_early		= pmac_init_early,
 	.show_cpuinfo		= pmac_show_cpuinfo,
-	.init_IRQ		= pmac_pic_init,
+	.init_IRQ		= pmac_init_irq,
 	.get_irq		= NULL,	/* changed later */
 	.pci_irq_fixup		= pmac_pci_irq_fixup,
 	.restart		= pmac_restart,

--

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

* [PATCH 04/10] powermac: clean up PIC initialisation code
@ 2007-02-05 18:30   ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Andrew Morton, linux-pm, Torrance

This patch cleans up the powermac PIC initialisation code so that for G5
powermacs we don't even compile the old pmac pic file.

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

---
Tested on powerbook and powermac, please apply to -mm.

--- mb-wireless.orig/arch/powerpc/platforms/powermac/Makefile	2007-02-05 14:24:06.054526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/Makefile	2007-02-05 14:24:38.804526864 +0100
@@ -1,6 +1,6 @@
 CFLAGS_bootx_init.o  		+= -fPIC
 
-obj-y				+= pic.o setup.o time.o feature.o pci.o \
+obj-y				+= setup.o time.o feature.o pci.o \
 				   sleep.o low_i2c.o cache.o pfunc_core.o \
 				   pfunc_base.o
 obj-$(CONFIG_PMAC_BACKLIGHT)	+= backlight.o
@@ -8,7 +8,7 @@ obj-$(CONFIG_CPU_FREQ_PMAC)	+= cpufreq_3
 obj-$(CONFIG_CPU_FREQ_PMAC64)	+= cpufreq_64.o
 obj-$(CONFIG_NVRAM)		+= nvram.o
 # ppc64 pmac doesn't define CONFIG_NVRAM but needs nvram stuff
-obj-$(CONFIG_PPC64)		+= nvram.o
-obj-$(CONFIG_PPC32)		+= bootx_init.o
+obj-$(CONFIG_PPC64)		+= nvram.o mpic.o
+obj-$(CONFIG_PPC32)		+= bootx_init.o pic.o mpic.o
 obj-$(CONFIG_SMP)		+= smp.o
 obj-$(CONFIG_PPC_MERGE)		+= udbg_scc.o udbg_adb.o
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ mb-wireless/arch/powerpc/platforms/powermac/mpic.c	2007-02-05 14:24:38.804526864 +0100
@@ -0,0 +1,143 @@
+/*
+ *  OpenPIC initialisation for PowerMacs.
+ *
+ *  Copyright (C) 1997 Paul Mackerras (paulus@samba.org)
+ *  Copyright (C) 2005 Benjamin Herrenschmidt (benh@kernel.crashing.org)
+ *                     IBM, Corp.
+ *
+ *  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 <asm/prom.h>
+#include <asm/pmac_feature.h>
+#include <asm/mpic.h>
+
+static void pmac_u3_cascade(unsigned int irq, struct irq_desc *desc)
+{
+	struct mpic *mpic = desc->handler_data;
+
+	unsigned int cascade_irq = mpic_get_one_irq(mpic);
+	if (cascade_irq != NO_IRQ)
+		generic_handle_irq(cascade_irq);
+	desc->chip->eoi(irq);
+}
+
+static void __init pmac_pic_setup_mpic_nmi(struct mpic *mpic)
+{
+#if defined(CONFIG_XMON) && defined(CONFIG_PPC32)
+	struct device_node* pswitch;
+	int nmi_irq;
+
+	pswitch = of_find_node_by_name(NULL, "programmer-switch");
+	if (pswitch) {
+		nmi_irq = irq_of_parse_and_map(pswitch, 0);
+		if (nmi_irq != NO_IRQ) {
+			mpic_irq_set_priority(nmi_irq, 9);
+			setup_irq(nmi_irq, &xmon_action);
+		}
+		of_node_put(pswitch);
+	}
+#endif	/* defined(CONFIG_XMON) && defined(CONFIG_PPC32) */
+}
+
+static struct mpic * __init pmac_setup_one_mpic(struct device_node *np,
+						int master)
+{
+	const char *name = master ? " MPIC 1   " : " MPIC 2   ";
+	struct resource r;
+	struct mpic *mpic;
+	unsigned int flags = master ? MPIC_PRIMARY : 0;
+	int rc;
+
+	rc = of_address_to_resource(np, 0, &r);
+	if (rc)
+		return NULL;
+
+	pmac_call_feature(PMAC_FTR_ENABLE_MPIC, np, 0, 0);
+
+	flags |= MPIC_WANTS_RESET;
+	if (get_property(np, "big-endian", NULL))
+		flags |= MPIC_BIG_ENDIAN;
+
+	/* Primary Big Endian means HT interrupts. This is quite dodgy
+	 * but works until I find a better way
+	 */
+	if (master && (flags & MPIC_BIG_ENDIAN))
+		flags |= MPIC_BROKEN_U3;
+
+	mpic = mpic_alloc(np, r.start, flags, 0, 0, name);
+	if (mpic == NULL)
+		return NULL;
+
+	mpic_init(mpic);
+
+	return mpic;
+ }
+
+int __init pmac_pic_probe_mpic(void)
+{
+	struct mpic *mpic1, *mpic2;
+	struct device_node *np, *master = NULL, *slave = NULL;
+	unsigned int cascade;
+
+	/* We can have up to 2 MPICs cascaded */
+	for (np = NULL; (np = of_find_node_by_type(np, "open-pic"))
+		     != NULL;) {
+		if (master == NULL &&
+		    get_property(np, "interrupts", NULL) == NULL)
+			master = of_node_get(np);
+		else if (slave == NULL)
+			slave = of_node_get(np);
+		if (master && slave)
+			break;
+	}
+
+	/* Check for bogus setups */
+	if (master == NULL && slave != NULL) {
+		master = slave;
+		slave = NULL;
+	}
+
+	/* Not found, default to good old pmac pic */
+	if (master == NULL)
+		return -ENODEV;
+
+	/* Set master handler */
+	ppc_md.get_irq = mpic_get_irq;
+
+	/* Setup master */
+	mpic1 = pmac_setup_one_mpic(master, 1);
+	BUG_ON(mpic1 == NULL);
+
+	/* Install NMI if any */
+	pmac_pic_setup_mpic_nmi(mpic1);
+
+	of_node_put(master);
+
+	/* No slave, let's go out */
+	if (slave == NULL)
+		return 0;
+
+	/* Get/Map slave interrupt */
+	cascade = irq_of_parse_and_map(slave, 0);
+	if (cascade == NO_IRQ) {
+		printk(KERN_ERR "Failed to map cascade IRQ\n");
+		return 0;
+	}
+
+	mpic2 = pmac_setup_one_mpic(slave, 0);
+	if (mpic2 == NULL) {
+		printk(KERN_ERR "Failed to setup slave MPIC\n");
+		of_node_put(slave);
+		return 0;
+	}
+	set_irq_data(cascade, mpic2);
+	set_irq_chained_handler(cascade, pmac_u3_cascade);
+
+	of_node_put(slave);
+	return 0;
+}
--- mb-wireless.orig/arch/powerpc/platforms/powermac/pic.c	2007-02-05 14:24:06.144526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/pic.c	2007-02-05 14:24:38.804526864 +0100
@@ -15,25 +15,14 @@
  *
  */
 
-#include <linux/stddef.h>
 #include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/sysdev.h>
 #include <linux/adb.h>
 #include <linux/pmu.h>
-#include <linux/module.h>
 
-#include <asm/sections.h>
-#include <asm/io.h>
 #include <asm/smp.h>
 #include <asm/prom.h>
-#include <asm/pci-bridge.h>
 #include <asm/time.h>
 #include <asm/pmac_feature.h>
-#include <asm/mpic.h>
 
 #include "pmac.h"
 
@@ -44,7 +33,6 @@
  */
 extern irqreturn_t xmon_irq(int, void *);
 
-#ifdef CONFIG_PPC32
 struct pmac_irq_hw {
         unsigned int    event;
         unsigned int    enable;
@@ -438,134 +426,6 @@ static void __init pmac_pic_probe_oldsty
 	setup_irq(irq_create_mapping(NULL, 20), &xmon_action);
 #endif
 }
-#endif /* CONFIG_PPC32 */
-
-static void pmac_u3_cascade(unsigned int irq, struct irq_desc *desc)
-{
-	struct mpic *mpic = desc->handler_data;
-
-	unsigned int cascade_irq = mpic_get_one_irq(mpic);
-	if (cascade_irq != NO_IRQ)
-		generic_handle_irq(cascade_irq);
-	desc->chip->eoi(irq);
-}
-
-static void __init pmac_pic_setup_mpic_nmi(struct mpic *mpic)
-{
-#if defined(CONFIG_XMON) && defined(CONFIG_PPC32)
-	struct device_node* pswitch;
-	int nmi_irq;
-
-	pswitch = of_find_node_by_name(NULL, "programmer-switch");
-	if (pswitch) {
-		nmi_irq = irq_of_parse_and_map(pswitch, 0);
-		if (nmi_irq != NO_IRQ) {
-			mpic_irq_set_priority(nmi_irq, 9);
-			setup_irq(nmi_irq, &xmon_action);
-		}
-		of_node_put(pswitch);
-	}
-#endif	/* defined(CONFIG_XMON) && defined(CONFIG_PPC32) */
-}
-
-static struct mpic * __init pmac_setup_one_mpic(struct device_node *np,
-						int master)
-{
-	const char *name = master ? " MPIC 1   " : " MPIC 2   ";
-	struct resource r;
-	struct mpic *mpic;
-	unsigned int flags = master ? MPIC_PRIMARY : 0;
-	int rc;
-
-	rc = of_address_to_resource(np, 0, &r);
-	if (rc)
-		return NULL;
-
-	pmac_call_feature(PMAC_FTR_ENABLE_MPIC, np, 0, 0);
-
-	flags |= MPIC_WANTS_RESET;
-	if (get_property(np, "big-endian", NULL))
-		flags |= MPIC_BIG_ENDIAN;
-
-	/* Primary Big Endian means HT interrupts. This is quite dodgy
-	 * but works until I find a better way
-	 */
-	if (master && (flags & MPIC_BIG_ENDIAN))
-		flags |= MPIC_BROKEN_U3;
-
-	mpic = mpic_alloc(np, r.start, flags, 0, 0, name);
-	if (mpic == NULL)
-		return NULL;
-
-	mpic_init(mpic);
-
-	return mpic;
- }
-
-static int __init pmac_pic_probe_mpic(void)
-{
-	struct mpic *mpic1, *mpic2;
-	struct device_node *np, *master = NULL, *slave = NULL;
-	unsigned int cascade;
-
-	/* We can have up to 2 MPICs cascaded */
-	for (np = NULL; (np = of_find_node_by_type(np, "open-pic"))
-		     != NULL;) {
-		if (master == NULL &&
-		    get_property(np, "interrupts", NULL) == NULL)
-			master = of_node_get(np);
-		else if (slave == NULL)
-			slave = of_node_get(np);
-		if (master && slave)
-			break;
-	}
-
-	/* Check for bogus setups */
-	if (master == NULL && slave != NULL) {
-		master = slave;
-		slave = NULL;
-	}
-
-	/* Not found, default to good old pmac pic */
-	if (master == NULL)
-		return -ENODEV;
-
-	/* Set master handler */
-	ppc_md.get_irq = mpic_get_irq;
-
-	/* Setup master */
-	mpic1 = pmac_setup_one_mpic(master, 1);
-	BUG_ON(mpic1 == NULL);
-
-	/* Install NMI if any */
-	pmac_pic_setup_mpic_nmi(mpic1);
-
-	of_node_put(master);
-
-	/* No slave, let's go out */
-	if (slave == NULL)
-		return 0;
-
-	/* Get/Map slave interrupt */
-	cascade = irq_of_parse_and_map(slave, 0);
-	if (cascade == NO_IRQ) {
-		printk(KERN_ERR "Failed to map cascade IRQ\n");
-		return 0;
-	}
-
-	mpic2 = pmac_setup_one_mpic(slave, 0);
-	if (mpic2 == NULL) {
-		printk(KERN_ERR "Failed to setup slave MPIC\n");
-		of_node_put(slave);
-		return 0;
-	}
-	set_irq_data(cascade, mpic2);
-	set_irq_chained_handler(cascade, pmac_u3_cascade);
-
-	of_node_put(slave);
-	return 0;
-}
-
 
 void __init pmac_pic_init(void)
 {
@@ -574,27 +434,17 @@ void __init pmac_pic_init(void)
 	/* We configure the OF parsing based on our oldworld vs. newworld
 	 * platform type and wether we were booted by BootX.
 	 */
-#ifdef CONFIG_PPC32
 	if (!pmac_newworld)
 		flags |= OF_IMAP_OLDWORLD_MAC;
 	if (get_property(of_chosen, "linux,bootx", NULL) != NULL)
 		flags |= OF_IMAP_NO_PHANDLE;
-#endif /* CONFIG_PPC_32 */
 
 	of_irq_map_init(flags);
 
-	/* We first try to detect Apple's new Core99 chipset, since mac-io
-	 * is quite different on those machines and contains an IBM MPIC2.
-	 */
-	if (pmac_pic_probe_mpic() == 0)
-		return;
-
-#ifdef CONFIG_PPC32
 	pmac_pic_probe_oldstyle();
-#endif
 }
 
-#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+#ifdef CONFIG_PM
 /*
  * These procedures are used in implementing sleep on the powerbooks.
  * sleep_save_intrs() saves the states of all interrupt enables
@@ -662,7 +512,7 @@ static int pmacpic_resume(struct sys_dev
 	return 0;
 }
 
-#endif /* CONFIG_PM && CONFIG_PPC32 */
+#endif /* CONFIG_PM */
 
 static struct sysdev_class pmacpic_sysclass = {
 	set_kset_name("pmac_pic"),
@@ -674,18 +524,17 @@ static struct sys_device device_pmacpic 
 };
 
 static struct sysdev_driver driver_pmacpic = {
-#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+#ifdef CONFIG_PM
 	.suspend	= &pmacpic_suspend,
 	.resume		= &pmacpic_resume,
-#endif /* CONFIG_PM && CONFIG_PPC32 */
+#endif /* CONFIG_PM */
 };
 
 static int __init init_pmacpic_sysfs(void)
 {
-#ifdef CONFIG_PPC32
 	if (max_irqs == 0)
 		return -ENODEV;
-#endif
+
 	printk(KERN_DEBUG "Registering pmac pic with sysfs...\n");
 	sysdev_class_register(&pmacpic_sysclass);
 	sysdev_register(&device_pmacpic);
--- mb-wireless.orig/arch/powerpc/platforms/powermac/pmac.h	2007-02-05 14:24:06.164526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/pmac.h	2007-02-05 14:24:38.804526864 +0100
@@ -44,6 +44,9 @@ extern void pmac_ide_init_hwif_ports(hw_
 	unsigned long data_port, unsigned long ctrl_port, int *irq);
 
 extern int pmac_nvram_init(void);
+#ifdef CONFIG_PPC32
 extern void pmac_pic_init(void);
+#endif
+extern int pmac_pic_probe_mpic(void);
 
 #endif /* __PMAC_H__ */
--- mb-wireless.orig/arch/powerpc/platforms/powermac/setup.c	2007-02-05 14:24:06.194526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/setup.c	2007-02-05 14:24:38.814526864 +0100
@@ -718,13 +718,28 @@ static int pmac_pci_probe_mode(struct pc
 }
 #endif
 
+static void __init pmac_init_irq(void)
+{
+	int ret;
+
+	/* We first try to detect Apple's new Core99 chipset, since mac-io
+	 * is quite different on those machines and contains an IBM MPIC2.
+	 */
+	ret = pmac_pic_probe_mpic();
+
+#ifdef CONFIG_PPC32
+	if (ret != 0)
+		pmac_pic_init();
+#endif
+}
+
 define_machine(powermac) {
 	.name			= "PowerMac",
 	.probe			= pmac_probe,
 	.setup_arch		= pmac_setup_arch,
 	.init_early		= pmac_init_early,
 	.show_cpuinfo		= pmac_show_cpuinfo,
-	.init_IRQ		= pmac_pic_init,
+	.init_IRQ		= pmac_init_irq,
 	.get_irq		= NULL,	/* changed later */
 	.pci_irq_fixup		= pmac_pci_irq_fixup,
 	.restart		= pmac_restart,

--

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

* [PATCH 05/10] powermac: generic time suspend/resume code
  2007-02-05 18:30 [PATCH/RFC 00/10] suspend to disk for powermac G5 Johannes Berg
@ 2007-02-05 18:30   ` Johannes Berg
  2007-02-05 18:30   ` Johannes Berg
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Andrew Morton, linux-pm, Torrance

[-- Attachment #1: time-resume.patch --]
[-- Type: text/plain, Size: 4497 bytes --]

This patch removes the time suspend/restore code that was done through
a PMU notifier in arch/platforms/powermac/time.c.

Instead, we introduce arch/powerpc/sysdev/timer.c which creates a sys
device and handles time of day suspend/resume through that.

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

---
Tested on powermac with suspend-to-disk and powerbook with
suspend-to-{ram,disk}, please apply to -mm.

--- mb-wireless.orig/arch/powerpc/platforms/powermac/time.c	2007-02-05 14:24:06.474526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/time.c	2007-02-05 14:24:37.624526864 +0100
@@ -297,49 +297,11 @@ int __init via_calibrate_decr(void)
 }
 #endif
 
-#ifdef CONFIG_PM
-/*
- * Reset the time after a sleep.
- */
-static int
-time_sleep_notify(struct pmu_sleep_notifier *self, int when)
-{
-	static unsigned long time_diff;
-	unsigned long flags;
-	unsigned long seq;
-	struct timespec tv;
-
-	switch (when) {
-	case PBOOK_SLEEP_NOW:
-		do {
-			seq = read_seqbegin_irqsave(&xtime_lock, flags);
-			time_diff = xtime.tv_sec - pmac_get_boot_time();
-		} while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
-		break;
-	case PBOOK_WAKE:
-		tv.tv_sec = pmac_get_boot_time() + time_diff;
-		tv.tv_nsec = 0;
-		do_settimeofday(&tv);
-		break;
-	}
-	return PBOOK_SLEEP_OK;
-}
-
-static struct pmu_sleep_notifier time_sleep_notifier = {
-	time_sleep_notify, SLEEP_LEVEL_MISC,
-};
-#endif /* CONFIG_PM */
-
 /*
  * Query the OF and get the decr frequency.
  */
 void __init pmac_calibrate_decr(void)
 {
-#if defined(CONFIG_PM) && defined(CONFIG_ADB_PMU)
-	/* XXX why here? */
-	pmu_register_sleep_notifier(&time_sleep_notifier);
-#endif
-
 	generic_calibrate_decr();
 
 #ifdef CONFIG_PPC32
--- mb-wireless.orig/arch/powerpc/Kconfig	2007-02-05 14:24:06.484526864 +0100
+++ mb-wireless/arch/powerpc/Kconfig	2007-02-05 14:24:37.624526864 +0100
@@ -11,6 +11,11 @@ config PPC64
 	  This option selects whether a 32-bit or a 64-bit kernel
 	  will be built.
 
+config PPC_PM_NEEDS_RTC_LIB
+	bool
+	select RTC_LIB
+	default y if PM
+
 config PPC32
 	bool
 	default y if !PPC64
--- mb-wireless.orig/arch/powerpc/sysdev/Makefile	2007-02-05 14:24:06.514526864 +0100
+++ mb-wireless/arch/powerpc/sysdev/Makefile	2007-02-05 14:24:37.624526864 +0100
@@ -13,6 +13,8 @@ obj-$(CONFIG_FSL_SOC)		+= fsl_soc.o
 obj-$(CONFIG_TSI108_BRIDGE)	+= tsi108_pci.o tsi108_dev.o
 obj-$(CONFIG_QUICC_ENGINE)	+= qe_lib/
 obj-$(CONFIG_MTD)		+= rom.o
+# contains only the suspend handler for time
+obj-$(CONFIG_PM)		+= timer.o
 
 ifeq ($(CONFIG_PPC_MERGE),y)
 obj-$(CONFIG_PPC_I8259)		+= i8259.o
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ mb-wireless/arch/powerpc/sysdev/timer.c	2007-02-05 14:24:37.624526864 +0100
@@ -0,0 +1,70 @@
+/*
+ * Common code to keep time when machine suspends.
+ *
+ * Copyright 2007	Johannes Berg <johannes@sipsolutions.net>
+ *
+ * GPLv2
+ */
+
+#include <linux/time.h>
+#include <asm/rtc.h>
+
+static unsigned long suspend_rtc_time;
+
+/*
+ * Reset the time after a sleep.
+ */
+static int timer_resume(struct sys_device *dev)
+{
+	struct timeval tv;
+	struct timespec ts;
+	struct rtc_time cur_rtc_tm;
+	unsigned long cur_rtc_time, diff;
+
+	/* get current RTC time and convert to seconds */
+	get_rtc_time(&cur_rtc_tm);
+	rtc_tm_to_time(&cur_rtc_tm, &cur_rtc_time);
+
+	diff = cur_rtc_time - suspend_rtc_time;
+
+	/* adjust time of day by seconds that elapsed while
+	 * we were suspended */
+	do_gettimeofday(&tv);
+	ts.tv_sec = tv.tv_sec + diff;
+	ts.tv_nsec = tv.tv_usec * NSEC_PER_USEC;
+	do_settimeofday(&ts);
+
+	return 0;
+}
+
+static int timer_suspend(struct sys_device *dev, pm_message_t state)
+{
+	struct rtc_time suspend_rtc_tm;
+	WARN_ON(!ppc_md.get_rtc_time);
+
+	get_rtc_time(&suspend_rtc_tm);
+	rtc_tm_to_time(&suspend_rtc_tm, &suspend_rtc_time);
+
+	return 0;
+}
+
+static struct sysdev_class timer_sysclass = {
+	.resume = timer_resume,
+	.suspend = timer_suspend,
+	set_kset_name("timer"),
+};
+
+static struct sys_device device_timer = {
+	.id = 0,
+	.cls = &timer_sysclass,
+};
+
+static int time_init_device(void)
+{
+	int error = sysdev_class_register(&timer_sysclass);
+	if (!error)
+		error = sysdev_register(&device_timer);
+	return error;
+}
+
+device_initcall(time_init_device);

--

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

* [PATCH 05/10] powermac: generic time suspend/resume code
@ 2007-02-05 18:30   ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Andrew Morton, linux-pm, Torrance

This patch removes the time suspend/restore code that was done through
a PMU notifier in arch/platforms/powermac/time.c.

Instead, we introduce arch/powerpc/sysdev/timer.c which creates a sys
device and handles time of day suspend/resume through that.

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

---
Tested on powermac with suspend-to-disk and powerbook with
suspend-to-{ram,disk}, please apply to -mm.

--- mb-wireless.orig/arch/powerpc/platforms/powermac/time.c	2007-02-05 14:24:06.474526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/time.c	2007-02-05 14:24:37.624526864 +0100
@@ -297,49 +297,11 @@ int __init via_calibrate_decr(void)
 }
 #endif
 
-#ifdef CONFIG_PM
-/*
- * Reset the time after a sleep.
- */
-static int
-time_sleep_notify(struct pmu_sleep_notifier *self, int when)
-{
-	static unsigned long time_diff;
-	unsigned long flags;
-	unsigned long seq;
-	struct timespec tv;
-
-	switch (when) {
-	case PBOOK_SLEEP_NOW:
-		do {
-			seq = read_seqbegin_irqsave(&xtime_lock, flags);
-			time_diff = xtime.tv_sec - pmac_get_boot_time();
-		} while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
-		break;
-	case PBOOK_WAKE:
-		tv.tv_sec = pmac_get_boot_time() + time_diff;
-		tv.tv_nsec = 0;
-		do_settimeofday(&tv);
-		break;
-	}
-	return PBOOK_SLEEP_OK;
-}
-
-static struct pmu_sleep_notifier time_sleep_notifier = {
-	time_sleep_notify, SLEEP_LEVEL_MISC,
-};
-#endif /* CONFIG_PM */
-
 /*
  * Query the OF and get the decr frequency.
  */
 void __init pmac_calibrate_decr(void)
 {
-#if defined(CONFIG_PM) && defined(CONFIG_ADB_PMU)
-	/* XXX why here? */
-	pmu_register_sleep_notifier(&time_sleep_notifier);
-#endif
-
 	generic_calibrate_decr();
 
 #ifdef CONFIG_PPC32
--- mb-wireless.orig/arch/powerpc/Kconfig	2007-02-05 14:24:06.484526864 +0100
+++ mb-wireless/arch/powerpc/Kconfig	2007-02-05 14:24:37.624526864 +0100
@@ -11,6 +11,11 @@ config PPC64
 	  This option selects whether a 32-bit or a 64-bit kernel
 	  will be built.
 
+config PPC_PM_NEEDS_RTC_LIB
+	bool
+	select RTC_LIB
+	default y if PM
+
 config PPC32
 	bool
 	default y if !PPC64
--- mb-wireless.orig/arch/powerpc/sysdev/Makefile	2007-02-05 14:24:06.514526864 +0100
+++ mb-wireless/arch/powerpc/sysdev/Makefile	2007-02-05 14:24:37.624526864 +0100
@@ -13,6 +13,8 @@ obj-$(CONFIG_FSL_SOC)		+= fsl_soc.o
 obj-$(CONFIG_TSI108_BRIDGE)	+= tsi108_pci.o tsi108_dev.o
 obj-$(CONFIG_QUICC_ENGINE)	+= qe_lib/
 obj-$(CONFIG_MTD)		+= rom.o
+# contains only the suspend handler for time
+obj-$(CONFIG_PM)		+= timer.o
 
 ifeq ($(CONFIG_PPC_MERGE),y)
 obj-$(CONFIG_PPC_I8259)		+= i8259.o
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ mb-wireless/arch/powerpc/sysdev/timer.c	2007-02-05 14:24:37.624526864 +0100
@@ -0,0 +1,70 @@
+/*
+ * Common code to keep time when machine suspends.
+ *
+ * Copyright 2007	Johannes Berg <johannes@sipsolutions.net>
+ *
+ * GPLv2
+ */
+
+#include <linux/time.h>
+#include <asm/rtc.h>
+
+static unsigned long suspend_rtc_time;
+
+/*
+ * Reset the time after a sleep.
+ */
+static int timer_resume(struct sys_device *dev)
+{
+	struct timeval tv;
+	struct timespec ts;
+	struct rtc_time cur_rtc_tm;
+	unsigned long cur_rtc_time, diff;
+
+	/* get current RTC time and convert to seconds */
+	get_rtc_time(&cur_rtc_tm);
+	rtc_tm_to_time(&cur_rtc_tm, &cur_rtc_time);
+
+	diff = cur_rtc_time - suspend_rtc_time;
+
+	/* adjust time of day by seconds that elapsed while
+	 * we were suspended */
+	do_gettimeofday(&tv);
+	ts.tv_sec = tv.tv_sec + diff;
+	ts.tv_nsec = tv.tv_usec * NSEC_PER_USEC;
+	do_settimeofday(&ts);
+
+	return 0;
+}
+
+static int timer_suspend(struct sys_device *dev, pm_message_t state)
+{
+	struct rtc_time suspend_rtc_tm;
+	WARN_ON(!ppc_md.get_rtc_time);
+
+	get_rtc_time(&suspend_rtc_tm);
+	rtc_tm_to_time(&suspend_rtc_tm, &suspend_rtc_time);
+
+	return 0;
+}
+
+static struct sysdev_class timer_sysclass = {
+	.resume = timer_resume,
+	.suspend = timer_suspend,
+	set_kset_name("timer"),
+};
+
+static struct sys_device device_timer = {
+	.id = 0,
+	.cls = &timer_sysclass,
+};
+
+static int time_init_device(void)
+{
+	int error = sysdev_class_register(&timer_sysclass);
+	if (!error)
+		error = sysdev_register(&device_timer);
+	return error;
+}
+
+device_initcall(time_init_device);

--

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

* [RFC 06/10] powerpc: MPIC sys_device & suspend/resume
  2007-02-05 18:30 [PATCH/RFC 00/10] suspend to disk for powermac G5 Johannes Berg
@ 2007-02-05 18:30   ` Johannes Berg
  2007-02-05 18:30   ` Johannes Berg
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-pm, Torrance

[-- Attachment #1: mpic-suspend.patch --]
[-- Type: text/plain, Size: 3684 bytes --]

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 <benh@kernel.crashing.org>

---
The first hunk is just a tiny whitespace cleanup.

Without this patch, i2sbus (built as a module) for example
doesn't work properly across a suspend-to-disk/resume cycle,
with this patch it works fine.

I'm not entirely sure if there should be some wait logic
after I restore the MPIC registers, it works as-is for me.

--- mb-wireless.orig/arch/powerpc/sysdev/mpic.c	2007-02-05 14:24:05.734526864 +0100
+++ mb-wireless/arch/powerpc/sysdev/mpic.c	2007-02-05 14:24:39.464526864 +0100
@@ -1123,7 +1123,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_BROKEN_U3) && (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 */
@@ -1147,6 +1147,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)
@@ -1376,3 +1382,61 @@ void smp_mpic_message_pass(int target, i
 	}
 }
 #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);
+	}
+
+	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);
--- mb-wireless.orig/include/asm-powerpc/mpic.h	2007-02-05 14:24:05.784526864 +0100
+++ mb-wireless/include/asm-powerpc/mpic.h	2007-02-05 14:24:39.464526864 +0100
@@ -3,6 +3,7 @@
 #ifdef __KERNEL__
 
 #include <linux/irq.h>
+#include <linux/sysdev.h>
 #include <asm/dcr.h>
 
 /*
@@ -243,6 +244,11 @@ struct mpic_reg_bank {
 #endif /* CONFIG_PPC_DCR */
 };
 
+struct mpic_irq_save {
+	u32		vecprio,
+			dest;
+};
+
 /* The instance data of a given MPIC */
 struct mpic
 {
@@ -302,6 +308,12 @@ struct mpic
 
 	/* link */
 	struct mpic		*next;
+
+	struct sys_device	sysdev;
+
+#ifdef CONFIG_PM
+	struct mpic_irq_save	*save_data;
+#endif
 };
 
 /*

--

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

* [RFC 06/10] powerpc: MPIC sys_device & suspend/resume
@ 2007-02-05 18:30   ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-pm, Torrance

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 <benh@kernel.crashing.org>

---
The first hunk is just a tiny whitespace cleanup.

Without this patch, i2sbus (built as a module) for example
doesn't work properly across a suspend-to-disk/resume cycle,
with this patch it works fine.

I'm not entirely sure if there should be some wait logic
after I restore the MPIC registers, it works as-is for me.

--- mb-wireless.orig/arch/powerpc/sysdev/mpic.c	2007-02-05 14:24:05.734526864 +0100
+++ mb-wireless/arch/powerpc/sysdev/mpic.c	2007-02-05 14:24:39.464526864 +0100
@@ -1123,7 +1123,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_BROKEN_U3) && (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 */
@@ -1147,6 +1147,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)
@@ -1376,3 +1382,61 @@ void smp_mpic_message_pass(int target, i
 	}
 }
 #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);
+	}
+
+	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);
--- mb-wireless.orig/include/asm-powerpc/mpic.h	2007-02-05 14:24:05.784526864 +0100
+++ mb-wireless/include/asm-powerpc/mpic.h	2007-02-05 14:24:39.464526864 +0100
@@ -3,6 +3,7 @@
 #ifdef __KERNEL__
 
 #include <linux/irq.h>
+#include <linux/sysdev.h>
 #include <asm/dcr.h>
 
 /*
@@ -243,6 +244,11 @@ struct mpic_reg_bank {
 #endif /* CONFIG_PPC_DCR */
 };
 
+struct mpic_irq_save {
+	u32		vecprio,
+			dest;
+};
+
 /* The instance data of a given MPIC */
 struct mpic
 {
@@ -302,6 +308,12 @@ struct mpic
 
 	/* link */
 	struct mpic		*next;
+
+	struct sys_device	sysdev;
+
+#ifdef CONFIG_PM
+	struct mpic_irq_save	*save_data;
+#endif
 };
 
 /*

--

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

* [RFC 07/10] powermac: support G5 CPU hotplug
  2007-02-05 18:30 [PATCH/RFC 00/10] suspend to disk for powermac G5 Johannes Berg
@ 2007-02-05 18:30   ` Johannes Berg
  2007-02-05 18:30   ` Johannes Berg
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-pm, Torrance

[-- Attachment #1: powermac-g5-cpu-offline.patch --]
[-- Type: text/plain, Size: 3395 bytes --]

This patch allows "hotplugging" of CPUs on G5 machines. CPUs that are
disabled are put into an idle loop with interrupts hard-disabled, to wake
them up again we kick them just like when bringing them up.

Maybe there's some way to actually turn off those CPUs even more?

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

--- mb-wireless.orig/arch/powerpc/platforms/powermac/smp.c	2007-02-05 16:07:09.164524763 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/smp.c	2007-02-05 16:07:50.774524763 +0100
@@ -898,7 +898,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 = {
@@ -908,8 +908,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
 };
--- mb-wireless.orig/arch/powerpc/platforms/powermac/setup.c	2007-02-05 16:07:22.024524763 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/setup.c	2007-02-05 16:07:50.784524763 +0100
@@ -490,6 +490,9 @@ static int pmac_late_init(void)
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	pm_set_ops(&pmac_pm_ops);
 #endif /* CONFIG_SOFTWARE_SUSPEND */
+	/* 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;
 }
 
@@ -716,6 +719,33 @@ 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 ... */
+	hard_irq_disable();
+
+	printk(KERN_DEBUG "CPU#%d offline\n", smp_processor_id());
+	__get_cpu_var(cpu_state) = CPU_DEAD;
+	smp_wmb();
+	while (1) {
+		ppc64_runlatch_off();
+		if (ppc_md.power_save) {
+			ppc_md.power_save();
+		} else {
+			HMT_low();
+			HMT_very_low();
+		}
+	}
+}
+#endif
+
 #endif
 
 static void __init pmac_init_irq(void)
@@ -769,6 +799,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
 };
--- mb-wireless.orig/arch/powerpc/kernel/smp.c	2007-02-05 16:07:09.274524763 +0100
+++ mb-wireless/arch/powerpc/kernel/smp.c	2007-02-05 18:15:51.114524763 +0100
@@ -558,6 +558,11 @@ int __devinit start_secondary(void *unus
 
 	local_irq_enable();
 
+	/* it seems to be possible that we died from within
+	 * an interrupt ... reset the in-irq counts */
+	task_thread_info(paca[cpu].__current)->preempt_count &=
+		~(SOFTIRQ_MASK|HARDIRQ_MASK);
+
 	cpu_idle();
 	return 0;
 }

--

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

* [RFC 07/10] powermac: support G5 CPU hotplug
@ 2007-02-05 18:30   ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-pm, Torrance

This patch allows "hotplugging" of CPUs on G5 machines. CPUs that are
disabled are put into an idle loop with interrupts hard-disabled, to wake
them up again we kick them just like when bringing them up.

Maybe there's some way to actually turn off those CPUs even more?

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

--- mb-wireless.orig/arch/powerpc/platforms/powermac/smp.c	2007-02-05 16:07:09.164524763 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/smp.c	2007-02-05 16:07:50.774524763 +0100
@@ -898,7 +898,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 = {
@@ -908,8 +908,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
 };
--- mb-wireless.orig/arch/powerpc/platforms/powermac/setup.c	2007-02-05 16:07:22.024524763 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/setup.c	2007-02-05 16:07:50.784524763 +0100
@@ -490,6 +490,9 @@ static int pmac_late_init(void)
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	pm_set_ops(&pmac_pm_ops);
 #endif /* CONFIG_SOFTWARE_SUSPEND */
+	/* 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;
 }
 
@@ -716,6 +719,33 @@ 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 ... */
+	hard_irq_disable();
+
+	printk(KERN_DEBUG "CPU#%d offline\n", smp_processor_id());
+	__get_cpu_var(cpu_state) = CPU_DEAD;
+	smp_wmb();
+	while (1) {
+		ppc64_runlatch_off();
+		if (ppc_md.power_save) {
+			ppc_md.power_save();
+		} else {
+			HMT_low();
+			HMT_very_low();
+		}
+	}
+}
+#endif
+
 #endif
 
 static void __init pmac_init_irq(void)
@@ -769,6 +799,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
 };
--- mb-wireless.orig/arch/powerpc/kernel/smp.c	2007-02-05 16:07:09.274524763 +0100
+++ mb-wireless/arch/powerpc/kernel/smp.c	2007-02-05 18:15:51.114524763 +0100
@@ -558,6 +558,11 @@ int __devinit start_secondary(void *unus
 
 	local_irq_enable();
 
+	/* it seems to be possible that we died from within
+	 * an interrupt ... reset the in-irq counts */
+	task_thread_info(paca[cpu].__current)->preempt_count &=
+		~(SOFTIRQ_MASK|HARDIRQ_MASK);
+
 	cpu_idle();
 	return 0;
 }

--

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

* [RFC 08/10] powerpc: dart iommu suspend
  2007-02-05 18:30 [PATCH/RFC 00/10] suspend to disk for powermac G5 Johannes Berg
@ 2007-02-05 18:30   ` Johannes Berg
  2007-02-05 18:30   ` Johannes Berg
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-pm, Torrance

[-- Attachment #1: dart-suspend.patch --]
[-- Type: text/plain, Size: 2647 bytes --]

This implements suspend and resume code for the dart iommu.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
Just come to think of it, I made it conditional on
CONFIG_SOFTWARE_SUSPEND but could imagine that it should
instead depend on CONFIG_PM... There is no lowlevel suspend
to RAM code yet which would call this so for now it's
probably fine.

--- mb-wireless.orig/arch/powerpc/sysdev/dart_iommu.c	2007-02-05 14:24:04.834526864 +0100
+++ mb-wireless/arch/powerpc/sysdev/dart_iommu.c	2007-02-05 14:24:40.684526864 +0100
@@ -54,6 +54,9 @@ static unsigned long dart_tablesize;
 
 /* Virtual base address of the DART table */
 static u32 *dart_vbase;
+#ifdef CONFIG_SOFTWARE_SUSPEND
+static u32 *dart_copy;
+#endif
 
 /* Mapped base address for the dart */
 static unsigned int __iomem *dart;
@@ -346,6 +349,52 @@ void iommu_init_early_dart(void)
 	pci_dma_ops = &dma_direct_ops;
 }
 
+#ifdef CONFIG_SOFTWARE_SUSPEND
+static int iommu_init_late_dart(void)
+{
+	unsigned long i;
+	struct page *p;
+
+	/* this 16MB area is left unmapped because of caching
+	 * considerations. that happens early so we can't mark
+	 * it there, do it now instead */
+	for (i = 0; i < (1<<24); i+= PAGE_SIZE)
+		SetPageNosave(virt_to_page((void*)((unsigned long)dart_tablebase + i)));
+
+	/* if no dart table exists then we don't need to save it */
+	if (!dart_tablebase)
+		return 0;
+
+	/* 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);
+
+	return 0;
+}
+
+late_initcall(iommu_init_late_dart);
+
+void iommu_dart_save(void)
+{
+	if (!dart_tablebase)
+		return;
+
+	memcpy(dart_copy, dart_vbase, 2*1024*1024);
+}
+
+void iommu_dart_restore(void)
+{
+	if (!dart_tablebase)
+		return;
+
+	memcpy(dart_vbase, dart_copy, 2*1024*1024);
+	dart_tlb_invalidate_all();
+}
+#endif
 
 void __init alloc_dart_table(void)
 {
--- mb-wireless.orig/include/asm-powerpc/iommu.h	2007-02-05 14:24:05.014526864 +0100
+++ mb-wireless/include/asm-powerpc/iommu.h	2007-02-05 14:24:40.684526864 +0100
@@ -108,6 +108,10 @@ static inline void pci_iommu_init(void) 
 #endif
 
 extern void alloc_dart_table(void);
+#if defined(CONFIG_SOFTWARE_SUSPEND) && defined(CONFIG_U3_DART)
+extern void iommu_dart_save(void);
+extern void iommu_dart_restore(void);
+#endif
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_IOMMU_H */

--

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

* [RFC 08/10] powerpc: dart iommu suspend
@ 2007-02-05 18:30   ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-pm, Torrance

This implements suspend and resume code for the dart iommu.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
Just come to think of it, I made it conditional on
CONFIG_SOFTWARE_SUSPEND but could imagine that it should
instead depend on CONFIG_PM... There is no lowlevel suspend
to RAM code yet which would call this so for now it's
probably fine.

--- mb-wireless.orig/arch/powerpc/sysdev/dart_iommu.c	2007-02-05 14:24:04.834526864 +0100
+++ mb-wireless/arch/powerpc/sysdev/dart_iommu.c	2007-02-05 14:24:40.684526864 +0100
@@ -54,6 +54,9 @@ static unsigned long dart_tablesize;
 
 /* Virtual base address of the DART table */
 static u32 *dart_vbase;
+#ifdef CONFIG_SOFTWARE_SUSPEND
+static u32 *dart_copy;
+#endif
 
 /* Mapped base address for the dart */
 static unsigned int __iomem *dart;
@@ -346,6 +349,52 @@ void iommu_init_early_dart(void)
 	pci_dma_ops = &dma_direct_ops;
 }
 
+#ifdef CONFIG_SOFTWARE_SUSPEND
+static int iommu_init_late_dart(void)
+{
+	unsigned long i;
+	struct page *p;
+
+	/* this 16MB area is left unmapped because of caching
+	 * considerations. that happens early so we can't mark
+	 * it there, do it now instead */
+	for (i = 0; i < (1<<24); i+= PAGE_SIZE)
+		SetPageNosave(virt_to_page((void*)((unsigned long)dart_tablebase + i)));
+
+	/* if no dart table exists then we don't need to save it */
+	if (!dart_tablebase)
+		return 0;
+
+	/* 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);
+
+	return 0;
+}
+
+late_initcall(iommu_init_late_dart);
+
+void iommu_dart_save(void)
+{
+	if (!dart_tablebase)
+		return;
+
+	memcpy(dart_copy, dart_vbase, 2*1024*1024);
+}
+
+void iommu_dart_restore(void)
+{
+	if (!dart_tablebase)
+		return;
+
+	memcpy(dart_vbase, dart_copy, 2*1024*1024);
+	dart_tlb_invalidate_all();
+}
+#endif
 
 void __init alloc_dart_table(void)
 {
--- mb-wireless.orig/include/asm-powerpc/iommu.h	2007-02-05 14:24:05.014526864 +0100
+++ mb-wireless/include/asm-powerpc/iommu.h	2007-02-05 14:24:40.684526864 +0100
@@ -108,6 +108,10 @@ static inline void pci_iommu_init(void) 
 #endif
 
 extern void alloc_dart_table(void);
+#if defined(CONFIG_SOFTWARE_SUSPEND) && defined(CONFIG_U3_DART)
+extern void iommu_dart_save(void);
+extern void iommu_dart_restore(void);
+#endif
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_IOMMU_H */

--

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

* [RFC 09/10] powermac: suspend to disk on G5
  2007-02-05 18:30 [PATCH/RFC 00/10] suspend to disk for powermac G5 Johannes Berg
@ 2007-02-05 18:30   ` Johannes Berg
  2007-02-05 18:30   ` Johannes Berg
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-pm, Torrance

[-- Attachment #1: ppc64-swsusp.patch --]
[-- Type: text/plain, Size: 10433 bytes --]

Next revision of my powermac G5 suspend to disk implementation. This part
didn't really change much except for fixes and cleanups.

I still have

	set_context(current->active_mm->context.id, current->active_mm->pgd);

ifdef'ed out because I didn't know what it is doing and it works without :)
Can somebody explain what this is about and what the 64-bit equivalent would
be?

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

--- mb-wireless.orig/arch/powerpc/kernel/Makefile	2007-02-05 14:24:04.414526864 +0100
+++ mb-wireless/arch/powerpc/kernel/Makefile	2007-02-05 14:24:40.674526864 +0100
@@ -36,6 +36,7 @@ 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
 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)
--- mb-wireless.orig/kernel/power/Kconfig	2007-02-05 14:24:04.864526864 +0100
+++ mb-wireless/kernel/power/Kconfig	2007-02-05 14:24:40.674526864 +0100
@@ -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) && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP))
 	---help---
 	  Enable the possibility of suspending the machine.
 	  It doesn't need ACPI or APM.
@@ -129,5 +129,5 @@ config PM_STD_PARTITION
 
 config SUSPEND_SMP
 	bool
-	depends on HOTPLUG_CPU && X86 && PM
+	depends on HOTPLUG_CPU && (X86 || PPC64) && PM
 	default y
--- mb-wireless.orig/arch/powerpc/platforms/powermac/setup.c	2007-02-05 14:24:40.054526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/setup.c	2007-02-05 14:24:40.674526864 +0100
@@ -455,8 +455,10 @@ static int pmac_pm_finish(suspend_state_
 {
 	printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
 
+#ifdef CONFIG_PPC32
 	/* Restore userland MMU context */
 	set_context(current->active_mm->context.id, current->active_mm->pgd);
+#endif
 
 	return 0;
 }
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ mb-wireless/include/asm-powerpc/suspend.h	2007-02-05 14:24:40.684526864 +0100
@@ -0,0 +1,17 @@
+#ifndef __ASM_POWERPC_SUSPEND_H
+#define __ASM_POWERPC_SUSPEND_H
+
+static inline int arch_prepare_suspend(void)
+{
+	return 0;
+}
+
+#ifdef CONFIG_PPC32
+static inline void save_processor_state(void) {}
+static inline void restore_processor_state(void) {}
+#else
+void save_processor_state(void);
+void restore_processor_state(void);
+#endif
+
+#endif /* __ASM_POWERPC_SUSPEND_H */
--- mb-wireless.orig/include/linux/suspend.h	2007-02-05 14:24:05.094526864 +0100
+++ mb-wireless/include/linux/suspend.h	2007-02-05 14:24:40.684526864 +0100
@@ -1,7 +1,7 @@
 #ifndef _LINUX_SWSUSP_H
 #define _LINUX_SWSUSP_H
 
-#if defined(CONFIG_X86) || defined(CONFIG_FRV) || defined(CONFIG_PPC32)
+#if defined(CONFIG_X86) || defined(CONFIG_FRV) || defined(CONFIG_PPC32) || defined(CONFIG_PPC64)
 #include <asm/suspend.h>
 #endif
 #include <linux/swap.h>
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ mb-wireless/arch/powerpc/kernel/swsusp_64.c	2007-02-05 14:24:40.684526864 +0100
@@ -0,0 +1,32 @@
+/*
+ * PowerPC 64-bit swsusp implementation
+ *
+ * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * GPLv2
+ */
+
+#include <asm/system.h>
+#include <asm/iommu.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+
+void save_processor_state(void)
+{
+	hard_irq_disable();
+}
+
+void restore_processor_state(void)
+{
+	hard_irq_enable();
+}
+
+void do_after_copyback(void)
+{
+#ifdef CONFIG_U3_DART
+	iommu_dart_restore();
+#endif
+	touch_softlockup_watchdog();
+	mb();
+	hard_irq_enable();
+}
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ mb-wireless/arch/powerpc/kernel/swsusp_asm64.S	2007-02-05 14:24:40.684526864 +0100
@@ -0,0 +1,231 @@
+/*
+ * PowerPC 64-bit swsusp implementation
+ *
+ * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * GPLv2
+ */
+
+#include <linux/threads.h>
+#include <asm/processor.h>
+#include <asm/page.h>
+#include <asm/cputable.h>
+#include <asm/thread_info.h>
+#include <asm/ppc_asm.h>
+#include <asm/asm-offsets.h>
+
+/*
+ * Structure for storing CPU registers on the save area.
+ */
+#define SL_r1		0x00	/* stack pointer */
+#define SL_PC		0x08
+#define SL_MSR		0x10
+#define SL_SDR1		0x18
+#define SL_XER		0x20
+#define SL_TB		0x40
+#define SL_r2		0x48
+#define SL_CR		0x50
+#define SL_LR		0x58
+#define SL_r12		0x60
+#define SL_r13		0x68
+#define SL_r14		0x70
+#define SL_r15		0x78
+#define SL_r16		0x80
+#define SL_r17		0x88
+#define SL_r18		0x90
+#define SL_r19		0x98
+#define SL_r20		0xa0
+#define SL_r21		0xa8
+#define SL_r22		0xb0
+#define SL_r23		0xb8
+#define SL_r24		0xc0
+#define SL_r25		0xc8
+#define SL_r26		0xd0
+#define SL_r27		0xd8
+#define SL_r28		0xe0
+#define SL_r29		0xe8
+#define SL_r30		0xf0
+#define SL_r31		0xf8
+#define SL_SIZE		SL_r31+8
+
+/* these macros rely on the save area being
+ * pointed to by r11 */
+#define SAVE_SPECIAL(special)		\
+	mf##special	r0		;\
+	std	r0, SL_##special(r11)
+#define RESTORE_SPECIAL(special)	\
+	ld	r0, SL_##special(r11)	;\
+	mt##special	r0
+#define SAVE_REGISTER(reg)		\
+	std	reg, SL_##reg(r11)
+#define RESTORE_REGISTER(reg)		\
+	ld	reg, SL_##reg(r11)
+
+/* space for storing cpu state */
+	.section .data
+	.align  5
+swsusp_save_area:
+	.space SL_SIZE
+
+	.section ".toc","aw"
+swsusp_save_area_ptr:
+	.tc	swsusp_save_area[TC],swsusp_save_area
+restore_pblist_ptr:
+	.tc	restore_pblist[TC],restore_pblist
+
+	.section .text
+	.align  5
+_GLOBAL(swsusp_arch_suspend)
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+	SAVE_SPECIAL(LR)
+	SAVE_REGISTER(r1)
+	SAVE_SPECIAL(CR)
+	SAVE_SPECIAL(TB)
+	SAVE_REGISTER(r2)
+	SAVE_REGISTER(r12)
+	SAVE_REGISTER(r13)
+	SAVE_REGISTER(r14)
+	SAVE_REGISTER(r15)
+	SAVE_REGISTER(r16)
+	SAVE_REGISTER(r17)
+	SAVE_REGISTER(r18)
+	SAVE_REGISTER(r19)
+	SAVE_REGISTER(r20)
+	SAVE_REGISTER(r21)
+	SAVE_REGISTER(r22)
+	SAVE_REGISTER(r23)
+	SAVE_REGISTER(r24)
+	SAVE_REGISTER(r25)
+	SAVE_REGISTER(r26)
+	SAVE_REGISTER(r27)
+	SAVE_REGISTER(r28)
+	SAVE_REGISTER(r29)
+	SAVE_REGISTER(r30)
+	SAVE_REGISTER(r31)
+	SAVE_SPECIAL(MSR)
+	SAVE_SPECIAL(SDR1)
+	SAVE_SPECIAL(XER)
+
+	/* we push the stack up 128 bytes but don't store the
+	 * stack pointer on the stack like a real stackframe */
+	addi	r1,r1,-128
+
+#ifdef	CONFIG_U3_DART
+	bl iommu_dart_save
+#endif
+
+	bl swsusp_save
+
+	/* restore LR */
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+	RESTORE_SPECIAL(LR)
+	addi	r1,r1,128
+
+	blr
+
+/* Resume code */
+_GLOBAL(swsusp_arch_resume)
+	/* Stop pending alitvec streams and memory accesses */
+BEGIN_FTR_SECTION
+	DSSALL
+END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
+	sync
+
+	ld	r12,restore_pblist_ptr@toc(r2)
+	ld	r12,0(r12)
+
+	cmpdi	r12,0
+	beq-	nothing_to_copy
+	li	r15,512
+copyloop:
+	ld	r13,pbe_address(r12)
+	ld	r14,pbe_orig_address(r12)
+
+	mtctr	r15
+	li	r10,0
+copy_page_loop:
+	ldx	r0,r10,r13
+	stdx	r0,r10,r14
+	addi	r10,r10,8
+	bdnz copy_page_loop
+
+	ld	r12,pbe_next(r12)
+	cmpdi	r12,0
+	bne+	copyloop
+nothing_to_copy:
+
+	/* flush caches */
+	lis	r3, 0x10
+	mtctr	r3
+	li	r3, 0
+	ori	r3, r3, CONFIG_KERNEL_START>>48
+	li	r0, 48
+	sld	r3, r3, r0
+	li	r0, 0
+1:
+	dcbf	r0,r3
+	addi	r3,r3,0x20
+	bdnz	1b
+
+	sync
+
+	tlbia
+
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+
+	RESTORE_SPECIAL(CR)
+
+	/* restore timebase */
+	/* load saved tb */
+	ld	r1, SL_TB(r11)
+	/* get upper 32 bits of it */
+	srdi	r2, r1, 32
+	/* clear tb lower to avoid wrap */
+	li	r0, 0
+	mttbl	r0
+	/* set tb upper */
+	mttbu	r2
+	/* set tb lower */
+	mttbl	r1
+
+	/* restore registers */
+	RESTORE_REGISTER(r1)
+	RESTORE_REGISTER(r2)
+	RESTORE_REGISTER(r12)
+	RESTORE_REGISTER(r13)
+	RESTORE_REGISTER(r14)
+	RESTORE_REGISTER(r15)
+	RESTORE_REGISTER(r16)
+	RESTORE_REGISTER(r17)
+	RESTORE_REGISTER(r18)
+	RESTORE_REGISTER(r19)
+	RESTORE_REGISTER(r20)
+	RESTORE_REGISTER(r21)
+	RESTORE_REGISTER(r22)
+	RESTORE_REGISTER(r23)
+	RESTORE_REGISTER(r24)
+	RESTORE_REGISTER(r25)
+	RESTORE_REGISTER(r26)
+	RESTORE_REGISTER(r27)
+	RESTORE_REGISTER(r28)
+	RESTORE_REGISTER(r29)
+	RESTORE_REGISTER(r30)
+	RESTORE_REGISTER(r31)
+	/* can't use RESTORE_SPECIAL(MSR) */
+	ld	r0, SL_MSR(r11)
+	mtmsrd	r0, 0
+	RESTORE_SPECIAL(SDR1)
+	RESTORE_SPECIAL(XER)
+
+	sync
+
+	addi	r1,r1,-128
+	bl	slb_flush_and_rebolt
+	bl	do_after_copyback
+	addi	r1,r1,128
+
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+	RESTORE_SPECIAL(LR)
+
+	li	r3, 0
+	blr
--- mb-wireless.orig/arch/powerpc/kernel/asm-offsets.c	2007-02-05 14:24:04.574526864 +0100
+++ mb-wireless/arch/powerpc/kernel/asm-offsets.c	2007-02-05 14:24:40.684526864 +0100
@@ -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 */
--- mb-wireless.orig/arch/powerpc/kernel/idle.c	2007-02-05 14:24:04.684526864 +0100
+++ mb-wireless/arch/powerpc/kernel/idle.c	2007-02-05 14:24:40.684526864 +0100
@@ -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

--

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

* [RFC 09/10] powermac: suspend to disk on G5
@ 2007-02-05 18:30   ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-pm, Torrance

Next revision of my powermac G5 suspend to disk implementation. This part
didn't really change much except for fixes and cleanups.

I still have

	set_context(current->active_mm->context.id, current->active_mm->pgd);

ifdef'ed out because I didn't know what it is doing and it works without :)
Can somebody explain what this is about and what the 64-bit equivalent would
be?

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

--- mb-wireless.orig/arch/powerpc/kernel/Makefile	2007-02-05 14:24:04.414526864 +0100
+++ mb-wireless/arch/powerpc/kernel/Makefile	2007-02-05 14:24:40.674526864 +0100
@@ -36,6 +36,7 @@ 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
 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)
--- mb-wireless.orig/kernel/power/Kconfig	2007-02-05 14:24:04.864526864 +0100
+++ mb-wireless/kernel/power/Kconfig	2007-02-05 14:24:40.674526864 +0100
@@ -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) && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP))
 	---help---
 	  Enable the possibility of suspending the machine.
 	  It doesn't need ACPI or APM.
@@ -129,5 +129,5 @@ config PM_STD_PARTITION
 
 config SUSPEND_SMP
 	bool
-	depends on HOTPLUG_CPU && X86 && PM
+	depends on HOTPLUG_CPU && (X86 || PPC64) && PM
 	default y
--- mb-wireless.orig/arch/powerpc/platforms/powermac/setup.c	2007-02-05 14:24:40.054526864 +0100
+++ mb-wireless/arch/powerpc/platforms/powermac/setup.c	2007-02-05 14:24:40.674526864 +0100
@@ -455,8 +455,10 @@ static int pmac_pm_finish(suspend_state_
 {
 	printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
 
+#ifdef CONFIG_PPC32
 	/* Restore userland MMU context */
 	set_context(current->active_mm->context.id, current->active_mm->pgd);
+#endif
 
 	return 0;
 }
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ mb-wireless/include/asm-powerpc/suspend.h	2007-02-05 14:24:40.684526864 +0100
@@ -0,0 +1,17 @@
+#ifndef __ASM_POWERPC_SUSPEND_H
+#define __ASM_POWERPC_SUSPEND_H
+
+static inline int arch_prepare_suspend(void)
+{
+	return 0;
+}
+
+#ifdef CONFIG_PPC32
+static inline void save_processor_state(void) {}
+static inline void restore_processor_state(void) {}
+#else
+void save_processor_state(void);
+void restore_processor_state(void);
+#endif
+
+#endif /* __ASM_POWERPC_SUSPEND_H */
--- mb-wireless.orig/include/linux/suspend.h	2007-02-05 14:24:05.094526864 +0100
+++ mb-wireless/include/linux/suspend.h	2007-02-05 14:24:40.684526864 +0100
@@ -1,7 +1,7 @@
 #ifndef _LINUX_SWSUSP_H
 #define _LINUX_SWSUSP_H
 
-#if defined(CONFIG_X86) || defined(CONFIG_FRV) || defined(CONFIG_PPC32)
+#if defined(CONFIG_X86) || defined(CONFIG_FRV) || defined(CONFIG_PPC32) || defined(CONFIG_PPC64)
 #include <asm/suspend.h>
 #endif
 #include <linux/swap.h>
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ mb-wireless/arch/powerpc/kernel/swsusp_64.c	2007-02-05 14:24:40.684526864 +0100
@@ -0,0 +1,32 @@
+/*
+ * PowerPC 64-bit swsusp implementation
+ *
+ * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * GPLv2
+ */
+
+#include <asm/system.h>
+#include <asm/iommu.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+
+void save_processor_state(void)
+{
+	hard_irq_disable();
+}
+
+void restore_processor_state(void)
+{
+	hard_irq_enable();
+}
+
+void do_after_copyback(void)
+{
+#ifdef CONFIG_U3_DART
+	iommu_dart_restore();
+#endif
+	touch_softlockup_watchdog();
+	mb();
+	hard_irq_enable();
+}
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ mb-wireless/arch/powerpc/kernel/swsusp_asm64.S	2007-02-05 14:24:40.684526864 +0100
@@ -0,0 +1,231 @@
+/*
+ * PowerPC 64-bit swsusp implementation
+ *
+ * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * GPLv2
+ */
+
+#include <linux/threads.h>
+#include <asm/processor.h>
+#include <asm/page.h>
+#include <asm/cputable.h>
+#include <asm/thread_info.h>
+#include <asm/ppc_asm.h>
+#include <asm/asm-offsets.h>
+
+/*
+ * Structure for storing CPU registers on the save area.
+ */
+#define SL_r1		0x00	/* stack pointer */
+#define SL_PC		0x08
+#define SL_MSR		0x10
+#define SL_SDR1		0x18
+#define SL_XER		0x20
+#define SL_TB		0x40
+#define SL_r2		0x48
+#define SL_CR		0x50
+#define SL_LR		0x58
+#define SL_r12		0x60
+#define SL_r13		0x68
+#define SL_r14		0x70
+#define SL_r15		0x78
+#define SL_r16		0x80
+#define SL_r17		0x88
+#define SL_r18		0x90
+#define SL_r19		0x98
+#define SL_r20		0xa0
+#define SL_r21		0xa8
+#define SL_r22		0xb0
+#define SL_r23		0xb8
+#define SL_r24		0xc0
+#define SL_r25		0xc8
+#define SL_r26		0xd0
+#define SL_r27		0xd8
+#define SL_r28		0xe0
+#define SL_r29		0xe8
+#define SL_r30		0xf0
+#define SL_r31		0xf8
+#define SL_SIZE		SL_r31+8
+
+/* these macros rely on the save area being
+ * pointed to by r11 */
+#define SAVE_SPECIAL(special)		\
+	mf##special	r0		;\
+	std	r0, SL_##special(r11)
+#define RESTORE_SPECIAL(special)	\
+	ld	r0, SL_##special(r11)	;\
+	mt##special	r0
+#define SAVE_REGISTER(reg)		\
+	std	reg, SL_##reg(r11)
+#define RESTORE_REGISTER(reg)		\
+	ld	reg, SL_##reg(r11)
+
+/* space for storing cpu state */
+	.section .data
+	.align  5
+swsusp_save_area:
+	.space SL_SIZE
+
+	.section ".toc","aw"
+swsusp_save_area_ptr:
+	.tc	swsusp_save_area[TC],swsusp_save_area
+restore_pblist_ptr:
+	.tc	restore_pblist[TC],restore_pblist
+
+	.section .text
+	.align  5
+_GLOBAL(swsusp_arch_suspend)
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+	SAVE_SPECIAL(LR)
+	SAVE_REGISTER(r1)
+	SAVE_SPECIAL(CR)
+	SAVE_SPECIAL(TB)
+	SAVE_REGISTER(r2)
+	SAVE_REGISTER(r12)
+	SAVE_REGISTER(r13)
+	SAVE_REGISTER(r14)
+	SAVE_REGISTER(r15)
+	SAVE_REGISTER(r16)
+	SAVE_REGISTER(r17)
+	SAVE_REGISTER(r18)
+	SAVE_REGISTER(r19)
+	SAVE_REGISTER(r20)
+	SAVE_REGISTER(r21)
+	SAVE_REGISTER(r22)
+	SAVE_REGISTER(r23)
+	SAVE_REGISTER(r24)
+	SAVE_REGISTER(r25)
+	SAVE_REGISTER(r26)
+	SAVE_REGISTER(r27)
+	SAVE_REGISTER(r28)
+	SAVE_REGISTER(r29)
+	SAVE_REGISTER(r30)
+	SAVE_REGISTER(r31)
+	SAVE_SPECIAL(MSR)
+	SAVE_SPECIAL(SDR1)
+	SAVE_SPECIAL(XER)
+
+	/* we push the stack up 128 bytes but don't store the
+	 * stack pointer on the stack like a real stackframe */
+	addi	r1,r1,-128
+
+#ifdef	CONFIG_U3_DART
+	bl iommu_dart_save
+#endif
+
+	bl swsusp_save
+
+	/* restore LR */
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+	RESTORE_SPECIAL(LR)
+	addi	r1,r1,128
+
+	blr
+
+/* Resume code */
+_GLOBAL(swsusp_arch_resume)
+	/* Stop pending alitvec streams and memory accesses */
+BEGIN_FTR_SECTION
+	DSSALL
+END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
+	sync
+
+	ld	r12,restore_pblist_ptr@toc(r2)
+	ld	r12,0(r12)
+
+	cmpdi	r12,0
+	beq-	nothing_to_copy
+	li	r15,512
+copyloop:
+	ld	r13,pbe_address(r12)
+	ld	r14,pbe_orig_address(r12)
+
+	mtctr	r15
+	li	r10,0
+copy_page_loop:
+	ldx	r0,r10,r13
+	stdx	r0,r10,r14
+	addi	r10,r10,8
+	bdnz copy_page_loop
+
+	ld	r12,pbe_next(r12)
+	cmpdi	r12,0
+	bne+	copyloop
+nothing_to_copy:
+
+	/* flush caches */
+	lis	r3, 0x10
+	mtctr	r3
+	li	r3, 0
+	ori	r3, r3, CONFIG_KERNEL_START>>48
+	li	r0, 48
+	sld	r3, r3, r0
+	li	r0, 0
+1:
+	dcbf	r0,r3
+	addi	r3,r3,0x20
+	bdnz	1b
+
+	sync
+
+	tlbia
+
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+
+	RESTORE_SPECIAL(CR)
+
+	/* restore timebase */
+	/* load saved tb */
+	ld	r1, SL_TB(r11)
+	/* get upper 32 bits of it */
+	srdi	r2, r1, 32
+	/* clear tb lower to avoid wrap */
+	li	r0, 0
+	mttbl	r0
+	/* set tb upper */
+	mttbu	r2
+	/* set tb lower */
+	mttbl	r1
+
+	/* restore registers */
+	RESTORE_REGISTER(r1)
+	RESTORE_REGISTER(r2)
+	RESTORE_REGISTER(r12)
+	RESTORE_REGISTER(r13)
+	RESTORE_REGISTER(r14)
+	RESTORE_REGISTER(r15)
+	RESTORE_REGISTER(r16)
+	RESTORE_REGISTER(r17)
+	RESTORE_REGISTER(r18)
+	RESTORE_REGISTER(r19)
+	RESTORE_REGISTER(r20)
+	RESTORE_REGISTER(r21)
+	RESTORE_REGISTER(r22)
+	RESTORE_REGISTER(r23)
+	RESTORE_REGISTER(r24)
+	RESTORE_REGISTER(r25)
+	RESTORE_REGISTER(r26)
+	RESTORE_REGISTER(r27)
+	RESTORE_REGISTER(r28)
+	RESTORE_REGISTER(r29)
+	RESTORE_REGISTER(r30)
+	RESTORE_REGISTER(r31)
+	/* can't use RESTORE_SPECIAL(MSR) */
+	ld	r0, SL_MSR(r11)
+	mtmsrd	r0, 0
+	RESTORE_SPECIAL(SDR1)
+	RESTORE_SPECIAL(XER)
+
+	sync
+
+	addi	r1,r1,-128
+	bl	slb_flush_and_rebolt
+	bl	do_after_copyback
+	addi	r1,r1,128
+
+	ld	r11,swsusp_save_area_ptr@toc(r2)
+	RESTORE_SPECIAL(LR)
+
+	li	r3, 0
+	blr
--- mb-wireless.orig/arch/powerpc/kernel/asm-offsets.c	2007-02-05 14:24:04.574526864 +0100
+++ mb-wireless/arch/powerpc/kernel/asm-offsets.c	2007-02-05 14:24:40.684526864 +0100
@@ -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 */
--- mb-wireless.orig/arch/powerpc/kernel/idle.c	2007-02-05 14:24:04.684526864 +0100
+++ mb-wireless/arch/powerpc/kernel/idle.c	2007-02-05 14:24:40.684526864 +0100
@@ -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

--

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

* [RFC 10/10] powermac: fix G5-cpufreq for cpu on/offline
  2007-02-05 18:30 [PATCH/RFC 00/10] suspend to disk for powermac G5 Johannes Berg
@ 2007-02-05 18:30   ` Johannes Berg
  2007-02-05 18:30   ` Johannes Berg
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-pm, cpufreq list, Torrance, Jacob Shin

[-- Attachment #1: powermac-fix-cpufreq.patch --]
[-- Type: text/plain, Size: 1422 bytes --]

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: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: cpufreq list <cpufreq@lists.linux.org.uk>
Cc: Jacob Shin <jacob.shin@amd.com>

---
Not tested yet but from what Jacob said this should work.

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

--

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

* [RFC 10/10] powermac: fix G5-cpufreq for cpu on/offline
@ 2007-02-05 18:30   ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 18:30 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-pm, cpufreq list, Torrance, Jacob Shin

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: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: cpufreq list <cpufreq@lists.linux.org.uk>
Cc: Jacob Shin <jacob.shin@amd.com>

---
Not tested yet but from what Jacob said this should work.

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

--

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

* Re: [PATCH 02/10] windfarm: dont die on suspend thread signal
  2007-02-05 18:30   ` Johannes Berg
  (?)
@ 2007-02-05 22:43   ` Christoph Hellwig
  2007-02-05 22:54     ` [PATCH revision 2] " Johannes Berg
  -1 siblings, 1 reply; 61+ messages in thread
From: Christoph Hellwig @ 2007-02-05 22:43 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance

On Mon, Feb 05, 2007 at 07:30:29PM +0100, Johannes Berg wrote:
> -		/* there should be no signal, but oh well */
> -		if (signal_pending(current)) {
> +		/* there should be no non-suspend signal, but oh well */
> +		if (signal_pending(current) && !try_to_freeze()) {

Given that the driver uses the kthread infrastructure and doesn't
explicitly re-enable signals there can't be any other signal.
So just remove the signal_pending check.

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

* Re: [PATCH 02/10] windfarm: dont die on suspend thread signal
  2007-02-05 18:30   ` Johannes Berg
  (?)
  (?)
@ 2007-02-05 22:54   ` Andrew Morton
  2007-02-05 22:55       ` Johannes Berg
  -1 siblings, 1 reply; 61+ messages in thread
From: Andrew Morton @ 2007-02-05 22:54 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, Torrance, linux-pm

On Mon, 05 Feb 2007 19:30:29 +0100
Johannes Berg <johannes@sipsolutions.net> wrote:

> When the windfarm thread gets a suspend signal it will die instead of
> freezing. This fixes it.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> Cc: Andrew Morton <akpm@osdl.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> 
> ---
> Please apply to -mm.
> 
> --- mb-wireless.orig/drivers/macintosh/windfarm_core.c	2007-02-05 14:24:06.344526864 +0100
> +++ mb-wireless/drivers/macintosh/windfarm_core.c	2007-02-05 14:24:38.264526864 +0100
> @@ -94,8 +94,6 @@ static int wf_thread_func(void *data)
>  	DBG("wf: thread started\n");
>  
>  	while(!kthread_should_stop()) {
> -		try_to_freeze();
> -
>  		if (time_after_eq(jiffies, next)) {
>  			wf_notify(WF_EVENT_TICK, NULL);
>  			if (wf_overtemp) {
> @@ -118,8 +116,8 @@ static int wf_thread_func(void *data)
>  		if (delay <= HZ)
>  			schedule_timeout_interruptible(delay);
>  
> -		/* there should be no signal, but oh well */
> -		if (signal_pending(current)) {
> +		/* there should be no non-suspend signal, but oh well */
> +		if (signal_pending(current) && !try_to_freeze()) {
>  			printk(KERN_WARNING "windfarm: thread got sigl !\n");
>  			break;
>  		}
> 
> --

That sounds like a fairly irritating feature.  Should we backport this into 2.6.20?

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

* [PATCH revision 2] windfarm: dont die on suspend thread signal
  2007-02-05 22:43   ` Christoph Hellwig
@ 2007-02-05 22:54     ` Johannes Berg
  2007-02-05 23:04         ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 22:54 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance

When the windfarm thread gets a suspend signal it will die instead of
freezing. This fixes it.

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

---
Adresses Christoph's comment: This keeps the original try_to_freeze() in
place and just remove the code that kills the thread on a signal.

--- mb-wireless.orig/drivers/macintosh/windfarm_core.c	2007-02-05 16:07:10.524524763 +0100
+++ mb-wireless/drivers/macintosh/windfarm_core.c	2007-02-05 23:49:46.004524763 +0100
@@ -117,12 +117,6 @@ static int wf_thread_func(void *data)
 		delay = next - jiffies;
 		if (delay <= HZ)
 			schedule_timeout_interruptible(delay);
-
-		/* there should be no signal, but oh well */
-		if (signal_pending(current)) {
-			printk(KERN_WARNING "windfarm: thread got sigl !\n");
-			break;
-		}
 	}
 
 	DBG("wf: thread stopped\n");

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

* Re: [PATCH 02/10] windfarm: dont die on suspend thread signal
  2007-02-05 22:54   ` [PATCH 02/10] " Andrew Morton
@ 2007-02-05 22:55       ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 22:55 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linuxppc-dev, Torrance, linux-pm


[-- Attachment #1.1: Type: text/plain, Size: 285 bytes --]

On Mon, 2007-02-05 at 14:54 -0800, Andrew Morton wrote:

> That sounds like a fairly irritating feature.  Should we backport this into 2.6.20?

It'll apply just fine, but don't bother. No machine that actually uses
this windfarm infrastructure can suspend right now.

johannes

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH 02/10] windfarm: dont die on suspend thread signal
@ 2007-02-05 22:55       ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-05 22:55 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linuxppc-dev, Torrance, linux-pm

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

On Mon, 2007-02-05 at 14:54 -0800, Andrew Morton wrote:

> That sounds like a fairly irritating feature.  Should we backport this into 2.6.20?

It'll apply just fine, but don't bother. No machine that actually uses
this windfarm infrastructure can suspend right now.

johannes

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

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

* Re: [PATCH 02/10] windfarm: dont die on suspend thread signal
  2007-02-05 18:30   ` Johannes Berg
                     ` (2 preceding siblings ...)
  (?)
@ 2007-02-05 22:58   ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 61+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-05 22:58 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Andrew Morton, linuxppc-dev, Torrance, linux-pm

On Mon, 2007-02-05 at 19:30 +0100, Johannes Berg wrote:
> plain text document attachment (windfarm-dont-die-on-signals.patch)
> When the windfarm thread gets a suspend signal it will die instead of
> freezing. This fixes it.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> Cc: Andrew Morton <akpm@osdl.org>

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> 
> ---
> Please apply to -mm.
> 
> --- mb-wireless.orig/drivers/macintosh/windfarm_core.c	2007-02-05 14:24:06.344526864 +0100
> +++ mb-wireless/drivers/macintosh/windfarm_core.c	2007-02-05 14:24:38.264526864 +0100
> @@ -94,8 +94,6 @@ static int wf_thread_func(void *data)
>  	DBG("wf: thread started\n");
>  
>  	while(!kthread_should_stop()) {
> -		try_to_freeze();
> -
>  		if (time_after_eq(jiffies, next)) {
>  			wf_notify(WF_EVENT_TICK, NULL);
>  			if (wf_overtemp) {
> @@ -118,8 +116,8 @@ static int wf_thread_func(void *data)
>  		if (delay <= HZ)
>  			schedule_timeout_interruptible(delay);
>  
> -		/* there should be no signal, but oh well */
> -		if (signal_pending(current)) {
> +		/* there should be no non-suspend signal, but oh well */
> +		if (signal_pending(current) && !try_to_freeze()) {
>  			printk(KERN_WARNING "windfarm: thread got sigl !\n");
>  			break;
>  		}
> 
> --

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

* Re: [PATCH 03/10] powerpc: fix comment in kernel/irq.c
  2007-02-05 18:30   ` Johannes Berg
  (?)
@ 2007-02-05 22:59   ` Benjamin Herrenschmidt
  2007-02-05 23:18     ` Andrew Morton
  -1 siblings, 1 reply; 61+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-05 22:59 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance

On Mon, 2007-02-05 at 19:30 +0100, Johannes Berg wrote:
> plain text document attachment (irq-comment.patch)
> kernel/irq.c contains a comment that speaks of -1 and -2 as interrupt
> numbers. Replace by NO_IRQ and NO_IRQ_IGNORE.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> Cc: Andrew Morton <akpm@osdl.org>

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

> --- mb-wireless.orig/arch/powerpc/kernel/irq.c	2007-02-05 14:24:06.694526864 +0100
> +++ mb-wireless/arch/powerpc/kernel/irq.c	2007-02-05 14:24:37.084526864 +0100
> @@ -281,10 +281,10 @@ void do_IRQ(struct pt_regs *regs)
>  
>  	/*
>  	 * Every platform is required to implement ppc_md.get_irq.
> -	 * This function will either return an irq number or -1 to
> +	 * This function will either return an irq number or NO_IRQ to
>  	 * indicate there are no more pending.
> -	 * The value -2 is for buggy hardware and means that this IRQ
> -	 * has already been handled. -- Tom
> +	 * The value NO_IRQ_IGNORE is for buggy hardware and means that this
> +	 * IRQ has already been handled. -- Tom
>  	 */
>  	irq = ppc_md.get_irq();
>  
> 
> --
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

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

* Re: [PATCH revision 2] windfarm: dont die on suspend thread signal
  2007-02-05 22:54     ` [PATCH revision 2] " Johannes Berg
@ 2007-02-05 23:04         ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 61+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-05 23:04 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Andrew Morton, linuxppc-dev, linux-pm, Christoph Hellwig, Torrance

On Mon, 2007-02-05 at 23:54 +0100, Johannes Berg wrote:
> When the windfarm thread gets a suspend signal it will die instead of
> freezing. This fixes it.

Don't we still need to call try_to_freeze() ?

> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> 
> ---
> Adresses Christoph's comment: This keeps the original try_to_freeze() in
> place and just remove the code that kills the thread on a signal.
> 
> --- mb-wireless.orig/drivers/macintosh/windfarm_core.c	2007-02-05 16:07:10.524524763 +0100
> +++ mb-wireless/drivers/macintosh/windfarm_core.c	2007-02-05 23:49:46.004524763 +0100
> @@ -117,12 +117,6 @@ static int wf_thread_func(void *data)
>  		delay = next - jiffies;
>  		if (delay <= HZ)
>  			schedule_timeout_interruptible(delay);
> -
> -		/* there should be no signal, but oh well */
> -		if (signal_pending(current)) {
> -			printk(KERN_WARNING "windfarm: thread got sigl !\n");
> -			break;
> -		}
>  	}
>  
>  	DBG("wf: thread stopped\n");
> 
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

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

* Re: [PATCH revision 2] windfarm: dont die on suspend thread signal
@ 2007-02-05 23:04         ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 61+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-05 23:04 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance

On Mon, 2007-02-05 at 23:54 +0100, Johannes Berg wrote:
> When the windfarm thread gets a suspend signal it will die instead of
> freezing. This fixes it.

Don't we still need to call try_to_freeze() ?

> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> 
> ---
> Adresses Christoph's comment: This keeps the original try_to_freeze() in
> place and just remove the code that kills the thread on a signal.
> 
> --- mb-wireless.orig/drivers/macintosh/windfarm_core.c	2007-02-05 16:07:10.524524763 +0100
> +++ mb-wireless/drivers/macintosh/windfarm_core.c	2007-02-05 23:49:46.004524763 +0100
> @@ -117,12 +117,6 @@ static int wf_thread_func(void *data)
>  		delay = next - jiffies;
>  		if (delay <= HZ)
>  			schedule_timeout_interruptible(delay);
> -
> -		/* there should be no signal, but oh well */
> -		if (signal_pending(current)) {
> -			printk(KERN_WARNING "windfarm: thread got sigl !\n");
> -			break;
> -		}
>  	}
>  
>  	DBG("wf: thread stopped\n");
> 
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

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

* Re: [PATCH revision 2] windfarm: dont die on suspend thread signal
  2007-02-05 23:04         ` Benjamin Herrenschmidt
@ 2007-02-05 23:04           ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 61+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-05 23:04 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Andrew Morton, linuxppc-dev, linux-pm, Christoph Hellwig, Torrance

On Tue, 2007-02-06 at 10:04 +1100, Benjamin Herrenschmidt wrote:
> On Mon, 2007-02-05 at 23:54 +0100, Johannes Berg wrote:
> > When the windfarm thread gets a suspend signal it will die instead of
> > freezing. This fixes it.
> 
> Don't we still need to call try_to_freeze() ?

Forget it... of course we do.

Ben.

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

* Re: [PATCH revision 2] windfarm: dont die on suspend thread signal
@ 2007-02-05 23:04           ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 61+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-05 23:04 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance

On Tue, 2007-02-06 at 10:04 +1100, Benjamin Herrenschmidt wrote:
> On Mon, 2007-02-05 at 23:54 +0100, Johannes Berg wrote:
> > When the windfarm thread gets a suspend signal it will die instead of
> > freezing. This fixes it.
> 
> Don't we still need to call try_to_freeze() ?

Forget it... of course we do.

Ben.

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

* Re: [PATCH 03/10] powerpc: fix comment in kernel/irq.c
  2007-02-05 22:59   ` Benjamin Herrenschmidt
@ 2007-02-05 23:18     ` Andrew Morton
  2007-02-05 23:53       ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 61+ messages in thread
From: Andrew Morton @ 2007-02-05 23:18 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Johannes Berg, linux-pm, Torrance

On Tue, 06 Feb 2007 09:59:36 +1100
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:

> On Mon, 2007-02-05 at 19:30 +0100, Johannes Berg wrote:
> > plain text document attachment (irq-comment.patch)
> > kernel/irq.c contains a comment that speaks of -1 and -2 as interrupt
> > numbers. Replace by NO_IRQ and NO_IRQ_IGNORE.
> > 
> > Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> > Cc: Andrew Morton <akpm@osdl.org>
> 
> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

I hope that wasn't acked at me.  I was only copied on half this patch
series and I only picked up swsusp-dont-copy-pages-that-arent-ram.patch and
windfarm-dont-die-on-suspend-thread-signal.patch.

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

* Re: [PATCH 03/10] powerpc: fix comment in kernel/irq.c
  2007-02-05 23:18     ` Andrew Morton
@ 2007-02-05 23:53       ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 61+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-05 23:53 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linuxppc-dev, Johannes Berg, linux-pm, Torrance

On Mon, 2007-02-05 at 15:18 -0800, Andrew Morton wrote:
> On Tue, 06 Feb 2007 09:59:36 +1100
> Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> 
> > On Mon, 2007-02-05 at 19:30 +0100, Johannes Berg wrote:
> > > plain text document attachment (irq-comment.patch)
> > > kernel/irq.c contains a comment that speaks of -1 and -2 as interrupt
> > > numbers. Replace by NO_IRQ and NO_IRQ_IGNORE.
> > > 
> > > Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> > > Cc: Andrew Morton <akpm@osdl.org>
> > 
> > Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> 
> I hope that wasn't acked at me.  I was only copied on half this patch
> series and I only picked up swsusp-dont-copy-pages-that-arent-ram.patch and
> windfarm-dont-die-on-suspend-thread-signal.patch.

This one is really independant of the rest, so it can be picked up by
either you or paulus or both, whoever jumps on it first :-) I wrote the
code this comment refers to so I just reviewed & acked :-)

Ben.

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

* Re: [RFC 08/10] powerpc: dart iommu suspend
  2007-02-05 18:30   ` Johannes Berg
  (?)
@ 2007-02-06  1:19   ` Olof Johansson
  2007-02-06  1:26       ` Johannes Berg
  2007-02-06  1:52     ` Johannes Berg
  -1 siblings, 2 replies; 61+ messages in thread
From: Olof Johansson @ 2007-02-06  1:19 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, linux-pm, Torrance

On Mon, Feb 05, 2007 at 07:30:35PM +0100, Johannes Berg wrote:
> This implements suspend and resume code for the dart iommu.

It's a good start, but it would be even nicer to have more generic iommu
suspend/resume hooks instead, and do the alloc/copy there. Add the hooks
to ppc_md together with the rest of the iommu/tce ops.

Minor code comment below.

> --- mb-wireless.orig/arch/powerpc/sysdev/dart_iommu.c	2007-02-05 14:24:04.834526864 +0100
> +++ mb-wireless/arch/powerpc/sysdev/dart_iommu.c	2007-02-05 14:24:40.684526864 +0100
> @@ -54,6 +54,9 @@ static unsigned long dart_tablesize;
>  
>  /* Virtual base address of the DART table */
>  static u32 *dart_vbase;
> +#ifdef CONFIG_SOFTWARE_SUSPEND
> +static u32 *dart_copy;
> +#endif
>  
>  /* Mapped base address for the dart */
>  static unsigned int __iomem *dart;
> @@ -346,6 +349,52 @@ void iommu_init_early_dart(void)
>  	pci_dma_ops = &dma_direct_ops;
>  }
>  
> +#ifdef CONFIG_SOFTWARE_SUSPEND
> +static int iommu_init_late_dart(void)
> +{
> +	unsigned long i;
> +	struct page *p;
> +
> +	/* this 16MB area is left unmapped because of caching
> +	 * considerations. that happens early so we can't mark
> +	 * it there, do it now instead */
> +	for (i = 0; i < (1<<24); i+= PAGE_SIZE)
> +		SetPageNosave(virt_to_page((void*)((unsigned long)dart_tablebase + i)));

Please do a local void * instead, makes for much less casting in the loop. :)

> +
> +	/* if no dart table exists then we don't need to save it */
> +	if (!dart_tablebase)
> +		return 0;
> +
> +	/* 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);
> +
> +	return 0;
> +}
> +
> +late_initcall(iommu_init_late_dart);
> +
> +void iommu_dart_save(void)
> +{
> +	if (!dart_tablebase)
> +		return;
> +
> +	memcpy(dart_copy, dart_vbase, 2*1024*1024);
> +}
> +
> +void iommu_dart_restore(void)
> +{
> +	if (!dart_tablebase)
> +		return;
> +
> +	memcpy(dart_vbase, dart_copy, 2*1024*1024);
> +	dart_tlb_invalidate_all();
> +}
> +#endif
>  
>  void __init alloc_dart_table(void)
>  {
> --- mb-wireless.orig/include/asm-powerpc/iommu.h	2007-02-05 14:24:05.014526864 +0100
> +++ mb-wireless/include/asm-powerpc/iommu.h	2007-02-05 14:24:40.684526864 +0100
> @@ -108,6 +108,10 @@ static inline void pci_iommu_init(void) 
>  #endif
>  
>  extern void alloc_dart_table(void);
> +#if defined(CONFIG_SOFTWARE_SUSPEND) && defined(CONFIG_U3_DART)
> +extern void iommu_dart_save(void);
> +extern void iommu_dart_restore(void);
> +#endif
>  
>  #endif /* __KERNEL__ */
>  #endif /* _ASM_IOMMU_H */
> 
> --
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

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

* Re: [RFC 08/10] powerpc: dart iommu suspend
  2007-02-06  1:19   ` Olof Johansson
@ 2007-02-06  1:26       ` Johannes Berg
  2007-02-06  1:52     ` Johannes Berg
  1 sibling, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-06  1:26 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, linux-pm, Torrance


[-- Attachment #1.1: Type: text/plain, Size: 1069 bytes --]

On Mon, 2007-02-05 at 19:19 -0600, Olof Johansson wrote:
> On Mon, Feb 05, 2007 at 07:30:35PM +0100, Johannes Berg wrote:
> > This implements suspend and resume code for the dart iommu.
> 
> It's a good start, but it would be even nicer to have more generic iommu
> suspend/resume hooks instead, and do the alloc/copy there. Add the hooks
> to ppc_md together with the rest of the iommu/tce ops.

Ok, I'll take a look. I think we should leave the alloc up to the code
and just have generic calls for what now is iommu_dart_{save,restore}, I
see no point in adding a callback for iommu_init_late_dart since any
other iommu can do it as a late_initcall as well.

> > +	/* this 16MB area is left unmapped because of caching
> > +	 * considerations. that happens early so we can't mark
> > +	 * it there, do it now instead */
> > +	for (i = 0; i < (1<<24); i+= PAGE_SIZE)
> > +		SetPageNosave(virt_to_page((void*)((unsigned long)dart_tablebase + i)));
> 
> Please do a local void * instead, makes for much less casting in the loop. :)

:)

johannes

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [RFC 08/10] powerpc: dart iommu suspend
@ 2007-02-06  1:26       ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-06  1:26 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, linux-pm, Torrance

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

On Mon, 2007-02-05 at 19:19 -0600, Olof Johansson wrote:
> On Mon, Feb 05, 2007 at 07:30:35PM +0100, Johannes Berg wrote:
> > This implements suspend and resume code for the dart iommu.
> 
> It's a good start, but it would be even nicer to have more generic iommu
> suspend/resume hooks instead, and do the alloc/copy there. Add the hooks
> to ppc_md together with the rest of the iommu/tce ops.

Ok, I'll take a look. I think we should leave the alloc up to the code
and just have generic calls for what now is iommu_dart_{save,restore}, I
see no point in adding a callback for iommu_init_late_dart since any
other iommu can do it as a late_initcall as well.

> > +	/* this 16MB area is left unmapped because of caching
> > +	 * considerations. that happens early so we can't mark
> > +	 * it there, do it now instead */
> > +	for (i = 0; i < (1<<24); i+= PAGE_SIZE)
> > +		SetPageNosave(virt_to_page((void*)((unsigned long)dart_tablebase + i)));
> 
> Please do a local void * instead, makes for much less casting in the loop. :)

:)

johannes

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

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

* Re: [RFC 08/10] powerpc: dart iommu suspend
  2007-02-06  1:19   ` Olof Johansson
  2007-02-06  1:26       ` Johannes Berg
@ 2007-02-06  1:52     ` Johannes Berg
  2007-02-07 12:22         ` Johannes Berg
  1 sibling, 1 reply; 61+ messages in thread
From: Johannes Berg @ 2007-02-06  1:52 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, linux-pm, Torrance

How's this? Needs to go along with the correct changes in the code that
uses it, of course.

I can't use a local void * as you suggested because it needs to be added
to as an unsigned long, but I can use a local unsigned long.

Not even compiled yet.

Btw. What does TCE stand for?

--- mb-wireless.orig/arch/powerpc/sysdev/dart_iommu.c	2007-02-06 02:45:34.464524763 +0100
+++ mb-wireless/arch/powerpc/sysdev/dart_iommu.c	2007-02-06 02:48:40.784524763 +0100
@@ -54,6 +54,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 +349,49 @@ void iommu_init_early_dart(void)
 	pci_dma_ops = &dma_direct_ops;
 }
 
+#ifdef CONFIG_PM
+static void iommu_dart_suspend(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 iommu_init_late_dart(void)
+{
+	unsigned long i, tbase = (unsigned long) dart_tablebase;
+	struct page *p;
+
+	/* this 16MB area is left unmapped because of caching
+	 * considerations. that happens early so we can't mark
+	 * it there, do it now instead */
+	for (i = 0; i < (1<<24); i+= PAGE_SIZE)
+		SetPageNosave(virt_to_page((void*)(tbase + i)));
+
+	/* if no dart table exists then we don't need to save it */
+	if (!dart_tablebase)
+		return 0;
+
+	/* 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_suspend = iommu_dart_suspend;
+	ppc_md.iommu_resume = iommu_dart_resume;
+
+	return 0;
+}
+
+late_initcall(iommu_init_late_dart);
+#endif
 
 void __init alloc_dart_table(void)
 {
--- mb-wireless.orig/include/asm-powerpc/iommu.h	2007-02-06 02:45:34.524524763 +0100
+++ mb-wireless/include/asm-powerpc/iommu.h	2007-02-06 02:46:28.964524763 +0100
@@ -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>
 
@@ -108,6 +109,19 @@ static inline void pci_iommu_init(void) 
 #endif
 
 extern void alloc_dart_table(void);
+#ifdef CONFIG_PM
+static inline void iommu_suspend(void)
+{
+	if (ppc_md.iommu_suspend)
+		ppc_md.iommu_suspend();
+}
+
+static inline void iommu_restore(void)
+{
+	if (ppc_md.iommu_resume)
+		ppc_md.iommu_resume();
+}
+#endif
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_IOMMU_H */
--- mb-wireless.orig/include/asm-powerpc/machdep.h	2007-02-06 02:45:34.584524763 +0100
+++ mb-wireless/include/asm-powerpc/machdep.h	2007-02-06 02:46:10.834524763 +0100
@@ -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_suspend)(void);
+	void		(*iommu_resume)(void);
+#endif
 #endif /* CONFIG_PPC64 */
 
 	int		(*probe)(void);

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

* Re: [RFC 08/10] powerpc: dart iommu suspend
  2007-02-05 18:30   ` Johannes Berg
@ 2007-02-06 12:40     ` Pavel Machek
  -1 siblings, 0 replies; 61+ messages in thread
From: Pavel Machek @ 2007-02-06 12:40 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, linux-pm, Torrance

Hi!

> This implements suspend and resume code for the dart iommu.
> 
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

> @@ -54,6 +54,9 @@ static unsigned long dart_tablesize;
>  
>  /* Virtual base address of the DART table */
>  static u32 *dart_vbase;
> +#ifdef CONFIG_SOFTWARE_SUSPEND
> +static u32 *dart_copy;
> +#endif
>  
>  /* Mapped base address for the dart */
>  static unsigned int __iomem *dart;
> @@ -346,6 +349,52 @@ void iommu_init_early_dart(void)
>  	pci_dma_ops = &dma_direct_ops;
>  }
>  
> +#ifdef CONFIG_SOFTWARE_SUSPEND
> +static int iommu_init_late_dart(void)
> +{
> +	unsigned long i;
> +	struct page *p;
> +
> +	/* this 16MB area is left unmapped because of caching
> +	 * considerations. that happens early so we can't mark
> +	 * it there, do it now instead */
> +	for (i = 0; i < (1<<24); i+= PAGE_SIZE)
> +		SetPageNosave(virt_to_page((void*)((unsigned long)dart_tablebase + i)));
> +

80 columns rule?

> --- mb-wireless.orig/include/asm-powerpc/iommu.h	2007-02-05 14:24:05.014526864 +0100
> +++ mb-wireless/include/asm-powerpc/iommu.h	2007-02-05 14:24:40.684526864 +0100
> @@ -108,6 +108,10 @@ static inline void pci_iommu_init(void) 
>  #endif
>  
>  extern void alloc_dart_table(void);
> +#if defined(CONFIG_SOFTWARE_SUSPEND) && defined(CONFIG_U3_DART)
> +extern void iommu_dart_save(void);
> +extern void iommu_dart_restore(void);
> +#endif

You can go without the ifdef; extra prototype does not do any harm.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [linux-pm] [RFC 08/10] powerpc: dart iommu suspend
@ 2007-02-06 12:40     ` Pavel Machek
  0 siblings, 0 replies; 61+ messages in thread
From: Pavel Machek @ 2007-02-06 12:40 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, linux-pm, Torrance

Hi!

> This implements suspend and resume code for the dart iommu.
> 
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

> @@ -54,6 +54,9 @@ static unsigned long dart_tablesize;
>  
>  /* Virtual base address of the DART table */
>  static u32 *dart_vbase;
> +#ifdef CONFIG_SOFTWARE_SUSPEND
> +static u32 *dart_copy;
> +#endif
>  
>  /* Mapped base address for the dart */
>  static unsigned int __iomem *dart;
> @@ -346,6 +349,52 @@ void iommu_init_early_dart(void)
>  	pci_dma_ops = &dma_direct_ops;
>  }
>  
> +#ifdef CONFIG_SOFTWARE_SUSPEND
> +static int iommu_init_late_dart(void)
> +{
> +	unsigned long i;
> +	struct page *p;
> +
> +	/* this 16MB area is left unmapped because of caching
> +	 * considerations. that happens early so we can't mark
> +	 * it there, do it now instead */
> +	for (i = 0; i < (1<<24); i+= PAGE_SIZE)
> +		SetPageNosave(virt_to_page((void*)((unsigned long)dart_tablebase + i)));
> +

80 columns rule?

> --- mb-wireless.orig/include/asm-powerpc/iommu.h	2007-02-05 14:24:05.014526864 +0100
> +++ mb-wireless/include/asm-powerpc/iommu.h	2007-02-05 14:24:40.684526864 +0100
> @@ -108,6 +108,10 @@ static inline void pci_iommu_init(void) 
>  #endif
>  
>  extern void alloc_dart_table(void);
> +#if defined(CONFIG_SOFTWARE_SUSPEND) && defined(CONFIG_U3_DART)
> +extern void iommu_dart_save(void);
> +extern void iommu_dart_restore(void);
> +#endif

You can go without the ifdef; extra prototype does not do any harm.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [RFC 07/10] powermac: support G5 CPU hotplug
  2007-02-05 18:30   ` Johannes Berg
@ 2007-02-06 12:42     ` Pavel Machek
  -1 siblings, 0 replies; 61+ messages in thread
From: Pavel Machek @ 2007-02-06 12:42 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, linux-pm, Torrance

Hi!

> This patch allows "hotplugging" of CPUs on G5 machines. CPUs that are
> disabled are put into an idle loop with interrupts hard-disabled, to wake
> them up again we kick them just like when bringing them up.
> 
> Maybe there's some way to actually turn off those CPUs even more?
> 
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

> --- mb-wireless.orig/arch/powerpc/kernel/smp.c	2007-02-05 16:07:09.274524763 +0100
> +++ mb-wireless/arch/powerpc/kernel/smp.c	2007-02-05 18:15:51.114524763 +0100
> @@ -558,6 +558,11 @@ int __devinit start_secondary(void *unus
>  
>  	local_irq_enable();
>  
> +	/* it seems to be possible that we died from within
> +	 * an interrupt ... reset the in-irq counts */
> +	task_thread_info(paca[cpu].__current)->preempt_count &=
> +		~(SOFTIRQ_MASK|HARDIRQ_MASK);
> +
>  	cpu_idle();
>  	return 0;

This is quite a nasty hack. Are you sure?

I've seen similar weirdness on pc, and it was caused by
swsusp-copying-code using FPU and incrementing preempt_count...

								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [linux-pm] [RFC 07/10] powermac: support G5 CPU hotplug
@ 2007-02-06 12:42     ` Pavel Machek
  0 siblings, 0 replies; 61+ messages in thread
From: Pavel Machek @ 2007-02-06 12:42 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, linux-pm, Torrance

Hi!

> This patch allows "hotplugging" of CPUs on G5 machines. CPUs that are
> disabled are put into an idle loop with interrupts hard-disabled, to wake
> them up again we kick them just like when bringing them up.
> 
> Maybe there's some way to actually turn off those CPUs even more?
> 
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

> --- mb-wireless.orig/arch/powerpc/kernel/smp.c	2007-02-05 16:07:09.274524763 +0100
> +++ mb-wireless/arch/powerpc/kernel/smp.c	2007-02-05 18:15:51.114524763 +0100
> @@ -558,6 +558,11 @@ int __devinit start_secondary(void *unus
>  
>  	local_irq_enable();
>  
> +	/* it seems to be possible that we died from within
> +	 * an interrupt ... reset the in-irq counts */
> +	task_thread_info(paca[cpu].__current)->preempt_count &=
> +		~(SOFTIRQ_MASK|HARDIRQ_MASK);
> +
>  	cpu_idle();
>  	return 0;

This is quite a nasty hack. Are you sure?

I've seen similar weirdness on pc, and it was caused by
swsusp-copying-code using FPU and incrementing preempt_count...

								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [linux-pm] [RFC 07/10] powermac: support G5 CPU hotplug
  2007-02-06 12:42     ` [linux-pm] " Pavel Machek
@ 2007-02-07 11:40       ` Johannes Berg
  -1 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 11:40 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linuxppc-dev, linux-pm, Torrance


[-- Attachment #1.1: Type: text/plain, Size: 757 bytes --]

Hi,

> > +	/* it seems to be possible that we died from within
> > +	 * an interrupt ... reset the in-irq counts */
> > +	task_thread_info(paca[cpu].__current)->preempt_count &=
> > +		~(SOFTIRQ_MASK|HARDIRQ_MASK);
> > +
> >  	cpu_idle();
> >  	return 0;
> 
> This is quite a nasty hack. Are you sure?
> 
> I've seen similar weirdness on pc, and it was caused by
> swsusp-copying-code using FPU and incrementing preempt_count...

I know. I'm not really happy with it. But I can't figure out where the
hardirq count can be incremented. The preempt count is fine (well, in my
latest patchset, this one forgot one spot), but the hard irq count is
not. Which is really strange because we only use that for actual in-irq
stuff...

johannes

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

[-- Attachment #2: Type: text/plain, Size: 146 bytes --]

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

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

* Re: [linux-pm] [RFC 07/10] powermac: support G5 CPU hotplug
@ 2007-02-07 11:40       ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 11:40 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linuxppc-dev, linux-pm, Torrance

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

Hi,

> > +	/* it seems to be possible that we died from within
> > +	 * an interrupt ... reset the in-irq counts */
> > +	task_thread_info(paca[cpu].__current)->preempt_count &=
> > +		~(SOFTIRQ_MASK|HARDIRQ_MASK);
> > +
> >  	cpu_idle();
> >  	return 0;
> 
> This is quite a nasty hack. Are you sure?
> 
> I've seen similar weirdness on pc, and it was caused by
> swsusp-copying-code using FPU and incrementing preempt_count...

I know. I'm not really happy with it. But I can't figure out where the
hardirq count can be incremented. The preempt count is fine (well, in my
latest patchset, this one forgot one spot), but the hard irq count is
not. Which is really strange because we only use that for actual in-irq
stuff...

johannes

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

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

* Re: [RFC 08/10] powerpc: dart iommu suspend
  2007-02-06 12:40     ` [linux-pm] " Pavel Machek
@ 2007-02-07 11:42       ` Johannes Berg
  -1 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 11:42 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linuxppc-dev, linux-pm, Torrance


[-- Attachment #1.1: Type: text/plain, Size: 949 bytes --]

On Tue, 2007-02-06 at 13:40 +0100, Pavel Machek wrote:

> > +		SetPageNosave(virt_to_page((void*)((unsigned long)dart_tablebase + i)));
> > +
> 
> 80 columns rule?

Good point. Changed according to Olof's comment anyway so it should be
shorter now.

> > --- mb-wireless.orig/include/asm-powerpc/iommu.h	2007-02-05 14:24:05.014526864 +0100
> > +++ mb-wireless/include/asm-powerpc/iommu.h	2007-02-05 14:24:40.684526864 +0100
> > @@ -108,6 +108,10 @@ static inline void pci_iommu_init(void) 
> >  #endif
> >  
> >  extern void alloc_dart_table(void);
> > +#if defined(CONFIG_SOFTWARE_SUSPEND) && defined(CONFIG_U3_DART)
> > +extern void iommu_dart_save(void);
> > +extern void iommu_dart_restore(void);
> > +#endif
> 
> You can go without the ifdef; extra prototype does not do any harm.

Changed as well anyway to introduce powerpc iommu suspend ops, though I
introduced two static inlines that are still ifdefed.

johannes

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [linux-pm] [RFC 08/10] powerpc: dart iommu suspend
@ 2007-02-07 11:42       ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 11:42 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linuxppc-dev, linux-pm, Torrance

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

On Tue, 2007-02-06 at 13:40 +0100, Pavel Machek wrote:

> > +		SetPageNosave(virt_to_page((void*)((unsigned long)dart_tablebase + i)));
> > +
> 
> 80 columns rule?

Good point. Changed according to Olof's comment anyway so it should be
shorter now.

> > --- mb-wireless.orig/include/asm-powerpc/iommu.h	2007-02-05 14:24:05.014526864 +0100
> > +++ mb-wireless/include/asm-powerpc/iommu.h	2007-02-05 14:24:40.684526864 +0100
> > @@ -108,6 +108,10 @@ static inline void pci_iommu_init(void) 
> >  #endif
> >  
> >  extern void alloc_dart_table(void);
> > +#if defined(CONFIG_SOFTWARE_SUSPEND) && defined(CONFIG_U3_DART)
> > +extern void iommu_dart_save(void);
> > +extern void iommu_dart_restore(void);
> > +#endif
> 
> You can go without the ifdef; extra prototype does not do any harm.

Changed as well anyway to introduce powerpc iommu suspend ops, though I
introduced two static inlines that are still ifdefed.

johannes

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

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

* Re: [RFC 10/10] powermac: fix G5-cpufreq for cpu on/offline
  2007-02-05 18:30   ` Johannes Berg
@ 2007-02-07 12:21     ` Johannes Berg
  -1 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 12:21 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: cpufreq list, linux-pm, Jacob Shin, Torrance


[-- Attachment #1.1: Type: text/plain, Size: 547 bytes --]

On Mon, 2007-02-05 at 19:30 +0100, Johannes Berg wrote:

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

> Not tested yet but from what Jacob said this should work.

Works great, will resend with proper signed-off-by etc. Thanks again
Jacob for explaining how it should work.

johannes

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [RFC 10/10] powermac: fix G5-cpufreq for cpu on/offline
@ 2007-02-07 12:21     ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 12:21 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: cpufreq list, linux-pm, Jacob Shin, Torrance

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

On Mon, 2007-02-05 at 19:30 +0100, Johannes Berg wrote:

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

> Not tested yet but from what Jacob said this should work.

Works great, will resend with proper signed-off-by etc. Thanks again
Jacob for explaining how it should work.

johannes

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

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

* Re: [RFC 08/10] powerpc: dart iommu suspend
  2007-02-06  1:52     ` Johannes Berg
@ 2007-02-07 12:22         ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 12:22 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, linux-pm, Torrance


[-- Attachment #1.1: Type: text/plain, Size: 410 bytes --]

On Tue, 2007-02-06 at 02:52 +0100, Johannes Berg wrote:
> How's this? Needs to go along with the correct changes in the code that
> uses it, of course.
> 
> I can't use a local void * as you suggested because it needs to be added
> to as an unsigned long, but I can use a local unsigned long.
> 
> Not even compiled yet.

which showed, it didn't compile but I sorted it out, will resend.

johannes

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [RFC 08/10] powerpc: dart iommu suspend
@ 2007-02-07 12:22         ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 12:22 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, linux-pm, Torrance

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

On Tue, 2007-02-06 at 02:52 +0100, Johannes Berg wrote:
> How's this? Needs to go along with the correct changes in the code that
> uses it, of course.
> 
> I can't use a local void * as you suggested because it needs to be added
> to as an unsigned long, but I can use a local unsigned long.
> 
> Not even compiled yet.

which showed, it didn't compile but I sorted it out, will resend.

johannes

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

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

* Re: [RFC 07/10] powermac: support G5 CPU hotplug
  2007-02-05 18:30   ` Johannes Berg
@ 2007-02-07 12:23     ` Johannes Berg
  -1 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 12:23 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Torrance, linux-pm


[-- Attachment #1.1: Type: text/plain, Size: 429 bytes --]

On Mon, 2007-02-05 at 19:30 +0100, Johannes Berg wrote:

> This patch allows "hotplugging" of CPUs on G5 machines. CPUs that are
> disabled are put into an idle loop with interrupts hard-disabled, to wake
> them up again we kick them just like when bringing them up.

testing with forced preemption revealed that the preempt count is messed
up. Will resend with the fix. The hardirq count is still strange...

johannes

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [RFC 07/10] powermac: support G5 CPU hotplug
@ 2007-02-07 12:23     ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 12:23 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Torrance, linux-pm

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

On Mon, 2007-02-05 at 19:30 +0100, Johannes Berg wrote:

> This patch allows "hotplugging" of CPUs on G5 machines. CPUs that are
> disabled are put into an idle loop with interrupts hard-disabled, to wake
> them up again we kick them just like when bringing them up.

testing with forced preemption revealed that the preempt count is messed
up. Will resend with the fix. The hardirq count is still strange...

johannes

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

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

* Re: [RFC 06/10] powerpc: MPIC sys_device & suspend/resume
  2007-02-05 18:30   ` Johannes Berg
@ 2007-02-07 12:24     ` Johannes Berg
  -1 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 12:24 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Torrance, linux-pm


[-- Attachment #1.1: Type: text/plain, Size: 511 bytes --]

On Mon, 2007-02-05 at 19:30 +0100, Johannes Berg wrote:
> plain text document attachment (mpic-suspend.patch)
> 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.

This patch isn't enough, I forgot about the broken u3 ht interrupt
stuff. Will resend with code that restores those as well which actually
makes all interrupts on my powermac work after resume.

johannes

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [RFC 06/10] powerpc: MPIC sys_device & suspend/resume
@ 2007-02-07 12:24     ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-07 12:24 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Torrance, linux-pm

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

On Mon, 2007-02-05 at 19:30 +0100, Johannes Berg wrote:
> plain text document attachment (mpic-suspend.patch)
> 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.

This patch isn't enough, I forgot about the broken u3 ht interrupt
stuff. Will resend with code that restores those as well which actually
makes all interrupts on my powermac work after resume.

johannes

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

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

* Re: [PATCH 04/10] powermac: clean up PIC initialisation code
  2007-02-05 18:30   ` Johannes Berg
  (?)
@ 2007-02-08  4:41   ` Paul Mackerras
  2007-02-08 13:03       ` Johannes Berg
  -1 siblings, 1 reply; 61+ messages in thread
From: Paul Mackerras @ 2007-02-08  4:41 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance

Johannes Berg writes:
> This patch cleans up the powermac PIC initialisation code so that for G5
> powermacs we don't even compile the old pmac pic file.

On a 32-bit powermac config, with this patch I get:

  CC      arch/powerpc/platforms/powermac/mpic.o
/home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c: In function ‘pmac_pic_setup_mpic_nmi’:
/home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c:40: error: ‘xmon_action’ undeclared (first use in this function)
/home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c:40: error: (Each undeclared identifier is reported only once
/home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c:40: error: for each function it appears in.)
make[3]: *** [arch/powerpc/platforms/powermac/mpic.o] Error 1

Paul.

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

* Re: [PATCH 04/10] powermac: clean up PIC initialisation code
  2007-02-08  4:41   ` Paul Mackerras
@ 2007-02-08 13:03       ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-08 13:03 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance


[-- Attachment #1.1: Type: text/plain, Size: 1063 bytes --]

On Thu, 2007-02-08 at 15:41 +1100, Paul Mackerras wrote:
> Johannes Berg writes:
> > This patch cleans up the powermac PIC initialisation code so that for G5
> > powermacs we don't even compile the old pmac pic file.
> 
> On a 32-bit powermac config, with this patch I get:
> 
>   CC      arch/powerpc/platforms/powermac/mpic.o
> /home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c: In function ‘pmac_pic_setup_mpic_nmi’:
> /home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c:40: error: ‘xmon_action’ undeclared (first use in this function)
> /home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c:40: error: (Each undeclared identifier is reported only once
> /home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c:40: error: for each function it appears in.)
> make[3]: *** [arch/powerpc/platforms/powermac/mpic.o] Error 1

Yeah. I noticed that yesterday as well, but too late. Sorry about that.
I could fix but it isn't nice, let's just drop this patch instead.
Sorry.

johannes

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

[-- Attachment #2: Type: text/plain, Size: 146 bytes --]

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

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

* Re: [PATCH 04/10] powermac: clean up PIC initialisation code
@ 2007-02-08 13:03       ` Johannes Berg
  0 siblings, 0 replies; 61+ messages in thread
From: Johannes Berg @ 2007-02-08 13:03 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance

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

On Thu, 2007-02-08 at 15:41 +1100, Paul Mackerras wrote:
> Johannes Berg writes:
> > This patch cleans up the powermac PIC initialisation code so that for G5
> > powermacs we don't even compile the old pmac pic file.
> 
> On a 32-bit powermac config, with this patch I get:
> 
>   CC      arch/powerpc/platforms/powermac/mpic.o
> /home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c: In function ‘pmac_pic_setup_mpic_nmi’:
> /home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c:40: error: ‘xmon_action’ undeclared (first use in this function)
> /home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c:40: error: (Each undeclared identifier is reported only once
> /home/paulus/kernel/powerpc/arch/powerpc/platforms/powermac/mpic.c:40: error: for each function it appears in.)
> make[3]: *** [arch/powerpc/platforms/powermac/mpic.o] Error 1

Yeah. I noticed that yesterday as well, but too late. Sorry about that.
I could fix but it isn't nice, let's just drop this patch instead.
Sorry.

johannes

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

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

* Re: [PATCH 05/10] powermac: generic time suspend/resume code
  2007-02-05 18:30   ` Johannes Berg
@ 2007-02-19 10:00     ` Guennadi Liakhovetski
  -1 siblings, 0 replies; 61+ messages in thread
From: Guennadi Liakhovetski @ 2007-02-19 10:00 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance

On Mon, 5 Feb 2007, Johannes Berg wrote:

> This patch removes the time suspend/restore code that was done through
> a PMU notifier in arch/platforms/powermac/time.c.
> 
> Instead, we introduce arch/powerpc/sysdev/timer.c which creates a sys
> device and handles time of day suspend/resume through that.

I think there's a problem with this one. In my tests with this patch the 
system time is incremented twice, so, looks like some code already takes 
care about that. Maybe there's some very indirect code in generic rtc, but 
I haven't found anything yet. Anyway, requires more investigation and, 
probably, should not be included before we clarify this.

Thanks
Guennadi
---
Guennadi Liakhovetski

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

* Re: [linux-pm] [PATCH 05/10] powermac: generic time suspend/resume code
@ 2007-02-19 10:00     ` Guennadi Liakhovetski
  0 siblings, 0 replies; 61+ messages in thread
From: Guennadi Liakhovetski @ 2007-02-19 10:00 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance

On Mon, 5 Feb 2007, Johannes Berg wrote:

> This patch removes the time suspend/restore code that was done through
> a PMU notifier in arch/platforms/powermac/time.c.
> 
> Instead, we introduce arch/powerpc/sysdev/timer.c which creates a sys
> device and handles time of day suspend/resume through that.

I think there's a problem with this one. In my tests with this patch the 
system time is incremented twice, so, looks like some code already takes 
care about that. Maybe there's some very indirect code in generic rtc, but 
I haven't found anything yet. Anyway, requires more investigation and, 
probably, should not be included before we clarify this.

Thanks
Guennadi
---
Guennadi Liakhovetski

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

* Re: [PATCH 05/10] powermac: generic time suspend/resume code
  2007-02-19 10:00     ` [linux-pm] " Guennadi Liakhovetski
@ 2007-02-19 23:19       ` Guennadi Liakhovetski
  -1 siblings, 0 replies; 61+ messages in thread
From: Guennadi Liakhovetski @ 2007-02-19 23:19 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance

On Mon, 19 Feb 2007, Guennadi Liakhovetski wrote:

> On Mon, 5 Feb 2007, Johannes Berg wrote:
> 
> > This patch removes the time suspend/restore code that was done through
> > a PMU notifier in arch/platforms/powermac/time.c.
> > 
> > Instead, we introduce arch/powerpc/sysdev/timer.c which creates a sys
> > device and handles time of day suspend/resume through that.
> 
> I think there's a problem with this one. In my tests with this patch the 
> system time is incremented twice, so, looks like some code already takes 
> care about that. Maybe there's some very indirect code in generic rtc, but 
> I haven't found anything yet. Anyway, requires more investigation and, 
> probably, should not be included before we clarify this.

Ok, it has been a problem with my testing. ATM I don't know of any 
problems with it, so, please, consider my objections void.

Thanks
Guennadi
---
Guennadi Liakhovetski

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

* Re: [linux-pm] [PATCH 05/10] powermac: generic time suspend/resume code
@ 2007-02-19 23:19       ` Guennadi Liakhovetski
  0 siblings, 0 replies; 61+ messages in thread
From: Guennadi Liakhovetski @ 2007-02-19 23:19 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Andrew Morton, linuxppc-dev, linux-pm, Torrance

On Mon, 19 Feb 2007, Guennadi Liakhovetski wrote:

> On Mon, 5 Feb 2007, Johannes Berg wrote:
> 
> > This patch removes the time suspend/restore code that was done through
> > a PMU notifier in arch/platforms/powermac/time.c.
> > 
> > Instead, we introduce arch/powerpc/sysdev/timer.c which creates a sys
> > device and handles time of day suspend/resume through that.
> 
> I think there's a problem with this one. In my tests with this patch the 
> system time is incremented twice, so, looks like some code already takes 
> care about that. Maybe there's some very indirect code in generic rtc, but 
> I haven't found anything yet. Anyway, requires more investigation and, 
> probably, should not be included before we clarify this.

Ok, it has been a problem with my testing. ATM I don't know of any 
problems with it, so, please, consider my objections void.

Thanks
Guennadi
---
Guennadi Liakhovetski

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

end of thread, other threads:[~2007-02-19 23:19 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-05 18:30 [PATCH/RFC 00/10] suspend to disk for powermac G5 Johannes Berg
2007-02-05 18:30 ` [PATCH 01/10] dont copy pages that arent RAM Johannes Berg
2007-02-05 18:30   ` Johannes Berg
2007-02-05 18:30 ` [PATCH 02/10] windfarm: dont die on suspend thread signal Johannes Berg
2007-02-05 18:30   ` Johannes Berg
2007-02-05 22:43   ` Christoph Hellwig
2007-02-05 22:54     ` [PATCH revision 2] " Johannes Berg
2007-02-05 23:04       ` Benjamin Herrenschmidt
2007-02-05 23:04         ` Benjamin Herrenschmidt
2007-02-05 23:04         ` Benjamin Herrenschmidt
2007-02-05 23:04           ` Benjamin Herrenschmidt
2007-02-05 22:54   ` [PATCH 02/10] " Andrew Morton
2007-02-05 22:55     ` Johannes Berg
2007-02-05 22:55       ` Johannes Berg
2007-02-05 22:58   ` Benjamin Herrenschmidt
2007-02-05 18:30 ` [PATCH 03/10] powerpc: fix comment in kernel/irq.c Johannes Berg
2007-02-05 18:30   ` Johannes Berg
2007-02-05 22:59   ` Benjamin Herrenschmidt
2007-02-05 23:18     ` Andrew Morton
2007-02-05 23:53       ` Benjamin Herrenschmidt
2007-02-05 18:30 ` [PATCH 04/10] powermac: clean up PIC initialisation code Johannes Berg
2007-02-05 18:30   ` Johannes Berg
2007-02-08  4:41   ` Paul Mackerras
2007-02-08 13:03     ` Johannes Berg
2007-02-08 13:03       ` Johannes Berg
2007-02-05 18:30 ` [PATCH 05/10] powermac: generic time suspend/resume code Johannes Berg
2007-02-05 18:30   ` Johannes Berg
2007-02-19 10:00   ` Guennadi Liakhovetski
2007-02-19 10:00     ` [linux-pm] " Guennadi Liakhovetski
2007-02-19 23:19     ` Guennadi Liakhovetski
2007-02-19 23:19       ` [linux-pm] " Guennadi Liakhovetski
2007-02-05 18:30 ` [RFC 06/10] powerpc: MPIC sys_device & suspend/resume Johannes Berg
2007-02-05 18:30   ` Johannes Berg
2007-02-07 12:24   ` Johannes Berg
2007-02-07 12:24     ` Johannes Berg
2007-02-05 18:30 ` [RFC 07/10] powermac: support G5 CPU hotplug Johannes Berg
2007-02-05 18:30   ` Johannes Berg
2007-02-06 12:42   ` Pavel Machek
2007-02-06 12:42     ` [linux-pm] " Pavel Machek
2007-02-07 11:40     ` Johannes Berg
2007-02-07 11:40       ` Johannes Berg
2007-02-07 12:23   ` Johannes Berg
2007-02-07 12:23     ` Johannes Berg
2007-02-05 18:30 ` [RFC 08/10] powerpc: dart iommu suspend Johannes Berg
2007-02-05 18:30   ` Johannes Berg
2007-02-06  1:19   ` Olof Johansson
2007-02-06  1:26     ` Johannes Berg
2007-02-06  1:26       ` Johannes Berg
2007-02-06  1:52     ` Johannes Berg
2007-02-07 12:22       ` Johannes Berg
2007-02-07 12:22         ` Johannes Berg
2007-02-06 12:40   ` Pavel Machek
2007-02-06 12:40     ` [linux-pm] " Pavel Machek
2007-02-07 11:42     ` Johannes Berg
2007-02-07 11:42       ` [linux-pm] " Johannes Berg
2007-02-05 18:30 ` [RFC 09/10] powermac: suspend to disk on G5 Johannes Berg
2007-02-05 18:30   ` Johannes Berg
2007-02-05 18:30 ` [RFC 10/10] powermac: fix G5-cpufreq for cpu on/offline Johannes Berg
2007-02-05 18:30   ` Johannes Berg
2007-02-07 12:21   ` Johannes Berg
2007-02-07 12:21     ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.