Showing posts with label S3. Show all posts
Showing posts with label S3. Show all posts

Friday, May 6, 2011

Suspend/wakeup for psmouse, atkbd device

Based on kernel 2.6.24

For PS2 mouse and PS2 keyboard. the driver is at:
/linuxsrc/driver/input/mouse/psmouse-base.c
/linuxsrc/driver/input/keyboard/atkbd.c

How does supend/wakeup works for mouse and drive?

/linuxsrc/kernel/power/main.c devince_suspend
->
/linuxsrc/driver/base/power/main.c call the driver of each device
->
/linuxsrc/driver/input/serio.c
serio_suspend() -> serio_cleanup()->
serio_resume() -> serio_reconnect_driver()-> 
->
/linuxsrc/driver/input/mouse/psmouse-base.c
/linuxsrc/driver/input/keyboard/atkbd.c
psmouse_cleanup(); atkbd_cleanup()
psmouse_reconnect(); atkbd_reconnect()

Thursday, May 5, 2011

Linux kernel Suspend Code

After echo "mem" > /sys/power/state directory, it jumps to kernel. start to execute code at /linux-2.6.24/kernel/power/main.c, it execute function

state_store() -> enter_state() ->
1. suspend_prepare()
2. suspend_device_and_enter() // machine stop here, and wakeup here!!!
3. suspend_finish()

remember, all the printk statement you added will be print into /var/log/message.
It doesn't necessary to pint out immediately. For example, printk statement before OS get into S3 state may print out after wakeup OS.
Basically, printk will write to memory first, and then print out to file.

Tuesday, April 12, 2011

How does Suspend work on Linux (CentOS)


How does suspend work on Linux:

Step1: suspend on Userspace
pm-suspend is shell script, which attempts to prepare the system for suspend. For example, it will tell NetworkManager to shut down networking, and use vbetool (run code at video option ROM) to save VGA state. Finally, it wil echo string “mem” to /sys/power/state. This jumps to kernel, and the userspace is stopped.
Detailed info:
pm-suspend: /usr/lib/pm-utils/bin/pm-action
functions: /usr/lib/pm-utils/functions
10NetworkManager: /usr/lib/pm-utils/sleep.d/10NetwrokManager
20video: /usr/lib/pm-utils/sleep.d/20video

Step2: suspend in kernel
After run “echo -n mem > /sys/power/state”, the kernel goes through the device tree and calls suspend method on each bound driver. In the mean while, kernel execute couple of ACPI methods acpi_enter_sleep_state_prep() and acpi_enter_sleep_state(). In this method, kernel will set the SLP_TYP register at south-bridge, which tell BIOS to wakeup from sleep state next time.
Detailed info:
acpi_enter_sleep_state_prep(): /linuxsrc/drivers/acpi/hardware/hwsleep.c
acpi_enter_sleep_state(): /linuxsrc/drivers/acpi/hardware/hwsleep.c
main.c /linux/src/drivers/acpi/sleep/main.c

Suspend Time measurements:
Userspace: 1.5 seconds
Kenerl: 1 second

Friday, April 8, 2011

Linux Suspend Info

http://www.linux.com/archive/feed/54610

http://www.advogato.org/article/913.html

Wednesday, March 23, 2011

Suspend Windows from command line by using systerm internals Pstool

http://technet.microsoft.com/en-us/sysinternals/bb897541

Monday, December 6, 2010

surspend to RAM S3

Suspend to RAM command:

$ echo mem > /sys/power/state
or
$ echo mem > /proc/acpi/sleep

$ echo cmd > /sys/power/state

        S1,                 "standby"         很低的延迟就能回到工作状态

        S3,                 "mem",                 suspend-to-RAM, STR

        S4,                 "disk"                 suspend-to-disk, STD,Hibernation