swsusp-bigdiff: power-managment changes that are waiting in my tree
Subsystems (21)
Hi!
This is diff between my tree and mainline; it includes swsusp speedups and driver-model-related changes. It also includes some junk; I tried to kill part of it, but this is more "take a look what I have".
It is also right tree to send swsusp patches against :-).
Nigel, if you are still wiling to benchmark swsusp1 vs. suspend2, please try 2.6.9+ this one.
pm-list: this is direction my tree is heading. These are only first steps, and obviously lots of drivers are missing.
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 +83 -51
195 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/common/amba.c +1 -1
@@ -59,7 +59,7 @@#define amba_hotplug NULL#endif -static int amba_suspend (struct device *dev,u32 state) +static int amba_suspend (struct device *dev,pm_message_t state) {struct amba_driver *drv =to_amba_driver (dev->driver);int ret =0 ;
arch/arm/common/locomo.c +1 -1
@@ -673,7 +673,7 @@return dev->devid == drv->devid; } -static int locomo_bus_suspend (struct device *dev,u32 state) +static int locomo_bus_suspend (struct device *dev,pm_message_t state) {struct locomo_dev *ldev =LOCOMO_DEV (dev);struct locomo_driver *drv =LOCOMO_DRV (dev->driver);
arch/arm/common/sa1111.c +1 -1
@@ -1185,7 +1185,7 @@return dev->devid == drv->devid; } -static int sa1111_bus_suspend (struct device *dev,u32 state) +static int sa1111_bus_suspend (struct device *dev,pm_message_t state) {struct sa1111_dev *sadev =SA1111_DEV (dev);struct sa1111_driver *drv =SA1111_DRV (dev->driver);
arch/arm/mach-pxa/pm.c +3 -3
@@ -66,7 +66,7 @@ }; -static int pxa_pm_enter (u32 state) +static int pxa_pm_enter (suspend_state_t state) {unsigned long sleep_save[SLEEP_SAVE_SIZE ];unsigned long checksum =0 ;
@@ -182,7 +182,7 @@/* * Called after processes are frozen, but before we shut down devices. */ -static int pxa_pm_prepare (u32 state) +static int pxa_pm_prepare (suspend_state_t state) {return 0 ; }
@@ -190,7 +190,7 @@/* * Called after devices are re-setup, but before processes are thawed. */ -static int pxa_pm_finish (u32 state) +static int pxa_pm_finish (suspend_state_t state) {return 0 ; }
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/acpi/sleep.c +2 -2
@@ -56,11 +56,11 @@ }/* -* acpi_restore_state +* acpi_restore_state - undo effects of acpi_save_state_mem */ void acpi_restore_state_mem (void ) { -zap_low_mappings (); +// zap_low_mappings(); }/**
arch/i386/kernel/acpi/wakeup.S +19 -3
@@ -11,7 +11,22 @@ # # If physical address of wakeup_code is 0x12345, BIOS should call us with # cs = 0x1234, eip = 0x05 -# +# + +#define BEEP \ + inb $97, %al; \ + outb %al, $0x80; \ + movb $3, %al; \ + outb %al, $97; \ + outb %al, $0x80; \ + movb $-74, %al; \ + outb %al, $67; \ + outb %al, $0x80; \ + movb $-119, %al; \ + outb %al, $66; \ + outb %al, $0x80; \ + movb $15, %al; \ + outb %al, $66; ALIGN .align 4096
@@ -20,6 +35,7 @@ wakeup_code_start = . .code16 + BEEP movw $0xb800, %ax movw %ax,%fs movw $0x0e00 + 'L', %fs:(0x10)
@@ -253,7 +269,7 @@ movl %edi, saved_context_edi pushfl ; popl saved_context_eflags - movl $ret_point,saved_eip + movl $ret_point, saved_eip ret
@@ -270,7 +286,7 @@ call save_registers pushl $3 call acpi_enter_sleep_state - addl $4,%esp + addl $4, %esp ret .p2align 4,,7 ret_point:
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/io_apic.c +3 -0
@@ -572,6 +572,7 @@for ( ; ; ) {set_current_state (TASK_INTERRUPTIBLE ); time_remaining =schedule_timeout (time_remaining); +try_to_freeze (PF_FREEZE );if (time_after (jiffies, prev_balance_time+balanced_irq_interval)) {do_irq_balance ();
@@ -2266,8 +2267,10 @@setup_IO_APIC_irqs ();init_IO_APIC_traps ();check_timer (); +#ifdef DEBUG if (!acpi_ioapic)print_IO_APIC (); +#endif }/*
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/kernel/time.c +5 -1
@@ -319,7 +319,7 @@return retval; } -static long clock_cmos_diff; +static long clock_cmos_diff, sleep_start;static int time_suspend (struct sys_device *dev,u32 state) {
@@ -328,6 +328,7 @@*/ clock_cmos_diff = -get_cmos_time (); clock_cmos_diff +=get_seconds (); + sleep_start =get_cmos_time ();return 0 ; }
@@ -335,10 +336,13 @@ {unsigned long flags;unsigned long sec =get_cmos_time () + clock_cmos_diff; +unsigned long sleep_length =get_cmos_time () - sleep_start; +write_seqlock_irqsave (&xtime_lock, flags); xtime.tv_sec = sec; xtime.tv_nsec =0 ;write_sequnlock_irqrestore (&xtime_lock, flags); + jiffies += sleep_length *HZ ;return 0 ; }
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);
arch/x86_64/kernel/time.c +34 -4
@@ -1,5 +1,5 @@/* -* linux/arch/x86-64/kernel/time.c +* linux/arch/x86_64/kernel/time.c * * "High Precision Event Timer" based timekeeping. *
@@ -22,7 +22,6 @@#include <linux/time.h> #include <linux/ioport.h> #include <linux/module.h> -#include <linux/device.h> #include <linux/sysdev.h> #include <linux/bcd.h> #include <linux/kallsyms.h>
@@ -779,7 +778,17 @@return 0 ; } -void __init pit_init (void ) +static struct sysdev_class rtc_sysclass = { +set_kset_name ("rtc" ), +}; + +/* XXX this driverfs stuff should probably go elsewhere later -john */ +static struct sys_device device_rtc = { + .id =0 , + .cls = &rtc_sysclass, +}; + +int __init pit_init (void ) {unsigned long flags;
@@ -788,8 +797,22 @@outb_p (LATCH &0xff ,0x40 );/* LSB */ outb_p (LATCH >>8 ,0x40 );/* MSB */ spin_unlock_irqrestore (&i8253_lock, flags); + +return 0 ; +} + +static int pit_devicefs_init (void ) +{ +int error =sysdev_class_register (&rtc_sysclass); +#if 0 +if (!error) + error =sysdev_register (&device_rtc); +#endif +return error; } +late_initcall (pit_devicefs_init); +int __init time_setup (char *str) { report_lost_ticks =1 ;
@@ -870,7 +893,8 @@__setup ("report_lost_ticks" , time_setup); -static long clock_cmos_diff; + +static long clock_cmos_diff, sleep_start;static int time_suspend (struct sys_device *dev,u32 state) {
@@ -879,17 +903,21 @@*/ clock_cmos_diff = -get_cmos_time (); clock_cmos_diff +=get_seconds (); + sleep_start =get_cmos_time ();return 0 ; }static int time_resume (struct sys_device *dev) {unsigned long flags; +unsigned long sleep_length =get_cmos_time () - sleep_start;unsigned long sec =get_cmos_time () + clock_cmos_diff;write_seqlock_irqsave (&xtime_lock,flags); xtime.tv_sec = sec; xtime.tv_nsec =0 ;write_sequnlock_irqrestore (&xtime_lock,flags); +printk (KERN_INFO "Slept for %d:%d minutes\n" , sleep_length/60 , sleep_length%60 ); + jiffies += sleep_length *HZ ;return 0 ; }
@@ -909,8 +937,10 @@static int time_init_device (void ) {int error =sysdev_class_register (&pit_sysclass); +#if 0 if (!error) error =sysdev_register (&device_i8253); +#endif return error; }
drivers/acpi/events/evgpeblk.c +1 -1
@@ -925,7 +925,7 @@/* * Runtime option: Should Wake GPEs be enabled at runtime? The default -* is No,they should only be enabled just as the machine goes to sleep. +* is No, they should only be enabled just as the machine goes to sleep. */ if (acpi_gbl_leave_wake_gpes_disabled) {/*
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/input/keyboard/atkbd.c +32 -0
@@ -26,6 +26,7 @@#include <linux/input.h> #include <linux/serio.h> #include <linux/workqueue.h> +#include <linux/dmi.h> #define DRIVER_DESC "AT and PS/2 keyboard driver"
@@ -986,8 +987,39 @@ .cleanup = atkbd_cleanup, }; +static int __init add_evo_keys (struct dmi_system_id *d) +{ +printk ("Compaq Evo detected, mapping extra keys\n" ); + atkbd_set2_keycode[0x80 | atkbd_unxlate_table[0x23 ] ] =150 ; + atkbd_set2_keycode[0x80 | atkbd_unxlate_table[0x1e ] ] =155 ; + atkbd_set2_keycode[0x80 | atkbd_unxlate_table[0x1a ] ] =217 ; + atkbd_set2_keycode[0x80 | atkbd_unxlate_table[0x1f ] ] =157 ; +return 0 ; +} + +static struct dmi_system_id __initdata keyboard_dmi_table[] = { + {/* Handle special keys on Compaq Evo */ + .callback = add_evo_keys, + .ident ="Compaq Evo" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Compaq" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Evo N620c" ), + }, + }, + {/* Handle special keys on Compaq Evo */ + .callback = add_evo_keys, + .ident ="Compaq Evo" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Compaq" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Evo N600c" ), + }, + } +}; + +int __init atkbd_init (void ) { +dmi_check_system (keyboard_dmi_table);serio_register_driver (&atkbd_drv);return 0 ; }
drivers/media/video/bttv-driver.c +2 -2
@@ -3945,7 +3945,7 @@/* save pci state */ pci_save_state (pci_dev, btv->state.pci_cfg); -if (0 !=pci_set_power_state (pci_dev, state)) { +if (0 !=pci_set_power_state (pci_dev,device_to_pci_power (pci_dev, state))) {pci_disable_device (pci_dev); btv->state.disabled =1 ; }
@@ -3964,7 +3964,7 @@pci_enable_device (pci_dev); btv->state.disabled =0 ; } -pci_set_power_state (pci_dev,0 ); +pci_set_power_state (pci_dev,PCI_D0 );pci_restore_state (pci_dev, btv->state.pci_cfg);/* restore bt878 state */
drivers/net/3c59x.c +4 -4
@@ -1550,7 +1550,7 @@int i;if (VORTEX_PCI (vp) && vp->enable_wol) { -pci_set_power_state (VORTEX_PCI (vp),0 );/* Go active */ +pci_set_power_state (VORTEX_PCI (vp),PCI_D0 );/* Go active */ pci_restore_state (VORTEX_PCI (vp), vp->power_state); }
@@ -2942,7 +2942,7 @@/* The kernel core really should have pci_get_power_state() */ if (state !=0 ) -pci_set_power_state (VORTEX_PCI (vp),0 ); +pci_set_power_state (VORTEX_PCI (vp),PCI_D0 ); err =vortex_do_ioctl (dev, rq, cmd);if (state !=0 )pci_set_power_state (VORTEX_PCI (vp), state);
@@ -3141,7 +3141,7 @@/* Change the power state to D3; RxEnable doesn't take effect. */ pci_enable_wake (VORTEX_PCI (vp),0 ,1 ); -pci_set_power_state (VORTEX_PCI (vp),3 ); +pci_set_power_state (VORTEX_PCI (vp), PCI_D3hot); }
@@ -3164,7 +3164,7 @@unregister_netdev (dev);if (VORTEX_PCI (vp) && vp->enable_wol) { -pci_set_power_state (VORTEX_PCI (vp),0 );/* Go active */ +pci_set_power_state (VORTEX_PCI (vp),PCI_D0 );/* Go active */ if (vp->pm_state_valid)pci_restore_state (VORTEX_PCI (vp), vp->power_state); }
drivers/net/8139cp.c +3 -3
@@ -1623,7 +1623,7 @@static void cp_set_d3_state (struct cp_private *cp) {pci_enable_wake (cp->pdev,0 ,1 );/* Enable PME# generation */ -pci_set_power_state (cp->pdev,3 ); +pci_set_power_state (cp->pdev, PCI_D3hot); }static int cp_init_one (struct pci_dev *pdev,const struct pci_device_id *ent)
@@ -1813,7 +1813,7 @@BUG ();unregister_netdev (dev);iounmap (cp->regs); -if (cp->wol_enabled)pci_set_power_state (pdev,0 ); +if (cp->wol_enabled)pci_set_power_state (pdev,PCI_D0 );pci_release_regions (pdev);pci_clear_mwi (pdev);pci_disable_device (pdev);
@@ -1863,7 +1863,7 @@netif_device_attach (dev);if (cp->pdev && cp->wol_enabled) { -pci_set_power_state (cp->pdev,0 ); +pci_set_power_state (cp->pdev,PCI_D0 );pci_restore_state (cp->pdev, cp->power_state); }
drivers/net/8139too.c +2 -2
@@ -2608,7 +2608,7 @@spin_unlock_irqrestore (&tp->lock, flags); -pci_set_power_state (pdev,3 ); +pci_set_power_state (pdev, PCI_D3hot);return 0 ; }
@@ -2622,7 +2622,7 @@pci_restore_state (pdev, tp->pci_state);if (!netif_running (dev))return 0 ; -pci_set_power_state (pdev,0 ); +pci_set_power_state (pdev,PCI_D0 );rtl8139_init_ring (dev);rtl8139_hw_start (dev);netif_device_attach (dev);
drivers/net/amd8111e.c +8 -8
@@ -1865,17 +1865,17 @@if (lp->options &OPTION_WAKE_PHY_ENABLE )amd8111e_enable_link_change (lp); -pci_enable_wake (pci_dev,3 ,1 ); -pci_enable_wake (pci_dev,4 ,1 );/* D3 cold */ +pci_enable_wake (pci_dev, PCI_D3hot,1 ); +pci_enable_wake (pci_dev, PCI_D3cold,1 ); }else { -pci_enable_wake (pci_dev,3 ,0 ); -pci_enable_wake (pci_dev,4 ,0 );/* 4 == D3 cold */ +pci_enable_wake (pci_dev, PCI_D3hot,0 ); +pci_enable_wake (pci_dev, PCI_D3cold,0 ); }pci_save_state (pci_dev, lp->pm_state); -pci_set_power_state (pci_dev,3 ); +pci_set_power_state (pci_dev, PCI_D3hot);return 0 ; }
@@ -1887,11 +1887,11 @@if (!netif_running (dev))return 0 ; -pci_set_power_state (pci_dev,0 ); +pci_set_power_state (pci_dev,PCI_D0 );pci_restore_state (pci_dev, lp->pm_state); -pci_enable_wake (pci_dev,3 ,0 ); -pci_enable_wake (pci_dev,4 ,0 );/* D3 cold */ +pci_enable_wake (pci_dev, PCI_D3hot,0 ); +pci_enable_wake (pci_dev, PCI_D3cold,0 );netif_device_attach (dev);
drivers/net/b44.c +10 -6
@@ -1,6 +1,7 @@/* b44.c: Broadcom 4400 device driver. * * Copyright (C) 2002 David S. Miller ([email protected]) +* Copyright (C) 2004 Pavel Machek ([email protected]) * Fixed by Pekka Pietikainen ([email protected]) * * Distribute under GPL.
@@ -89,6 +90,10 @@ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401B1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, + { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401B0, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, + { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401B1, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, { } /* terminate list with empty entry */ };
@@ -606,9 +611,6 @@struct ring_info *rp = &bp->tx_buffers[cons];struct sk_buff *skb = rp->skb; -if (unlikely (skb ==NULL )) -BUG (); - pci_unmap_single(bp->pdev, pci_unmap_addr(rp, mapping), skb->len,
@@ -1307,9 +1309,6 @@spin_lock_irq (&bp->lock); -#if 0 -b44_dump_state (bp); -#endif b44_halt (bp);b44_free_rings (bp); bp->flags &= ~B44_FLAG_INIT_COMPLETE ;
@@ -1885,6 +1884,8 @@b44_free_rings (bp);spin_unlock_irq (&bp->lock); + +free_irq (dev->irq, dev);return 0 ; }
@@ -1898,6 +1899,9 @@if (!netif_running (dev))return 0 ; +if (request_irq (dev->irq, b44_interrupt,SA_SHIRQ , dev->name, dev)) + printk(KERN_ERR PFX "%s: request_irq failed\n", dev->name); +spin_lock_irq (&bp->lock);b44_init_rings (bp);
drivers/net/e100.c +2 -2
@@ -2313,7 +2313,7 @@pci_save_state (pdev, nic->pm_state);pci_enable_wake (pdev, state, nic->flags & (wol_magic |e100_asf (nic)));pci_disable_device (pdev); -pci_set_power_state (pdev, state); +pci_set_power_state (pdev,pci_choose_state (pdev, state));return 0 ; }
@@ -2323,7 +2323,7 @@struct net_device *netdev =pci_get_drvdata (pdev);struct nic *nic =netdev_priv (netdev); -pci_set_power_state (pdev,0 ); +pci_set_power_state (pdev,PCI_D0 );pci_restore_state (pdev, nic->pm_state);e100_hw_init (nic);
drivers/net/eepro100.c +4 -14
@@ -155,16 +155,6 @@#define RUN_AT (x) (jiffies + (x)) -/* ACPI power states don't universally work (yet) */ -#ifndef CONFIG_PM -#undef pci_set_power_state -#define pci_set_power_state null_set_power_state -static inline int null_set_power_state (struct pci_dev *dev,int state) -{ -return 0 ; -} -#endif /* CONFIG_PM */ -#define netdevice_start (dev)#define netdevice_stop (dev)#define netif_set_tx_timeout (dev, tf, tm) \
@@ -1015,7 +1005,7 @@if (netif_msg_ifup (sp))printk (KERN_DEBUG "%s: speedo_open() irq %d.\n" , dev->name, dev->irq); -pci_set_power_state (sp->pdev,0 ); +pci_set_power_state (sp->pdev,PCI_D0 );/* Set up the Tx queue early.. */ sp->cur_tx =0 ;
@@ -1964,7 +1954,7 @@if (netif_msg_ifdown (sp))printk (KERN_DEBUG "%s: %d multicast blocks dropped.\n" , dev->name, i); -pci_set_power_state (sp->pdev,2 ); +pci_set_power_state (sp->pdev,PCI_D2 );return 0 ; }
@@ -2103,7 +2093,7 @@access from the timeout handler. They are currently serialized only with MDIO access from the timer routine. 2000/05/09 SAW */ - saved_acpi =pci_set_power_state (sp->pdev,0 ); + saved_acpi =pci_set_power_state (sp->pdev,PCI_D0 ); t =del_timer_sync (&sp->timer); data->val_out =mdio_read (dev, data->phy_id &0x1f , data->reg_num &0x1f );if (t)
@@ -2114,7 +2104,7 @@case SIOCSMIIREG :/* Write MII PHY register. */ if (!capable (CAP_NET_ADMIN ))return -EPERM ; - saved_acpi =pci_set_power_state (sp->pdev,0 ); + saved_acpi =pci_set_power_state (sp->pdev,PCI_D0 ); t =del_timer_sync (&sp->timer);mdio_write (dev, data->phy_id, data->reg_num, data->val_in);if (t)
drivers/net/pci-skeleton.c +2 -2
@@ -1922,7 +1922,7 @@spin_unlock_irqrestore (&tp->lock, flags);pci_save_state (pdev, tp->pci_state); -pci_set_power_state (pdev,3 ); +pci_set_power_state (pdev, PCI_D3hot);return 0 ; }
@@ -1935,7 +1935,7 @@if (!netif_running (dev))return 0 ; -pci_set_power_state (pdev,0 ); +pci_set_power_state (pdev,PCI_D0 );pci_restore_state (pdev, tp->pci_state);netif_device_attach (dev);netdrv_hw_start (dev);
drivers/net/sis900.c +2 -2
@@ -2212,7 +2212,7 @@/* Stop the chip's Tx and Rx Status Machine */ outl (RxDIS | TxDIS |inl (ioaddr + cr), ioaddr + cr); -pci_set_power_state (pci_dev,3 ); +pci_set_power_state (pci_dev, PCI_D3hot);pci_save_state (pci_dev, sis_priv->pci_state);return 0 ;
@@ -2227,7 +2227,7 @@if (!netif_running (net_dev))return 0 ;pci_restore_state (pci_dev, sis_priv->pci_state); -pci_set_power_state (pci_dev,0 ); +pci_set_power_state (pci_dev,PCI_D0 );sis900_init_rxfilter (net_dev);
drivers/net/starfire.c +1 -1
@@ -2186,7 +2186,7 @@unregister_netdev (dev);/* XXX: add wakeup code -- requires firmware for MagicPacket */ -pci_set_power_state (pdev,3 );/* go to sleep in D3 mode */ +pci_set_power_state (pdev, PCI_D3hot);/* go to sleep in D3 mode */ pci_disable_device (pdev);iounmap ((char *)dev->base_addr);
drivers/net/typhoon.c +3 -3
@@ -1884,7 +1884,7 @@pci_enable_wake (tp->pdev, state,1 );pci_disable_device (pdev); -return pci_set_power_state (pdev, state); +return pci_set_power_state (pdev,pci_choose_state (pdev, state)); } static int
@@ -1893,7 +1893,7 @@struct pci_dev *pdev = tp->pdev;void __iomem *ioaddr = tp->ioaddr; -pci_set_power_state (pdev,0 ); +pci_set_power_state (pdev,PCI_D0 );pci_restore_state (pdev, tp->pci_state);/* Post 2.x.x versions of the Sleep Image require a reset before
@@ -2541,7 +2541,7 @@struct typhoon *tp = (struct typhoon *) (dev->priv);unregister_netdev (dev); -pci_set_power_state (pdev,0 ); +pci_set_power_state (pdev,PCI_D0 );pci_restore_state (pdev, tp->pci_state);typhoon_reset (tp->ioaddr, NoWait);iounmap (tp->ioaddr);
drivers/net/via-rhine.c +5 -1
@@ -1957,6 +1957,7 @@rhine_shutdown (&pdev->dev);spin_unlock_irqrestore (&rp->lock, flags); +free_irq (dev->irq, dev);return 0 ; }
@@ -1970,7 +1971,10 @@if (!netif_running (dev))return 0 ; - ret =pci_set_power_state (pdev,0 ); +if (request_irq (dev->irq, rhine_interrupt,SA_SHIRQ , dev->name, dev)) +printk (KERN_ERR "via-rhine %s: request_irq failed\n" , dev->name); + + ret =pci_set_power_state (pdev,PCI_D0 );if (debug >1 )printk (KERN_INFO "%s: Entering power state D0 %s (%d).\n" , dev->name, ret ?"failed" :"succeeded" , ret);
drivers/net/via-velocity.c +16 -16
@@ -804,7 +804,7 @@/* and leave the chip powered down */ -pci_set_power_state (pdev,3 ); +pci_set_power_state (pdev, PCI_D3hot);#ifdef CONFIG_PM {unsigned long flags;
@@ -1742,7 +1742,7 @@ goto err_free_rd_ring;/* Ensure chip is running */ -pci_set_power_state (vptr->pdev,0 ); +pci_set_power_state (vptr->pdev,PCI_D0 );velocity_init_registers (vptr,VELOCITY_INIT_COLD );
@@ -1750,7 +1750,7 @@ dev->name, dev);if (ret <0 ) {/* Power down the chip */ -pci_set_power_state (vptr->pdev,3 ); +pci_set_power_state (vptr->pdev, PCI_D3hot); goto err_free_td_ring; }
@@ -1868,7 +1868,7 @@free_irq (dev->irq, dev);/* Power down the chip */ -pci_set_power_state (vptr->pdev,3 ); +pci_set_power_state (vptr->pdev, PCI_D3hot);/* Free the resources */ velocity_free_td_ring (vptr);
@@ -2194,8 +2194,8 @@/* If we are asked for information and the device is power saving then we need to bring the device back up to talk to it */ -if (!netif_running (dev)) -pci_set_power_state (vptr->pdev,0 ); +if (!netif_running (dev)) +pci_set_power_state (vptr->pdev,PCI_D0 );switch (cmd) {case SIOCGMIIPHY :/* Get address of MII PHY in use. */
@@ -2207,8 +2207,8 @@default : ret = -EOPNOTSUPP ; } -if (!netif_running (dev)) -pci_set_power_state (vptr->pdev,3 ); +if (!netif_running (dev)) +pci_set_power_state (vptr->pdev, PCI_D3hot);return ret;
@@ -2818,8 +2818,8 @@static int velocity_ethtool_up (struct net_device *dev) {struct velocity_info *vptr = dev->priv; -if (!netif_running (dev)) -pci_set_power_state (vptr->pdev,0 ); +if (!netif_running (dev)) +pci_set_power_state (vptr->pdev,PCI_D0 );return 0 ; }
@@ -2834,8 +2834,8 @@static void velocity_ethtool_down (struct net_device *dev) {struct velocity_info *vptr = dev->priv; -if (!netif_running (dev)) -pci_set_power_state (vptr->pdev,3 ); +if (!netif_running (dev)) +pci_set_power_state (vptr->pdev, PCI_D3hot); }static int velocity_get_settings (struct net_device *dev,struct ethtool_cmd *cmd)
@@ -3229,15 +3229,15 @@velocity_shutdown (vptr);velocity_set_wol (vptr);pci_enable_wake (pdev,3 ,1 ); - pci_set_power_state(pdev, 3); + pci_set_power_state(pdev, PCI_D3hot); }else {velocity_save_context (vptr, &vptr->context);velocity_shutdown (vptr);pci_disable_device (pdev); -pci_set_power_state (pdev, state); +pci_set_power_state (pdev,pci_choose_state (pdev, state)); }#else -pci_set_power_state (pdev, state); +pci_set_power_state (pdev,pci_choose_state (pdev, state));#endif spin_unlock_irqrestore (&vptr->lock, flags);return 0 ;
@@ -3252,7 +3252,7 @@if (!netif_running (vptr->dev))return 0 ; -pci_set_power_state (pdev,0 ); +pci_set_power_state (pdev,PCI_D0 );pci_enable_wake (pdev,0 ,0 );pci_restore_state (pdev, vptr->pci_state);
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/sched.h +28 -0
@@ -1027,6 +1027,34 @@extern long sched_setaffinity (pid_t pid,cpumask_t new_mask);extern long sched_getaffinity (pid_t pid,cpumask_t *mask); +/* try_to_freeze +* +* Checks whether we need to enter the refrigerator +* and returns 1 if we did so. +*/ +#ifdef CONFIG_PM +extern void refrigerator (unsigned long ); +extern int freeze_processes (void ); +extern void thaw_processes (void ); + +static inline int try_to_freeze (unsigned long refrigerator_flags) +{ +if (unlikely (current->flags &PF_FREEZE )) { +refrigerator (refrigerator_flags); +return 1 ; + }else +return 0 ; +} +#else +static inline void refrigerator (unsigned long flag) {} +static inline int freeze_processes (void ) {BUG (); } +static inline void thaw_processes (void ) {} + +static inline int try_to_freeze (unsigned long refrigerator_flags) +{ +return 0 ; +} +#endif /* CONFIG_PM */ #endif /* __KERNEL__ */ #endif
include/linux/suspend.h +6 -15
@@ -31,30 +31,21 @@/* 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 ); -#else /* CONFIG_SOFTWARE_SUSPEND */ +extern int pm_prepare_console (void ); +extern void pm_restore_console (void ); + +#else static inline int software_suspend (void ) {printk ("Warning: fake suspend called\n" );return -EPERM ; } -#endif /* CONFIG_SOFTWARE_SUSPEND */ - - -#ifdef CONFIG_PM -extern void refrigerator (unsigned long ); -extern int freeze_processes (void ); -extern void thaw_processes (void ); - -extern int pm_prepare_console (void ); -extern void pm_restore_console (void ); - -#else -static inline void refrigerator (unsigned long flag) {} -#endif /* CONFIG_PM */ +#endif #ifdef CONFIG_SMP extern void disable_nonboot_cpus (void );
kernel/power/disk.c +31 -24
128 lines not on this page · raw message
kernel/power/main.c +14 -13
@@ -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 * */
@@ -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 +91 -103
394 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!
Documentation/power/devices.txt line 155
Quoted 3 lines
Documentation/power/devices.txt +2
-0+ON -- no need to do anything except special cases like broken +HW.
I'm not sure what is this one supposed to be ... The description is definitely not clear, can you precise in what context it is sent and give maybe an example of "broken hw" ?
Ok, now I'm reading the rest of the mail and I see but your description is really confusing. Also, we really need the resume argument to be added for the opposite (after resume) call to be sent. It makes little sense to pipe it through the suspned() callback.
Documentation/power/devices.txt line 164
Quoted 8 lines
Documentation/power/devices.txt +8
-0+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.
Some examples of the kind of transitions to be expected by drivers or contexts in which the above will be called would be useful as part of the documentation
Documentation/power/devices.txt line 168
Quoted 3 lines
Documentation/power/devices.txt +3
-0+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.
Here add a blurb about transitions. They are only from a resumed state to a suspended state, never between 2 suspended states.
Documentation/power/devices.txt line 177
Quoted 8 lines
Documentation/power/devices.txt +8
-0+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
Note that we should probably fix kmalloc itself to turn GFP_KERNEL into GFP_NOIO during the suspend process. For call_usermodehelper, I wnated to "queue" them, but greg suggested that instead, we fail them, and at the end of the suspend process, we send a special /sbin/hotplug event telling userland to rescan sysfs.
Now about your (long) list bewlow, it's really confusing as a documentation. People will think they have somewhat to switch/case on all these possible 'events' which is implied by the fact that you indicate different actions for each of them. I would redo that documentation completely differently.
First , describe the kind of transitions we have identified, then present the 3 major states and quickly explain how they would cover all needs, then give the table showing how we map all those events to those 3 major states, and a small blurb about the flags allowing the few drivers that care to know more precisely what the initial event was.
Quoted 11 lines
Documentation/power/devices.txt +11
-0+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 =
Documentation/power/devices.txt line 199
Quoted 10 lines
Documentation/power/devices.txt +10
-0+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
Hrm... shuoldn't we rather use different calls for the above ? For S3/S4 do a SUSPEND call rather than freeze ?
Quoted 11 lines
Documentation/power/devices.txt +11
-0+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
Documentation/power/devices.txt line 221
Quoted 10 lines
Documentation/power/devices.txt +10
-0+= 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
I think we need to add the pm_message_t to resume. You are already "fixing" everybody to change u32 -> pm_message_t, so it shouldn't be that bad to add this too.
Ben.
Hi!
Quoted 4 lines
Quoted 4 lines
Documentation/power/devices.txt +4
-0+#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
Quoted 8 lines
Documentation/power/devices.txt line 221
Quoted 4 lines
Documentation/power/devices.txt +4
-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_RESUMEI think we need to add the
pm_message_tto resume. You are already "fixing" everybody to change u32 ->pm_message_t, so it shouldn't be that bad to add this too.
We need to add pm_message_t to resume, I agree about that, but yes, it would be quite bad if I added this, too.
All changes I'm doing are "break nothing", because pm_message_t is typedefed to u32 for now. Therefore they can be safely merged in any order etc...
For the documentation changes... I already rewrote that twice. I'm not native english speaker and I need some sleep now. If you send me nicely-looking diff, I'm likely to accept 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!
Quoted 6 lines · Pavel Machek
We need to add
pm_message_tto resume, I agree about that, but yes, it would be quite bad if I added this, too.All changes I'm doing are "break nothing", because
pm_message_tis typedefed to u32 for now. Therefore they can be safely merged in any order etc...
Hrm... adding it to all resume, if done at once, won't break anything since nobody uses it yet.
Quoted 3 lines
For the documentation changes... I already rewrote that twice. I'm not native english speaker and I need some sleep now. If you send me nicely-looking diff, I'm likely to accept it :-).
I'll think about it :)
Ben.
Hi!
Quoted 9 lines
Quoted 6 lines
We need to add
pm_message_tto resume, I agree about that, but yes, it would be quite bad if I added this, too.All changes I'm doing are "break nothing", because
pm_message_tis typedefed to u32 for now. Therefore they can be safely merged in any order etc...Hrm... adding it to all resume, if done at once, won't break anything since nobody uses it yet.
"Done at once" is going to be a problem. I do not have that kind of magical sed skills yet ;-).
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!
Quoted 9 lines · Pavel Machek
Hi!
Quoted 7 lines
Quoted 6 lines
We need to add
pm_message_tto resume, I agree about that, but yes, it would be quite bad if I added this, too.All changes I'm doing are "break nothing", because
pm_message_tis typedefed to u32 for now. Therefore they can be safely merged in any order etc...
Quoted 5 lines
Quoted 2 lines
Hrm... adding it to all resume, if done at once, won't break anything since nobody uses it yet.
"Done at once" is going to be a problem. I do not have that kind of magical sed skills yet ;-).
Me neither ... but I though you did :)
Ben.
Pavel Machek
AppliedHi!
Quoted 11 lines
Documentation/power/devices.txt line 155
Quoted 2 lines
Documentation/power/devices.txt +2
-0+ON -- no need to do anything except special cases like broken +HW.I'm not sure what is this one supposed to be ... The description is definitely not clear, can you precise in what context it is sent and give maybe an example of "broken hw" ?
Ok, now I'm reading the rest of the mail and I see but your description is really confusing. Also, we really need the resume argument to be added for the opposite (after resume) call to be sent. It makes little sense to pipe it through the
suspned()callback.
Oh I just wanted to have ON for future expansion, like that "warning userland is going away" or something like that. Maybe it can be even killed.
Quoted 6 lines
Documentation/power/devices.txt line 168
Quoted 3 lines
Documentation/power/devices.txt +3
-0+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.Here add a blurb about transitions. They are only from a resumed state to a suspended state, never between 2 suspended states.
Applied.
Quoted 6 lines
Quoted 6 lines
Documentation/power/devices.txt +6
-0+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
Quoted 8 lines
Documentation/power/devices.txt line 177
Quoted 2 lines
Documentation/power/devices.txt +2
-0+#are forbiden once the suspend dance is started.. event = ON, flags = +#PREPARE_TO_SUSPENDNote that we should probably fix kmalloc itself to turn
GFP_KERNELintoGFP_NOIOduring the suspend process. Forcall_usermodehelper, I wnated to "queue" them, but greg suggested that instead, we fail them, and at the end of the suspend process, we send a special/sbin/hotplugevent telling userland to rescan sysfs.
Actually I do not think that automatically doing GFP_NOIO instead of GFP_KERNEL is right thing. Is it that hard to teach drivers to get it right?
Quoted 5 lines
Now about your (long) list bewlow, it's really confusing as a documentation. People will think they have somewhat to switch/case on all these possible 'events' which is implied by the fact that you indicate different actions for each of them. I would redo that documentation completely differently.
No idea, it is certainly usefull for me :-). Hopefully noone is stupid enough to do case according to this, and flags are not even defined just yet, so spending extra time writing docs does not seem that great right now...
Anyway, feel free to send improved version...
Quoted 8 lines
Documentation/power/devices.txt line 199
Quoted 5 lines
Documentation/power/devices.txt +5
-0+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_S4Hrm... shuoldn't we rather use different calls for the above ? For S3/S4 do a SUSPEND call rather than freeze ?
S3 needs SUSPEND (and I specify it like that). At suspend-to-disk, you don't care about hardware state before poweroff (on PC anyway) so FREEZE seems like right thing to do.
Attached is my version of file with one paragraph added.
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!
Device Power Management
Device power management encompasses two areas - the ability to save state and transition a device to a low-power state when the system is entering a low-power state; and the ability to transition a device to a low-power state while the system is running (and independently of any other power management activity).
Methods
The methods to suspend and resume devices reside in struct bus_type:
struct bus_type {
...
int (*suspend)(struct device * dev, u32 state);
int (*resume)(struct device * dev);
};Each bus driver is responsible implementing these methods, translating the call into a bus-specific request and forwarding the call to the bus-specific drivers. For example, PCI drivers implement suspend() and resume() methods in struct pci_driver. The PCI core is simply responsible for translating the pointers to PCI-specific ones and calling the low-level driver.
This is done to a) ease transition to the new power management methods and leverage the existing PM code in various bus drivers; b) allow buses to implement generic and default PM routines for devices, and c) make the flow of execution obvious to the reader.
System Power Management
When the system enters a low-power state, the device tree is walked in a depth-first fashion to transition each device into a low-power state. The ordering of the device tree is guaranteed by the order in which devices get registered - children are never registered before their ancestors, and devices are placed at the back of the list when registered. By walking the list in reverse order, we are guaranteed to suspend devices in the proper order.
Devices are suspended once with interrupts enabled. Drivers are expected to stop I/O transactions, save device state, and place the device into a low-power state. Drivers may sleep, allocate memory, etc. at will.
Some devices are broken and will inevitably have problems powering down or disabling themselves with interrupts enabled. For these special cases, they may return -EAGAIN. This will put the device on a list to be taken care of later. When interrupts are disabled, before we enter the low-power state, their drivers are called again to put their device to sleep.
On resume, the devices that returned -EAGAIN will be called to power themselves back on with interrupts disabled. Once interrupts have been re-enabled, the rest of the drivers will be called to resume their devices. On resume, a driver is responsible for powering back on each device, restoring state, and re-enabling I/O transactions for that device.
System devices follow a slightly different API, which can be found in
include/linux/sysdev.h
drivers/base/sys.c
System devices will only be suspended with interrupts disabled, and after all other devices have been suspended. On resume, they will be resumed before any other devices, and also with interrupts disabled.
Runtime Power Management
Many devices are able to dynamically power down while the system is still running. This feature is useful for devices that are not being used, and can offer significant power savings on a running system.
In each device's directory, there is a 'power' directory, which contains at least a 'state' file. Reading from this file displays what power state the device is currently in. Writing to this file initiates a transition to the specified power state, which must be a decimal in the range 1-3, inclusive; or 0 for 'On'.
The PM core will call the ->suspend() method in the bus_type object that the device belongs to if the specified state is not 0, or ->resume() if it is.
Nothing will happen if the specified state is the same state the device is currently in.
If the device is already in a low-power state, and the specified state is another, but different, low-power state, the ->resume() method will first be called to power the device back on, then ->suspend() will be called again with the new state.
The driver is responsible for saving the working state of the device and putting it into the low-power state specified. If this was successful, it returns 0, and the device's power_state field is updated.
The driver must take care to know whether or not it is able to properly resume the device, including all step of reinitialization necessary. (This is the hardest part, and the one most protected by NDA'd documents).
The driver must also take care not to suspend a device that is currently in use. It is their responsibility to provide their own exclusion mechanisms.
The runtime power transition happens with interrupts enabled. If a device cannot support being powered down with interrupts, it may return -EAGAIN (as it would during a system power management transition), but it will _not_ be called again, and the transaction will fail.
There is currently no way to know what states a device or driver supports a priori. This will change in the future.
Driver Detach Power Management
The kernel now supports the ability to place a device in a low-power state when it is detached from its driver, which happens when its module is removed.
Each device contains a 'detach_state' file in its sysfs directory which can be used to control this state. Reading from this file displays what the current detach state is set to. This is 0 (On) by default. A user may write a positive integer value to this file in the range of 1-4 inclusive.
A value of 1-3 will indicate the device should be placed in that low-power state, which will cause ->suspend() to be called for that device. A value of 4 indicates that the device should be shutdown, so ->shutdown() will be called for that device.
The driver is responsible for reinitializing the device when the module is re-inserted during it's ->probe() (or equivalent) method. 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.
Transitions are only from a resumed state to a suspended state, never between 2 suspended states. (ON -> FREEZE or ON -> SUSPEND can happen, FREEZE -> SUSPEND or SUSPEND -> FREEZE can not).
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
#
Quoted 4 lines
Oh I just wanted to have ON for future expansion, like that "warning userland is going away" or something like that. Maybe it can be eve killed.
Ok, I'm a bit confused by the "ON" terminology. I wouldn't mind having 2 separate messages: NOTIFY_WILL_SUSPEND and NOTIFY_RESUMED here, but we can keep that on hold for now. We'll need a system-wide notifier at one point too I suppose. I also need to think how to hoook the APM emulation in there (which is the missing piece even on x86/ACPI S3 for X to work properly in lots of cases on resume).
Quoted 9 lines
Quoted 5 lines
Note that we should probably fix kmalloc itself to turn
GFP_KERNELintoGFP_NOIOduring the suspend process. Forcall_usermodehelper, I wnated to "queue" them, but greg suggested that instead, we fail them, and at the end of the suspend process, we send a special/sbin/hotplugevent telling userland to rescan sysfs.Actually I do not think that automatically doing
GFP_NOIOinstead ofGFP_KERNELis right thing. Is it that hard to teach drivers to get it right?
But what about non-drivers ? Teaching drivers is hard because that would require every single of them to actually have notifiers to "know" that we are about to start the suspend dance or that we have completed it, which mean keeping track additional state, etc... So that is a significant burden on drivers to add. Besides, as I wrote earlier, it may concern things implicitely called by drivers, or other kernel subsystems (like things in keventd, we don't wnat keventd to block or work_queues would stop, and drivers could die on flush_work_queues, which is common to be called on suspend) etc...
Quoted 6 lines
No idea, it is certainly usefull for me :-). Hopefully noone is stupid enough to do case according to this, and flags are not even defined just yet, so spending extra time writing docs does not seem that great right now...
Anyway, feel free to send improved version...
Yes, I'm thinking about rewriting it in the plane to France next week-end :)
Quoted 9 lines
Quoted 8 lines
Documentation/power/devices.txt line 199
Quoted 5 lines
Documentation/power/devices.txt +5
-0+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_S4Hrm... shuoldn't we rather use different calls for the above ? For S3/S4 do a SUSPEND call rather than freeze ?
Quoted 3 lines
S3 needs SUSPEND (and I specify it like that). At suspend-to-disk, you don't care about hardware state before poweroff (on PC anyway) so FREEZE seems like right thing to do.
Oh, I meant S4/S5... shouldn't it be SUSPEND rather than FREEZE ? I mean, don't some BIOSes who do S4/S5 expect us to actually suspend the HW (while other machines that don't have BIOS support will do a normal SHUTDOWN and thus wouldn't care). I don't know for sure here, this is an x86 thing ...
Quoted 2 lines
Attached is my version of file with one paragraph added.
Pavel
Signature · 1 line
Benjamin Herrenschmidt <[email protected]>