suspend to disk for powermac G5
Subsystems (4)
cover suspend to disk for powermac G5
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
PATCH 1/10 dont copy pages that arent RAM
Pages that aren't RAM obviously cannot be saved during suspend-to-disk so skip them.
---
Pavel Machek requested this be put into -mm for some more testing although he says it seems fine.
kernel/power/snapshot.c +2 -0
@@ -686,6 +686,8 @@ static struct page *saveable_page(unsignif (PageReserved (page) &&pfn_is_nosave (pfn))return NULL ; +if (!page_is_ram (pfn)) +return NULL ;return page; }
--
PATCH 2/10 windfarm: dont die on suspend thread signal
In reply to Johannes BergWhen the windfarm thread gets a suspend signal it will die instead of freezing. This fixes it.
---
Please apply to -mm.
drivers/macintosh/windfarm_core.c +2 -4
@@ -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 ; }
--
Re: [PATCH 02/10] windfarm: dont die on suspend thread signal
drivers/macintosh/windfarm_core.c static int wf_thread_func(void *data) · line 120
Quoted 4 lines · Johannes Berg
drivers/macintosh/windfarm_core.c +2
-2-/* 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.
PATCH 1/1 windfarm: dont die on suspend thread signal
When the windfarm thread gets a suspend signal it will die instead of freezing. This fixes it.
---
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.
drivers/macintosh/windfarm_core.c +0 -6
@@ -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" );
Re: [PATCH revision 2] windfarm: dont die on suspend thread signal
Quoted 2 lines · Johannes Berg
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() ?
Quoted 27 lines
Signed-off-by Johannes Berg <[email protected]>---
Adresses Christoph's comment: This keeps the originaltry_to_freeze()in place and just remove the code that kills the thread on a signal.drivers/macintosh/windfarm_core.c +0
-6@@ -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
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH revision 2] windfarm: dont die on suspend thread signal
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 2 lines · Johannes Berg
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.
Re: [PATCH 02/10] windfarm: dont die on suspend thread signal
In reply to Johannes BergQuoted 24 lines · On Mon, 05 Feb 2007 19:30:29 +0100 Johannes Berg <[email protected]>…
When the windfarm thread gets a suspend signal it will die instead of freezing. This fixes it.
Signed-off-by Johannes Berg <[email protected]>Cc Andrew Morton <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>---
Please apply to -mm.drivers/macintosh/windfarm_core.c +0
-2@@ -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);
drivers/macintosh/windfarm_core.c static int wf_thread_func(void *data)
Quoted 10 lines
drivers/macintosh/windfarm_core.c +2
-3-/* 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?
Re: [PATCH 02/10] windfarm: dont die on suspend thread signal
Quoted 1 line · Andrew Morton
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
Re: [PATCH 02/10] windfarm: dont die on suspend thread signal
In reply to Johannes BergQuoted 6 lines · Johannes Berg
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 <[email protected]>Cc Andrew Morton <[email protected]>
Quoted 28 lines
---
Please apply to -mm.drivers/macintosh/windfarm_core.c +2
-5@@ -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 ; } --
PATCH 3/10 powerpc: fix comment in kernel/irq.c
In reply to Johannes Bergkernel/irq.c contains a comment that speaks of -1 and -2 as interrupt numbers. Replace by NO_IRQ and NO_IRQ_IGNORE.
arch/powerpc/kernel/irq.c +3 -3
@@ -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 ();
--
Re: [PATCH 03/10] powerpc: fix comment in kernel/irq.c
Quoted 6 lines · Johannes Berg
plain text document attachment (irq-comment.patch)
kernel/irq.ccontains a comment that speaks of -1 and -2 as interrupt numbers. Replace byNO_IRQandNO_IRQ_IGNORE.Signed-off-by Johannes Berg <[email protected]>Cc Andrew Morton <[email protected]>
Quoted 23 lines
arch/powerpc/kernel/irq.c +3
-4@@ -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
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 03/10] powerpc: fix comment in kernel/irq.c
Quoted 9 lines · On Tue, 06 Feb 2007 09:59:36 +1100 Benjamin Herrenschmidt…
Quoted 6 lines · Johannes Berg
plain text document attachment (irq-comment.patch)
kernel/irq.ccontains a comment that speaks of -1 and -2 as interrupt numbers. Replace byNO_IRQandNO_IRQ_IGNORE.Signed-off-by Johannes Berg <[email protected]>Cc Andrew Morton <[email protected]>
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.
Re: [PATCH 03/10] powerpc: fix comment in kernel/irq.c
Quoted 8 lines · Andrew Morton
Quoted 5 lines · On Tue, 06 Feb 2007 09:59:36 +1100 Benjamin Herrenschmidt…
Quoted 4 lines · Johannes Berg
plain text document attachment (irq-comment.patch)
kernel/irq.ccontains a comment that speaks of -1 and -2 as interrupt numbers. Replace byNO_IRQandNO_IRQ_IGNORE.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Johannes Berg <[email protected]>Cc Andrew Morton <[email protected]>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.
PATCH 4/10 powermac: clean up PIC initialisation code
In reply to Johannes BergThis patch cleans up the powermac PIC initialisation code so that for G5 powermacs we don't even compile the old pmac pic file.
---
Tested on powerbook and powermac, please apply to -mm.
arch/powerpc/platforms/powermac/Makefile +3 -3
@@ -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
arch/powerpc/platforms/powermac/mpic.c new file +143 -0
143 lines not on this page · raw message
arch/powerpc/platforms/powermac/pic.c +5 -156
223 lines not on this page · raw message
arch/powerpc/platforms/powermac/pmac.h +3 -0
@@ -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__ */
arch/powerpc/platforms/powermac/setup.c +16 -1
@@ -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,
--
Re: [PATCH 04/10] powermac: clean up PIC initialisation code
Quoted 2 lines · Johannes Berg
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.
Re: [PATCH 04/10] powermac: clean up PIC initialisation code
Quoted 4 lines · Paul Mackerras
Quoted 2 lines · Johannes Berg
This patch cleans up the powermac PIC initialisation code so that for G5 powermacs we don't even compile the old pmac pic file.
Quoted 8 lines
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
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
PATCH 5/10 powermac: generic time suspend/resume code
In reply to Johannes BergThis 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.
---
Tested on powermac with suspend-to-disk and powerbook with suspend-to-{ram,disk}, please apply to -mm.
arch/powerpc/platforms/powermac/time.c +0 -38
@@ -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
arch/powerpc/Kconfig +5 -0
@@ -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
arch/powerpc/sysdev/Makefile +2 -0
@@ -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
arch/powerpc/sysdev/timer.c new file +70 -0
70 lines not on this page · raw message
--
Re: [PATCH 05/10] powermac: generic time suspend/resume code
Quoted 5 lines · Johannes Berg
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.cwhich 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
Re: [PATCH 05/10] powermac: generic time suspend/resume code
Quoted 5 lines · Guennadi Liakhovetski
Quoted 3 lines · Johannes Berg
This patch removes the time suspend/restore code that was done through a PMU notifier in
arch/platforms/powermac/time.c.
Quoted 8 lines
Quoted 2 lines
Instead, we introduce
arch/powerpc/sysdev/timer.cwhich 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
RFC 6/10 powerpc: MPIC sys_device & suspend/resume
In reply to Johannes BergThis 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.
---
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.
arch/powerpc/sysdev/mpic.c +65 -1
@@ -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);
include/asm-powerpc/mpic.h +12 -0
@@ -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 };/*
--
Re: [RFC 06/10] powerpc: MPIC sys_device & suspend/resume
Quoted 4 lines · Johannes Berg
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
RFC 7/10 powermac: support G5 CPU hotplug
In reply to Johannes BergThis 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?
arch/powerpc/platforms/powermac/smp.c +10 -2
@@ -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 };
arch/powerpc/platforms/powermac/setup.c +31 -1
@@ -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 pcreturn 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 };
arch/powerpc/kernel/smp.c +5 -0
@@ -558,6 +558,11 @@ int __devinit start_secondary(void *unuslocal_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 ; }
--
Re: [RFC 07/10] powermac: support G5 CPU hotplug
Hi!
Quoted 11 lines
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 <[email protected]>
arch/powerpc/kernel/smp.c int __devinit start_secondary(void *unus · line 567
Quoted 10 lines
arch/powerpc/kernel/smp.c +5
-0@@ -558,6 +558,11 @@ int __devinit start_secondary(void *unuslocal_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
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [linux-pm] [RFC 07/10] powermac: support G5 CPU hotplug
Hi,
Quoted 10 lines
arch/powerpc/kernel/smp.c int __devinit start_secondary(void *unus · line 567
Quoted 7 lines
arch/powerpc/kernel/smp.c +5
-0+/* 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?
Quoted 2 lines
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
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [RFC 07/10] powermac: support G5 CPU hotplug
In reply to Johannes BergQuoted 3 lines · Johannes Berg
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
RFC 8/10 powerpc: dart iommu suspend
In reply to Johannes BergThis implements suspend and resume code for the dart iommu.
---
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.
arch/powerpc/sysdev/dart_iommu.c +49 -0
@@ -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 ) {
include/asm-powerpc/iommu.h +4 -0
@@ -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 */
--
Re: [RFC 08/10] powerpc: dart iommu suspend
Quoted 1 line · Johannes Berg
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.
Quoted 17 lines
arch/powerpc/sysdev/dart_iommu.c +4
-0@@ -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
arch/powerpc/sysdev/dart_iommu.c void iommu_init_early_dart(void) · line 362
Quoted 10 lines
arch/powerpc/sysdev/dart_iommu.c +10
-0+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. :)
Quoted 58 lines
arch/powerpc/sysdev/dart_iommu.c +35
-0+ +/* 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 ) {include/asm-powerpc/iommu.h +4
-1@@ -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
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [RFC 08/10] powerpc: dart iommu suspend
Quoted 6 lines · Olof Johansson
Quoted 1 line · Johannes Berg
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_mdtogether 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.
Quoted 7 lines
arch/powerpc/sysdev/dart_iommu.c void iommu_init_early_dart(void) · line 362
Quoted 5 lines
arch/powerpc/sysdev/dart_iommu.c +5
-0+/* 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
Re: [RFC 08/10] powerpc: dart iommu suspend
In reply to Olof JohanssonHow'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?
arch/powerpc/sysdev/dart_iommu.c +46 -0
@@ -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 ) {
include/asm-powerpc/iommu.h +14 -0
@@ -26,6 +26,7 @@#include <linux/spinlock.h> #include <linux/device.h> #include <linux/dma-mapping.h> +#include <asm/machdep.h> #include <asm/types.h> #include <asm/bitops.h>
@@ -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 */
include/asm-powerpc/machdep.h +5 -0
@@ -91,6 +91,11 @@ struct machdep_calls {void __iomem * (*ioremap)(phys_addr_t addr,unsigned long size,unsigned long flags);void (*iounmap)(volatile void __iomem *token); + +#ifdef CONFIG_PM +void (*iommu_suspend)(void ); +void (*iommu_resume)(void ); +#endif #endif /* CONFIG_PPC64 */ int (*probe)(void );
Re: [RFC 08/10] powerpc: dart iommu suspend
Quoted 7 lines · Johannes Berg
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
Re: [RFC 08/10] powerpc: dart iommu suspend
In reply to Johannes BergHi!
Quoted 20 lines
This implements suspend and resume code for the dart iommu.
Cc Benjamin Herrenschmidt <[email protected]>arch/powerpc/sysdev/dart_iommu.c +5
-0@@ -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 )
arch/powerpc/sysdev/dart_iommu.c void iommu_init_early_dart(void) · line 363
Quoted 10 lines
arch/powerpc/sysdev/dart_iommu.c +10
-0+{ +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?
include/asm-powerpc/iommu.h static inline void pci_iommu_init(void) · line 114
Quoted 10 lines
include/asm-powerpc/iommu.h +4
-0@@ -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
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC 08/10] powerpc: dart iommu suspend
Quoted 4 lines · Pavel Machek
Review
Quoted 2 lines
(quoted diff) +2
-0+ 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.
Quoted 5 lines
Quoted 5 lines
include/asm-powerpc/iommu.h +0
-0@@ -108,6 +108,10 @@ static inline void pci_iommu_init(void)#endif
Quoted 7 lines
include/asm-powerpc/iommu.h static inline void pci_iommu_init(void) · line 114
Quoted 5 lines
include/asm-powerpc/iommu.h +4
-0extern 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
RFC 9/10 powermac: suspend to disk on G5
In reply to Johannes BergNext 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?
arch/powerpc/kernel/Makefile +1 -0
@@ -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)
kernel/power/Kconfig +2 -2
@@ -79,7 +79,7 @@ config PM_SYSFS_DEPRECATED config SOFTWARE_SUSPEND bool "Software Suspend" - depends on PM && SWAP && ((X86 && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP)) + depends on PM && SWAP && (((X86 || PPC64) && (!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
arch/powerpc/platforms/powermac/setup.c +2 -0
@@ -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 ; }
include/asm-powerpc/suspend.h new file +17 -0
@@ -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 */
include/linux/suspend.h +1 -1
@@ -1,7 +1,7 @@#ifndef _LINUX_SWSUSP_H#define _LINUX_SWSUSP_H -#if defined(CONFIG_X86 ) || defined(CONFIG_FRV ) || defined(CONFIG_PPC32 ) +#if defined(CONFIG_X86 ) || defined(CONFIG_FRV ) || defined(CONFIG_PPC32 ) || defined(CONFIG_PPC64 )#include <asm/suspend.h> #endif #include <linux/swap.h>
arch/powerpc/kernel/swsusp_64.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* PowerPC 64-bit swsusp implementation +* +* Copyright 2006 Johannes Berg <[email protected]> +* +* GPLv2 +*/ + +#include <asm/system.h> +#include <asm/iommu.h> +#include <linux/irq.h> +#include <linux/interrupt.h> + +void 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 (); +}
arch/powerpc/kernel/swsusp_asm64.S new file +231 -0
231 lines not on this page · raw message
arch/powerpc/kernel/asm-offsets.c +2 -2
@@ -21,12 +21,12 @@#include <linux/types.h> #include <linux/mman.h> #include <linux/mm.h> +#include <linux/suspend.h> #ifdef CONFIG_PPC64 #include <linux/time.h> #include <linux/hardirq.h> #else #include <linux/ptrace.h> -#include <linux/suspend.h> #endif #include <asm/io.h>
@@ -257,11 +257,11 @@ int main(void)DEFINE (CPU_SPEC_SETUP , offsetof(struct cpu_spec , cpu_setup));DEFINE (CPU_SPEC_RESTORE , offsetof(struct cpu_spec , cpu_restore)); -#ifndef CONFIG_PPC64 DEFINE (pbe_address, offsetof(struct pbe , address));DEFINE (pbe_orig_address, offsetof(struct pbe , orig_address));DEFINE (pbe_next, offsetof(struct pbe , next)); +#ifndef CONFIG_PPC64 DEFINE (TASK_SIZE ,TASK_SIZE );DEFINE (NUM_USER_SEGMENTS ,TASK_SIZE >>28 );#endif /* ! CONFIG_PPC64 */
arch/powerpc/kernel/idle.c +4 -1
@@ -33,8 +33,11 @@#include <asm/smp.h> #ifdef CONFIG_HOTPLUG_CPU +/* this is used for software suspend, and that shuts down +* CPUs even while the system is still booting... */ #define cpu_should_die () (cpu_is_offline(smp_processor_id()) && \ - system_state == SYSTEM_RUNNING) + (system_state == SYSTEM_RUNNING \ + || system_state == SYSTEM_BOOTING))#else #define cpu_should_die () 0#endif
--
RFC 10/10 powermac: fix G5-cpufreq for cpu on/offline
In reply to Johannes BergThe 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.
arch/powerpc/platforms/powermac/cpufreq_64.c +4 -4
@@ -357,13 +357,13 @@ static unsigned int g5_cpufreq_get_speedstatic 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,
--
Re: [RFC 10/10] powermac: fix G5-cpufreq for cpu on/offline
Quoted 7 lines · Johannes Berg
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