: swsusp on linux-2.6.9-rc3]
Subsystems (5)
PATCH 1/1 : swsusp on linux-2.6.9-rc3]
Hi,
attached is a forward port of Benjamin's pmdisk code to swsusp which got finally merged with pmdisk in 2.6.9-rc3. This has only been very lightly tested but survived a couple of suspend/resumes so far.
Have fun,
-- Guido
arch/ppc/Kconfig +2 -0
@@ -987,6 +987,8 @@ source "drivers/zorro/Kconfig" +source kernel/power/Kconfig + endmenu menu "Bus options"
arch/ppc/kernel/Makefile +1 -0
@@ -16,6 +16,7 @@ semaphore.o syscalls.o setup.o \ cputable.o ppc_htab.o obj-$(CONFIG_6xx) += l2cr.o cpu_setup_6xx.o +obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o obj-$(CONFIG_POWER4) += cpu_setup_power4.o obj-$(CONFIG_MODULES) += module.o ppc_ksyms.o obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-mapping.o
arch/ppc/kernel/signal.c +10 -0
@@ -28,6 +28,7 @@#include <linux/elf.h> #include <linux/tty.h> #include <linux/binfmts.h> +#include <linux/suspend.h> #include <asm/ucontext.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
@@ -604,6 +605,14 @@unsigned long frame, newsp;int signr, ret; +if (current->flags &PF_FREEZE ) { +refrigerator (PF_FREEZE ); + signr =0 ; + ret = regs->gpr[3 ]; +if (!signal_pending (current)) + goto no_signal; + } +if (!oldset) oldset = ¤t->blocked;
@@ -626,6 +635,7 @@ regs->gpr[3 ] =EINTR ;/* note that the cr0.SO bit is already set */ }else { +no_signal: regs->nip -=4 ;/* Back up & retry system call */ regs->result =0 ; regs->trap =0 ;
arch/ppc/kernel/swsusp.S +356 -0
356 lines not on this page · raw message
arch/ppc/kernel/vmlinux.lds.S +6 -0
@@ -74,6 +74,12 @@ CONSTRUCTORS } + . = ALIGN(4096); + __nosave_begin = .; + .data_nosave : { *(.data.nosave) } + . = ALIGN(4096); + __nosave_end = .; + . = ALIGN(32); .data.cacheline_aligned : { *(.data.cacheline_aligned) }
arch/ppc/platforms/pmac_setup.c +59 -0
82 lines not on this page · raw message
drivers/ide/ppc/pmac.c +3 -2
@@ -32,6 +32,7 @@#include <linux/notifier.h> #include <linux/reboot.h> #include <linux/pci.h> +#include <linux/pm.h> #include <linux/adb.h> #include <linux/pmu.h>
@@ -1364,7 +1365,7 @@ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata (&mdev->ofdev.dev);int rc =0 ; -if (state != mdev->ofdev.dev.power_state && state >=2 ) { +if (state != mdev->ofdev.dev.power_state && state ==PM_SUSPEND_MEM ) { rc =pmac_ide_do_suspend (hwif);if (rc ==0 ) mdev->ofdev.dev.power_state = state;
@@ -1472,7 +1473,7 @@ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata (pdev);int rc =0 ; -if (state != pdev->dev.power_state && state >=2 ) { +if (state != pdev->dev.power_state && state ==PM_SUSPEND_MEM ) { rc =pmac_ide_do_suspend (hwif);if (rc ==0 ) pdev->dev.power_state = state;
drivers/macintosh/Kconfig +1 -6
@@ -80,7 +80,7 @@ config PMAC_PBOOK bool "Power management support for PowerBooks" - depends on ADB_PMU + depends on PM && ADB_PMU ---help--- This provides support for putting a PowerBook to sleep; it also enables media bay support. Power management works on the
@@ -97,11 +97,6 @@ have it autoloaded. The act of removing the module shuts down the sound hardware for more power savings. -config PM - bool - depends on PPC_PMAC && ADB_PMU && PMAC_PBOOK - default y - config PMAC_APM_EMU tristate "APM emulation" depends on PMAC_PBOOK
drivers/macintosh/mediabay.c +1 -1
@@ -713,7 +713,7 @@ {struct media_bay_info *bay =macio_get_drvdata (mdev); -if (state != mdev->ofdev.dev.power_state && state >=2 ) { +if (state != mdev->ofdev.dev.power_state && state ==PM_SUSPEND_MEM ) {down (&bay->lock); bay->sleeping =1 ;set_mb_power (bay,0 );
drivers/macintosh/via-pmu.c +84 -2
110 lines not on this page · raw message
drivers/video/aty/radeon_pm.c +2 -0
@@ -859,6 +859,8 @@* know we'll be rebooted, ... */ +if (state !=PM_SUSPEND_MEM ) +return 0 ;printk (KERN_DEBUG "radeonfb: suspending to state: %d...\n" , state);acquire_console_sem ();
include/asm-ppc/suspend.h +12 -0
@@ -0,0 +1,12 @@ +static inline int arch_prepare_suspend (void ) +{ +return 0 ; +} + +static inline void save_processor_state (void ) +{ +} + +static inline void restore_processor_state (void ) +{ +}
include/linux/reboot.h +2 -0
@@ -42,6 +42,8 @@extern int register_reboot_notifier (struct notifier_block *);extern int unregister_reboot_notifier (struct notifier_block *); +/* For use by swsusp only */ +extern struct notifier_block *reboot_notifier_list;/* * Architecture-specific implementations of sys_reboot commands.
include/linux/suspend.h +1 -1
@@ -1,7 +1,7 @@#ifndef _LINUX_SWSUSP_H#define _LINUX_SWSUSP_H -#ifdef CONFIG_X86 +#if (definedCONFIG_X86 ) || (definedCONFIG_PPC32 )#include <asm/suspend.h> #endif #include <linux/swap.h>
kernel/power/disk.c +5 -2
@@ -15,6 +15,7 @@#include <linux/device.h> #include <linux/delay.h> #include <linux/fs.h> +#include <linux/reboot.h> #include "power.h"
@@ -46,14 +47,15 @@unsigned long flags;int error =0 ; -local_irq_save (flags);switch (mode) {case PM_DISK_PLATFORM : -device_power_down (PM_SUSPEND_DISK ); +local_irq_save (flags); error = pm_ops->enter (PM_SUSPEND_DISK ); +local_irq_restore (flags);break ;case PM_DISK_SHUTDOWN :printk ("Powering off system\n" ); +notifier_call_chain (&reboot_notifier_list,SYS_POWER_OFF ,NULL );device_shutdown ();machine_power_off ();break ;
@@ -171,6 +173,7 @@ in_suspend =1 ;if ((error =swsusp_suspend ())) goto Done; +pr_debug ("PM: after memory snapshot.\n" );if (in_suspend) {pr_debug ("PM: writing image.\n" );
kernel/power/main.c +1 -1
@@ -4,7 +4,7 @@* Copyright (c) 2003 Patrick Mochel * Copyright (c) 2003 Open Source Development Lab * -* This file is release under the GPLv2 +* This file is released under the GPLv2 * */
kernel/power/swsusp.c +9 -4
@@ -854,14 +854,16 @@if ((error =arch_prepare_suspend ()))return error;local_irq_disable (); +device_power_down (PM_SUSPEND_DISK );save_processor_state (); error =swsusp_arch_suspend ();restore_processor_state (); +device_power_up ();local_irq_enable ();return error; } - +#if 0 asmlinkage int swsusp_restore(void) {BUG_ON (nr_copy_pages_check != nr_copy_pages);
@@ -871,15 +873,18 @@__flush_tlb_global (); return 0; } +#endif int swsusp_resume (void ) {int error;local_irq_disable (); +device_power_down (PM_SUSPEND_DISK );save_processor_state (); error =swsusp_arch_resume ();restore_processor_state ();restore_highmem (); +device_power_up ();local_irq_enable ();return error; }
@@ -1165,7 +1170,7 @@return -ENOMEM ; pagedir_nosave = (struct pbe *)addr; -pr_debug ("pmdisk: Reading pagedir (%d Pages)\n" ,n); +pr_debug ("swsusp: Reading pagedir (%d Pages)\n" ,n);for (i =0 ; i < n && !error; i++, addr +=PAGE_SIZE ) {unsigned long offset =swp_offset (swsusp_info.pagedir[i]);
@@ -1195,7 +1200,7 @@ }/** -* pmdisk_read - Read saved image from swap. +* swsusp_read - Read saved image from swap. */ int __init swsusp_read (void )
@@ -1219,6 +1224,6 @@if (!error)pr_debug ("Reading resume file was successful\n" );else -pr_debug ("pmdisk: Error %d resuming\n" , error); +pr_debug ("swsusp: Error %d resuming\n" , error);return error; }
kernel/sys.c +1 -1
@@ -84,7 +84,7 @@* and the like. */ -static struct notifier_block *reboot_notifier_list; +struct notifier_block *reboot_notifier_list;rwlock_t notifier_lock =RW_LOCK_UNLOCKED ;/**
----- End forwarded message -----
Quoted 5 lines · Guido Guenther
Hi,
attached is a forward port of Benjamin's pmdisk code to swsusp which got finally merged with pmdisk in 2.6.9-rc3. This has only been very lightly tested but survived a couple of suspend/resumes so far.
Have fun,
I have more of that in a tree here that I need to rediff... paulus also got real sleep working on his M10 based 15" albook by spying the MacOS driver using that ndrver hack I wrote a while ago, hopefully, we'll get that in shape & merged soon.
Ben.
Quoted 4 lines · Benjamin Herrenschmidt
I have more of that in a tree here that I need to rediff... paulus also got real sleep working on his M10 based 15" albook by spying the MacOS driver using that ndrver hack I wrote a while ago, hopefully, we'll get that in shape & merged soon.
Great! Let me know if I can help to get this merged. What exactly is the ndrver hack? Google didn't show up anything.
-- Guido
Quoted 8 lines · Guido Guenther
Quoted 4 lines · Benjamin Herrenschmidt
I have more of that in a tree here that I need to rediff... paulus also got real sleep working on his M10 based 15" albook by spying the MacOS driver using that ndrver hack I wrote a while ago, hopefully, we'll get that in shape & merged soon.
Great! Let me know if I can help to get this merged. What exactly is the ndrver hack? Google didn't show up anything.
A hack I wrote a while ago that allows to run the MacOS "ndrv" video driver within a userland "shell" in linux. It works with old-style 'ndrv's that ATI still uses but not with the newer nVidia 'fully native' drivers and it can spy all IOs done by the driver
Ben.
Quoted 4 lines · Benjamin Herrenschmidt
A hack I wrote a while ago that allows to run the MacOS "ndrv" video driver within a userland "shell" in linux. It works with old-style 'ndrv's that ATI still uses but not with the newer nVidia 'fully native' drivers and it can spy all IOs done by the driver
Nice. Can you think of a way to monitor calls of MacOS X into the OF? Cheers,
-- Guido
Quoted 1 line
Nice. Can you think of a way to monitor calls of MacOS X into the OF?
The video driver is not calling into OF -- OF is long dead and gone by the time the video driver runs.
Segher
Quoted 7 lines · Guido Guenther
Quoted 4 lines · Benjamin Herrenschmidt
A hack I wrote a while ago that allows to run the MacOS "ndrv" video driver within a userland "shell" in linux. It works with old-style 'ndrv's that ATI still uses but not with the newer nVidia 'fully native' drivers and it can spy all IOs done by the driver
Nice. Can you think of a way to monitor calls of MacOS X into the OF?
It has nothing to do with OF. We need to spy the IO accesses. Roughly the same mecanism I use on linux but moved to kernel-land in OS X would be possible but complicated: basically feeding the nvdia driver with a non-mapped IO area and catching all faults, emulating the actual accesses and logging them. But my knowledge of OS X low levels isn't that good and I don't have time to work on that.
Ben.
Quoted 4 lines · Benjamin Herrenschmidt
I have more of that in a tree here that I need to rediff... paulus also got real sleep working on his M10 based 15" albook by spying the MacOS driver using that ndrver hack I wrote a while ago, hopefully, we'll get that in shape & merged soon.
Presumably this same technique could be used to figure out sleep for the M9 in the iBook G4s? I've been hanging out for that feature for some time.
cheers,
John
Quoted 8 lines · John Steele Scott
Quoted 4 lines · Benjamin Herrenschmidt
I have more of that in a tree here that I need to rediff... paulus also got real sleep working on his M10 based 15" albook by spying the MacOS driver using that ndrver hack I wrote a while ago, hopefully, we'll get that in shape & merged soon.
Presumably this same technique could be used to figure out sleep for the M9 in the iBook G4s? I've been hanging out for that feature for some time.
Yes, I have some traces from the driver on this one already. I'll compare them to what we got on the M10 and see if I can produce something useful, but I'll need volunteers to test :)
Ben.
Quoted 4 lines · Segher Boessenkool
Quoted 1 line
Nice. Can you think of a way to monitor calls of MacOS X into the OF?
The video driver is not calling into OF -- OF is long dead and gone by the time the video driver runs.
I was told that MacOS X reexecutes the cards OF code to reinitialize it after resume. I'd be nice for linux to do the same.
Cheers,
-- Guido
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 7 lines · Guido Guenther
Quoted 4 lines · Benjamin Herrenschmidt
A hack I wrote a while ago that allows to run the MacOS "ndrv" video driver within a userland "shell" in linux. It works with old-style 'ndrv's that ATI still uses but not with the newer nVidia 'fully native' drivers and it can spy all IOs done by the driver
Nice. Can you think of a way to monitor calls of MacOS X into the OF?
It has nothing to do with OF. We need to spy the IO accesses. Roughly
Well at least the nv driver uses the cards OF code to reiinitialize it after resume.
-- Guido
Quoted 8 lines · Guido Guenther
Quoted 4 lines · Segher Boessenkool
Quoted 1 line
Nice. Can you think of a way to monitor calls of MacOS X into the OF?
The video driver is not calling into OF -- OF is long dead and gone by the time the video driver runs.
I was told that MacOS X reexecutes the cards OF code to reinitialize it after resume. I'd be nice for linux to do the same.
Who told you that ? I don't know of any facility in OS X to do that...
Ben.
Quoted 8 lines · Guido Guenther
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 5 lines · Guido Guenther
Quoted 4 lines · Benjamin Herrenschmidt
A hack I wrote a while ago that allows to run the MacOS "ndrv" video driver within a userland "shell" in linux. It works with old-style 'ndrv's that ATI still uses but not with the newer nVidia 'fully native' drivers and it can spy all IOs done by the driver
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Nice. Can you think of a way to monitor calls of MacOS X into the OF?
It has nothing to do with OF. We need to spy the IO accesses. Roughly
Well at least the nv driver uses the cards OF code to reiinitialize it after resume
They built a full OF interpreter in their driver ? We know how to "locate" the card's OF, but it relies on a lot of stuffs, unless they have this part of the code in a very self-contained limited portion of their f-code which is easy to interpret ? It would be useful to have more details from whoever told you that, knowing that they don't need to tell us how to locate the card OF (I know there's some issues releasing that information), just tell us what they do once they have it :)
Ben.
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 3 lines
Presumably this same technique could be used to figure out sleep for the M9 in the iBook G4s? I've been hanging out for that feature for some time.
Yes, I have some traces from the driver on this one already. I'll compare them to what we got on the M10 and see if I can produce something useful, but I'll need volunteers to test :)
Anything I can do to help, just let me know. There's a few others I can think of from the Gentoo forums who'd be willing to give it a shot as well.
cheers,
John