Software Suspend split to two stage V2.
Subsystems (22)
PATCH 1/1 Software Suspend split to two stage V2.
Hi Pavel Machek:
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.
kernel/power/disk.c +11 -8
@@ -17,7 +17,6 @@#include <linux/fs.h> #include "power.h" -extern u32 pm_disk_mode;extern struct pm_ops * pm_ops;
@@ -26,7 +25,7 @@extern int swsusp_read (void );extern int swsusp_resume (void );extern int swsusp_free (void ); - +extern int pcs_suspend (int resume);static int noresume =0 ;char resume_file[256 ] =CONFIG_PM_STD_PARTITION ;
@@ -73,7 +72,7 @@ static int in_suspend __nosavedata = 0; - +#if 0 /** * free_some_memory - Try to free as much memory as possible *
@@ -91,7 +90,7 @@ printk("|\n"); } - +#endif static inline void platform_finish (void ) {if (pm_disk_mode ==PM_DISK_PLATFORM ) {
@@ -104,13 +103,14 @@ {device_resume ();platform_finish (); +pcs_suspend (2 );enable_nonboot_cpus ();thaw_processes ();pm_restore_console (); } -static int prepare (void ) +static int prepare (int resume) {int error;
@@ -130,9 +130,12 @@ }/* Free memory before shutting down devices. */ -free_some_memory (); +//free_some_memory(); disable_nonboot_cpus (); +if ((error =pcs_suspend (resume))) { + goto Finish; + }if ((error =device_suspend (PM_SUSPEND_DISK ))) goto Finish;
@@ -160,7 +163,7 @@ {int error; -if ((error =prepare ())) +if ((error =prepare (0 )))return error;pr_debug ("PM: Attempting to suspend to disk.\n" );
@@ -226,7 +229,7 @@pr_debug ("PM: Preparing system for restore.\n" ); -if ((error =prepare ())) +if ((error =prepare (1 ))) goto Free;barrier ();
kernel/power/process.c +0 -2
@@ -4,8 +4,6 @@* * Originally from swsusp. */ - -#undef DEBUG#include <linux/smp_lock.h>
kernel/power/swsusp.c +332 -53
462 lines not on this page · raw message
--
Hu Gang / Steve
Linux Registered User 204016
GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi!
Quoted 8 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.
BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Pavel
Documentation/pm.txt +4 -52
@@ -36,8 +36,8 @@ apmd: http://worldvisions.ca/~apenwarr/apmd/ acpid: http://acpid.sf.net/ -Driver Interface ----------------- +Driver Interface -- OBSOLETE, DO NOT USE! +----------------************************* If you are writing a new driver or maintaining an old driver, it should include power management support. Without power management support, a single driver may prevent a system with power management
@@ -91,54 +91,6 @@ void pm_unregister_all(pm_callback cback); /* - * Device idle/use detection - * - * In general, drivers for all devices should call "pm_access" - * before accessing the hardware (ie. before reading or modifying - * a hardware register). Request or packet-driven drivers should - * additionally call "pm_dev_idle" when a device is not being used. - * - * Examples: - * 1) A keyboard driver would call pm_access whenever a key is pressed - * 2) A network driver would call pm_access before submitting - * a packet for transmit or receive and pm_dev_idle when its - * transfer and receive queues are empty. - * 3) A VGA driver would call pm_access before it accesses any - * of the video controller registers - * - * Ultimately, the PM policy manager uses the access and idle - * information to decide when to suspend individual devices - * or when to suspend the entire system - */ - -/* - * Description: Update device access time and wake up device, if necessary - * - * Parameters: - * dev - PM device previously returned from pm_register - * - * Details: If called from an interrupt handler pm_access updates - * access time but should never need to wake up the device - * (if device is generating interrupts, it should be awake - * already) This is important as we can not wake up - * devices from an interrupt handler. - */ -void pm_access(struct pm_dev *dev); - -/* - * Description: Identify device as currently being idle - * - * Parameters: - * dev - PM device previously returned from pm_register - * - * Details: A call to pm_dev_idle might signal to the policy manager - * to put a device to sleep. If a new device request arrives - * between the call to pm_dev_idle and the pm_callback - * callback, the driver should fail the pm_callback request. - */ -void pm_dev_idle(struct pm_dev *dev); - -/* * Power management request callback * * Parameters:
@@ -262,8 +214,8 @@ ACPI Development mailing list: [email protected] -System Interface ----------------- +System Interface -- OBSOLETE, DO NOT USE! +----------------************************* If you are providing new power management support to Linux (ie. adding support for something like APM or ACPI), you should communicate with drivers through the existing generic power
Documentation/power/devices.txt +79 -0
82 lines not on this page · raw message
Documentation/power/swsusp.txt +75 -51
187 lines not on this page · raw message
Documentation/power/video.txt +7 -4
@@ -17,15 +17,18 @@ * systems where video state is preserved over S3. (Athlon HP Omnibook xe3s) -* systems that initialize video card into vga text mode and where BIOS - works well enough to be able to set video mode. Use - acpi_sleep=s3_mode on these. (Toshiba 4030cdt) - * systems where it is possible to call video bios during S3 resume. Unfortunately, it is not correct to call video BIOS at that point, but it happens to work on some machines. Use acpi_sleep=s3_bios (Athlon64 desktop system) +* systems that initialize video card into vga text mode and where BIOS + works well enough to be able to set video mode. Use + acpi_sleep=s3_mode on these. (Toshiba 4030cdt) + +* on some systems s3_bios kicks video into text mode, and + acpi_sleep=s3_bios,s3_mode is needed (Toshiba Satellite P10-554) + * radeon systems, where X can soft-boot your video card. You'll need patched X, and plain text console (no vesafb or radeonfb), see http://www.doesi.gmxhome.de/linux/tm800s3/s3.html. (Acer TM 800)
Documentation/sparse.txt +72 -0
72 lines not on this page · raw message
Makefile +1 -1
@@ -325,7 +325,7 @@ DEPMOD = /sbin/depmod KALLSYMS = scripts/kallsyms PERL = perl -CHECK = sparse +CHECK = sparse -Wbitwise CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ MODFLAGS = -DMODULE CFLAGS_MODULE = $(MODFLAGS)
arch/arm/mach-sa1100/pm.c +3 -3
@@ -57,7 +57,7 @@ }; -static int sa11x0_pm_enter (u32 state) +static int sa11x0_pm_enter (suspend_state_t state) {unsigned long gpio, sleep_save[SLEEP_SAVE_SIZE ];struct timespec delta, rtc;
@@ -153,7 +153,7 @@/* * Called after processes are frozen, but before we shut down devices. */ -static int sa11x0_pm_prepare (u32 state) +static int sa11x0_pm_prepare (suspend_state_t state) {return 0 ; }
@@ -161,7 +161,7 @@/* * Called after devices are re-setup, but before processes are thawed. */ -static int sa11x0_pm_finish (u32 state) +static int sa11x0_pm_finish (suspend_state_t state) {return 0 ; }
arch/i386/kernel/apm.c +3 -3
@@ -1201,8 +1201,8 @@printk (KERN_CRIT "apm: suspend was vetoed, but suspending anyway.\n" ); } -device_suspend (3 ); -device_power_down (3 ); +device_suspend (PMSG_SUSPEND ); +device_power_down (PMSG_SUSPEND );/* serialize with the timer interrupt */ write_seqlock_irq (&xtime_lock);
@@ -1255,7 +1255,7 @@ {int err; -device_power_down (3 ); +device_power_down (PMSG_SUSPEND );/* serialize with the timer interrupt */ write_seqlock_irq (&xtime_lock);/* If needed, notify drivers here */
arch/i386/kernel/signal.c +2 -1
@@ -587,7 +587,8 @@if (current->flags &PF_FREEZE ) {refrigerator (0 ); - goto no_signal; +if (!signal_pending (current)) + goto no_signal; }if (!oldset)
arch/i386/mm/fault.c +2 -0
@@ -21,6 +21,7 @@#include <linux/vt_kern.h> /* For unblank_screen() */ #include <linux/highmem.h> #include <linux/module.h> +#include <linux/delay.h> #include <asm/system.h> #include <asm/uaccess.h>
@@ -451,6 +452,7 @@ asm("movl %%cr3,%0" :"=r" (page)); page = ((unsigned long *)__va (page))[address >>22 ];printk (KERN_ALERT "*pde = %08lx\n" , page); +mdelay (10000 );/* * We must not directly access the pte in the highpte * case, the page table might be allocated in highmem.
arch/i386/power/cpu.c +1 -1
@@ -148,6 +148,6 @@__restore_processor_state (&saved_context); } - +/* Needed by apm.c */ EXPORT_SYMBOL (save_processor_state);EXPORT_SYMBOL (restore_processor_state);
drivers/acpi/sleep/main.c +4 -4
@@ -42,7 +42,7 @@* wakeup code to the waking vector. */ -static int acpi_pm_prepare (u32 pm_state) +static int acpi_pm_prepare (suspend_state_t pm_state) {u32 acpi_state = acpi_suspend_states[pm_state];
@@ -74,7 +74,7 @@* It's unfortunate, but it works. Please fix if you're feeling frisky. */ -static int acpi_pm_enter (u32 pm_state) +static int acpi_pm_enter (suspend_state_t pm_state) {acpi_status status =AE_OK ;unsigned long flags =0 ;
@@ -136,7 +136,7 @@* failed). */ -static int acpi_pm_finish (u32 pm_state) +static int acpi_pm_finish (suspend_state_t pm_state) {u32 acpi_state = acpi_suspend_states[pm_state];
@@ -156,7 +156,7 @@int acpi_suspend (u32 acpi_state) { -u32 states[] = { +suspend_state_t states[] = { [1 ] =PM_SUSPEND_STANDBY , [3 ] =PM_SUSPEND_MEM , [4 ] =PM_SUSPEND_DISK ,
drivers/base/platform.c +1 -1
@@ -238,7 +238,7 @@return (strncmp (pdev->name, drv->name,BUS_ID_SIZE ) ==0 ); } -static int platform_suspend (struct device * dev,u32 state) +static int platform_suspend (struct device * dev,pm_message_t state) {int ret =0 ;
drivers/base/power/power.h +3 -3
@@ -66,14 +66,14 @@/* * suspend.c */ -extern int suspend_device (struct device *,u32 ); +extern int suspend_device (struct device *,pm_message_t );/* * runtime.c */ -extern int dpm_runtime_suspend (struct device *,u32 ); +extern int dpm_runtime_suspend (struct device *,pm_message_t );extern void dpm_runtime_resume (struct device *);#else /* CONFIG_PM */
@@ -88,7 +88,7 @@ } -static inline int dpm_runtime_suspend (struct device * dev,u32 state) +static inline int dpm_runtime_suspend (struct device * dev,pm_message_t state) {return 0 ; }
drivers/base/power/resume.c +1 -1
@@ -36,7 +36,7 @@struct device * dev =to_device (entry);list_del_init (entry); -if (!dev->power.prev_state) +if (dev->power.prev_state ==PMSG_ON )resume_device (dev);list_add_tail (entry, &dpm_active);
drivers/base/power/runtime.c +5 -5
@@ -13,10 +13,10 @@static void runtime_resume (struct device * dev) {dev_dbg (dev,"resuming\n" ); -if (!dev->power.power_state) +if (dev->power.power_state ==PMSG_ON )return ;if (!resume_device (dev)) - dev->power.power_state =0 ; + dev->power.power_state =PMSG_ON ; }
@@ -44,7 +44,7 @@* @state: State to enter. */ -int dpm_runtime_suspend (struct device * dev,u32 state) +int dpm_runtime_suspend (struct device * dev,pm_message_t state) {int error =0 ;
@@ -52,7 +52,7 @@if (dev->power.power_state == state) goto Done; -if (dev->power.power_state) +if (dev->power.power_state !=PMSG_ON )runtime_resume (dev);if (!(error =suspend_device (dev, state)))
@@ -73,7 +73,7 @@* always be able to tell, but we need accurate information to * work reliably. */ -void dpm_set_power_state (struct device * dev,u32 state) +void dpm_set_power_state (struct device * dev,pm_message_t state) {down (&dpm_sem); dev->power.power_state = state;
drivers/base/power/shutdown.c +2 -1
@@ -29,7 +29,8 @@ dev->driver->shutdown (dev);return 0 ; } -return dpm_runtime_suspend (dev, dev->detach_state); +/* FIXME */ +return dpm_runtime_suspend (dev,PMSG_FREEZE ); }
drivers/base/power/suspend.c +5 -5
@@ -11,7 +11,7 @@#include <linux/device.h> #include "power.h" -extern int sysdev_suspend (u32 state); +extern int sysdev_suspend (pm_message_t state);/* * The entries in the dpm_active list are in a depth first order, simply
@@ -35,7 +35,7 @@* @state: Power state device is entering. */ -int suspend_device (struct device * dev,u32 state) +int suspend_device (struct device * dev,pm_message_t state) {int error =0 ;
@@ -43,7 +43,7 @@ dev->power.prev_state = dev->power.power_state; -if (dev->bus && dev->bus->suspend && !dev->power.power_state) +if (dev->bus && dev->bus->suspend && (dev->power.power_state ==PMSG_ON )) error = dev->bus->suspend (dev, state);return error;
@@ -70,7 +70,7 @@* */ -int device_suspend (u32 state) +int device_suspend (pm_message_t state) {int error =0 ;
@@ -112,7 +112,7 @@* done, power down system devices. */ -int device_power_down (u32 state) +int device_power_down (pm_message_t state) {int error =0 ;struct device * dev;
drivers/char/vt.c +0 -6
@@ -2186,8 +2186,6 @@if (!printable ||test_and_set_bit (0 , &printing))return ; -pm_access (pm_con); -if (kmsg_redirect &&vc_cons_allocated (kmsg_redirect -1 )) currcons = kmsg_redirect -1 ;
@@ -2387,7 +2385,6 @@ {int retval; -pm_access (pm_con); retval =do_con_write (tty, from_user, buf, count);con_flush_chars (tty);
@@ -2398,7 +2395,6 @@ {if (in_interrupt ())return ;/* n_r3964 calls put_char() from interrupt context */ -pm_access (pm_con);do_con_write (tty,0 , &ch,1 ); }
@@ -2467,8 +2463,6 @@if (in_interrupt ())/* from flush_to_ldisc */ return ; -pm_access (pm_con); -/* if we race with con_close(), vt may be null */ acquire_console_sem (); vt = tty->driver_data;
drivers/ide/ide-disk.c +4 -2
@@ -1419,9 +1419,12 @@ {switch (rq->pm->pm_step) {case idedisk_pm_flush_cache:/* Suspend step 1 (flush cache) complete */ -if (rq->pm->pm_state ==4 ) +#if 0 +/* FIXME!! */ +if (system_state ==SYSTEM_SNAPSHOT ) rq->pm->pm_step = ide_pm_state_completed; else +#endif rq->pm->pm_step = idedisk_pm_standby;break ;case idedisk_pm_standby:/* Suspend step 2 (standby) complete */
@@ -1702,7 +1705,6 @@return ; } -printk ("Shutdown: %s\n" , drive->name); dev->bus->suspend (dev,PM_SUSPEND_STANDBY ); }
drivers/ide/ide.c +1 -1
@@ -1499,7 +1499,7 @@return 1 ; } -static int generic_ide_suspend (struct device *dev,u32 state) +static int generic_ide_suspend (struct device *dev,pm_message_t state) {ide_drive_t *drive = dev->driver_data;struct request rq;
drivers/ieee1394/ieee1394_core.c +5 -0
@@ -1039,6 +1039,11 @@continue ; } +if (current->flags &PF_FREEZE ) { +refrigerator (0 ); +continue ; + } +while ((skb =skb_dequeue (&hpsbpkt_queue)) !=NULL ) { packet = (struct hpsb_packet *)skb->data;
drivers/input/input.c +0 -7
@@ -67,9 +67,6 @@ {struct input_handle *handle; -if (dev->pm_dev) -pm_access (dev->pm_dev); -if (type >EV_MAX || !test_bit (type, dev->evbit))return ;
@@ -230,8 +227,6 @@int input_open_device (struct input_handle *handle) { -if (handle->dev->pm_dev) -pm_access (handle->dev->pm_dev); handle->open++;if (handle->dev->open)return handle->dev->open (handle->dev);
@@ -249,8 +244,6 @@void input_close_device (struct input_handle *handle) {input_release_device (handle); -if (handle->dev->pm_dev) -pm_dev_idle (handle->dev->pm_dev);if (handle->dev->close) handle->dev->close (handle->dev); handle->open--;
drivers/pci/pci-driver.c +1 -1
@@ -295,7 +295,7 @@return 0 ; } -static int pci_device_suspend (struct device * dev,u32 state) +static int pci_device_suspend (struct device * dev,pm_message_t state) {struct pci_dev * pci_dev =to_pci_dev (dev);struct pci_driver * drv = pci_dev->driver;
drivers/pci/pci.c +28 -4
@@ -229,7 +229,7 @@/** * pci_set_power_state - Set the power state of a PCI device * @dev: PCI device to be suspended -* @state: Power state we're entering +* @state: PCI power state (D0, D1, D2, D3hot, D3cold) we're entering * * Transition a device to a new power state, using the Power Management * Capabilities in the device's config space.
@@ -242,7 +242,7 @@*/ int -pci_set_power_state (struct pci_dev *dev,int state) +pci_set_power_state (struct pci_dev *dev,pci_power_t state) {int pm;u16 pmcsr;
@@ -300,6 +300,30 @@ }/** +* pci_choose_state - Choose the power state of a PCI device +* @dev: PCI device to be suspended +* @state: target sleep state for the whole system +* +* Returns PCI power state suitable for given device and given system +* message. +*/ + +pci_power_t pci_choose_state (struct pci_dev *dev,u32 state) +{ +if (!pci_find_capability (dev,PCI_CAP_ID_PM )) +return PCI_D0 ; + +switch (state) { +case 0 :return PCI_D0 ; +case 2 :return PCI_D2 ; +case 3 :return PCI_D3hot; +default :BUG (); + } +} + +EXPORT_SYMBOL (pci_choose_state); + +/** * pci_save_state - save the PCI configuration space of a device before suspending * @dev: - PCI device that we're dealing with * @buffer: - buffer to hold config space context
@@ -365,7 +389,7 @@ {int err; -pci_set_power_state (dev,0 ); +pci_set_power_state (dev,PCI_D0 );if ((err =pcibios_enable_device (dev, bars)) <0 )return err;return 0 ;
@@ -422,7 +446,7 @@* 0 if operation is successful. * */ -int pci_enable_wake (struct pci_dev *dev,u32 state,int enable) +int pci_enable_wake (struct pci_dev *dev,pci_power_t state,int enable) {int pm;u16 value;
drivers/usb/core/hcd-pci.c +2 -2
@@ -355,8 +355,8 @@ hcd->state =USB_STATE_RESUMING ;if (has_pci_pm) -pci_set_power_state (dev,0 ); - dev->dev.power.power_state =0 ; +pci_set_power_state (dev,PCI_D0 ); + dev->dev.power.power_state =PMSG_ON ; retval =request_irq (dev->irq, usb_hcd_irq,SA_SHIRQ , hcd->description, hcd);if (retval <0 ) {
drivers/usb/host/ohci-hub.c +1 -1
@@ -76,7 +76,7 @@struct usb_device *root =hcd_to_bus (&ohci->hcd)->root_hub;int status =0 ; -if (root->dev.power.power_state !=0 ) +if (root->dev.power.power_state !=PMSG_ON )return 0 ;if (time_before (jiffies, ohci->next_statechange))return -EAGAIN ;
include/asm-i386/suspend.h +3 -0
@@ -9,6 +9,9 @@static inline int arch_prepare_suspend (void ) { +/* If you want to make non-PSE machine work, turn off paging +in do_magic. swsusp_pg_dir should have identity mapping, so +it could work... */ if (!cpu_has_pse)return -EPERM ;return 0 ;
include/linux/device.h +1 -1
@@ -61,7 +61,7 @@int (*match)(struct device * dev,struct device_driver * drv);int (*hotplug) (struct device *dev,char **envp,int num_envp,char *buffer,int buffer_size); -int (*suspend)(struct device * dev,u32 state); +int (*suspend)(struct device * dev,pm_message_t state);int (*resume)(struct device * dev); };
include/linux/page-flags.h +5 -1
@@ -74,7 +74,7 @@#define PG_swapcache 16/* Swap page: swp_entry_t in private */ #define PG_mappedtodisk 17/* Has blocks allocated on-disk */ #define PG_reclaim 18/* To be reclaimed asap */ - +#define PG_nosave_free 19/* Page is free and should not be written */ /* * Global page accounting. One instance per CPU. Only unsigned longs are
@@ -277,6 +277,10 @@#define ClearPageNosave (page) clear_bit(PG_nosave, &(page)->flags)#define TestClearPageNosave (page) test_and_clear_bit(PG_nosave, &(page)->flags) +#define PageNosaveFree (page) test_bit(PG_nosave_free, &(page)->flags) +#define SetPageNosaveFree (page) set_bit(PG_nosave_free, &(page)->flags) +#define ClearPageNosaveFree (page) clear_bit(PG_nosave_free, &(page)->flags) +#define PageMappedToDisk (page) test_bit(PG_mappedtodisk, &(page)->flags)#define SetPageMappedToDisk (page) set_bit(PG_mappedtodisk, &(page)->flags)#define ClearPageMappedToDisk (page) clear_bit(PG_mappedtodisk, &(page)->flags)
include/linux/pci.h +12 -4
@@ -480,6 +480,14 @@#define DEVICE_COUNT_COMPATIBLE 4#define DEVICE_COUNT_RESOURCE 12 +typedef int __bitwise pci_power_t ; + +#define PCI_D0 ((pci_power_t __force) 0) +#define PCI_D1 ((pci_power_t __force) 1) +#define PCI_D2 ((pci_power_t __force) 2) +#define PCI_D3hot ((pci_power_t __force) 3) +#define PCI_D3cold ((pci_power_t __force) 4) +/* * The pci_dev structure is used to describe PCI devices. */
@@ -508,7 +516,7 @@this if your device has broken DMA or supports 64-bit transfers. */ -u32 current_state;/* Current operating state. In ACPI-speak, +pci_power_t current_state;/* Current operating state. In ACPI-speak, this is D0-D3, D0 being fully functional, and D3 being off. */
@@ -645,7 +653,7 @@struct pci_dynids dynids; }; -#define to_pci_driver (drv) container_of(drv,struct pci_driver, driver) +#define to_pci_driver (drv) container_of(drv, struct pci_driver, driver)/** * PCI_DEVICE - macro used to describe a specific pci device
@@ -781,8 +789,8 @@/* Power management related routines */ int pci_save_state (struct pci_dev *dev,u32 *buffer);int pci_restore_state (struct pci_dev *dev,u32 *buffer); -int pci_set_power_state (struct pci_dev *dev,int state); -int pci_enable_wake (struct pci_dev *dev,u32 state,int enable); +int pci_set_power_state (struct pci_dev *dev,pci_power_t state); +int pci_enable_wake (struct pci_dev *dev,pci_power_t state,int enable);/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ void pci_bus_assign_resources (struct pci_bus *bus);
include/linux/pm.h +69 -79
218 lines not on this page · raw message
include/linux/suspend.h +3 -0
@@ -31,6 +31,7 @@/* mm/page_alloc.c */ extern void drain_local_pages (void ); +extern void mark_free_pages (struct zone *zone);/* kernel/power/swsusp.c */ extern int software_suspend (void );
@@ -54,6 +55,8 @@#else static inline void refrigerator (unsigned long flag) {} +static inline int freeze_processes (void ) {BUG (); } +static inline void thaw_processes (void ) {}#endif /* CONFIG_PM */ #ifdef CONFIG_SMP
kernel/power/disk.c +31 -24
128 lines not on this page · raw message
kernel/power/main.c +13 -12
@@ -22,7 +22,7 @@DECLARE_MUTEX (pm_sem);struct pm_ops * pm_ops =NULL ; -u32 pm_disk_mode =PM_DISK_SHUTDOWN ; +suspend_disk_method_t pm_disk_mode =PM_DISK_SHUTDOWN ;/** * pm_set_ops - Set the global power method table.
@@ -46,7 +46,7 @@* the platform can enter the requested state. */ -static int suspend_prepare (u32 state) +static int suspend_prepare (suspend_state_t state) {int error =0 ;
@@ -65,7 +65,7 @@ goto Thaw; } -if ((error =device_suspend (state))) +if ((error =device_suspend (PMSG_SUSPEND ))) goto Finish;return 0 ; Finish:
@@ -78,13 +78,14 @@ } -static int suspend_enter (u32 state) +static int suspend_enter (suspend_state_t state) {int error =0 ;unsigned long flags;local_irq_save (flags); -if ((error =device_power_down (state))) + +if ((error =device_power_down (PMSG_SUSPEND ))) goto Done; error = pm_ops->enter (state);device_power_up ();
@@ -99,10 +100,10 @@* @state: State we're coming out of. * * Call platform code to clean up, restart processes, and free the -* console that we've allocated. +* console that we've allocated. This is not called for suspend-to-disk. */ -static void suspend_finish (u32 state) +static void suspend_finish (suspend_state_t state) {device_resume ();if (pm_ops && pm_ops->finish)
@@ -133,7 +134,7 @@* we've woken up). */ -static int enter_state (u32 state) +static int enter_state (suspend_state_t state) {int error;
@@ -183,7 +184,7 @@* structure, and enter (above). */ -int pm_suspend (u32 state) +int pm_suspend (suspend_state_t state) {if (state >PM_SUSPEND_ON && state <PM_SUSPEND_MAX )return enter_state (state);
@@ -221,7 +222,7 @@static ssize_t state_store (struct subsystem * subsys,const char * buf,size_t n) { -u32 state =PM_SUSPEND_STANDBY ; +suspend_state_t state =PM_SUSPEND_STANDBY ;char ** s;char *p;int error;
@@ -230,8 +231,8 @@ p =memchr (buf,'\n' , n); len = p ? p - buf : n; -for (s = &pm_states[state]; state <PM_SUSPEND_MAX ; s++, state++) { -if (*s && !strncmp (buf, *s, len)) +for (s = &pm_states[state]; *s; s++, state++) { +if (!strncmp (buf, *s, len))break ; }if (*s)
kernel/power/pm.c +0 -31
@@ -256,41 +256,10 @@return 0 ; } -/** -* pm_find - find a device -* @type: type of device -* @from: where to start looking -* -* Scan the power management list for devices of a specific type. The -* return value for a matching device may be passed to further calls -* to this function to find further matches. A %NULL indicates the end -* of the list. -* -* To search from the beginning pass %NULL as the @from value. -* -* The caller MUST hold the pm_devs_lock lock when calling this -* function. The instant that the lock is dropped all pointers returned -* may become invalid. -*/ - -struct pm_dev *pm_find (pm_dev_t type,struct pm_dev *from) -{ -struct list_head *entry = from ? from->entry.next:pm_devs.next; -while (entry != &pm_devs) { - struct pm_dev *dev = list_entry(entry, struct pm_dev, entry); -if (type ==PM_UNKNOWN_DEV || dev->type == type) -return dev; - entry = entry->next; - } -return NULL ; -} -EXPORT_SYMBOL (pm_register);EXPORT_SYMBOL (pm_unregister);EXPORT_SYMBOL (pm_unregister_all); -EXPORT_SYMBOL (pm_send);EXPORT_SYMBOL (pm_send_all); -EXPORT_SYMBOL (pm_find);EXPORT_SYMBOL (pm_active);
kernel/power/swsusp.c +89 -101
383 lines not on this page · raw message
kernel/signal.c +4 -2
@@ -21,6 +21,7 @@#include <linux/binfmts.h> #include <linux/security.h> #include <linux/ptrace.h> +#include <linux/suspend.h> #include <asm/param.h> #include <asm/uaccess.h> #include <asm/unistd.h>
@@ -1483,8 +1484,7 @@unsigned long flags;struct sighand_struct *psig; -if (sig ==-1 ) -BUG (); +BUG_ON (sig ==-1 );/* do_notify_parent_cldstop should have been called instead. */ BUG_ON (tsk->state & (TASK_STOPPED |TASK_TRACED ));
@@ -2260,6 +2260,8 @@ ret = -EINTR ; } +if (current->flags &PF_FREEZE ) +refrigerator (1 );return ret; }
kernel/sys.c +3 -0
@@ -471,6 +471,7 @@case LINUX_REBOOT_CMD_HALT :notifier_call_chain (&reboot_notifier_list,SYS_HALT ,NULL ); system_state =SYSTEM_HALT ; +device_suspend (PMSG_SUSPEND );device_shutdown ();printk (KERN_EMERG "System halted.\n" );machine_halt ();
@@ -481,6 +482,7 @@case LINUX_REBOOT_CMD_POWER_OFF :notifier_call_chain (&reboot_notifier_list,SYS_POWER_OFF ,NULL ); system_state =SYSTEM_POWER_OFF ; +device_suspend (PMSG_SUSPEND );device_shutdown ();printk (KERN_EMERG "Power down.\n" );machine_power_off ();
@@ -497,6 +499,7 @@notifier_call_chain (&reboot_notifier_list,SYS_RESTART , buffer); system_state =SYSTEM_RESTART ; +device_suspend (PMSG_FREEZE );device_shutdown ();printk (KERN_EMERG "Restarting system with command '%s'.\n" , buffer);machine_restart (buffer);
mm/page_alloc.c +18 -14
@@ -434,26 +434,30 @@#endif /* CONFIG_PM || CONFIG_HOTPLUG_CPU */ #ifdef CONFIG_PM -int is_head_of_free_region (struct page *page) + +void mark_free_pages (struct zone *zone) { -struct zone *zone =page_zone (page); -unsigned long flags; +unsigned long zone_pfn, flags;int order;struct list_head *curr; -/* -* Should not matter as we need quiescent system for -* suspend anyway, but... -*/ +if (!zone->spanned_pages) +return ; +spin_lock_irqsave (&zone->lock, flags); +for (zone_pfn =0 ; zone_pfn < zone->spanned_pages; ++zone_pfn) +ClearPageNosaveFree (pfn_to_page (zone_pfn + zone->zone_start_pfn)); +for (order =MAX_ORDER -1 ; order >=0 ; --order) -list_for_each (curr, &zone->free_area[order].free_list) - if (page == list_entry(curr, struct page, lru)) { -spin_unlock_irqrestore (&zone->lock, flags); -return 1 << order; - } +list_for_each (curr, &zone->free_area[order].free_list) { +unsigned long start_pfn, i; + + start_pfn = page_to_pfn(list_entry(curr, struct page, lru)); + +for (i=0 ; i < (1 <<order); i++) +SetPageNosaveFree (pfn_to_page (start_pfn+i)); + }spin_unlock_irqrestore (&zone->lock, flags); -return 0 ; }/*
@@ -1568,7 +1572,7 @@ zone->zone_start_pfn = zone_start_pfn;if ((zone_start_pfn) & (zone_required_alignment-1 )) -printk ("BUG: wrong zone alignment, it will crash\n" ); +printk (KERN_CRIT "BUG: wrong zone alignment, it will crash\n" );memmap_init (size, nid, j, zone_start_pfn);
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Quoted 7 lines · Pavel Machek
Hi!
Quoted 5 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
Quoted 8 lines
Quoted 3 lines
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Really big diff, I'll trying.
Here is my diff.
Changes:
* Change pcs_ to page_cachs_
* Hold lru_lock to sure data not modified, I can't sure that full works, but tested passed.
* Adding new page flags, I'll move to mm-flags when it doing right things.
* If memory not enough, using shrink_all_memory to get more.
kernel/power/disk.c +14 -7
@@ -17,7 +17,6 @@#include <linux/fs.h> #include "power.h" -extern u32 pm_disk_mode;extern struct pm_ops * pm_ops;
@@ -27,6 +26,8 @@extern int swsusp_resume (void );extern int swsusp_free (void ); +extern int write_page_caches (void ); +extern int read_page_caches (void );static int noresume =0 ;char resume_file[256 ] =CONFIG_PM_STD_PARTITION ;
@@ -73,7 +74,7 @@ static int in_suspend __nosavedata = 0; - +#if 0 /** * free_some_memory - Try to free as much memory as possible *
@@ -91,7 +92,7 @@ printk("|\n"); } - +#endif static inline void platform_finish (void ) {if (pm_disk_mode ==PM_DISK_PLATFORM ) {
@@ -104,13 +105,14 @@ {device_resume ();platform_finish (); +read_page_caches ();enable_nonboot_cpus ();thaw_processes ();pm_restore_console (); } -static int prepare (void ) +static int prepare (int resume) {int error;
@@ -130,9 +132,14 @@ }/* Free memory before shutting down devices. */ -free_some_memory (); +//free_some_memory(); disable_nonboot_cpus (); +if (!resume) { +if ((error =write_page_caches ())) { + goto Finish; + } + }if ((error =device_suspend (PM_SUSPEND_DISK ))) goto Finish;
@@ -160,7 +167,7 @@ {int error; -if ((error =prepare ())) +if ((error =prepare (0 )))return error;pr_debug ("PM: Attempting to suspend to disk.\n" );
@@ -226,7 +233,7 @@pr_debug ("PM: Preparing system for restore.\n" ); -if ((error =prepare ())) +if ((error =prepare (1 ))) goto Free;barrier ();
kernel/power/process.c +0 -2
@@ -4,8 +4,6 @@* * Originally from swsusp. */ - -#undef DEBUG#include <linux/smp_lock.h>
kernel/power/swsusp.c +344 -55
489 lines not on this page · raw message
Only in linux-2.6.9-hg/mm: .vmscan.c.swp
Signature · 4 lines
-- Hu Gang / Steve Linux Registered User 204016 GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi!
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
Quoted 8 lines
Quoted 3 lines
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Quoted 8 lines
Really big diff, I'll trying.
Here is my diff.
Changes:
* Changepcs_topage_cachs_
* Holdlru_lockto sure data not modified, I can't sure that full works, but tested passed.
I'd really like to understand why it works (and have it documented somewhere).
Good test to break swsusp is run kernel compilation in one window and suspend every 30 seconds from another one.
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
In reply to Pavel MachekQuoted 7 lines · Pavel Machek
Hi!
Quoted 5 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
Quoted 9 lines
Quoted 3 lines
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Here is the patch relative to your big diff. It tested pass with my x86 pc, But the sysfs interface can't works, I using reboot system call.
TODO:
Using range struct replace with pagedir in PageCache links, Current
pagedir can't works with large pages, it need many continuous phiscal pages
kernel/power/disk.c +12 -4
@@ -29,6 +29,8 @@extern int swsusp_resume (void );extern int swsusp_free (void ); +extern int write_page_caches (void ); +extern int read_page_caches (void );static int noresume =0 ;char resume_file[256 ] =CONFIG_PM_STD_PARTITION ;
@@ -106,6 +108,7 @@ } } +static inline void platform_finish (void ) {if (pm_disk_mode ==PM_DISK_PLATFORM ) {
@@ -118,13 +121,14 @@ {device_resume ();platform_finish (); +read_page_caches ();enable_nonboot_cpus ();thaw_processes ();pm_restore_console (); } -static int prepare (void ) +static int prepare (int resume) {int error;
@@ -144,9 +148,13 @@ }/* Free memory before shutting down devices. */ -free_some_memory (); +/* free_some_memory(); */ disable_nonboot_cpus (); +if (!resume) +if ((error =write_page_caches ())) { + goto Finish; + }if ((error =device_suspend (PMSG_FREEZE ))) {printk ("Some devices failed to suspend\n" ); goto Finish;
@@ -176,7 +184,7 @@ {int error; -if ((error =prepare ())) +if ((error =prepare (0 )))return error;pr_debug ("PM: Attempting to suspend to disk.\n" );
@@ -233,7 +241,7 @@pr_debug ("PM: Preparing system for restore.\n" ); -if ((error =prepare ())) +if ((error =prepare (1 ))) goto Free;barrier ();
Only in linux-2.6.9-peval-hg/kernel/power: disk.c~
kernel/power/process.c +0 -2
@@ -4,8 +4,6 @@* * Originally from swsusp. */ - -#undef DEBUG#include <linux/smp_lock.h>
kernel/power/swsusp.c +349 -56
508 lines not on this page · raw message
Only in linux-2.6.9-peval-hg/kernel/power: swsusp.c~
--
Hu Gang / Steve
Linux Registered User 204016
GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi!
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.
Quoted 7 lines
Quoted 4 lines
BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Here is the patch relative to your big diff. It tested pass with my x86 pc, But the sysfs interface can't works, I using reboot system call.
Even without CONFIG_PREEMPT, it does NULL pointer dereference in copy_data_pages.
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
In reply to [email protected]Hi!
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.
Quoted 7 lines
Quoted 4 lines
BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Here is the patch relative to your big diff. It tested pass with my x86 pc, But the sysfs interface can't works, I using reboot system call.
Try enabling config_preempt and see how it prints about 1000 warnings and then oopses. (Okay, perhaps oops is because of highmem? I'll check.)
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
In reply to [email protected]Hi!
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.
Quoted 7 lines
Quoted 4 lines
BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Here is the patch relative to your big diff. It tested pass with my x86 pc, But the sysfs interface can't works, I using reboot system call.
Okay, I tried wihtout PREEMPT and HIGHMEM, and it seemed to work okay. [Well, it was somehow too fast ;-)].
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
In reply to [email protected]Hi!
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.
Quoted 8 lines
Quoted 5 lines
BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Here is the patch relative to your big diff. It tested pass with my x86 pc, But the sysfs interface can't works, I using reboot system call.
Without PREEMPT and HIGHMEM it worked okay on an idle system. When I started kernel compilation while trying to swsusp, it crashed on resume.
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Quoted 17 lines · Pavel Machek
Hi!
Quoted 15 lines
Quoted 14 lines
Quoted 8 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Quoted 7 lines
Quoted 2 lines
Here is the patch relative to your big diff. It tested pass with my x86 pc, But the sysfs interface can't works, I using reboot system call.
Without PREEMPT and HIGHMEM it worked okay on an idle system. When I started kernel compilation while trying to swsusp, it crashed on resume.
Pavel
Good, Not only works for myself. Here is the update patch relative to your diff, Now We not need continuous page to save pagecache pagedir. have a look, please.
I don't wannt this patch can merge into mainline kernel, just have a look thanks.
TODO:
* I have to be sure the pagecache are not modified after saved to swap device until snaphot memory finished, This is the problem that why only system idle can worked, But how can i sure that? :)
* Adding comments in source code, :)
* Clean ppc part then send to Ben.
kernel/power/disk.c +12 -4
@@ -29,6 +29,8 @@extern int swsusp_resume (void );extern int swsusp_free (void ); +extern int write_page_caches (void ); +extern int read_page_caches (void );static int noresume =0 ;char resume_file[256 ] =CONFIG_PM_STD_PARTITION ;
@@ -106,6 +108,7 @@ } } +static inline void platform_finish (void ) {if (pm_disk_mode ==PM_DISK_PLATFORM ) {
@@ -118,13 +121,14 @@ {device_resume ();platform_finish (); +read_page_caches ();enable_nonboot_cpus ();thaw_processes ();pm_restore_console (); } -static int prepare (void ) +static int prepare (int resume) {int error;
@@ -144,9 +148,13 @@ }/* Free memory before shutting down devices. */ -free_some_memory (); +/* free_some_memory(); */ disable_nonboot_cpus (); +if (!resume) +if ((error =write_page_caches ())) { + goto Finish; + }if ((error =device_suspend (PMSG_FREEZE ))) {printk ("Some devices failed to suspend\n" ); goto Finish;
@@ -176,7 +184,7 @@ {int error; -if ((error =prepare ())) +if ((error =prepare (0 )))return error;pr_debug ("PM: Attempting to suspend to disk.\n" );
@@ -233,7 +241,7 @@pr_debug ("PM: Preparing system for restore.\n" ); -if ((error =prepare ())) +if ((error =prepare (1 ))) goto Free;barrier ();
kernel/power/swsusp.c +474 -14
583 lines not on this page · raw message
--
Hu Gang / Steve
Linux Registered User 204016
GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
In reply to Pavel MachekQuoted 17 lines · Pavel Machek
Hi!
Quoted 15 lines
Quoted 14 lines
Quoted 8 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Quoted 7 lines
Quoted 2 lines
Here is the patch relative to your big diff. It tested pass with my x86 pc, But the sysfs interface can't works, I using reboot system call.
Without PREEMPT and HIGHMEM it worked okay on an idle system. When I started kernel compilation while trying to swsusp, it crashed on resume.
Pavel
Here is my big diff relative to your big diff. :), It works.
- Not need continuous page for pagedir.
Swsusp using continuous page (pagedir), to save the new address, old address and swap offset, but in current implemention, it using continuous page as array, so if has so many pages to save, we have to allocate many (>5) continuous pages, most it it will failed.
I using a easy link struct to resolve it.
a powerpc version will come soon.
Pavel, Have a look, and comment, thanks.
arch/i386/power/swsusp.S +49 -15
@@ -31,25 +31,59 @@ movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx movl %ecx,%cr3 - movl pagedir_nosave, %ebx - xorl %eax, %eax - xorl %edx, %edx + mov pagedir_nosave, %edx + test %edx, %edx + mov %edx, swsusp_pbe_pgdir + je copy_loop_end + +copy_loop_start: + mov swsusp_pbe_pgdir, %edx + mov 0xc(%edx), %eax + mov %eax, swsusp_pbe_next + xor %eax, %eax + mov %eax, swsusp_pbe_nums + + lea 0x0(%esi,1), %esi + lea 0x0(%edi,1), %edi + mov 0x4(%edx),%eax + test %eax, %eax + je copy_loop_end .p2align 4,,7 -copy_loop: - movl 4(%ebx,%edx),%edi - movl (%ebx,%edx),%esi - - movl $1024, %ecx - rep - movsl - - incl %eax - addl $16, %edx - cmpl nr_copy_pages,%eax - jb copy_loop +copy_one_pgdir: + xor %ecx, %ecx + lea 0x0(%esi,1), %esi .p2align 4,,7 +copy_one_page: + mov 0x4(%edx), %eax + mov (%edx), %edx + mov (%edx,%ecx,4), %edx + mov %edx,(%eax,%ecx,4) + inc %ecx + cmp $0x3ff, %ecx + ja copy_one_pgdir_end + mov swsusp_pbe_pgdir, %edx + jmp copy_one_page + .p2align 4,,7 + +copy_one_pgdir_end: + mov swsusp_pbe_nums, %eax + mov swsusp_pbe_pgdir, %edx + inc %eax + mov %eax, swsusp_pbe_nums + + add $0x10, %edx + cmp $0xfe, %eax + mov %edx, swsusp_pbe_pgdir + + jbe copy_one_pgdir + mov swsusp_pbe_next, %eax + test %eax, %eax + mov %eax, swsusp_pbe_pgdir + jne copy_loop_start +copy_loop_end: + movl saved_context_esp, %esp movl saved_context_ebp, %ebp movl saved_context_ebx, %ebx
Only in linux-2.6.9-peval-hg/arch/i386/power: .swsusp.S.swp Only in linux-2.6.9-peval-hg: b-i386
Only in linux-2.6.9-peval-hg: b-ppc
kernel/power/disk.c +12 -4
@@ -29,6 +29,8 @@extern int swsusp_resume (void );extern int swsusp_free (void ); +extern int write_page_caches (void ); +extern int read_page_caches (void );static int noresume =0 ;char resume_file[256 ] =CONFIG_PM_STD_PARTITION ;
@@ -106,6 +108,7 @@ } } +static inline void platform_finish (void ) {if (pm_disk_mode ==PM_DISK_PLATFORM ) {
@@ -118,13 +121,14 @@ {device_resume ();platform_finish (); +read_page_caches ();enable_nonboot_cpus ();thaw_processes ();pm_restore_console (); } -static int prepare (void ) +static int prepare (int resume) {int error;
@@ -144,9 +148,13 @@ }/* Free memory before shutting down devices. */ -free_some_memory (); +/* free_some_memory(); */ disable_nonboot_cpus (); +if (!resume) +if ((error =write_page_caches ())) { + goto Finish; + }if ((error =device_suspend (PMSG_FREEZE ))) {printk ("Some devices failed to suspend\n" ); goto Finish;
@@ -176,7 +184,7 @@ {int error; -if ((error =prepare ())) +if ((error =prepare (0 )))return error;pr_debug ("PM: Attempting to suspend to disk.\n" );
@@ -233,7 +241,7 @@pr_debug ("PM: Preparing system for restore.\n" ); -if ((error =prepare ())) +if ((error =prepare (1 ))) goto Free;barrier ();
kernel/power/swsusp.c +654 -261
1,144 lines not on this page · raw message
Signature · 4 lines
-- Hu Gang / Steve Linux Registered User 204016 GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi!
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Here is the patch relative to your big diff. It tested pass with my x86 pc, But the sysfs interface can't works, I using reboot system call.
Without PREEMPT and HIGHMEM it worked okay on an idle system. When I started kernel compilation while trying to swsusp, it crashed on resume.
Here is my big diff relative to your big diff. :), It works.
Quoted 7 lines
- Not need continuous page for pagedir.
Swsusp using continuous page (pagedir), to save the new address, old address and swap offset, but in current implemention, it using continuous page as array, so if has so many pages to save, we have to allocate many (>5) continuous pages, most it it will failed.I using a easy link struct to resolve it.
Yes, I'd like to get rid of "too many continuous pages" problem before. Small problem is that it needs to update x86-64 too, but I guess that's okay. I'd like that version to go in *before* that page-cache stuff (it actually fails a lot in wild).
Could you possibly put page-cache stuff into separate file? It would be even nicer to have it configurable (run-time or compile-time) so that if swsusp fails, I can tell people "try again with page-cache stuff turned off"...
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Quoted 17 lines · Pavel Machek
Hi!
Quoted 15 lines
Quoted 6 lines
Quoted 2 lines
Here is the patch relative to your big diff. It tested pass with my x86 pc, But the sysfs interface can't works, I using reboot system call.
Without PREEMPT and HIGHMEM it worked okay on an idle system. When I started kernel compilation while trying to swsusp, it crashed on resume.
Here is my big diff relative to your big diff. :), It works.
- Not need continuous page for pagedir.
Swsusp using continuous page (pagedir), to save the new address, old address and swap offset, but in current implemention, it using continuous page as array, so if has so many pages to save, we have to allocate many (>5) continuous pages, most it it will failed.
Quoted 4 lines
Quoted 1 line
I using a easy link struct to resolve it.
Yes, I'd like to get rid of "too many continuous pages" problem before. Small problem is that it needs to update x86-64 too, but I
I have not x86-64, so I have no chance to do it.
Quoted 2 lines
guess that's okay. I'd like that version to go in *before* that page-cache stuff (it actually fails a lot in wild).
Yes, I agree.
Quoted 6 lines
Could you possibly put page-cache stuff into separate file? It would be even nicer to have it configurable (run-time or compile-time) so that if swsusp fails, I can tell people "try again with page-cache stuff turned off"...
Pavel
I'll do that. :)
--
Hu Gang / Steve
Linux Registered User 204016
GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi!
Quoted 3 lines
Quoted 2 lines
Yes, I'd like to get rid of "too many continuous pages" problem before. Small problem is that it needs to update x86-64 too, but I
I have not x86-64, so I have no chance to do it.
I have access to x86-64, so I can do it...
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Quoted 7 lines · Pavel Machek
Hi!
Quoted 3 lines
Quoted 2 lines
Yes, I'd like to get rid of "too many continuous pages" problem before. Small problem is that it needs to update x86-64 too, but I
I have not x86-64, so I have no chance to do it.
I have access to x86-64, so I can do it...
Please, let me know when you have it done. I'd like to test ... ;-)
RJW
Signature · 3 lines
- Would you tell me, please, which way I ought to go from here? - That depends a good deal on where you want to get to. -- Lewis Carroll "Alice's Adventures in Wonderland"
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi.
You guys are slowly developing swsusp into suspend2 :>. Just in case you're wondering, I haven't given up on merging; I've just been seeking to get it as bug free as possible, do clean ups and documentation and so on before getting stuck in to submitting it.
Regards,
Nigel
Quoted 12 lines · Rafael J. Wysocki
Quoted 7 lines · Pavel Machek
Hi!
Quoted 3 lines
Quoted 2 lines
Yes, I'd like to get rid of "too many continuous pages" problem before. Small problem is that it needs to update x86-64 too, but I
I have not x86-64, so I have no chance to do it.
I have access to x86-64, so I can do it...
Please, let me know when you have it done. I'd like to test ... ;-)
RJW
Signature · 7 lines
Nigel Cunningham Pastoral Worker Christian Reformed Church of Tuggeranong PO Box 1004, Tuggeranong, ACT 2901 You see, at just the right time, when we were still powerless, Christ died for the ungodly. -- Romans 5:6
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi!
Quoted 4 lines
You guys are slowly developing swsusp into suspend2 :>. Just in case you're wondering, I haven't given up on merging; I've just been seeking to get it as bug free as possible, do clean ups and documentation and so on before getting stuck in to submitting it.
:-) Well, see how he is producing relatively small patches ;-).
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi.
Quoted 8 lines · Pavel Machek
Hi!
Quoted 4 lines
You guys are slowly developing swsusp into suspend2 :>. Just in case you're wondering, I haven't given up on merging; I've just been seeking to get it as bug free as possible, do clean ups and documentation and so on before getting stuck in to submitting it.
:-) Well, see how he is producing relatively small patches ;-).
Mmm. But I don't want to try to patch swsusp into suspend2. I just want to merge - there are too many big differences between swsusp and suspend2 for that (it's been redesigned from the ground up).
I'm thinking that rather than trying to get everything nice and tidy and perfect before I submit it, I should just put it up for review now, acknowledging that I still need to do more work on the docs and so on, and see how I go. Sound feasible?
Regards,
Nigel
Signature · 7 lines
Nigel Cunningham Pastoral Worker Christian Reformed Church of Tuggeranong PO Box 1004, Tuggeranong, ACT 2901 You see, at just the right time, when we were still powerless, Christ died for the ungodly. -- Romans 5:6
[PATH] 11-24 swsusp update 2/3
In reply to Pavel Machek--i386.diff--
arch/i386/power/swsusp.S +27 -18
@@ -31,24 +31,33 @@ movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx movl %ecx,%cr3 - movl pagedir_nosave, %ebx - xorl %eax, %eax - xorl %edx, %edx - .p2align 4,,7 - -copy_loop: - movl 4(%ebx,%edx),%edi - movl (%ebx,%edx),%esi - - movl $1024, %ecx - rep - movsl - - incl %eax - addl $16, %edx - cmpl nr_copy_pages,%eax - jb copy_loop - .p2align 4,,7 + movl pagedir_nosave, %eax + test %eax, %eax + je copy_loop_end + movl $1024, %edx + +copy_loop_start: + movl 0xc(%eax), %ebp + xorl %ebx, %ebx + leal 0x0(%esi),%esi + +copy_one_pgdir: + movl 0x4(%eax),%edi + test %edi, %edi + je copy_loop_end + + movl (%eax), %esi + movl %edx, %ecx + repz movsl %ds:(%esi),%es:(%edi) + + incl %ebx + addl $0x10, %eax + cmpl $0xff, %ebx + jbe copy_one_pgdir + test %ebp, %ebp + movl %ebp, %eax + jne copy_loop_start +copy_loop_end: movl saved_context_esp, %esp movl saved_context_ebp, %ebp
[PATH] 11-24 swsusp update 3/3
In reply to Pavel Machek--ppc.diff--
arch/ppc/Kconfig +2 -0
@@ -983,6 +983,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/swsusp.S new file +366 -0
366 lines not on this page · raw message
include/asm-ppc/suspend.h new file +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 ) +{ +}
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/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
arch/ppc/syslib/open_pic.c +2 -1
@@ -776,7 +776,8 @@if (ISR [irq] ==0 )return ;if (!cpus_empty (keepmask)) { -cpumask_t irqdest = { .bits[0 ] =openpic_read (&ISR [irq]->Destination) }; +cpumask_t irqdest; + irqdest.bits[0 ] =openpic_read (&ISR [irq]->Destination);cpus_and (irqdest, irqdest, keepmask);cpus_or (physmask, physmask, irqdest); }
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/therm_adt746x.c +6 -0
@@ -22,6 +22,7 @@#include <linux/spinlock.h> #include <linux/smp_lock.h> #include <linux/wait.h> +#include <linux/suspend.h> #include <asm/prom.h> #include <asm/machdep.h> #include <asm/io.h>
@@ -238,6 +239,11 @@#endif while (!kthread_should_stop ()) { +if (current->flags &PF_FREEZE ) { +printk (KERN_INFO "therm_adt746x: freezing thermostat\n" ); +refrigerator (PF_FREEZE ); + } +msleep_interruptible (2000 );/* Check status */
drivers/macintosh/therm_pm72.c +6 -0
@@ -88,6 +88,7 @@#include <linux/spinlock.h> #include <linux/smp_lock.h> #include <linux/wait.h> +#include <linux/suspend.h> #include <linux/reboot.h> #include <linux/kmod.h> #include <linux/i2c.h>
@@ -1044,6 +1045,11 @@while (state == state_attached) {unsigned long elapsed, start; +if (current->flags &PF_FREEZE ) { +printk (KERN_INFO "therm_pm72: freezing thermostat\n" ); +refrigerator (PF_FREEZE ); + } + start = jiffies;down (&driver_lock);
drivers/macintosh/via-pmu.c +84 -2
110 lines not on this page · raw message
drivers/video/aty/radeon_pm.c +4 -0
@@ -859,6 +859,10 @@* know we'll be rebooted, ... */ +#if 0 /* this breaks suspend to ram until the dust settles... */ + if (state != PM_SUSPEND_MEM) +#endif +return 0 ;printk (KERN_DEBUG "radeonfb: suspending to state: %d...\n" , state);acquire_console_sem ();
Re: [PATH] 11-24 swsusp update 3/3
Quoted 2 lines · On Wed, Nov 24, 2004 at 04:04:59PM +0800, [email protected] wrote:
--ppc.diff--
Slient warnning message when writing page cache to swap device and fix a bug.
include/linux/suspend.h +1 -1
@@ -1,7 +1,7 @@#ifndef _LINUX_SWSUSP_H#define _LINUX_SWSUSP_H -#if (definedCONFIG_X86) || (definedCONFIG_PPC32 ) +#if (defined(CONFIG_X86 )) || (defined (CONFIG_PPC32 ))#include <asm/suspend.h> #endif #include <linux/swap.h>
kernel/power/disk.c +1 -1
@@ -123,8 +123,8 @@static void finish (void ) {device_resume (); -read_page_caches ();platform_finish (); +read_page_caches ();enable_nonboot_cpus ();thaw_processes ();pm_restore_console ();
kernel/power/swsusp.c +49 -51
240 lines not on this page · raw message
Signature · 4 lines
-- Hu Gang / Steve Linux Registered User 204016 GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Colin Leroy
maintainerRe: [PATH] 11-24 swsusp update 3/3
In reply to [email protected]On 24 Nov 2004 at 16h11, [email protected] wrote:
Hi,
drivers/macintosh/therm_adt746x.c line 246
Quoted 10 lines
+++
linux-2.6.9-ppc-g4-peval-hg/drivers/macintosh/therm_adt746x.cdrivers/macintosh/therm_adt746x.c +5
-0@@ -238,6 +239,11 @@#endif while (!kthread_should_stop ()) { +if (current->flags &PF_FREEZE ) { +printk (KERN_INFO "therm_adt746x: freezing thermostat\n" ); +refrigerator (PF_FREEZE ); + } +
It's already in BK:
http://linux.bkbits.net:8080/linux-2.5/cset@4174ae53kZONcTQPizEVPMKvSrJB6g
Signature · 1 line
Colin
[PATH] swsusp update 3/3
In reply to Pavel MachekQuoted 11 lines · Pavel Machek
Hi!
Quoted 3 lines
Quoted 2 lines
Yes, I'd like to get rid of "too many continuous pages" problem before. Small problem is that it needs to update x86-64 too, but I
I have not x86-64, so I have no chance to do it.
I have access to x86-64, so I can do it...
PavelSignature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
arch/ppc/Kconfig +2 -0
@@ -983,6 +983,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/swsusp.S new file +366 -0
366 lines not on this page · raw message
include/asm-ppc/suspend.h new file +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 ) +{ +}
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/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
arch/ppc/syslib/open_pic.c +2 -1
@@ -776,7 +776,8 @@if (ISR [irq] ==0 )return ;if (!cpus_empty (keepmask)) { -cpumask_t irqdest = { .bits[0 ] =openpic_read (&ISR [irq]->Destination) }; +cpumask_t irqdest; + irqdest.bits[0 ] =openpic_read (&ISR [irq]->Destination);cpus_and (irqdest, irqdest, keepmask);cpus_or (physmask, physmask, irqdest); }
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/therm_adt746x.c +6 -0
@@ -22,6 +22,7 @@#include <linux/spinlock.h> #include <linux/smp_lock.h> #include <linux/wait.h> +#include <linux/suspend.h> #include <asm/prom.h> #include <asm/machdep.h> #include <asm/io.h>
@@ -238,6 +239,11 @@#endif while (!kthread_should_stop ()) { +if (current->flags &PF_FREEZE ) { +printk (KERN_INFO "therm_adt746x: freezing thermostat\n" ); +refrigerator (PF_FREEZE ); + } +msleep_interruptible (2000 );/* Check status */
drivers/macintosh/therm_pm72.c +6 -0
@@ -88,6 +88,7 @@#include <linux/spinlock.h> #include <linux/smp_lock.h> #include <linux/wait.h> +#include <linux/suspend.h> #include <linux/reboot.h> #include <linux/kmod.h> #include <linux/i2c.h>
@@ -1044,6 +1045,11 @@while (state == state_attached) {unsigned long elapsed, start; +if (current->flags &PF_FREEZE ) { +printk (KERN_INFO "therm_pm72: freezing thermostat\n" ); +refrigerator (PF_FREEZE ); + } + start = jiffies;down (&driver_lock);
drivers/macintosh/via-pmu.c +84 -2
110 lines not on this page · raw message
drivers/video/aty/radeon_pm.c +4 -0
@@ -859,6 +859,10 @@* know we'll be rebooted, ... */ +#if 0 /* this breaks suspend to ram until the dust settles... */ + if (state != PM_SUSPEND_MEM) +#endif +return 0 ;printk (KERN_DEBUG "radeonfb: suspending to state: %d...\n" , state);acquire_console_sem ();
Signature · 4 lines
-- Hu Gang / Steve Linux Registered User 204016 GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Re: [PATH] swsusp update 3/3
Hi!
Can you start pushing this through maintainers?
LINUX FOR POWERPC
P: Paul Mackerras M: [email protected] W: http://www.penguinppc.org/ L: [email protected] S: Supported
LINUX FOR POWER MACINTOSH
P: Benjamin Herrenschmidt M: [email protected] W: http://www.penguinppc.org/ L: [email protected] S: Maintained
Quoted 14 lines
arch/ppc/Kconfig +2
-0@@ -983,6 +983,8 @@ source "drivers/zorro/Kconfig" +source kernel/power/Kconfig + endmenu menu "Bus options"
arch/ppc/kernel/Makefile line 22
Quoted 7 lines
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
Ok. Or perhaps you want Kconfig part to go in last...
Quoted 2 lines
arch/ppc/kernel/swsusp.S new file +0
-0
...
arch/ppc/kernel/swsusp.S line 123
Quoted 13 lines
arch/ppc/kernel/swsusp.S new file +13
-0+ mfibatu r4,3 + stw r4,SL_IBAT3(r11) + mfibatl r4,3 + stw r4,SL_IBAT3+4(r11) + +#if 0 + /* Backup various CPU config stuffs */ + bl __save_cpu_setup +#endif + /* Call the low level suspend stuff (we should probably have made + * a stackframe... + */ + bl swsusp_save
I can't really check ppc assembly, but you probably want to kill that #if 0s.
Quoted 26 lines
arch/ppc/kernel/signal.c +9
-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;
arch/ppc/kernel/signal.c line 641
Quoted 7 lines
arch/ppc/kernel/signal.c +1
-0@@ -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 ;
Ok.
Quoted 5 lines
arch/ppc/kernel/vmlinux.lds.S +0
-0@@ -74,6 +74,12 @@ CONSTRUCTORS }
arch/ppc/kernel/vmlinux.lds.S line 85
Quoted 10 lines
arch/ppc/kernel/vmlinux.lds.S +6
-0+ . = ALIGN(4096); + __nosave_begin = .; + .data_nosave : { *(.data.nosave) } + . = ALIGN(4096); + __nosave_end = .; + . = ALIGN(32); .data.cacheline_aligned : { *(.data.cacheline_aligned) }
Ok.
arch/ppc/syslib/open_pic.c line 783
Quoted 12 lines
arch/ppc/syslib/open_pic.c +2
-1@@ -776,7 +776,8 @@if (ISR [irq] ==0 )return ;if (!cpus_empty (keepmask)) { -cpumask_t irqdest = { .bits[0 ] =openpic_read (&ISR [irq]->Destination) }; +cpumask_t irqdest; + irqdest.bits[0 ] =openpic_read (&ISR [irq]->Destination);cpus_and (irqdest, irqdest, keepmask);cpus_or (physmask, physmask, irqdest); }
Why this?
Quoted 20 lines
drivers/ide/ppc/pmac.c +2
-1@@ -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;
drivers/ide/ppc/pmac.c line 1479
Quoted 8 lines
drivers/ide/ppc/pmac.c +1
-1@@ -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;
Don't do this just yet. Big changes in this area are pending.
drivers/macintosh/mediabay.c line 719
Quoted 11 lines
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 );
Wait with this one, too.
Quoted 12 lines
drivers/macintosh/therm_adt746x.c +1
-0@@ -22,6 +22,7 @@#include <linux/spinlock.h> #include <linux/smp_lock.h> #include <linux/wait.h> +#include <linux/suspend.h> #include <asm/prom.h> #include <asm/machdep.h> #include <asm/io.h> @@ -238,6 +239,11 @@#endif
drivers/macintosh/therm_adt746x.c line 249
Quoted 10 lines
drivers/macintosh/therm_adt746x.c +5
-0while (!kthread_should_stop ()) { +if (current->flags &PF_FREEZE ) { +printk (KERN_INFO "therm_adt746x: freezing thermostat\n" ); +refrigerator (PF_FREEZE ); + } +msleep_interruptible (2000 );/* Check status */
You probably want to avoid that printk. (And similar for therm_pm72). Otherwise good.
Quoted 20 lines
drivers/macintosh/via-pmu.c +2
-1@@ -43,6 +43,7 @@#include <linux/init.h> #include <linux/interrupt.h> #include <linux/device.h> +#include <linux/sysdev.h> #include <linux/suspend.h> #include <linux/syscalls.h> #include <asm/prom.h> @@ -2326,7 +2327,7 @@/* Sync the disks. */ /* XXX It would be nice to have some way to ensure that * nobody is dirtying any new buffers while we wait. That -* could be acheived using the refrigerator for processes +* could be achieved using the refrigerator for processes * that swsusp uses */ sys_sync ();
drivers/macintosh/via-pmu.c line 2385
Quoted 7 lines
drivers/macintosh/via-pmu.c +0
-1@@ -2379,7 +2380,6 @@/* Wait for completion of async backlight requests */ while (!bright_req_1.complete || !bright_req_2.complete || - !batt_req.complete)pmu_poll ();
Ok.
drivers/video/aty/radeon_pm.c line 868
Quoted 13 lines
drivers/video/aty/radeon_pm.c +4
-0@@ -859,6 +859,10 @@* know we'll be rebooted, ... */ +#if 0 /* this breaks suspend to ram until the dust settles... */ + if (state != PM_SUSPEND_MEM) +#endif +return 0 ;printk (KERN_DEBUG "radeonfb: suspending to state: %d...\n" , state);acquire_console_sem ();
Wait with this one. (And notice that this is not ppc-specific and could do some damage...)
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: [PATH] swsusp update 3/3
In reply to [email protected]drivers/video/aty/radeon_pm.c line 868
Quoted 13 lines · On Tue, Nov 23, 2004 at 12:58:58AM +0800, [email protected] wrote:
drivers/video/aty/radeon_pm.c +4
-0@@ -859,6 +859,10 @@* know we'll be rebooted, ... */ +#if 0 /* this breaks suspend to ram until the dust settles... */ + if (state != PM_SUSPEND_MEM) +#endif +return 0 ;printk (KERN_DEBUG "radeonfb: suspending to state: %d...\n" , state);acquire_console_sem ();
Please don't. I only added this to my ppc swsusp patches as a temporary hack. It should use "flags = SUSPEND_TO_RAM" from Pavel's bigdiff. I submitted other parts to BenH a while ago, I'm currently working on cleaning some parts up and make it work with suspend-to-ram.
-- Guido
[PATH] swsusp update 2/3
In reply to Pavel MachekQuoted 11 lines · Pavel Machek
Hi!
Quoted 3 lines
Quoted 2 lines
Yes, I'd like to get rid of "too many continuous pages" problem before. Small problem is that it needs to update x86-64 too, but I
I have not x86-64, so I have no chance to do it.
I have access to x86-64, so I can do it...
PavelSignature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
arch/i386/power/swsusp.S +49 -15
@@ -31,25 +31,59 @@ movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx movl %ecx,%cr3 - movl pagedir_nosave, %ebx - xorl %eax, %eax - xorl %edx, %edx + mov pagedir_nosave, %edx + test %edx, %edx + mov %edx, swsusp_pbe_pgdir + je copy_loop_end + +copy_loop_start: + mov swsusp_pbe_pgdir, %edx + mov 0xc(%edx), %eax + mov %eax, swsusp_pbe_next + xor %eax, %eax + mov %eax, swsusp_pbe_nums + + lea 0x0(%esi,1), %esi + lea 0x0(%edi,1), %edi + mov 0x4(%edx),%eax + test %eax, %eax + je copy_loop_end .p2align 4,,7 -copy_loop: - movl 4(%ebx,%edx),%edi - movl (%ebx,%edx),%esi - - movl $1024, %ecx - rep - movsl - - incl %eax - addl $16, %edx - cmpl nr_copy_pages,%eax - jb copy_loop +copy_one_pgdir: + xor %ecx, %ecx + lea 0x0(%esi,1), %esi .p2align 4,,7 +copy_one_page: + mov 0x4(%edx), %eax + mov (%edx), %edx + mov (%edx,%ecx,4), %edx + mov %edx,(%eax,%ecx,4) + inc %ecx + cmp $0x3ff, %ecx + ja copy_one_pgdir_end + mov swsusp_pbe_pgdir, %edx + jmp copy_one_page + .p2align 4,,7 + +copy_one_pgdir_end: + mov swsusp_pbe_nums, %eax + mov swsusp_pbe_pgdir, %edx + inc %eax + mov %eax, swsusp_pbe_nums + + add $0x10, %edx + cmp $0xfe, %eax + mov %edx, swsusp_pbe_pgdir + + jbe copy_one_pgdir + mov swsusp_pbe_next, %eax + test %eax, %eax + mov %eax, swsusp_pbe_pgdir + jne copy_loop_start +copy_loop_end: + movl saved_context_esp, %esp movl saved_context_ebp, %ebp movl saved_context_ebx, %ebx
Signature · 4 lines
-- Hu Gang / Steve Linux Registered User 204016 GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Re: [PATH] swsusp update 2/3
Hi!
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Yes, I'd like to get rid of "too many continuous pages" problem before. Small problem is that it needs to update x86-64 too, but I
I have not x86-64, so I have no chance to do it.
Looks okay to me...
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
[PATH] swsusp update 1/3
In reply to Pavel MachekQuoted 8 lines · Pavel Machek
Hi!
Quoted 3 lines
Quoted 2 lines
Yes, I'd like to get rid of "too many continuous pages" problem before. Small problem is that it needs to update x86-64 too, but I
I have not x86-64, so I have no chance to do it.
I have access to x86-64, so I can do it...
Pavel
Ok, Now I finised ppc part, it works. :)
Here is all of the patch relative with your big diff.
core.diff - swsusp core part.
i386.diff - i386 part.
ppc.diff - PowerPC part.
Now we have a option in /proc/sys/kernel/swsusp_pagecache, if that is sure using swsusp pagecache, otherwise.
Please test and comments. thanks.
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 +17 -6
@@ -16,6 +16,7 @@#include <linux/device.h> #include <linux/delay.h> #include <linux/fs.h> +#include <linux/reboot.h> #include <linux/device.h> #include "power.h"
@@ -29,6 +30,8 @@extern int swsusp_resume (void );extern int swsusp_free (void ); +extern int write_page_caches (void ); +extern int read_page_caches (void );static int noresume =0 ;char resume_file[256 ] =CONFIG_PM_STD_PARTITION ;
@@ -48,14 +51,16 @@unsigned long flags;int error =0 ; -local_irq_save (flags);switch (mode) {case PM_DISK_PLATFORM : -device_power_down (PMSG_SUSPEND ); +/* device_power_down(PMSG_SUSPEND); */ +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 ;
@@ -106,6 +111,7 @@ } } +static inline void platform_finish (void ) {if (pm_disk_mode ==PM_DISK_PLATFORM ) {
@@ -118,13 +124,14 @@ {device_resume ();platform_finish (); +read_page_caches ();enable_nonboot_cpus ();thaw_processes ();pm_restore_console (); } -static int prepare (void ) +static int prepare (int resume) {int error;
@@ -144,9 +151,13 @@ }/* Free memory before shutting down devices. */ -free_some_memory (); +/* free_some_memory(); */ disable_nonboot_cpus (); +if (!resume) +if ((error =write_page_caches ())) { + goto Finish; + }if ((error =device_suspend (PMSG_FREEZE ))) {printk ("Some devices failed to suspend\n" ); goto Finish;
@@ -176,7 +187,7 @@ {int error; -if ((error =prepare ())) +if ((error =prepare (0 )))return error;pr_debug ("PM: Attempting to suspend to disk.\n" );
@@ -233,7 +244,7 @@pr_debug ("PM: Preparing system for restore.\n" ); -if ((error =prepare ())) +if ((error =prepare (1 ))) goto Free;barrier ();
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 +698 -263
1,190 lines not on this page · raw message
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 ;/**
kernel/sysctl.c +16 -0
@@ -66,6 +66,10 @@extern int printk_ratelimit_jiffies;extern int printk_ratelimit_burst; +#if defined(CONFIG_SOFTWARE_SUSPEND ) +extern int swsusp_pagecache; +#endif +#if defined(CONFIG_X86_LOCAL_APIC ) && defined(__i386__)int unknown_nmi_panic; extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *,
@@ -792,6 +796,18 @@ .strategy = &sysctl_intvec, .extra1 = &zero, }, +#if defined(CONFIG_SOFTWARE_SUSPEND ) + { + .ctl_name = VM_SWSUP_PAGECACHE, + .procname = "swsusp_pagecache", + .data = &swsusp_pagecache, + .maxlen = sizeof(swsusp_pagecache), + .mode = 0644, + .proc_handler = &proc_dointvec, + .strategy = &sysctl_intvec, + .extra1 = &zero, + }, +#endif { .ctl_name = VM_BLOCK_DUMP, .procname = "block_dump",
include/linux/sysctl.h +1 -0
@@ -170,6 +170,7 @@VM_VFS_CACHE_PRESSURE =26 ,/* dcache/icache reclaim pressure */ VM_LEGACY_VA_LAYOUT =27 ,/* legacy/compatibility virtual address space layout */ VM_HARDMAPLIMIT =28 ,/* Make mapped a hard limit */ + VM_SWSUP_PAGECACHE=29, /* Enable/Disable Suspend PageCaches */ };
--
Hu Gang / Steve
Linux Registered User 204016
GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Pavel Machek
AppliedRe: [PATH] swsusp update 1/3
Hi!
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Yes, I'd like to get rid of "too many continuous pages" problem before. Small problem is that it needs to update x86-64 too, but I
I have not x86-64, so I have no chance to do it.
I have access to x86-64, so I can do it...
PavelOk, Now I finised ppc part, it works. :)
Quoted 7 lines
Here is all of the patch relative with your big diff.
core.diff - swsusp core part.
i386.diff - i386 part.
ppc.diff - PowerPC part.Now we have a option in
/proc/sys/kernel/swsusp_pagecache, if that is sure using swsusp pagecache, otherwise.
Hmm, okay, I guess temporary sysctl is okay. [I'd probably just put there variable, and not export it to anyone. That way people will not want us to retain that in future.]
include/linux/suspend.h line 4
Quoted 8 lines
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 )
~ extra space.
Quoted 9 lines
include/linux/suspend.h +1
-2@@ -48,14 +51,16 @@unsigned long flags;int error =0 ; -local_irq_save (flags);switch (mode) {case PM_DISK_PLATFORM : -device_power_down (PMSG_SUSPEND ); +/* device_power_down(PMSG_SUSPEND); */
include/linux/suspend.h line 66
Quoted 10 lines
include/linux/suspend.h +3
-0+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 ;
Either drop this one or explain why it is good idea. It seems to be independend on the rest.
include/linux/suspend.h line 154
Quoted 6 lines
include/linux/suspend.h +1
-1@@ -144,9 +151,13 @@ }/* Free memory before shutting down devices. */ -free_some_memory (); +/* free_some_memory(); */
Needs to be if (!swsusp_pagecache), right?
kernel/power/main.c line 9
Quoted 10 lines
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 * */
Applied.
kernel/power/main.c line 224
Quoted 7 lines
kernel/power/main.c +3
-0@@ -223,7 +219,148 @@swap_list_unlock (); } +#define ONE_PAGE_PBE_NUM ( PAGE_SIZE / sizeof(struct pbe) - 1) + +/* for each pagdir */
~ missing e
Quoted 8 lines
kernel/power/main.c +8
-0+typedef int (*susp_pgdir_t )(suspend_pagedir_t *cur,void *fun,void *arg); + +static int inline for_each_pgdir (struct pbe *pbe,susp_pgdir_t fun, +void *subfun,void *arg) +{ +suspend_pagedir_t *pgdir = pbe; +int error =0 ; +
kernel/power/main.c line 242
Quoted 10 lines
kernel/power/main.c +10
-0+while (pgdir !=NULL ) { +suspend_pagedir_t *next = (suspend_pagedir_t *)pgdir->dummy.val; +pr_debug ("next %p, cur %p\n" , next, pgdir); + error =fun (pgdir, subfun, arg); +if (error)return error; + pgdir = next; + } + +return (0 ); +}
Perhaps this should be done as a macro to avoid casting fun forward and back? See list_for_each for inspiration.
Also it would be nice to have this part of patch split out... I'd like to merge it sooner than pagecache_write() and friends.
Quoted 17 lines
kernel/power/main.c +17
-0+/* +* for_each_pbe_copy_back +* +* That usefuly for writing the code in assemble code. +* +*/ +/* #define CREATE_ASM_CODE */ +#ifdef CREATE_ASM_CODE +asmlinkage void for_each_pbe_copy_back_i386(void) +{ + swsusp_pbe_pgdir = pagedir_nosave; +while (swsusp_pbe_pgdir !=NULL ) { + swsusp_pbe_next = (suspend_pagedir_t *)swsusp_pbe_pgdir->dummy.val; +for (swsusp_pbe_nums =0 ; + swsusp_pbe_nums <ONE_PAGE_PBE_NUM ; + swsusp_pbe_nums++) { + registerunsigned long i;
kernel/power/main.c line 269
Quoted 10 lines
kernel/power/main.c +10
-0+if (swsusp_pbe_pgdir->orig_address ==0 )return ; +for (i =0 ; i <PAGE_SIZE / (sizeof (unsigned long )); i+=4 ) { + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i)) = + *(((unsigned long *)(swsusp_pbe_pgdir->address) + i)); + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i+1 )) = + *(((unsigned long *)(swsusp_pbe_pgdir->address) + i+1 )); + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i+2 )) = + *(((unsigned long *)(swsusp_pbe_pgdir->address) + i+2 )); + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i+3 )) = + *(((unsigned long *)(swsusp_pbe_pgdir->address) + i+3 ));
Do you really have to do manual loop unrolling? Why can't C code be same for i386 and ppc?
kernel/power/main.c line 278
Quoted 9 lines
kernel/power/main.c +7
-0+static int mod_progress =1 ; + +static void inline mod_printk_progress (int i) +{ +if (mod_progress ==0 ) mod_progress =1 ; +if (!(i%100 )) +printk ("\b\b\b\b%3d%%" , i / mod_progress ); }
Hmm, so you did cleanup to progress printing... Good, but it would be nice to get it separately, too.
Quoted 11 lines
kernel/power/main.c +1
-1@@ -730,7 +1205,7 @@struct sysinfo i;si_swapinfo (&i); -if (i.freeswap < (nr_copy_pages +PAGES_FOR_IO )) { +if (i.freeswap < (nr_copy_pages + nr_copy_pcs +PAGES_FOR_IO )) {pr_debug ("swsusp: Not enough swap. Need %ld\n" ,i.freeswap);return 0 ; }@@ -750,25 +1225,24 @@
kernel/power/main.c line 1231
Quoted 10 lines
kernel/power/main.c +4
-4if (!enough_swap ())return -ENOSPC ; - -if ((error =alloc_pagedir ())) { -pr_debug ("suspend: Allocating pagedir failed.\n" ); -return error; + error =alloc_pagedir (&pagedir_save, nr_copy_pages,NULL ); +if (error <0 ) { +printk ("suspend: Allocating pagedir failed.\n" ); +return -ENOMEM ;
Hmm, I liked previous code better. Plus you throw out error information and just return -ENOMEM, always.
kernel/power/main.c line 1236
Quoted 6 lines
kernel/power/main.c +1
-1if ((error =alloc_image_pages ())) { -pr_debug ("suspend: Allocating image pages failed.\n" ); +printk ("suspend: Allocating image pages failed.\n" );swsusp_free ();return error; }
Applied.
kernel/power/main.c line 1328
Quoted 11 lines
kernel/power/main.c +2
-2@@ -854,11 +1321,11 @@ asmlinkage int swsusp_restore(void) { -BUG_ON (pagedir_order_check != pagedir_order); -/* Even mappings of "global" things (vmalloc) need to be fixed */ +#if defined(CONFIG_X86 ) && defined(CONFIG_X86_64 )__flush_tlb_global ();wbinvd ();/* Nigel says wbinvd here is good idea... */ +#endif
This is needed on i386, too... Okay, wbinvd probably can go... or do we have some good arch-neutral wbinvd-like thing?
kernel/power/main.c line 1371
Quoted 7 lines
kernel/power/main.c +1
-1@@ -993,7 +1367,7 @@return 0 ; } -static struct block_device * resume_bdev; +static struct block_device * resume_bdev __nosavedata;
Why?
kernel/power/main.c line 1372
Quoted 1 line
kernel/power/main.c +1
-0+return (0 );
Please avoid "return (0);". Using "return 0;" will do just fine.
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
[PATH] 11-24 swsusp update 1/3
Quoted 14 lines · Pavel Machek
Quoted 14 lines
(quoted diff) +3
-2@@ -48,14 +51,16 @@ unsigned long flags; int error = 0; - local_irq_save(flags); switch(mode) { case PM_DISK_PLATFORM: - device_power_down(PMSG_SUSPEND); + /* device_power_down(PMSG_SUSPEND); */ + local_irq_save(flags); error = pm_ops->enter(PM_SUSPEND_DISK); + local_irq_restore(flags); break; case PM_DISK_SHUTDOWN:
Quoted 8 lines
Review line 66
Quoted 5 lines
(quoted diff) +1
-0printk("Powering off system\n"); + notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); device_shutdown(); machine_power_off(); break;Either drop this one or explain why it is good idea. It seems to be independend on the rest.
This code I just copy from old ppc swsusp port, I don't why, :).
Quoted 9 lines
Review line 154
Quoted 7 lines
(quoted diff) +1
-1@@ -144,9 +151,13 @@ } /* Free memory before shutting down devices. */ - free_some_memory(); + /* free_some_memory(); */Needs to be if (!swsusp_pagecache), right?
I think we can drop this one, In write_page_caches has same code, and do the best.
Quoted 5 lines
(quoted diff) +1
-0+ if (swsusp_pbe_pgdir->orig_address == 0) return;Quoted 4 lines
(quoted diff) +4
-0+ for (i = 0; i < PAGE_SIZE / (sizeof(unsigned long)); i+=4) { + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i)) = + *(((unsigned long *)(swsusp_pbe_pgdir->address) + i)); + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i+1)) =
Quoted 8 lines
Review line 163
Quoted 5 lines
(quoted diff) +5
-0+ *(((unsigned long *)(swsusp_pbe_pgdir->address) + i+1)); + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i+2)) = + *(((unsigned long *)(swsusp_pbe_pgdir->address) + i+2)); + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i+3)) = + *(((unsigned long *)(swsusp_pbe_pgdir->address) + i+3));Do you really have to do manual loop unrolling? Why can't C code be same for i386 and ppc?
here is stupid code, update in my new patch, I using memcopy in i386, it create small assemble code.
Quoted 14 lines
Review
Quoted 11 lines
(quoted diff) +4
-4if (!enough_swap()) return -ENOSPC; - - if ((error = alloc_pagedir())) { - pr_debug("suspend: Allocating pagedir failed.\n"); - return error; + error = alloc_pagedir(&pagedir_save, nr_copy_pages, NULL); + if (error < 0) { + printk("suspend: Allocating pagedir failed.\n"); + return -ENOMEM;Hmm, I liked previous code better. Plus you throw out error information and just return
-ENOMEM, always.
Ok, It backed.
Quoted 15 lines
Review line 1328
Quoted 12 lines
(quoted diff) +2
-2@@ -854,11 +1321,11 @@ asmlinkage int swsusp_restore(void) { - BUG_ON (pagedir_order_check != pagedir_order); - /* Even mappings of "global" things (vmalloc) need to be fixed */ +#if defined(CONFIG_X86) && defined(CONFIG_X86_64) __flush_tlb_global(); wbinvd(); /* Nigel says wbinvd here is good idea... */ +#endifThis is needed on i386, too... Okay, wbinvd probably can go... or do we have some good arch-neutral wbinvd-like thing?
Quoted 7 lines
Review line 1371
Quoted 7 lines
(quoted diff) +1
-1@@ -993,7 +1367,7 @@ return 0; } -static struct block_device * resume_bdev; +static struct block_device * resume_bdev __nosavedata;
I'll re think.
Quoted 6 lines
Why?
Review line 1372
Quoted 1 line
(quoted diff) +1
-0+ return (0);Please avoid "return (0);". Using "return 0;" will do just fine.
fixed.
here is my patch relative with your big diff, hope can merge.
- correct relocating pages, that's every important, now new swsusp seem stable for me.
- corrent calc_num.
- adding some comments, sorry for my stupid english.
- improvment i386 copy back code.
---core.diff--
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 +17 -6
@@ -16,6 +16,7 @@#include <linux/device.h> #include <linux/delay.h> #include <linux/fs.h> +#include <linux/reboot.h> #include <linux/device.h> #include "power.h"
@@ -29,6 +30,8 @@extern int swsusp_resume (void );extern int swsusp_free (void ); +extern int write_page_caches (void ); +extern int read_page_caches (void );static int noresume =0 ;char resume_file[256 ] =CONFIG_PM_STD_PARTITION ;
@@ -48,14 +51,16 @@unsigned long flags;int error =0 ; -local_irq_save (flags);switch (mode) {case PM_DISK_PLATFORM : -device_power_down (PMSG_SUSPEND ); +/* device_power_down(PMSG_SUSPEND); */ +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 ;
@@ -106,6 +111,7 @@ } } +static inline void platform_finish (void ) {if (pm_disk_mode ==PM_DISK_PLATFORM ) {
@@ -117,6 +123,7 @@static void finish (void ) {device_resume (); +read_page_caches ();platform_finish ();enable_nonboot_cpus ();thaw_processes ();
@@ -124,7 +131,7 @@ } -static int prepare (void ) +static int prepare (int resume) {int error;
@@ -144,9 +151,13 @@ }/* Free memory before shutting down devices. */ -free_some_memory (); +/* free_some_memory(); */ disable_nonboot_cpus (); +if (!resume) +if ((error =write_page_caches ())) { + goto Finish; + }if ((error =device_suspend (PMSG_FREEZE ))) {printk ("Some devices failed to suspend\n" ); goto Finish;
@@ -176,7 +187,7 @@ {int error; -if ((error =prepare ())) +if ((error =prepare (0 )))return error;pr_debug ("PM: Attempting to suspend to disk.\n" );
@@ -233,7 +244,7 @@pr_debug ("PM: Preparing system for restore.\n" ); -if ((error =prepare ())) +if ((error =prepare (1 ))) goto Free;barrier ();
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 +762 -270
1,277 lines not on this page · raw message
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 ;/**
kernel/sysctl.c +16 -0
@@ -66,6 +66,10 @@extern int printk_ratelimit_jiffies;extern int printk_ratelimit_burst; +#if defined(CONFIG_SOFTWARE_SUSPEND ) +extern int swsusp_pagecache; +#endif +#if defined(CONFIG_X86_LOCAL_APIC ) && defined(__i386__)int unknown_nmi_panic; extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *,
@@ -792,6 +796,18 @@ .strategy = &sysctl_intvec, .extra1 = &zero, }, +#if defined(CONFIG_SOFTWARE_SUSPEND ) + { + .ctl_name = VM_SWSUSP_PAGECACHE, + .procname = "swsusp_pagecache", + .data = &swsusp_pagecache, + .maxlen = sizeof(swsusp_pagecache), + .mode = 0644, + .proc_handler = &proc_dointvec, + .strategy = &sysctl_intvec, + .extra1 = &zero, + }, +#endif { .ctl_name = VM_BLOCK_DUMP, .procname = "block_dump",
include/linux/sysctl.h +1 -0
@@ -170,6 +170,7 @@VM_VFS_CACHE_PRESSURE =26 ,/* dcache/icache reclaim pressure */ VM_LEGACY_VA_LAYOUT =27 ,/* legacy/compatibility virtual address space layout */ VM_HARDMAPLIMIT =28 ,/* Make mapped a hard limit */ + VM_SWSUSP_PAGECACHE=29, /* Enable/Disable Suspend PageCaches */ };
--
Hu Gang / Steve
Linux Registered User 204016
GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Re: [PATH] 11-24 swsusp update 1/3
Hi!
Quoted 3 lines
Quoted 2 lines
Either drop this one or explain why it is good idea. It seems to be independend on the rest.
This code I just copy from old ppc swsusp port, I don't why, :).
So drop the patch...
Quoted 11 lines
Quoted 9 lines
kernel/power/disk.c line 154
Quoted 7 lines
kernel/power/disk.c +1
-1@@ -144,9 +151,13 @@ }/* Free memory before shutting down devices. */ -free_some_memory (); +/* free_some_memory(); */ Needs to be if (!swsusp_pagecache), right?
I think we can drop this one, In
write_page_cacheshas same code, and do the best.
So at least delete it properly; no need to comment it out.
Quoted 13 lines
Quoted 5 lines
(quoted diff) +1
-0+ if (swsusp_pbe_pgdir->orig_address == 0) return;Quoted 4 lines
(quoted diff) +4
-0+ for (i = 0; i < PAGE_SIZE / (sizeof(unsigned long)); i+=4) { + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i)) = + *(((unsigned long *)(swsusp_pbe_pgdir->address) + i)); + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i+1)) =Quoted 8 lines
Review line 163
Quoted 5 lines
(quoted diff) +5
-0+ *(((unsigned long *)(swsusp_pbe_pgdir->address) + i+1)); + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i+2)) = + *(((unsigned long *)(swsusp_pbe_pgdir->address) + i+2)); + *(((unsigned long *)(swsusp_pbe_pgdir->orig_address) + i+3)) = + *(((unsigned long *)(swsusp_pbe_pgdir->address) + i+3));Do you really have to do manual loop unrolling? Why can't C code be same for i386 and ppc?
Quoted 2 lines
here is stupid code, update in my new patch, I using memcopy in i386, it create small assemble code.
Warning: memcpy() may uses MMX or SSE or something on some cpus....
Quoted 4 lines
Quoted 1 line
Please avoid "return (0);". Using "return 0;" will do just fine.
fixed.
here is my patch relative with your big diff, hope can merge.
I have already too big difference against mainline, so I can only merge trivial patches at this point. When 2.6.10 comes out, I'd like to merge "no-high-order-allocation" patch, and "pagecache writer" sometime after that...
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: [PATH] swsusp update 1/3
In reply to Pavel MachekHi!
Quoted 7 lines
Quoted 7 lines
Ok, Now I finised ppc part, it works. :)
Here is all of the patch relative with your big diff.
core.diff - swsusp core part.
i386.diff - i386 part.
ppc.diff - PowerPC part.
Quoted 6 lines
Quoted 2 lines
Now we have a option in
/proc/sys/kernel/swsusp_pagecache, if that is sure using swsusp pagecache, otherwise.Hmm, okay, I guess temporary sysctl is okay. [I'd probably just put there variable, and not export it to anyone. That way people will not want us to retain that in future.]
I've tried 11-24 version here, and it killed my machine during suspend. (While radeonfb was suspended -> no usefull output). Can you enable CONFIG_PREEMPT and CONFIG_HIGHMEM and get it to work?
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: [PATH] swsusp update 1/3
Quoted 8 lines · Pavel Machek
Quoted 3 lines
Hmm, okay, I guess temporary sysctl is okay. [I'd probably just put there variable, and not export it to anyone. That way people will not want us to retain that in future.]
I've tried 11-24 version here, and it killed my machine during suspend. (While radeonfb was suspended -> no usefull output). Can you enable
CONFIG_PREEMPTandCONFIG_HIGHMEMand get it to work?
Yes, It passed in my two computers, a pc and a PowerBook G4, enable CONFIG_HIGMEM and CONFIG_PREEMPT.
Here is a new patch relative with your big diff.
- using a bitmap do collidate check, faster than before. I can't sure using four pages do bitmap that's enough.
- changing pgdir_for_each to list_for.. style.
- I'm using qemu as i386 suspend testing platform, tha't perfect to do kernel level debug. If someone wanny using qemu as linux suspend testing platform, please apply this patch to let qemu support ide idle command. http://soulinfo.com/~hugang/swsusp/qemu/ide.patch
only core.diff attached, other parts nothing changed.
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 (defined(CONFIG_X86 )) || (defined (CONFIG_PPC32 ))#include <asm/suspend.h> #endif #include <linux/swap.h>
kernel/power/disk.c +17 -6
@@ -16,6 +16,7 @@#include <linux/device.h> #include <linux/delay.h> #include <linux/fs.h> +#include <linux/reboot.h> #include <linux/device.h> #include "power.h"
@@ -29,6 +30,8 @@extern int swsusp_resume (void );extern int swsusp_free (void ); +extern int write_page_caches (void ); +extern int read_page_caches (void );static int noresume =0 ;char resume_file[256 ] =CONFIG_PM_STD_PARTITION ;
@@ -48,14 +51,16 @@unsigned long flags;int error =0 ; -local_irq_save (flags);switch (mode) {case PM_DISK_PLATFORM : -device_power_down (PMSG_SUSPEND ); +/* device_power_down(PMSG_SUSPEND); */ +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 ;
@@ -106,6 +111,7 @@ } } +static inline void platform_finish (void ) {if (pm_disk_mode ==PM_DISK_PLATFORM ) {
@@ -118,13 +124,14 @@ {device_resume ();platform_finish (); +read_page_caches ();enable_nonboot_cpus ();thaw_processes ();pm_restore_console (); } -static int prepare (void ) +static int prepare (int resume) {int error;
@@ -144,9 +151,13 @@ }/* Free memory before shutting down devices. */ -free_some_memory (); +/* free_some_memory(); */ disable_nonboot_cpus (); +if (!resume) +if ((error =write_page_caches ())) { + goto Finish; + }if ((error =device_suspend (PMSG_FREEZE ))) {printk ("Some devices failed to suspend\n" ); goto Finish;
@@ -176,7 +187,7 @@ {int error; -if ((error =prepare ())) +if ((error =prepare (0 )))return error;pr_debug ("PM: Attempting to suspend to disk.\n" );
@@ -233,7 +244,7 @@pr_debug ("PM: Preparing system for restore.\n" ); -if ((error =prepare ())) +if ((error =prepare (1 ))) goto Free;barrier ();
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 +823 -275
1,340 lines not on this page · raw message
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 ;/**
kernel/sysctl.c +16 -0
@@ -66,6 +66,10 @@extern int printk_ratelimit_jiffies;extern int printk_ratelimit_burst; +#if defined(CONFIG_SOFTWARE_SUSPEND ) +extern int swsusp_pagecache; +#endif +#if defined(CONFIG_X86_LOCAL_APIC ) && defined(__i386__)int unknown_nmi_panic; extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *,
@@ -792,6 +796,18 @@ .strategy = &sysctl_intvec, .extra1 = &zero, }, +#if defined(CONFIG_SOFTWARE_SUSPEND ) + { + .ctl_name = VM_SWSUSP_PAGECACHE, + .procname = "swsusp_pagecache", + .data = &swsusp_pagecache, + .maxlen = sizeof(swsusp_pagecache), + .mode = 0644, + .proc_handler = &proc_dointvec, + .strategy = &sysctl_intvec, + .extra1 = &zero, + }, +#endif { .ctl_name = VM_BLOCK_DUMP, .procname = "block_dump",
include/linux/sysctl.h +1 -1
@@ -170,6 +170,7 @@VM_VFS_CACHE_PRESSURE =26 ,/* dcache/icache reclaim pressure */ VM_LEGACY_VA_LAYOUT =27 ,/* legacy/compatibility virtual address space layout */ VM_HARDMAPLIMIT =28 ,/* Make mapped a hard limit */ + VM_SWSUSP_PAGECACHE=29, /* Enable/Disable Suspend PageCaches */ }; --
--
Hu Gang / Steve
Linux Registered User 204016
GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Re: [PATH] swsusp update 1/3
Quoted 855 lines · On Thu, Nov 25, 2004 at 02:30:31AM +0800, [email protected] wrote:
Quoted 8 lines · Pavel Machek
Quoted 3 lines
Hmm, okay, I guess temporary sysctl is okay. [I'd probably just put there variable, and not export it to anyone. That way people will not want us to retain that in future.]
I've tried 11-24 version here, and it killed my machine during suspend. (While radeonfb was suspended -> no usefull output). Can you enable
CONFIG_PREEMPTandCONFIG_HIGHMEMand get it to work?Yes, It passed in my two computers, a pc and a PowerBook G4, enable
CONFIG_HIGMEMandCONFIG_PREEMPT.Here is a new patch relative with your big diff.
- using a bitmap do collidate check, faster than before. I can't sure using four pages do bitmap that's enough.
- changingpgdir_for_eachtolist_for.. style.- I'm using qemu as i386 suspend testing platform, tha't perfect to do kernel level debug. If someone wanny using qemu as linux suspend testing platform, please apply this patch to let qemu support ide idle command. http://soulinfo.com/~hugang/swsusp/qemu/ide.patch
only core.diff attached, other parts nothing changed.
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 (defined(CONFIG_X86 )) || (defined (CONFIG_PPC32 ))#include <asm/suspend.h> #endif #include <linux/swap.h> kernel/power/disk.c +17
-6@@ -16,6 +16,7 @@#include <linux/device.h> #include <linux/delay.h> #include <linux/fs.h> +#include <linux/reboot.h> #include <linux/device.h> #include "power.h" @@ -29,6 +30,8 @@extern int swsusp_resume (void );extern int swsusp_free (void ); +extern int write_page_caches (void ); +extern int read_page_caches (void );static int noresume =0 ;char resume_file[256 ] =CONFIG_PM_STD_PARTITION ;@@ -48,14 +51,16 @@unsigned long flags;int error =0 ; -local_irq_save (flags);switch (mode) {case PM_DISK_PLATFORM : -device_power_down (PMSG_SUSPEND ); +/* device_power_down(PMSG_SUSPEND); */ +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 ;@@ -106,6 +111,7 @@ } } +static inline void platform_finish (void ) {if (pm_disk_mode ==PM_DISK_PLATFORM ) {@@ -118,13 +124,14 @@ {device_resume ();platform_finish (); +read_page_caches ();enable_nonboot_cpus ();thaw_processes ();pm_restore_console (); } -static int prepare (void ) +static int prepare (int resume) {int error;@@ -144,9 +151,13 @@ }/* Free memory before shutting down devices. */ -free_some_memory (); +/* free_some_memory(); */ disable_nonboot_cpus (); +if (!resume) +if ((error =write_page_caches ())) { + goto Finish; + }if ((error =device_suspend (PMSG_FREEZE ))) {printk ("Some devices failed to suspend\n" ); goto Finish;@@ -176,7 +187,7 @@ {int error; -if ((error =prepare ())) +if ((error =prepare (0 )))return error;pr_debug ("PM: Attempting to suspend to disk.\n" );@@ -233,7 +244,7 @@pr_debug ("PM: Preparing system for restore.\n" ); -if ((error =prepare ())) +if ((error =prepare (1 ))) goto Free;barrier ();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 +594
-36@@ -74,9 +74,6 @@/* References to section boundaries */ extern char __nosave_begin, __nosave_end; -/* Variables to be preserved over suspend */ -static int pagedir_order_check; -extern char resume_file[];static dev_t resume_device;/* Local variables that should not be affected by save */ @@ -97,7 +94,6 @@*/ suspend_pagedir_t *pagedir_nosave __nosavedata = NULL;static suspend_pagedir_t *pagedir_save; -static int pagedir_order __nosavedata = 0;#define SWSUSP_SIG "S1SUSPEND"@@ -222,8 +218,137 @@ }swap_list_unlock (); } + +#define ONE_PAGE_PBE_NUM (PAGE_SIZE/sizeof(struct pbe)) + +/* for each pagedir */ +typedef int (*susp_pgdir_t )(suspend_pagedir_t *cur,void *fun,void *arg); + +#define pgdir_for_each_safe (pos, n, head) \ + for(pos = head, n = pos ? (suspend_pagedir_t*)pos->dummy.val : NULL; \ + pos != NULL; \ + pos = n, n = pos ? (suspend_pagedir_t *)pos->dummy.val : NULL) + +/* free pagedir */ +static void pagedir_free (suspend_pagedir_t *head) +{ +suspend_pagedir_t *next, *cur; +pgdir_for_each_safe (cur, next, head) { +free_page ((unsigned long )cur); + } +} + +/* +* swsup_pbe_t +* +* a callback funtion in foreach pbe loop. +* +* @param pbe pointer of current pbe +* @param p private data +* @param cur current index +* +* @return 0 is ok, otherwise +*/ + +typedef int (*swsup_pbe_t )(struct pbe *pbe,void *p,int cur); + +/* +* for_each_pbe +* +* @param pbe pointer of the pbe head +* @param fun callback function +* @param p private data +* @param max max the the pbe numbers +* +* @return 0 is ok, otherwise +*/ +static int for_each_pbe (struct pbe *pbe,swsup_pbe_t fun,void *p,int max) +{ +struct pbe *pgdir = pbe, *next =NULL ; +unsigned long i =0 ; +int error =0 ; + +while (pgdir !=NULL ) { +unsigned long nums; + next = (struct pbe *)pgdir->dummy.val; +for (nums =0 ; nums <ONE_PAGE_PBE_NUM ; nums++, pgdir++, i ++) { +if (i == max) {/* end */ +return 0 ; + } +if ((error =fun (pgdir, p, i))) {/* got error */ +return error; + } + } + pgdir = next; + } +return (error); +} +/* for_each_pbe_copy_back +* +* That usefuly for writing the code in assemble code. +* +*/ +/*#define CREATE_ASM_CODE */ +#ifdef CREATE_ASM_CODE +#if 0 +#define GET_ADDRESS (x) __pa(x) +#else +#define GET_ADDRESS (x) (x) +#endif +asmlinkage void for_each_pbe_copy_back(void) +{ +struct pbe *pgdir, *next; + + pgdir = pagedir_nosave; +while (pgdir !=NULL ) { +unsigned long nums, i; + pgdir = (struct pbe *)GET_ADDRESS (pgdir); + next = (struct pbe *)pgdir->dummy.val; +for (nums =0 ; nums <ONE_PAGE_PBE_NUM ; nums++) { + registerunsigned long *orig, *copy; + orig = (unsigned long *)pgdir->orig_address; +if (orig ==0 ) goto end; + orig = (unsigned long *)GET_ADDRESS (orig); + copy = (unsigned long *)GET_ADDRESS (pgdir->address); +#if 0 +memcpy (orig, copy,PAGE_SIZE ); +#else +for (i =0 ; i <PAGE_SIZE /sizeof (unsigned long ); i+=4 ) { + *(orig + i) = *(copy + i); + *(orig + i+1 ) = *(copy + i+1 ); + *(orig + i+2 ) = *(copy + i+2 ); + *(orig + i+3 ) = *(copy + i+3 ); + } +#endif + pgdir ++; + } + pgdir = next; + } +end: +panic ("just asm code" ); +} +#endif + +static int find_bpe_index (struct pbe *p,void *tmp,int cur) +{ +if (*(int *)tmp == cur) { + *(struct pbe **)tmp = p; +return (1 ); + } +return 0 ; +} +static struct pbe *find_pbe_by_index (struct pbe *pgdir,int index,int max) +{ +unsigned long p = index; +/* pr_debug("find_pbe_by_index: %p, %d, %d ", pgdir, index, max); */ +if (for_each_pbe (pgdir, find_bpe_index, &p, max) ==1 ) { +/* pr_debug("%p\n", (void*)p); */ +return ((struct pbe *)p); + } +return (NULL ); +}/** * write_swap_page - Write one page to a fresh swap location. @@ -257,6 +382,17 @@return error; } +static int data_free_pbe (struct pbe *p,void *tmp,int cur) +{ +swp_entry_t entry; + + entry = p->swap_address; +if (entry.val) +swap_free (entry); + p->swap_address = (swp_entry_t ){0 }; + +return 0 ; +}/** * data_free - Free the swap entries used by the saved image. @@ -267,43 +403,49 @@static void data_free (void ) { -swp_entry_t entry; -int i; +for_each_pbe (pagedir_nosave, data_free_pbe,NULL , nr_copy_pages); +} -for (i =0 ; i < nr_copy_pages; i++) { - entry = (pagedir_nosave + i)->swap_address; -if (entry.val) -swap_free (entry); -else -break ; - (pagedir_nosave + i)->swap_address = (swp_entry_t ){0 }; - } +static int mod_progress =1 ; + +static void inline mod_printk_progress (int i) +{ +if (mod_progress ==0 ) mod_progress =1 ; +if (!(i%100 )) +printk ("\b\b\b\b%3d%%" , i / mod_progress ); } +static int write_one_pbe (struct pbe *p,void *tmp,int cur) +{ +int error =0 ; + +BUG_ON (p->address ==0 ); +BUG_ON (p->orig_address ==0 ); +if ((error =write_page (p->address, &p->swap_address))) { +return error; + } +mod_printk_progress (cur); +pr_debug ("write_one_pbe: %p, o{%p} c{%p} %lu %d\n" , p, + (void *)p->orig_address, (void *)p->address, + p->swap_address.val, cur); +return 0 ; +}/** * data_write - Write saved image to swap. * * Walk the list of pages in the image and sync each one to swap. */ -static int data_write (void ) { -int error =0 ; -int i; -unsigned int mod = nr_copy_pages /100 ; - -if (!mod) - mod =1 ; +int error; + + mod_progress = nr_copy_pages /100 ; -printk ("Writing data to swap (%d pages)... " , nr_copy_pages ); -for (i =0 ; i < nr_copy_pages && !error; i++) { -if (!(i%mod)) -printk ("\b\b\b\b%3d%%" , i / mod ); - error =write_page ((pagedir_nosave+i)->address, - &((pagedir_nosave+i)->swap_address)); - } +printk ("Writing data to swap (%d pages)... " , nr_copy_pages); + error =for_each_pbe (pagedir_nosave, write_one_pbe,NULL , nr_copy_pages);printk ("\b\b\b\bdone\n" ); +return error; }@@ -363,7 +505,6 @@swap_free (swsusp_info.pagedir[i]); } -/** * write_pagedir - Write the array of pages holding the page directory. * @last: Last swap entry we write (needed for header). @@ -371,15 +512,19 @@static int write_pagedir (void ) { -unsigned long addr = (unsigned long )pagedir_nosave; -int error =0 ; -int n =SUSPEND_PD_PAGES (nr_copy_pages); -int i; +int error =0 , n =0 ; +suspend_pagedir_t *pgdir, *next; - swsusp_info.pagedir_pages = n; +pgdir_for_each_safe (pgdir, next, pagedir_nosave) { + error =write_page ((unsigned long )pgdir, &swsusp_info.pagedir[n]); +if (error) { +break ; + } + n++; + }printk ("Writing pagedir (%d pages)\n" , n); -for (i =0 ; i < n && !error; i++, addr +=PAGE_SIZE ) - error =write_page (addr, &swsusp_info.pagedir[i]); + swsusp_info.pagedir_pages = n; +return error; }@@ -504,6 +649,464 @@return 0 ; } +typedef int (*do_page_t )(struct page *page,int p); + +static int foreach_zone_page (struct zone *zone,do_page_t fun,int p) +{ +int inactive =0 , active =0 ; + +spin_lock_irq (&zone->lru_lock); +if (zone->nr_inactive) { +struct list_head * entry = zone->inactive_list.prev; +while (entry != &zone->inactive_list) { +if (fun) { + struct page * page = list_entry(entry, struct page, lru); + inactive +=fun (page, p); + }else { + inactive ++; + } + entry = entry->prev; + } + } +if (zone->nr_active) { +struct list_head * entry = zone->active_list.prev; +while (entry != &zone->active_list) { +if (fun) { + struct page * page = list_entry(entry, struct page, lru); + active +=fun (page, p); + }else { + active ++; + } + entry = entry->prev; + } + } +spin_unlock_irq (&zone->lru_lock); + +return (active + inactive); +} + +/* enable/disable pagecache suspend */ +int swsusp_pagecache =0 ; + +/* I'll move this to include/linux/page-flags.h */ +#define PG_page_caches (PG_nosave_free + 1) + +#define SetPagePcs (page) set_bit(PG_page_caches, &(page)->flags) +#define ClearPagePcs (page) clear_bit(PG_page_caches, &(page)->flags) +#define PagePcs (page) test_bit(PG_page_caches, &(page)->flags) + +static suspend_pagedir_t *pagedir_cache =NULL ; +static int nr_copy_page_caches =0 ; + +static void lock_pagecaches (void ) +{ +struct zone *zone; +for_each_zone (zone) { +if (!is_highmem (zone)) { +spin_lock_irq (&zone->lru_lock); + } + } +} + +static void unlock_pagecaches (void ) +{ +struct zone *zone; +for_each_zone (zone) { +if (!is_highmem (zone)) { +spin_unlock_irq (&zone->lru_lock); + } + } +} + +static int setup_page_caches_pe (struct page *page,int setup) +{ +unsigned long pfn =page_to_pfn (page); + +BUG_ON (PageReserved (page) &&PageNosave (page)); +if (!pfn_valid (pfn)) { +printk ("not valid page\n" ); +return 0 ; + } +if (PageNosave (page)) { +printk ("nosave\n" ); +return 0 ; + } +if (PageReserved (page)/*&& pfn_is_nosave(pfn)*/ ) { +printk ("[nosave]\n" ); +return 0 ; + } +if (PageSlab (page)) { +printk ("slab\n" ); +return 0 ; + } +if (setup) { +struct pbe *p =find_pbe_by_index (pagedir_cache, nr_copy_page_caches,-1 ); +BUG_ON (p ==NULL ); + p->address = (long )page_address (page); +BUG_ON (p->address ==0 ); +/*pr_debug("setup_page_caches: cur %p, o{%p}, d{%p}, nr %u\n", +(void*)p, (void*)p->orig_address, +(void*)p->address, nr_copy_page_caches);*/ + nr_copy_page_caches ++; + } +SetPagePcs (page); + +return (1 ); +} + +static int count_page_caches (struct zone *zone,int p) +{ +if (swsusp_pagecache) +return foreach_zone_page (zone, setup_page_caches_pe, p); +return 0 ; +} + +/* a bitmap base collide check */ +static inline void collide_set_bit (unsigned char *bitmap, +unsigned long bitnum) +{ + bitnum -=0xc0000000 ; + bitnum = bitnum >>12 ; + bitmap[bitnum /8 ] |= (1 << (bitnum%8 )); +} + +static inline int collide_is_bit_set (unsigned char *bitmap, +unsigned long bitnum) +{ + bitnum -=0xc0000000 ; + bitnum = bitnum >>12 ; +return !!(bitmap[bitnum /8 ] & (1 << (bitnum%8 ))); +} + +static void collide_bitmap_free (unsigned char *bitmap) +{ +free_pages ((unsigned long )bitmap,2 ); +} + +/* +* four pages are enough for bitmap +* +*/ +static unsigned char *collide_bitmap_init (struct pbe *pgdir) +{ +unsigned char *bitmap = + (unsigned char *)__get_free_pages (GFP_ATOMIC | __GFP_COLD,2 ); +struct pbe *next; + +if (bitmap ==NULL ) { +return NULL ; + } +memset (bitmap,0 ,4 *PAGE_SIZE ); + +/* do base check */ +BUG_ON (collide_is_bit_set (bitmap, (unsigned long )bitmap) ==1 ); +collide_set_bit (bitmap, (unsigned long )bitmap); +BUG_ON (collide_is_bit_set (bitmap, (unsigned long )bitmap) ==0 ); + +while (pgdir !=NULL ) { +unsigned long nums; + next = (struct pbe *)pgdir->dummy.val; +for (nums =0 ; nums <ONE_PAGE_PBE_NUM ; nums++) { +collide_set_bit (bitmap, (unsigned long )pgdir); +collide_set_bit (bitmap, (unsigned long )pgdir->orig_address); + pgdir ++; + } + pgdir = next; + } + +return bitmap; +} + +/* +* redefine in PageCahe pagdir. +* +* struct pbe { +* unsigned long address; +* unsigned long orig_address; pointer of next struct pbe +* swp_entry_t swap_address; +* swp_entry_t dummy; current index +* } +* +*/ +static suspend_pagedir_t *alloc_one_pagedir (suspend_pagedir_t *prev, +unsigned char *collide) +{ +suspend_pagedir_t *pgdir =NULL ; +int i; + + pgdir = (suspend_pagedir_t *) +__get_free_pages (GFP_ATOMIC | __GFP_COLD,0 ); +if (!pgdir) { +return NULL ; + } + +if (collide) { +while (collide_is_bit_set (collide, (unsigned long )pgdir)) { + pgdir = (suspend_pagedir_t *) +__get_free_pages (GFP_ATOMIC | __GFP_COLD,0 ); +if (!pgdir) { +return NULL ; + } + } + } + +/*pr_debug("pgdir: %p, %p, %d\n", +pgdir, prev, sizeof(suspend_pagedir_t)); */ +for (i =0 ; i <ONE_PAGE_PBE_NUM ; i++) { + pgdir[i].dummy.val =0 ; + pgdir[i].address =0 ; + pgdir[i].orig_address =0 ; +if (prev) + prev[i].dummy.val= (unsigned long )pgdir; + } + +return (pgdir); +} + +/* calc_nums - Determine the nums of allocation needed for pagedir_save. */ +static int calc_nums (int nr_copy) +{ +int diff =0 , ret =0 ; +do { + diff = (nr_copy /ONE_PAGE_PBE_NUM ) - ret +1 ; +if (diff) { + ret += diff; + nr_copy += diff; + } + }while (diff); +return nr_copy; +} + + +/* +* alloc_pagedir +* +* @param pbe +* @param pbe_nums +* @param collide +* @param page_nums +* +*/ +static int alloc_pagedir (struct pbe **pbe,int pbe_nums, +unsigned char *collide,int page_nums) +{ +unsigned int nums =0 ; +unsigned int after_alloc = pbe_nums; +suspend_pagedir_t *prev =NULL , *cur =NULL ; + +if (page_nums) + after_alloc =ONE_PAGE_PBE_NUM * page_nums; +else + after_alloc =calc_nums (after_alloc); + +pr_debug ("alloc_pagedir: %d, %d\n" , pbe_nums, after_alloc); +for (nums =0 ; nums < after_alloc ; nums +=ONE_PAGE_PBE_NUM ) { + cur =alloc_one_pagedir (prev, collide); +pr_debug ("alloc_one_pagedir: %p\n" , cur); +if (!cur) {/* get page failed */ + goto no_mem; + } +if (nums ==0 ) {/* setup the head */ + *pbe = cur; + } + prev = cur; + } +return after_alloc - pbe_nums; + +no_mem: +pagedir_free (*pbe); + *pbe =NULL ; + +return (-ENOMEM ); +} + +static char *page_cache_buf =NULL ; + +static int bio_read_page (pgoff_t page_off,void * page); + +static int pagecache_read_pbe (struct pbe *p,void *tmp,int cur) +{ +int error =0 ; +swp_entry_t entry; + +mod_printk_progress (cur); + +pr_debug ("pagecache_read_pbe: %p, o{%p} c{%p} %lu\n" , + p, (void *)p->orig_address, (void *)p->address, +swp_offset (p->swap_address)); + + error =bio_read_page (swp_offset (p->swap_address), page_cache_buf); +if (error)return error; +memcpy ((void *)p->address, (void *)page_cache_buf,PAGE_SIZE ); + + entry = p->swap_address; +if (entry.val) +swap_free (entry); + +return 0 ; +} + +int read_page_caches (void ) +{ +int error =0 ; + +if (swsusp_pagecache ==0 )return 0 ; + + mod_progress = nr_copy_page_caches /100 ; + +printk ("Reading PageCaches from swap (%d pages)... " , nr_copy_page_caches); + error =for_each_pbe (pagedir_cache, pagecache_read_pbe,NULL , + nr_copy_page_caches); +printk ("\b\b\b\bdone\n" ); + +unlock_pagecaches (); +pagedir_free (pagedir_cache); +free_page ((unsigned long )page_cache_buf); + +return error; +} + +static int pagecache_write_pbe (struct pbe *p,void *tmp,int cur) +{ +int error =0 ; + +mod_printk_progress (cur); + +pr_debug ("pagecache_write_pbe: %p, o{%p} c{%p} %d " , + p, (void *)p->orig_address, (void *)p->address, cur); +BUG_ON (p->address ==0 ); +memcpy ((void *)page_cache_buf, (void *)p->address,PAGE_SIZE ); + error =write_page ((unsigned long )page_cache_buf, &p->swap_address); +if (error)return error; + +pr_debug ("%lu\n" ,swp_offset (p->swap_address)); + +return 0 ; +} + +static int page_caches_write (void ) +{ +int error; + + mod_progress = nr_copy_page_caches /100 ; + +lock_pagecaches (); +printk ("Writing PageCaches to swap (%d pages)... " , + nr_copy_page_caches); + error =for_each_pbe (pagedir_cache, pagecache_write_pbe,NULL , + nr_copy_page_caches); +printk ("\b\b\b\bdone\n" ); + +return error; +} + +static int setup_pagedir_pbe (void ) +{ +struct zone *zone; + + nr_copy_page_caches =0 ; +for_each_zone (zone) { +if (!is_highmem (zone)) { +count_page_caches (zone,1 ); + } + } + +return 0 ; +} + +static void count_data_pages (void ); +static int swsusp_alloc (void ); + +static void page_caches_recal (void ) +{ +struct zone *zone; +int i; + +for (i =0 ; i < max_mapnr; i++) +ClearPagePcs (mem_map+i); + + nr_copy_page_caches =0 ; +drain_local_pages (); +for_each_zone (zone) { +if (!is_highmem (zone)) { + nr_copy_page_caches +=count_page_caches (zone,0 ); + } + } +} + +int write_page_caches (void ) +{ +int error; +int recal =0 ; + +if ((error =swsusp_swap_check ())) { +/* FIXME free pagedir_cache */ +return error; + } + +if (swsusp_pagecache) { + page_cache_buf = (char *)__get_free_pages (GFP_ATOMIC | __GFP_COLD,0 ); +if (!page_cache_buf) { +/* FIXME try shrink memory */ +return -ENOMEM ; + } + +page_caches_recal (); + +if (nr_copy_page_caches ==0 ) { +return 0 ; + } +if (alloc_pagedir (&pagedir_cache, nr_copy_page_caches,NULL ,0 ) <0 ) { +/* FIXME try shrink memory */ +return -ENOMEM ; + } + } +
kernel/power/swsusp.c line 1074
Quoted 10 lines
kernel/power/swsusp.c +10
-0+drain_local_pages (); +count_data_pages (); + +if (nr_free_pages () < nr_copy_pages +PAGES_FOR_IO ) { +printk ("swsusp: need %d pages, free %d pages\n" , + nr_copy_pages,nr_free_pages ()); +printk ("swsusp: Freeing memory:... " ); +while (shrink_all_memory (nr_copy_pages *2 )) { + current->state =TASK_INTERRUPTIBLE ; +schedule_timeout (HZ /5 );
This should be msleep_interruptible() [I do not see any wait-queue events around this code].
Thanks,
Nish
Re: [PATH] swsusp update 1/3
Hi!
Quoted 10 lines
kernel/power/swsusp.c line 1074
Quoted 7 lines
kernel/power/swsusp.c +7
-0+if (nr_free_pages () < nr_copy_pages +PAGES_FOR_IO ) { +printk ("swsusp: need %d pages, free %d pages\n" , + nr_copy_pages,nr_free_pages ()); +printk ("swsusp: Freeing memory:... " ); +while (shrink_all_memory (nr_copy_pages *2 )) { + current->state =TASK_INTERRUPTIBLE ; +schedule_timeout (HZ /5 );This should be
msleep_interruptible()[I do not see any wait-queue events around this code].
Agreed, it also makes code nicer... Anyway, the loop should not be needed in the first place....
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
In reply to Pavel MachekQuoted 11 lines · Pavel Machek
Hi!
Quoted 8 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.
Quoted 7 lines
BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Pavel
Here is my diff with powerpc support, tested passed, readlly faster in my powerpc laptop.
First get clean 2.6.9 kernel, apply big diff, apply my diff, apply 2.6.9-oom-kill-fix.patch from ck1.
* The sysfs interface can't works, I still using reboot system call reading Documents/power/swsusp.txt.
Have fun.
arch/ppc/Kconfig +2 -0
@@ -983,6 +983,8 @@ source "drivers/zorro/Kconfig" +source kernel/power/Kconfig + endmenu menu "Bus options"
Only in linux-2.6.9-peval-hg-ppc.old/arch/ppc: Kconfig~
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 ;
Only in linux-2.6.9-peval-hg-ppc.old/arch/ppc/kernel: swsusp.S
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
arch/ppc/syslib/open_pic.c +2 -1
@@ -776,7 +776,8 @@if (ISR [irq] ==0 )return ;if (!cpus_empty (keepmask)) { -cpumask_t irqdest = { .bits[0 ] =openpic_read (&ISR [irq]->Destination) }; +cpumask_t irqdest; + irqdest.bits[0 ] =openpic_read (&ISR [irq]->Destination);cpus_and (irqdest, irqdest, keepmask);cpus_or (physmask, physmask, irqdest); }
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/therm_adt746x.c +6 -0
@@ -22,6 +22,7 @@#include <linux/spinlock.h> #include <linux/smp_lock.h> #include <linux/wait.h> +#include <linux/suspend.h> #include <asm/prom.h> #include <asm/machdep.h> #include <asm/io.h>
@@ -238,6 +239,11 @@#endif while (!kthread_should_stop ()) { +if (current->flags &PF_FREEZE ) { +printk (KERN_INFO "therm_adt746x: freezing thermostat\n" ); +refrigerator (PF_FREEZE ); + } +msleep_interruptible (2000 );/* Check status */
drivers/macintosh/therm_pm72.c +6 -0
@@ -88,6 +88,7 @@#include <linux/spinlock.h> #include <linux/smp_lock.h> #include <linux/wait.h> +#include <linux/suspend.h> #include <linux/reboot.h> #include <linux/kmod.h> #include <linux/i2c.h>
@@ -1044,6 +1045,11 @@while (state == state_attached) {unsigned long elapsed, start; +if (current->flags &PF_FREEZE ) { +printk (KERN_INFO "therm_pm72: freezing thermostat\n" ); +refrigerator (PF_FREEZE ); + } + start = jiffies;down (&driver_lock);
drivers/macintosh/via-pmu.c +84 -2
110 lines not on this page · raw message
drivers/video/aty/radeon_pm.c +4 -0
@@ -859,6 +859,10 @@* know we'll be rebooted, ... */ +#if 0 /* this breaks suspend to ram until the dust settles... */ + if (state != PM_SUSPEND_MEM) +#endif +return 0 ;printk (KERN_DEBUG "radeonfb: suspending to state: %d...\n" , state);acquire_console_sem ();
Only in linux-2.6.9-peval-hg-ppc.old/include/asm-ppc: suspend.h
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
@@ -16,6 +16,7 @@#include <linux/device.h> #include <linux/delay.h> #include <linux/fs.h> +#include <linux/reboot.h> #include <linux/device.h> #include "power.h"
@@ -50,14 +51,16 @@unsigned long flags;int error =0 ; -local_irq_save (flags);switch (mode) {case PM_DISK_PLATFORM : -device_power_down (PMSG_SUSPEND ); +/* device_power_down(PMSG_SUSPEND); */ +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 ;
kernel/power/disk.c~ +12 -4
@@ -29,6 +29,8 @@ extern int swsusp_resume(void); extern int swsusp_free(void); +extern int write_page_caches(void); +extern int read_page_caches(void); static int noresume = 0; char resume_file[256] = CONFIG_PM_STD_PARTITION;
@@ -106,6 +108,7 @@ } } + static inline void platform_finish(void) { if (pm_disk_mode == PM_DISK_PLATFORM) {
@@ -118,13 +121,14 @@ { device_resume(); platform_finish(); + read_page_caches(); enable_nonboot_cpus(); thaw_processes(); pm_restore_console(); } -static int prepare(void) +static int prepare(int resume) { int error;
@@ -144,9 +148,13 @@ } /* Free memory before shutting down devices. */ - free_some_memory(); + /* free_some_memory(); */ disable_nonboot_cpus(); + if (!resume) + if ((error = write_page_caches())) { + goto Finish; + } if ((error = device_suspend(PMSG_FREEZE))) { printk("Some devices failed to suspend\n"); goto Finish;
@@ -176,7 +184,7 @@ { int error; - if ((error = prepare())) + if ((error = prepare(0))) return error; pr_debug("PM: Attempting to suspend to disk.\n");
@@ -233,7 +241,7 @@ pr_debug("PM: Preparing system for restore.\n"); - if ((error = prepare())) + if ((error = prepare(1))) goto Free; barrier();
Only in linux-2.6.9-peval-hg-ppc.old/kernel/power: disk.c.rej
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 +5 -4
@@ -1138,7 +1138,7 @@return error; } - +#if defined(__i386__) asmlinkage int swsusp_restore(void) {BUG_ON (pagedir_order_check != pagedir_order);
@@ -1149,6 +1149,7 @@wbinvd ();/* Nigel says wbinvd here is good idea... */ return 0; } +#endif int swsusp_resume (void ) {
@@ -1453,7 +1454,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]);
@@ -1483,7 +1484,7 @@ }/** -* pmdisk_read - Read saved image from swap. +* swsusp_read - Read saved image from swap. */ int __init swsusp_read (void )
@@ -1507,6 +1508,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/power/swsusp.c~ +349 -56
508 lines not on this page · raw message
Only in linux-2.6.9-peval-hg-ppc.old/kernel/power: swsusp.c.rej
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 ;/**
--
Hu Gang / Steve
Linux Registered User 204016
GPG Public Key: http://soulinfo.com/~hugang/hugang.asc
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
In reply to Pavel MachekQuoted 1,389 lines · Pavel Machek
Hi!
Quoted 8 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Test passed in my ppc and x86 laptop.
ppc swsusp patch for 2.6.9
http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
Have fun.BTW here's my curent bigdiff. It already has some rather nice swsusp speedups. Please try it on your machine; if it works for you, try to send your patches relative to this one. I hope to merge these changes during 2.6.11.
Pavel
Documentation/pm.txt +4
-52@@ -36,8 +36,8 @@ apmd: http://worldvisions.ca/~apenwarr/apmd/ acpid: http://acpid.sf.net/ -Driver Interface ----------------- +Driver Interface -- OBSOLETE, DO NOT USE! +----------------************************* If you are writing a new driver or maintaining an old driver, it should include power management support. Without power management support, a single driver may prevent a system with power management@@ -91,54 +91,6 @@ void pm_unregister_all(pm_callback cback); /* - * Device idle/use detection - * - * In general, drivers for all devices should call "pm_access" - * before accessing the hardware (ie. before reading or modifying - * a hardware register). Request or packet-driven drivers should - * additionally call "pm_dev_idle" when a device is not being used. - * - * Examples: - * 1) A keyboard driver would call pm_access whenever a key is pressed - * 2) A network driver would call pm_access before submitting - * a packet for transmit or receive and pm_dev_idle when its - * transfer and receive queues are empty. - * 3) A VGA driver would call pm_access before it accesses any - * of the video controller registers - * - * Ultimately, the PM policy manager uses the access and idle - * information to decide when to suspend individual devices - * or when to suspend the entire system - */ - -/* - * Description: Update device access time and wake up device, if necessary - * - * Parameters: - * dev - PM device previously returned from pm_register - * - * Details: If called from an interrupt handler pm_access updates - * access time but should never need to wake up the device - * (if device is generating interrupts, it should be awake - * already) This is important as we can not wake up - * devices from an interrupt handler. - */ -void pm_access(struct pm_dev *dev); - -/* - * Description: Identify device as currently being idle - * - * Parameters: - * dev - PM device previously returned from pm_register - * - * Details: A call to pm_dev_idle might signal to the policy manager - * to put a device to sleep. If a new device request arrives - * between the call to pm_dev_idle and the pm_callback - * callback, the driver should fail the pm_callback request. - */ -void pm_dev_idle(struct pm_dev *dev); - -/* * Power management request callback * * Parameters:@@ -262,8 +214,8 @@ ACPI Development mailing list: [email protected] -System Interface ----------------- +System Interface -- OBSOLETE, DO NOT USE! +----------------************************* If you are providing new power management support to Linux (ie. adding support for something like APM or ACPI), you should communicate with drivers through the existing generic powerDocumentation/power/devices.txt +79
-0@@ -141,3 +141,82 @@ The driver core will not call any extra functions when binding the device to the driver. +pm_message_t meaning + +pm_message_t has two fields. event ("major"), and flags. If driver +does not know event code, it aborts the request, returning error. Some +drivers may need to deal with special cases based on the actual type +of suspend operation being done at the system level. This is why +there are flags. + +Event codes are: + +ON -- no need to do anything except special cases like broken +HW. + +FREEZE -- stop DMA and interrupts, and be prepared to reinit HW from +scratch. That probably means stop accepting upstream requests, the +actual policy of what to do with them beeing specific to a given +driver. It's acceptable for a network driver to just drop packets +while a block driver is expected to block the queue so no request is +lost. (Use IDE as an example on how to do that). FREEZE requires no +power state change, and it's expected for drivers to be able to +quickly transition back to operating state. + +SUSPEND -- like FREEZE, but also put hardware into low-power state. If +there's need to distinguish several levels of sleep, additional flag +is probably best way to do that. + +All events are: + +#Prepare for suspend -- userland is still running but we are going to +#enter suspend state. This gives drivers chance to load firmware from +#disk and store it in memory, or do other activities taht require +#operating userland, ability to kmalloc GFP_KERNEL, etc... All of these +#are forbiden once the suspend dance is started.. event = ON, flags = +#PREPARE_TO_SUSPEND + +Apm standby -- prepare for APM event. Quiesce devices to make life +easier for APM BIOS. event = FREEZE, flags = APM_STANDBY + +Apm suspend -- same as APM_STANDBY, but it we should probably avoid +spinning down disks. event = FREEZE, flags = APM_SUSPEND + +System halt, reboot -- quiesce devices to make life easier for BIOS. event += FREEZE, flags = SYSTEM_HALT or SYSTEM_REBOOT + +System shutdown -- at least disks need to be spun down, or data may be +lost. Quiesce devices, just to make life easier for BIOS. event = +FREEZE, flags = SYSTEM_SHUTDOWN + +Kexec -- turn off DMAs and put hardware into some state where new +kernel can take over. event = FREEZE, flags = KEXEC + +Powerdown at end of swsusp -- very similar to SYSTEM_SHUTDOWN, except wake +may need to be enabled on some devices. This actually has at least 3 +subtypes, system can reboot, enter S4 and enter S5 at the end of +swsusp. event = FREEZE, flags = SWSUSP and one of SYSTEM_REBOOT, +SYSTEM_SHUTDOWN, SYSTEM_S4 + +Suspend to ram -- put devices into low power state. event = SUSPEND, +flags = SUSPEND_TO_RAM + +Freeze for swsusp snapshot -- stop DMA and interrupts. No need to put +devices into low power mode, but you must be able to reinitialize +device from scratch in resume method. This has two flavors, its done +once on suspending kernel, once on resuming kernel. event = FREEZE, +flags = DURING_SUSPEND or DURING_RESUME + +Device detach requested from /sys -- deinitialize device; proably same as +SYSTEM_SHUTDOWN, I do not understand this one too much. probably event += FREEZE, flags = DEV_DETACH. + +#These are not really events sent: +# +#System fully on -- device is working normally; this is probably never +#passed to suspend() method... event = ON, flags = 0 +# +#Ready after resume -- userland is now running, again. Time to free any +#memory you ate during prepare to suspend... event = ON, flags = +#READY_AFTER_RESUME +#Documentation/power/swsusp.txt +75
-51@@ -15,10 +15,21 @@ * If you change kernel command line between suspend and resume... * ...prepare for nasty fsck or worse. * - * (*) pm interface support is needed to make it safe. + * If you change your hardware while system is suspended... + * ...well, it was not good idea. + * + * (*) suspend/resume support is needed to make it safe. You need to append resume=/dev/your_swap_partition to kernel command -line. Then you suspend by echo 4 > /proc/acpi/sleep. +line. Then you suspend by + +echo shutdown > /sys/power/disk; echo disk > /sys/power/state + +. If you feel ACPI works pretty well on your system, you might try + +echo platform > /sys/power/disk; echo disk > /sys/power/state + + Article about goals and implementation of Software Suspend for Linux ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@@ -32,42 +43,24 @@ to standby mode. Later resuming the machine the saved state is loaded back to ram and the machine can continue its work. It has two real benefits. First we save ourselves the time machine goes down and later boots up, energy costs -real high when running from batteries. The other gain is that we don't have to +are real high when running from batteries. The other gain is that we don't have to interrupt our programs so processes that are calculating something for a long time shouldn't need to be written interruptible. -Using the code - -You have two ways to use this code. The first one is is with a patched -SysVinit (my patch is against 2.76 and available at my home page). You -might call 'swsusp' or 'shutdown -z <time>'. Next way is to echo 4 > -/proc/acpi/sleep. - -Either way it saves the state of the machine into active swaps and then -reboots. You must explicitly specify the swap partition to resume from with +swsusp saves the state of the machine into active swaps and then reboots or +powerdowns. You must explicitly specify the swap partition to resume from with ``resume='' kernel option. If signature is found it loads and restores saved state. If the option ``noresume'' is specified as a boot parameter, it skips the resuming. -In the meantime while the system is suspended you should not touch any of the -hardware! - -About the code - -Things to implement -- We should only make a copy of data related to kernel segment, since any - process data won't be changed. -- Should make more sanity checks. Or are these enough? - -Not so important ideas for implementing +In the meantime while the system is suspended you should not add/remove any +of the hardware, write to the filesystems, etc. -- If a real time process is running then don't suspend the machine. -- Support for adding/removing hardware while suspended? -- We should not free pages at the beginning so aggressively, most of them - go there anyway.. +Sleep states summary +==================== -Sleep states summary (thanx, Ducrot) -==================================== +There are three different interfaces you can use, /proc/acpi should +work like this: In a really perfect world: echo 1 > /proc/acpi/sleep # for standby@@ -79,7 +72,6 @@ and perhaps echo 4b > /proc/acpi/sleep # for suspend to disk via s4bios - Frequently Asked Questions ==========================@@ -123,27 +115,13 @@ Q: Does linux support ACPI S4? -A: No. - -When swsusp was created, ACPI was not too widespread, so we tried to -avoid using ACPI-specific stuff. ACPI also is/was notoriously -buggy. These days swsusp works on APM-only i386 machines and even -without any power managment at all. Some versions also work on PPC. - -That means that machine does not enter S4 on suspend-to-disk, but -simply enters S5. That has few advantages, you can for example boot -windows on next boot, and return to your Linux session later. You -could even have few different Linuxes on your box (not sharing any -partitions), and switch between them. - -It also has disadvantages. On HP nx5000, if you unplug power cord -while machine is suspended-to-disk, Linux will fail to notice that. +A: Yes. That's what echo platform > /sys/power/disk does. Q: My machine doesn't work with ACPI. How can I use swsusp than ? A: Do a reboot() syscall with right parameters. Warning: glibc gets in its way, so check with strace: - + reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, 0xd000fce2) (Thanks to Peter Osterlund:)@@ -162,6 +140,8 @@ return 0; } +Also /sys/ interface should be still present. + Q: What is 'suspend2'? A: suspend2 is 'Software Suspend 2', a forked implementation of@@ -175,17 +155,22 @@ website, and not to the Linux Kernel Mailing List. We are working toward merging suspend2 into the mainline kernel. -Q: Kernel thread must voluntarily freeze itself (call 'refrigerator'). But -I found some kernel threads don't do it, and they don't freeze, and +Q: A kernel thread must voluntarily freeze itself (call 'refrigerator'). +I found some kernel threads that don't do it, and they don't freeze so the system can't sleep. Is this a known behavior? -A: All such kernel threads need to be fixed, one by one. Select place -where it is safe to be frozen (no kernel semaphores should be held at -that point and it must be safe to sleep there), and add: +A: All such kernel threads need to be fixed, one by one. Select the +place where the thread is safe to be frozen (no kernel semaphores +should be held at that point and it must be safe to sleep there), and +add: if (current->flags & PF_FREEZE) refrigerator(PF_FREEZE); +If the thread is needed for writing the image to storage, you should +instead set the PF_NOFREEZE process flag when creating the thread. + + Q: What is the difference between between "platform", "shutdown" and "firmware" in /sys/power/disk?@@ -201,3 +186,42 @@ "platform" is actually right thing to do, but "shutdown" is most reliable. + +Q: I do not understand why you have such strong objections to idea of +selective suspend. + +A: Do selective suspend during runtime power managment, that's okay. But +its useless for suspend-to-disk. (And I do not see how you could use +it for suspend-to-ram, I hope you do not want that). + +Lets see, so you suggest to + +* SUSPEND all but swap device and parents +* Snapshot +* Write image to disk +* SUSPEND swap device and parents +* Powerdown + +Oh no, that does not work, if swap device or its parents uses DMA, +you've corrupted data. You'd have to do + +* SUSPEND all but swap device and parents +* FREEZE swap device and parents +* Snapshot +* UNFREEZE swap device and parents +* Write +* SUSPEND swap device and parents + +Which means that you still need that FREEZE state, and you get more +complicated code. (And I have not yet introduce details like system +devices). + +Q: There don't seem to be any generally useful behavioral +distinctions between SUSPEND and FREEZE. + +A: Doing SUSPEND when you are asked to do FREEZE is always correct, +but it may be unneccessarily slow. If you want USB to stay simple, +slowness may not matter to you. It can always be fixed later. + +For devices like disk it does matter, you do not want to spindown for +FREEZE.Documentation/power/video.txt +7
-4@@ -17,15 +17,18 @@ * systems where video state is preserved over S3. (Athlon HP Omnibook xe3s) -* systems that initialize video card into vga text mode and where BIOS - works well enough to be able to set video mode. Use - acpi_sleep=s3_mode on these. (Toshiba 4030cdt) - * systems where it is possible to call video bios during S3 resume. Unfortunately, it is not correct to call video BIOS at that point, but it happens to work on some machines. Use acpi_sleep=s3_bios (Athlon64 desktop system) +* systems that initialize video card into vga text mode and where BIOS + works well enough to be able to set video mode. Use + acpi_sleep=s3_mode on these. (Toshiba 4030cdt) + +* on some systems s3_bios kicks video into text mode, and + acpi_sleep=s3_bios,s3_mode is needed (Toshiba Satellite P10-554) + * radeon systems, where X can soft-boot your video card. You'll need patched X, and plain text console (no vesafb or radeonfb), see http://www.doesi.gmxhome.de/linux/tm800s3/s3.html. (Acer TM 800)Documentation/sparse.txt +72
-0@@ -0,0 +1,72 @@ +Copyright 2004 Linus Torvalds +Copyright 2004 Pavel Machek <[email protected]> + +Using sparse for typechecking +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +"__bitwise" is a type attribute, so you have to do something like this: + + typedef int __bitwise pm_request_t; + + enum pm_request { + PM_SUSPEND = (__force pm_request_t) 1, + PM_RESUME = (__force pm_request_t) 2 + }; + +which makes PM_SUSPEND and PM_RESUME "bitwise" integers (the "__force" is +there because sparse will complain about casting to/from a bitwise type, +but in this case we really _do_ want to force the conversion). And because +the enum values are all the same type, now "enum pm_request" will be that +type too. + +And with gcc, all the __bitwise/__force stuff goes away, and it all ends +up looking just like integers to gcc. + +Quite frankly, you don't need the enum there. The above all really just +boils down to one special "int __bitwise" type. + +So the simpler way is to just do + + typedef int __bitwise pm_request_t; + + #define PM_SUSPEND ((__force pm_request_t) 1) + #define PM_RESUME ((__force pm_request_t) 2) + +and you now have all the infrastructure needed for strict typechecking. + +One small note: the constant integer "0" is special. You can use a +constant zero as a bitwise integer type without sparse ever complaining. +This is because "bitwise" (as the name implies) was designed for making +sure that bitwise types don't get mixed up (little-endian vs big-endian +vs cpu-endian vs whatever), and there the constant "0" really _is_ +special. + +Modify top-level Makefile to say + +CHECK = sparse -Wbitwise + +or you don't get any checking at all. + + +Where to get sparse +~~~~~~~~~~~~~~~~~~~ + +With BK, you can just get it from + + bk://sparse.bkbits.net/sparse + +and DaveJ has tar-balls at + + http://www.codemonkey.org.uk/projects/bitkeeper/sparse/ + + +Once you have it, just do + + make + make install + +as your regular user, and it will install sparse in your ~/bin directory. +After that, doing a kernel make with "make C=1" will run sparse on all the +C files that get recompiled, or with "make C=2" will run sparse on the +files whether they need to be recompiled or not (ie the latter is fast way +to check the whole tree if you have already built it).Makefile +1
-1@@ -325,7 +325,7 @@ DEPMOD = /sbin/depmod KALLSYMS = scripts/kallsyms PERL = perl -CHECK = sparse +CHECK = sparse -Wbitwise CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ MODFLAGS = -DMODULE CFLAGS_MODULE = $(MODFLAGS)arch/arm/mach-sa1100/pm.c +3
-3@@ -57,7 +57,7 @@ }; -static int sa11x0_pm_enter (u32 state) +static int sa11x0_pm_enter (suspend_state_t state) {unsigned long gpio, sleep_save[SLEEP_SAVE_SIZE ];struct timespec delta, rtc;@@ -153,7 +153,7 @@/* * Called after processes are frozen, but before we shut down devices. */ -static int sa11x0_pm_prepare (u32 state) +static int sa11x0_pm_prepare (suspend_state_t state) {return 0 ; }@@ -161,7 +161,7 @@/* * Called after devices are re-setup, but before processes are thawed. */ -static int sa11x0_pm_finish (u32 state) +static int sa11x0_pm_finish (suspend_state_t state) {return 0 ; }arch/i386/kernel/apm.c +3
-3@@ -1201,8 +1201,8 @@printk (KERN_CRIT "apm: suspend was vetoed, but suspending anyway.\n" ); } -device_suspend (3 ); -device_power_down (3 ); +device_suspend (PMSG_SUSPEND ); +device_power_down (PMSG_SUSPEND );/* serialize with the timer interrupt */ write_seqlock_irq (&xtime_lock);@@ -1255,7 +1255,7 @@ {int err; -device_power_down (3 ); +device_power_down (PMSG_SUSPEND );/* serialize with the timer interrupt */ write_seqlock_irq (&xtime_lock);/* If needed, notify drivers here */ arch/i386/kernel/signal.c +2
-1@@ -587,7 +587,8 @@if (current->flags &PF_FREEZE ) {refrigerator (0 ); - goto no_signal; +if (!signal_pending (current)) + goto no_signal; }if (!oldset)arch/i386/mm/fault.c +2
-0@@ -21,6 +21,7 @@#include <linux/vt_kern.h> /* For unblank_screen() */ #include <linux/highmem.h> #include <linux/module.h> +#include <linux/delay.h> #include <asm/system.h> #include <asm/uaccess.h> @@ -451,6 +452,7 @@ asm("movl %%cr3,%0" :"=r" (page)); page = ((unsigned long *)__va (page))[address >>22 ];printk (KERN_ALERT "*pde = %08lx\n" , page); +mdelay (10000 );/* * We must not directly access the pte in the highpte * case, the page table might be allocated in highmem. arch/i386/power/cpu.c +1
-1@@ -148,6 +148,6 @@__restore_processor_state (&saved_context); } - +/* Needed by apm.c */ EXPORT_SYMBOL (save_processor_state);EXPORT_SYMBOL (restore_processor_state);drivers/acpi/sleep/main.c +4
-4@@ -42,7 +42,7 @@* wakeup code to the waking vector. */ -static int acpi_pm_prepare (u32 pm_state) +static int acpi_pm_prepare (suspend_state_t pm_state) {u32 acpi_state = acpi_suspend_states[pm_state];@@ -74,7 +74,7 @@* It's unfortunate, but it works. Please fix if you're feeling frisky. */ -static int acpi_pm_enter (u32 pm_state) +static int acpi_pm_enter (suspend_state_t pm_state) {acpi_status status =AE_OK ;unsigned long flags =0 ;@@ -136,7 +136,7 @@* failed). */ -static int acpi_pm_finish (u32 pm_state) +static int acpi_pm_finish (suspend_state_t pm_state) {u32 acpi_state = acpi_suspend_states[pm_state];@@ -156,7 +156,7 @@int acpi_suspend (u32 acpi_state) { -u32 states[] = { +suspend_state_t states[] = { [1 ] =PM_SUSPEND_STANDBY , [3 ] =PM_SUSPEND_MEM , [4 ] =PM_SUSPEND_DISK ,drivers/base/platform.c +1
-1@@ -238,7 +238,7 @@return (strncmp (pdev->name, drv->name,BUS_ID_SIZE ) ==0 ); } -static int platform_suspend (struct device * dev,u32 state) +static int platform_suspend (struct device * dev,pm_message_t state) {int ret =0 ;drivers/base/power/power.h +3
-3@@ -66,14 +66,14 @@/* * suspend.c */ -extern int suspend_device (struct device *,u32 ); +extern int suspend_device (struct device *,pm_message_t );/* * runtime.c */ -extern int dpm_runtime_suspend (struct device *,u32 ); +extern int dpm_runtime_suspend (struct device *,pm_message_t );extern void dpm_runtime_resume (struct device *);#else /* CONFIG_PM */ @@ -88,7 +88,7 @@ } -static inline int dpm_runtime_suspend (struct device * dev,u32 state) +static inline int dpm_runtime_suspend (struct device * dev,pm_message_t state) {return 0 ; }drivers/base/power/resume.c +1
-1@@ -36,7 +36,7 @@struct device * dev =to_device (entry);list_del_init (entry); -if (!dev->power.prev_state) +if (dev->power.prev_state ==PMSG_ON )resume_device (dev);list_add_tail (entry, &dpm_active);drivers/base/power/runtime.c +5
-5@@ -13,10 +13,10 @@static void runtime_resume (struct device * dev) {dev_dbg (dev,"resuming\n" ); -if (!dev->power.power_state) +if (dev->power.power_state ==PMSG_ON )return ;if (!resume_device (dev)) - dev->power.power_state =0 ; + dev->power.power_state =PMSG_ON ; }@@ -44,7 +44,7 @@* @state: State to enter. */ -int dpm_runtime_suspend (struct device * dev,u32 state) +int dpm_runtime_suspend (struct device * dev,pm_message_t state) {int error =0 ;@@ -52,7 +52,7 @@if (dev->power.power_state == state) goto Done; -if (dev->power.power_state) +if (dev->power.power_state !=PMSG_ON )runtime_resume (dev);if (!(error =suspend_device (dev, state)))@@ -73,7 +73,7 @@* always be able to tell, but we need accurate information to * work reliably. */ -void dpm_set_power_state (struct device * dev,u32 state) +void dpm_set_power_state (struct device * dev,pm_message_t state) {down (&dpm_sem); dev->power.power_state = state;drivers/base/power/shutdown.c +2
-1@@ -29,7 +29,8 @@ dev->driver->shutdown (dev);return 0 ; } -return dpm_runtime_suspend (dev, dev->detach_state); +/* FIXME */ +return dpm_runtime_suspend (dev,PMSG_FREEZE ); }drivers/base/power/suspend.c +5
-5@@ -11,7 +11,7 @@#include <linux/device.h> #include "power.h" -extern int sysdev_suspend (u32 state); +extern int sysdev_suspend (pm_message_t state);/* * The entries in the dpm_active list are in a depth first order, simply @@ -35,7 +35,7 @@* @state: Power state device is entering. */ -int suspend_device (struct device * dev,u32 state) +int suspend_device (struct device * dev,pm_message_t state) {int error =0 ;@@ -43,7 +43,7 @@ dev->power.prev_state = dev->power.power_state; -if (dev->bus && dev->bus->suspend && !dev->power.power_state) +if (dev->bus && dev->bus->suspend && (dev->power.power_state ==PMSG_ON )) error = dev->bus->suspend (dev, state);return error;@@ -70,7 +70,7 @@* */ -int device_suspend (u32 state) +int device_suspend (pm_message_t state) {int error =0 ;@@ -112,7 +112,7 @@* done, power down system devices. */ -int device_power_down (u32 state) +int device_power_down (pm_message_t state) {int error =0 ;struct device * dev;drivers/char/vt.c +0
-6@@ -2186,8 +2186,6 @@if (!printable ||test_and_set_bit (0 , &printing))return ; -pm_access (pm_con); -if (kmsg_redirect &&vc_cons_allocated (kmsg_redirect -1 )) currcons = kmsg_redirect -1 ;@@ -2387,7 +2385,6 @@ {int retval; -pm_access (pm_con); retval =do_con_write (tty, from_user, buf, count);con_flush_chars (tty);@@ -2398,7 +2395,6 @@ {if (in_interrupt ())return ;/* n_r3964 calls put_char() from interrupt context */ -pm_access (pm_con);do_con_write (tty,0 , &ch,1 ); }@@ -2467,8 +2463,6 @@if (in_interrupt ())/* from flush_to_ldisc */ return ; -pm_access (pm_con); -/* if we race with con_close(), vt may be null */ acquire_console_sem (); vt = tty->driver_data;drivers/ide/ide-disk.c +4
-2@@ -1419,9 +1419,12 @@ {switch (rq->pm->pm_step) {case idedisk_pm_flush_cache:/* Suspend step 1 (flush cache) complete */ -if (rq->pm->pm_state ==4 ) +#if 0 +/* FIXME!! */ +if (system_state ==SYSTEM_SNAPSHOT ) rq->pm->pm_step = ide_pm_state_completed; else +#endif rq->pm->pm_step = idedisk_pm_standby;break ;case idedisk_pm_standby:/* Suspend step 2 (standby) complete */ @@ -1702,7 +1705,6 @@return ; } -printk ("Shutdown: %s\n" , drive->name); dev->bus->suspend (dev,PM_SUSPEND_STANDBY ); }drivers/ide/ide.c +1
-1@@ -1499,7 +1499,7 @@return 1 ; } -static int generic_ide_suspend (struct device *dev,u32 state) +static int generic_ide_suspend (struct device *dev,pm_message_t state) {ide_drive_t *drive = dev->driver_data;struct request rq;drivers/ieee1394/ieee1394_core.c +5
-0@@ -1039,6 +1039,11 @@continue ; } +if (current->flags &PF_FREEZE ) { +refrigerator (0 ); +continue ; + } +while ((skb =skb_dequeue (&hpsbpkt_queue)) !=NULL ) { packet = (struct hpsb_packet *)skb->data;drivers/input/input.c +0
-7@@ -67,9 +67,6 @@ {struct input_handle *handle; -if (dev->pm_dev) -pm_access (dev->pm_dev); -if (type >EV_MAX || !test_bit (type, dev->evbit))return ;@@ -230,8 +227,6 @@int input_open_device (struct input_handle *handle) { -if (handle->dev->pm_dev) -pm_access (handle->dev->pm_dev); handle->open++;if (handle->dev->open)return handle->dev->open (handle->dev);@@ -249,8 +244,6 @@void input_close_device (struct input_handle *handle) {input_release_device (handle); -if (handle->dev->pm_dev) -pm_dev_idle (handle->dev->pm_dev);if (handle->dev->close) handle->dev->close (handle->dev); handle->open--;drivers/pci/pci-driver.c +1
-1@@ -295,7 +295,7 @@return 0 ; } -static int pci_device_suspend (struct device * dev,u32 state) +static int pci_device_suspend (struct device * dev,pm_message_t state) {struct pci_dev * pci_dev =to_pci_dev (dev);struct pci_driver * drv = pci_dev->driver;drivers/pci/pci.c +28
-4@@ -229,7 +229,7 @@/** * pci_set_power_state - Set the power state of a PCI device * @dev: PCI device to be suspended -* @state: Power state we're entering +* @state: PCI power state (D0, D1, D2, D3hot, D3cold) we're entering * * Transition a device to a new power state, using the Power Management * Capabilities in the device's config space. @@ -242,7 +242,7 @@*/ int -pci_set_power_state (struct pci_dev *dev,int state) +pci_set_power_state (struct pci_dev *dev,pci_power_t state) {int pm;u16 pmcsr;@@ -300,6 +300,30 @@ }/** +* pci_choose_state - Choose the power state of a PCI device +* @dev: PCI device to be suspended +* @state: target sleep state for the whole system +* +* Returns PCI power state suitable for given device and given system +* message. +*/ + +pci_power_t pci_choose_state (struct pci_dev *dev,u32 state) +{ +if (!pci_find_capability (dev,PCI_CAP_ID_PM )) +return PCI_D0 ; + +switch (state) { +case 0 :return PCI_D0 ; +case 2 :return PCI_D2 ; +case 3 :return PCI_D3hot; +default :BUG (); + } +} + +EXPORT_SYMBOL (pci_choose_state); + +/** * pci_save_state - save the PCI configuration space of a device before suspending * @dev: - PCI device that we're dealing with * @buffer: - buffer to hold config space context @@ -365,7 +389,7 @@ {int err; -pci_set_power_state (dev,0 ); +pci_set_power_state (dev,PCI_D0 );if ((err =pcibios_enable_device (dev, bars)) <0 )return err;return 0 ;@@ -422,7 +446,7 @@* 0 if operation is successful. * */ -int pci_enable_wake (struct pci_dev *dev,u32 state,int enable) +int pci_enable_wake (struct pci_dev *dev,pci_power_t state,int enable) {int pm;u16 value;drivers/usb/core/hcd-pci.c +2
-2@@ -355,8 +355,8 @@ hcd->state =USB_STATE_RESUMING ;if (has_pci_pm) -pci_set_power_state (dev,0 ); - dev->dev.power.power_state =0 ; +pci_set_power_state (dev,PCI_D0 ); + dev->dev.power.power_state =PMSG_ON ; retval =request_irq (dev->irq, usb_hcd_irq,SA_SHIRQ , hcd->description, hcd);if (retval <0 ) {drivers/usb/host/ohci-hub.c +1
-1@@ -76,7 +76,7 @@struct usb_device *root =hcd_to_bus (&ohci->hcd)->root_hub;int status =0 ; -if (root->dev.power.power_state !=0 ) +if (root->dev.power.power_state !=PMSG_ON )return 0 ;if (time_before (jiffies, ohci->next_statechange))return -EAGAIN ;include/asm-i386/suspend.h +3
-0@@ -9,6 +9,9 @@static inline int arch_prepare_suspend (void ) { +/* If you want to make non-PSE machine work, turn off paging +in do_magic. swsusp_pg_dir should have identity mapping, so +it could work... */ if (!cpu_has_pse)return -EPERM ;return 0 ;include/linux/device.h +1
-1@@ -61,7 +61,7 @@int (*match)(struct device * dev,struct device_driver * drv);int (*hotplug) (struct device *dev,char **envp,int num_envp,char *buffer,int buffer_size); -int (*suspend)(struct device * dev,u32 state); +int (*suspend)(struct device * dev,pm_message_t state);int (*resume)(struct device * dev); };include/linux/page-flags.h +5
-1@@ -74,7 +74,7 @@#define PG_swapcache 16/* Swap page: swp_entry_t in private */ #define PG_mappedtodisk 17/* Has blocks allocated on-disk */ #define PG_reclaim 18/* To be reclaimed asap */ - +#define PG_nosave_free 19/* Page is free and should not be written */ /* * Global page accounting. One instance per CPU. Only unsigned longs are @@ -277,6 +277,10 @@#define ClearPageNosave (page) clear_bit(PG_nosave, &(page)->flags)#define TestClearPageNosave (page) test_and_clear_bit(PG_nosave, &(page)->flags) +#define PageNosaveFree (page) test_bit(PG_nosave_free, &(page)->flags) +#define SetPageNosaveFree (page) set_bit(PG_nosave_free, &(page)->flags) +#define ClearPageNosaveFree (page) clear_bit(PG_nosave_free, &(page)->flags) +#define PageMappedToDisk (page) test_bit(PG_mappedtodisk, &(page)->flags)#define SetPageMappedToDisk (page) set_bit(PG_mappedtodisk, &(page)->flags)#define ClearPageMappedToDisk (page) clear_bit(PG_mappedtodisk, &(page)->flags)include/linux/pci.h +12
-4@@ -480,6 +480,14 @@#define DEVICE_COUNT_COMPATIBLE 4#define DEVICE_COUNT_RESOURCE 12 +typedef int __bitwise pci_power_t ; + +#define PCI_D0 ((pci_power_t __force) 0) +#define PCI_D1 ((pci_power_t __force) 1) +#define PCI_D2 ((pci_power_t __force) 2) +#define PCI_D3hot ((pci_power_t __force) 3) +#define PCI_D3cold ((pci_power_t __force) 4) +/* * The pci_dev structure is used to describe PCI devices. */ @@ -508,7 +516,7 @@this if your device has broken DMA or supports 64-bit transfers. */ -u32 current_state;/* Current operating state. In ACPI-speak, +pci_power_t current_state;/* Current operating state. In ACPI-speak, this is D0-D3, D0 being fully functional, and D3 being off. */ @@ -645,7 +653,7 @@struct pci_dynids dynids; }; -#define to_pci_driver (drv) container_of(drv,struct pci_driver, driver) +#define to_pci_driver (drv) container_of(drv, struct pci_driver, driver)/** * PCI_DEVICE - macro used to describe a specific pci device @@ -781,8 +789,8 @@/* Power management related routines */ int pci_save_state (struct pci_dev *dev,u32 *buffer);int pci_restore_state (struct pci_dev *dev,u32 *buffer); -int pci_set_power_state (struct pci_dev *dev,int state); -int pci_enable_wake (struct pci_dev *dev,u32 state,int enable); +int pci_set_power_state (struct pci_dev *dev,pci_power_t state); +int pci_enable_wake (struct pci_dev *dev,pci_power_t state,int enable);/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ void pci_bus_assign_resources (struct pci_bus *bus);include/linux/pm.h +69
-79@@ -28,44 +28,28 @@#include <asm/atomic.h> /* -* Power management requests +* Power management requests... these are passed to pm_send_all() and friends. +* +* these functions are old and deprecated, see below. */ -enum -{ -PM_SUSPEND ,/* enter D1-D3 */ -PM_RESUME ,/* enter D0 */ - -PM_SAVE_STATE ,/* save device's state */ +typedef int __bitwise pm_request_t ; -/* enable wake-on */ -PM_SET_WAKEUP , - -/* bus resource management */ -PM_GET_RESOURCES , -PM_SET_RESOURCES , - -/* base station management */ -PM_EJECT , -PM_LOCK , -}; +#define PM_SUSPEND ((__force pm_request_t) 1)/* enter D1-D3 */ +#define PM_RESUME ((__force pm_request_t) 2)/* enter D0 */ -typedef int pm_request_t ;/* -* Device types +* Device types... these are passed to pm_register */ -enum -{ -PM_UNKNOWN_DEV =0 ,/* generic */ -PM_SYS_DEV ,/* system device (fan, KB controller, ...) */ -PM_PCI_DEV ,/* PCI device */ -PM_USB_DEV ,/* USB device */ -PM_SCSI_DEV ,/* SCSI device */ -PM_ISA_DEV ,/* ISA device */ -PM_MTD_DEV ,/* Memory Technology Device */ -}; +typedef int __bitwise pm_dev_t ; -typedef int pm_dev_t ; +#define PM_UNKNOWN_DEV ((__force pm_request_t) 0)/* generic */ +#define PM_SYS_DEV ((__force pm_request_t) 1)/* system device (fan, KB controller, ...) */ +#define PM_PCI_DEV ((__force pm_request_t) 2)/* PCI device */ +#define PM_USB_DEV ((__force pm_request_t) 3)/* USB device */ +#define PM_SCSI_DEV ((__force pm_request_t) 4)/* SCSI device */ +#define PM_ISA_DEV ((__force pm_request_t) 5)/* ISA device */ +#define PM_MTD_DEV ((__force pm_request_t) 6)/* Memory Technology Device */ /* * System device hardware ID (PnP) values @@ -119,37 +103,27 @@/* * Register a device with power management */ -struct pm_dev *pm_register (pm_dev_t type, -unsigned long id, -pm_callback callback); +struct pm_dev __deprecated *pm_register (pm_dev_t type,unsigned long id,pm_callback callback);/* * Unregister a device with power management */ -void pm_unregister (struct pm_dev *dev); +void __deprecated pm_unregister (struct pm_dev *dev);/* * Unregister all devices with matching callback */ -void pm_unregister_all (pm_callback callback); +void __deprecated pm_unregister_all (pm_callback callback);/* * Send a request to a single device */ -int pm_send (struct pm_dev *dev,pm_request_t rqst,void *data); +int __deprecated pm_send (struct pm_dev *dev,pm_request_t rqst,void *data);/* * Send a request to all devices */ -int pm_send_all (pm_request_t rqst,void *data); - -/* -* Find a device -*/ -struct pm_dev *pm_find (pm_dev_t type,struct pm_dev *from); - -static inline void pm_access (struct pm_dev *dev) {} -static inline void pm_dev_idle (struct pm_dev *dev) {} +int __deprecated pm_send_all (pm_request_t rqst,void *data);#else /* CONFIG_PM */ @@ -176,16 +150,10 @@ return 0; } -static inline struct pm_dev *pm_find (pm_dev_t type,struct pm_dev *from) -{ -return 0 ; -} - -static inline void pm_access (struct pm_dev *dev) {} -static inline void pm_dev_idle (struct pm_dev *dev) {} -#endif /* CONFIG_PM */ +/* Functions above this comment are list-based old-style power +* managment. Please avoid using them. */ /* * Callbacks for platform drivers to implement. @@ -193,34 +161,32 @@extern void (*pm_idle)(void );extern void (*pm_power_off)(void ); -enum { -PM_SUSPEND_ON =0 , -PM_SUSPEND_STANDBY =1 , -/* NOTE: PM_SUSPEND_MEM == PCI_D3hot */ -PM_SUSPEND_MEM =3 , -PM_SUSPEND_DISK =4 , -PM_SUSPEND_MAX =5 , -}; - -enum { -PM_DISK_FIRMWARE =1 , -PM_DISK_PLATFORM , -PM_DISK_SHUTDOWN , -PM_DISK_REBOOT , -PM_DISK_MAX , -}; +typedef int __bitwise suspend_state_t ; +#define PM_SUSPEND_ON ((__force suspend_state_t) 0) +#define PM_SUSPEND_STANDBY ((__force suspend_state_t) 1) +#define PM_SUSPEND_MEM ((__force suspend_state_t) 3) +#define PM_SUSPEND_DISK ((__force suspend_state_t) 4) +#define PM_SUSPEND_MAX ((__force suspend_state_t) 5) + +typedef int __bitwise suspend_disk_method_t ; + +#define PM_DISK_FIRMWARE ((__force suspend_disk_method_t) 1) +#define PM_DISK_PLATFORM ((__force suspend_disk_method_t) 2) +#define PM_DISK_SHUTDOWN ((__force suspend_disk_method_t) 3) +#define PM_DISK_REBOOT ((__force suspend_disk_method_t) 4) +#define PM_DISK_MAX ((__force suspend_disk_method_t) 5)struct pm_ops { -u32 pm_disk_mode; -int (*prepare)(u32 state); -int (*enter)(u32 state); -int (*finish)(u32 state); +suspend_disk_method_t pm_disk_mode; +int (*prepare)(suspend_state_t state); +int (*enter)(suspend_state_t state); +int (*finish)(suspend_state_t state); };extern void pm_set_ops (struct pm_ops *); -extern int pm_suspend (u32 state); +extern int pm_suspend (suspend_state_t state);/* @@ -229,10 +195,34 @@struct device ; +typedef u32 __bitwise pm_message_t ; + +/* +* There are 4 important states driver can be in: +* ON -- driver is working +* FREEZE -- stop operations and apply whatever policy is applicable to a suspended driver +* of that class, freeze queues for block like IDE does, drop packets for +* ethernet, etc... stop DMA engine too etc... so a consistent image can be +* saved; but do not power any hardware down. +* SUSPEND - like FREEZE, but hardware is doing as much powersaving as possible. Roughly +* pci D3. +* +* Unfortunately, current drivers only recognize numeric values 0 (ON) and 3 (SUSPEND). +* We'll need to fix the drivers. So yes, putting 3 to all diferent defines is intentional, +* and will go away as soon as drivers are fixed. Also note that typedef is neccessary, +* we'll probably want to switch to +* typedef struct pm_message_t { int event; int flags; } pm_message_t +* or something similar soon. +*/ + +#define PMSG_FREEZE ((__force pm_message_t) 3) +#define PMSG_SUSPEND ((__force pm_message_t) 3) +#define PMSG_ON ((__force pm_message_t) 0) +struct dev_pm_info { -u32 power_state; +pm_message_t power_state;#ifdef CONFIG_PM -u32 prev_state; +pm_message_t prev_state;u8 * saved_state;atomic_t pm_users;struct device * pm_parent;@@ -242,8 +232,8 @@extern void device_pm_set_parent (struct device * dev,struct device * parent); -extern int device_suspend (u32 state); -extern int device_power_down (u32 state); +extern int device_suspend (pm_message_t state); +extern int device_power_down (pm_message_t state);extern void device_power_up (void );extern void device_resume (void );include/linux/suspend.h +3
-0@@ -31,6 +31,7 @@/* mm/page_alloc.c */ extern void drain_local_pages (void ); +extern void mark_free_pages (struct zone *zone);/* kernel/power/swsusp.c */ extern int software_suspend (void );@@ -54,6 +55,8 @@#else static inline void refrigerator (unsigned long flag) {} +static inline int freeze_processes (void ) {BUG (); } +static inline void thaw_processes (void ) {}#endif /* CONFIG_PM */ #ifdef CONFIG_SMP kernel/power/disk.c +12
-8@@ -3,6 +3,7 @@* * Copyright (c) 2003 Patrick Mochel * Copyright (c) 2003 Open Source Development Lab +* Copyright (c) 2004 Pavel Machek <[email protected]> * * This file is released under the GPLv2. * @@ -15,10 +16,11 @@#include <linux/device.h> #include <linux/delay.h> #include <linux/fs.h> +#include <linux/device.h> #include "power.h" -extern u32 pm_disk_mode; +extern suspend_disk_method_t pm_disk_mode;extern struct pm_ops * pm_ops;extern int swsusp_suspend (void );@@ -41,7 +43,7 @@* there ain't no turning back. */ -static int power_down (u32 mode) +static void power_down (suspend_disk_method_t mode) {unsigned long flags;int error =0 ;@@ -49,7 +51,7 @@local_irq_save (flags);switch (mode) {case PM_DISK_PLATFORM : -device_power_down (PM_SUSPEND_DISK ); +device_power_down (PMSG_SUSPEND ); error = pm_ops->enter (PM_SUSPEND_DISK );break ;case PM_DISK_SHUTDOWN :@@ -67,7 +69,6 @@after resume. */ printk (KERN_CRIT "Please power me down manually\n" );while (1 ); -return 0 ; }@@ -85,13 +86,26 @@static void free_some_memory (void ) { -printk ("Freeing memory: " ); -while (shrink_all_memory (10000 )) -printk ("." ); -printk ("|\n" ); +int i; +for (i=0 ; i<5 ; i++) { +int i =0 , tmp; +long pages =0 ; +char *p ="-\\|/" ; + +printk ("Freeing memory... " );
kernel/power/disk.c line 105
Quoted 10 lines
kernel/power/disk.c +10
-0+while ((tmp =shrink_all_memory (10000 ))) { + pages += tmp; +printk ("\b%c" , p[i]); + i++; +if (i >3 ) + i =0 ; + } +printk ("\bdone (%li pages freed)\n" , pages); + current->state =TASK_INTERRUPTIBLE ; +schedule_timeout (HZ /5 );
This should be msleep_interruptible() [I do not see any wait-queue events around this code].
-Nish
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi!
Quoted 20 lines
Quoted 20 lines
kernel/power/disk.c +12
-4@@ -85,13 +86,26 @@static void free_some_memory (void ) { -printk ("Freeing memory: " ); -while (shrink_all_memory (10000 )) -printk ("." ); -printk ("|\n" ); +int i; +for (i=0 ; i<5 ; i++) { +int i =0 , tmp; +long pages =0 ; +char *p ="-\\|/" ; + +printk ("Freeing memory... " ); +while ((tmp =shrink_all_memory (10000 ))) { + pages += tmp; +printk ("\b%c" , p[i]); + i++; +if (i >3 )
Quoted 8 lines
kernel/power/disk.c line 105
Quoted 5 lines
kernel/power/disk.c +5
-0+ i =0 ; + } +printk ("\bdone (%li pages freed)\n" , pages); + current->state =TASK_INTERRUPTIBLE ; +schedule_timeout (HZ /5 );This should be
msleep_interruptible()[I do not see any wait-queue events around this code].
Ugh, okay, this is my dirty hack to work around shrink_all_memory() problems. Fixed, anyway.
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
In reply to Nishanth AravamudanQuoted 6 lines · Nishanth Aravamudan
kernel/power/disk.c line 105
Quoted 3 lines
kernel/power/disk.c +3
-0+printk ("\bdone (%li pages freed)\n" , pages); + current->state =TASK_INTERRUPTIBLE ; +schedule_timeout (HZ /5 );This should be
msleep_interruptible()[I do not see any wait-queue events around this code].
'Gads! I hate to stalk you like this, but please trim your replies! =)
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
In reply to Pavel MachekHi.
Quoted 4 lines · Pavel Machek
Documentation/power/devices.txt +0
-0@@ -141,3 +141,82 @@ The driver core will not call any extra functions when binding the
Documentation/power/devices.txt line 151
Quoted 10 lines
Documentation/power/devices.txt +8
-0device to the driver. +pm_message_t meaning + +pm_message_t has two fields. event ("major"), and flags. If driver +does not know event code, it aborts the request, returning error. Some +drivers may need to deal with special cases based on the actual type +of suspend operation being done at the system level. This is why +there are flags. +
I don't know how I managed to miss this before, but I think it's definitely a step in the right direction. I do wonder, though, if we're going about this whole thing in a peacemeal approach. I feel like the whole issue of power state management on the system wide and driver level are being treated as two separate issues. Is it just me?
Regards,
Nigel
Signature · 8 lines
Nigel Cunningham Cyclades Software Engineer Canberra, Australia http://www.cyclades.com +61 (2) 6292 8028 +61 (417) 100 574
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi!
Quoted 7 lines · Pavel Machek
Quoted 6 lines
Documentation/power/devices.txt +0
-0@@ -141,3 +141,82 @@ The driver core will not call any extra functions when binding the device to the driver.
Quoted 14 lines
Documentation/power/devices.txt line 151
Quoted 8 lines
Documentation/power/devices.txt +8
-0+pm_message_t meaning + +pm_message_t has two fields. event ("major"), and flags. If driver +does not know event code, it aborts the request, returning error. Some +drivers may need to deal with special cases based on the actual type +of suspend operation being done at the system level. This is why +there are flags. +I don't know how I managed to miss this before, but I think it's definitely a step in the right direction. I do wonder, though, if we're going about this whole thing in a peacemeal approach. I feel like the whole issue of power state management on the system wide and driver level are being treated as two separate issues. Is it just me?
Well, we are starting with small steps... And since nobody knows how to do one-device-suspend properly, we started with fixing system suspend first.
Passing structure instead of u32 should make one-device-suspend easier in future... Hopefully.
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi.
Quoted 24 lines · Pavel Machek
Hi!
Quoted 7 lines · Pavel Machek
Quoted 6 lines
Documentation/power/devices.txt +0
-0@@ -141,3 +141,82 @@ The driver core will not call any extra functions when binding the device to the driver.Quoted 14 lines
Documentation/power/devices.txt line 151
Quoted 8 lines
Documentation/power/devices.txt +8
-0+pm_message_t meaning + +pm_message_t has two fields. event ("major"), and flags. If driver +does not know event code, it aborts the request, returning error. Some +drivers may need to deal with special cases based on the actual type +of suspend operation being done at the system level. This is why +there are flags. +I don't know how I managed to miss this before, but I think it's definitely a step in the right direction. I do wonder, though, if we're going about this whole thing in a peacemeal approach. I feel like the whole issue of power state management on the system wide and driver level are being treated as two separate issues. Is it just me?
Quoted 6 lines
Well, we are starting with small steps... And since nobody knows how to do one-device-suspend properly, we started with fixing system suspend first.
Passing structure instead of u32 should make one-device-suspend easier in future... Hopefully.
I could spend some time working on a proposal for this, if you like. It would probably do me good in preparation for my presentation on 2.6 PM (in general) at the CELF Linux Form next month.
Regards,
Nigel
Signature · 8 lines
Nigel Cunningham Cyclades Software Engineer Canberra, Australia http://www.cyclades.com +61 (2) 6292 8028 +61 (417) 100 574
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi!
Quoted 10 lines
Quoted 6 lines
Well, we are starting with small steps... And since nobody knows how to do one-device-suspend properly, we started with fixing system suspend first.
Passing structure instead of u32 should make one-device-suspend easier in future... Hopefully.
I could spend some time working on a proposal for this, if you like. It would probably do me good in preparation for my presentation on 2.6 PM (in general) at the CELF Linux Form next month.
You mean proposal for one-device-suspend? Well, I'd really like to have whole machine case working, first... Then, yes, that would be nice. It needs to be discussed at linux-pm list.
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
Hi.
Quoted 3 lines · Pavel Machek
You mean proposal for one-device-suspend? Well, I'd really like to have whole machine case working, first... Then, yes, that would be nice. It needs to be discussed at linux-pm list.
Yes - a proposal for one-device-suspend.
When you say linux-pm list, do you mean linux-pm-devel on lists dot sourceforge dot net? I've subscribed there, but it seems to be just about about dead, so I'm wondering if there's another location.
Regards,
Nigel
Signature · 8 lines
Nigel Cunningham Cyclades Software Engineer Canberra, Australia http://www.cyclades.com +61 (2) 6292 8028 +61 (417) 100 574
Re: swsusp bigdiff [was Re: [PATCH] Software Suspend split to two stage V2.]
In reply to Pavel MachekQuoted 79 lines · Pavel Machek
[...]
Documentation/sparse.txt +72
-0@@ -0,0 +1,72 @@ +Copyright 2004 Linus Torvalds +Copyright 2004 Pavel Machek <[email protected]> + +Using sparse for typechecking +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +"__bitwise" is a type attribute, so you have to do something like this: + + typedef int __bitwise pm_request_t; + + enum pm_request { + PM_SUSPEND = (__force pm_request_t) 1, + PM_RESUME = (__force pm_request_t) 2 + }; + +which makes PM_SUSPEND and PM_RESUME "bitwise" integers (the "__force" is +there because sparse will complain about casting to/from a bitwise type, +but in this case we really _do_ want to force the conversion). And because +the enum values are all the same type, now "enum pm_request" will be that +type too. + +And with gcc, all the __bitwise/__force stuff goes away, and it all ends +up looking just like integers to gcc. + +Quite frankly, you don't need the enum there. The above all really just +boils down to one special "int __bitwise" type. + +So the simpler way is to just do + + typedef int __bitwise pm_request_t; + + #define PM_SUSPEND ((__force pm_request_t) 1) + #define PM_RESUME ((__force pm_request_t) 2) + +and you now have all the infrastructure needed for strict typechecking. + +One small note: the constant integer "0" is special. You can use a +constant zero as a bitwise integer type without sparse ever complaining. +This is because "bitwise" (as the name implies) was designed for making +sure that bitwise types don't get mixed up (little-endian vs big-endian +vs cpu-endian vs whatever), and there the constant "0" really _is_ +special. + +Modify top-level Makefile to say + +CHECK = sparse -Wbitwise + +or you don't get any checking at all. + + +Where to get sparse +~~~~~~~~~~~~~~~~~~~ + +With BK, you can just get it from + + bk://sparse.bkbits.net/sparse + +and DaveJ has tar-balls at + + http://www.codemonkey.org.uk/projects/bitkeeper/sparse/ + + +Once you have it, just do + + make + make install + +as your regular user, and it will install sparse in your ~/bin directory. +After that, doing a kernel make with "make C=1" will run sparse on all the +C files that get recompiled, or with "make C=2" will run sparse on the +files whether they need to be recompiled or not (ie the latter is fast way +to check the whole tree if you have already built it).
Makefile line 328
Quoted 5 lines
Makefile +1
-1@@ -325,7 +325,7 @@ DEPMOD = /sbin/depmod KALLSYMS = scripts/kallsyms PERL = perl -CHECK = sparse +CHECK = sparse -Wbitwise
I know this is a "big diff" patch, but it seems that these sparse changes are completely unrelated to software suspend.
Signature · 4 lines
Paulo Marques - www.grupopie.com "A journey of a thousand miles begins with a single step." Lao-tzu, The Way of Lao-tzu
Hi!
Quoted 2 lines
This patch using pagemap for PageSet2 bitmap, It increase suspend speed, In my PowerPC suspend only need 5 secs, cool.
Well, speed is nice but... I have O(n^2) => O(n) patch in my tree that provides some nice speedup too, and is less invasive. They are probably orthogonal.
* you'll have to explain (in Documentation/power/swsusp.txt) why this is safe. Normal swsusp is safe because interrupts&DMAs are disabled. You are doing writes but data in page-cache may not be modified, right? What are exact requirements for this and how it is guaranteed that data are indeed not modified?
* what is pcs_ prefix? Page Cache Suspend?
(ouch and be warned that this will take quite long to get in. There are patches in my queue I'd like to get in first, like O(n^2) => O(n) page marking).
Review
Quoted 2 lines
(quoted diff) +2
-0+static void calc_order(int *po, int *nr) +{
"po" is bad name even for local variable.
Quoted 4 lines
kernel/power/swsusp.c +4
-0+static unsigned long *pageset2map =NULL ; + +#define PAGENUMBER (page) (page-mem_map) +#define PAGEINDEX (page) ((PAGENUMBER(page))/(8*sizeof(unsigned long)))
kernel/power/swsusp.c line 605
Quoted 10 lines
kernel/power/swsusp.c +9
-0+#define PAGEBIT (page) ((int) ((PAGENUMBER(page))%(8 * sizeof(unsigned long)))) + +#define BITS_PER_PAGE (PAGE_SIZE * 8) +#define PAGES_PER_BITMAP ((max_mapnr + BITS_PER_PAGE - 1) / BITS_PER_PAGE) +#define BITMAP_ORDER (get_bitmask_order((PAGES_PER_BITMAP) - 1)) +#define PagePageset2 (page) \ + test_bit(PAGEBIT(page), &pageset2map[PAGEINDEX(page)]) +#define SetPagePageset2 (page) \ + set_bit(PAGEBIT(page), &pageset2map[PAGEINDEX(page)])
Can't you just get another bit in page.h to avoid these arrays?
kernel/power/swsusp.c line 739
Quoted 9 lines
kernel/power/swsusp.c +9
-0+static int pcs_write (void ) +{ +int error =0 ; +int i; + +printk ("Writing PageCaches to swap (%d pages): " , nr_copy_pcs); +for (i =0 ; i < nr_copy_pcs && !error; i++) { +if (!(i%100 )) +printk ("." );
Please take % progress from newer swsusp.
Quoted 7 lines
kernel/power/swsusp.c +7
-0+static void count_data_pages (void ); +static int swsusp_alloc (void ); + +int pcs_suspend (int resume) +{ +struct zone *zone; +suspend_pagedir_t *pe =NULL ;
kernel/power/swsusp.c line 770
Quoted 10 lines
kernel/power/swsusp.c +10
-0+int error; + +if (resume ==1 ) { +return (0 ); + } +if (resume ==2 ) { +pcs_read (); +pcs_free_pagemap (); +return (0 ); + }
I'd understand int resume taking 0 and 1, but what does 2 mean? Also use return 0; not return (0);
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!