Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cbcd085d authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge branch 'pm-sleep' into acpi-battery

parents 9e50bc14 0c5ff0ef
Loading
Loading
Loading
Loading
+20 −9
Original line number Original line Diff line number Diff line
@@ -7,19 +7,30 @@ Description:
		subsystem.
		subsystem.


What:		/sys/power/state
What:		/sys/power/state
Date:		August 2006
Date:		May 2014
Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
Description:
Description:
		The /sys/power/state file controls the system power state.
		The /sys/power/state file controls system sleep states.
		Reading from this file returns what states are supported,
		Reading from this file returns the available sleep state
		which is hard-coded to 'freeze' (Low-Power Idle), 'standby'
		labels, which may be "mem", "standby", "freeze" and "disk"
		(Power-On Suspend), 'mem' (Suspend-to-RAM), and 'disk'
		(hibernation).  The meanings of the first three labels depend on
		(Suspend-to-Disk).
		the relative_sleep_states command line argument as follows:
		 1) relative_sleep_states = 1
		    "mem", "standby", "freeze" represent non-hibernation sleep
		    states from the deepest ("mem", always present) to the
		    shallowest ("freeze").  "standby" and "freeze" may or may
		    not be present depending on the capabilities of the
		    platform.  "freeze" can only be present if "standby" is
		    present.
		 2) relative_sleep_states = 0 (default)
		    "mem" - "suspend-to-RAM", present if supported.
		    "standby" - "power-on suspend", present if supported.
		    "freeze" - "suspend-to-idle", always present.


		Writing to this file one of these strings causes the system to
		Writing to this file one of these strings causes the system to
		transition into that state. Please see the file
		transition into the corresponding state, if available.  See
		Documentation/power/states.txt for a description of each of
		Documentation/power/states.txt for a description of what
		these states.
		"suspend-to-RAM", "power-on suspend" and "suspend-to-idle" mean.


What:		/sys/power/disk
What:		/sys/power/disk
Date:		September 2006
Date:		September 2006
+7 −0
Original line number Original line Diff line number Diff line
@@ -2889,6 +2889,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
			[KNL, SMP] Set scheduler's default relax_domain_level.
			[KNL, SMP] Set scheduler's default relax_domain_level.
			See Documentation/cgroups/cpusets.txt.
			See Documentation/cgroups/cpusets.txt.


	relative_sleep_states=
			[SUSPEND] Use sleep state labeling where the deepest
			state available other than hibernation is always "mem".
			Format: { "0" | "1" }
			0 -- Traditional sleep state labels.
			1 -- Relative sleep state labels.

	reserve=	[KNL,BUGS] Force the kernel to ignore some iomem area
	reserve=	[KNL,BUGS] Force the kernel to ignore some iomem area


	reservetop=	[X86-32]
	reservetop=	[X86-32]
+30 −4
Original line number Original line Diff line number Diff line
@@ -2,6 +2,7 @@ Device Power Management


Copyright (c) 2010-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
Copyright (c) 2010-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
Copyright (c) 2010 Alan Stern <stern@rowland.harvard.edu>
Copyright (c) 2010 Alan Stern <stern@rowland.harvard.edu>
Copyright (c) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>




Most of the code in Linux is device drivers, so most of the Linux power
Most of the code in Linux is device drivers, so most of the Linux power
@@ -326,6 +327,20 @@ the phases are:
	driver in some way for the upcoming system power transition, but it
	driver in some way for the upcoming system power transition, but it
	should not put the device into a low-power state.
	should not put the device into a low-power state.


	For devices supporting runtime power management, the return value of the
	prepare callback can be used to indicate to the PM core that it may
	safely leave the device in runtime suspend (if runtime-suspended
	already), provided that all of the device's descendants are also left in
	runtime suspend.  Namely, if the prepare callback returns a positive
	number and that happens for all of the descendants of the device too,
	and all of them (including the device itself) are runtime-suspended, the
	PM core will skip the suspend, suspend_late and	suspend_noirq suspend
	phases as well as the resume_noirq, resume_early and resume phases of
	the following system resume for all of these devices.	In that case,
	the complete callback will be called directly after the prepare callback
	and is entirely responsible for bringing the device back to the
	functional state as appropriate.

    2.	The suspend methods should quiesce the device to stop it from performing
    2.	The suspend methods should quiesce the device to stop it from performing
	I/O.  They also may save the device registers and put it into the
	I/O.  They also may save the device registers and put it into the
	appropriate low-power state, depending on the bus type the device is on,
	appropriate low-power state, depending on the bus type the device is on,
@@ -400,12 +415,23 @@ When resuming from freeze, standby or memory sleep, the phases are:
	the resume callbacks occur; it's not necessary to wait until the
	the resume callbacks occur; it's not necessary to wait until the
	complete phase.
	complete phase.


	Moreover, if the preceding prepare callback returned a positive number,
	the device may have been left in runtime suspend throughout the whole
	system suspend and resume (the suspend, suspend_late, suspend_noirq
	phases of system suspend and the resume_noirq, resume_early, resume
	phases of system resume may have been skipped for it).  In that case,
	the complete callback is entirely responsible for bringing the device
	back to the functional state after system suspend if necessary.  [For
	example, it may need to queue up a runtime resume request for the device
	for this purpose.]  To check if that is the case, the complete callback
	can consult the device's power.direct_complete flag.  Namely, if that
	flag is set when the complete callback is being run, it has been called
	directly after the preceding prepare and special action may be required
	to make the device work correctly afterward.

At the end of these phases, drivers should be as functional as they were before
At the end of these phases, drivers should be as functional as they were before
suspending: I/O can be performed using DMA and IRQs, and the relevant clocks are
suspending: I/O can be performed using DMA and IRQs, and the relevant clocks are
gated on.  Even if the device was in a low-power state before the system sleep
gated on.
because of runtime power management, afterwards it should be back in its
full-power state.  There are multiple reasons why it's best to do this; they are
discussed in more detail in Documentation/power/runtime_pm.txt.


However, the details here may again be platform-specific.  For example,
However, the details here may again be platform-specific.  For example,
some systems support multiple "run" states, and the mode in effect at
some systems support multiple "run" states, and the mode in effect at
+17 −0
Original line number Original line Diff line number Diff line
@@ -2,6 +2,7 @@ Runtime Power Management Framework for I/O Devices


(C) 2009-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
(C) 2009-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
(C) 2010 Alan Stern <stern@rowland.harvard.edu>
(C) 2010 Alan Stern <stern@rowland.harvard.edu>
(C) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>


1. Introduction
1. Introduction


@@ -444,6 +445,10 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
  bool pm_runtime_status_suspended(struct device *dev);
  bool pm_runtime_status_suspended(struct device *dev);
    - return true if the device's runtime PM status is 'suspended'
    - return true if the device's runtime PM status is 'suspended'


  bool pm_runtime_suspended_if_enabled(struct device *dev);
    - return true if the device's runtime PM status is 'suspended' and its
      'power.disable_depth' field is equal to 1

  void pm_runtime_allow(struct device *dev);
  void pm_runtime_allow(struct device *dev);
    - set the power.runtime_auto flag for the device and decrease its usage
    - set the power.runtime_auto flag for the device and decrease its usage
      counter (used by the /sys/devices/.../power/control interface to
      counter (used by the /sys/devices/.../power/control interface to
@@ -644,6 +649,18 @@ place (in particular, if the system is not waking up from hibernation), it may
be more efficient to leave the devices that had been suspended before the system
be more efficient to leave the devices that had been suspended before the system
suspend began in the suspended state.
suspend began in the suspended state.


To this end, the PM core provides a mechanism allowing some coordination between
different levels of device hierarchy.  Namely, if a system suspend .prepare()
callback returns a positive number for a device, that indicates to the PM core
that the device appears to be runtime-suspended and its state is fine, so it
may be left in runtime suspend provided that all of its descendants are also
left in runtime suspend.  If that happens, the PM core will not execute any
system suspend and resume callbacks for all of those devices, except for the
complete callback, which is then entirely responsible for handling the device
as appropriate.  This only applies to system suspend transitions that are not
related to hibernation (see Documentation/power/devices.txt for more
information).

The PM core does its best to reduce the probability of race conditions between
The PM core does its best to reduce the probability of race conditions between
the runtime PM and system suspend/resume (and hibernation) callbacks by carrying
the runtime PM and system suspend/resume (and hibernation) callbacks by carrying
out the following operations:
out the following operations:
+56 −31
Original line number Original line Diff line number Diff line
System Power Management Sleep States


System Power Management States
(C) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>


The kernel supports up to four system sleep states generically, although three
of them depend on the platform support code to implement the low-level details
for each state.


The kernel supports four power management states generically, though
The states are represented by strings that can be read or written to the
one is generic and the other three are dependent on platform support
/sys/power/state file.  Those strings may be "mem", "standby", "freeze" and
code to implement the low-level details for each state.
"disk", where the last one always represents hibernation (Suspend-To-Disk) and
This file describes each state, what they are
the meaning of the remaining ones depends on the relative_sleep_states command
commonly called, what ACPI state they map to, and what string to write
line argument.
to /sys/power/state to enter that state


state:		Freeze / Low-Power Idle
For relative_sleep_states=1, the strings "mem", "standby" and "freeze" label the
available non-hibernation sleep states from the deepest to the shallowest,
respectively.  In that case, "mem" is always present in /sys/power/state,
because there is at least one non-hibernation sleep state in every system.  If
the given system supports two non-hibernation sleep states, "standby" is present
in /sys/power/state in addition to "mem".  If the system supports three
non-hibernation sleep states, "freeze" will be present in /sys/power/state in
addition to "mem" and "standby".

For relative_sleep_states=0, which is the default, the following descriptions
apply.

state:		Suspend-To-Idle
ACPI state:	S0
ACPI state:	S0
String:		"freeze"
Label:		"freeze"


This state is a generic, pure software, light-weight, low-power state.
This state is a generic, pure software, light-weight, system sleep state.
It allows more energy to be saved relative to idle by freezing user
It allows more energy to be saved relative to runtime idle by freezing user
space and putting all I/O devices into low-power states (possibly
space and putting all I/O devices into low-power states (possibly
lower-power than available at run time), such that the processors can
lower-power than available at run time), such that the processors can
spend more time in their idle states.
spend more time in their idle states.
This state can be used for platforms without Standby/Suspend-to-RAM

This state can be used for platforms without Power-On Suspend/Suspend-to-RAM
support, or it can be used in addition to Suspend-to-RAM (memory sleep)
support, or it can be used in addition to Suspend-to-RAM (memory sleep)
to provide reduced resume latency.
to provide reduced resume latency.  It is always supported.




State:		Standby / Power-On Suspend
State:		Standby / Power-On Suspend
ACPI State:	S1
ACPI State:	S1
String:		"standby"
Label:		"standby"


This state offers minimal, though real, power savings, while providing
This state, if supported, offers moderate, though real, power savings, while
a very low-latency transition back to a working system. No operating
providing a relatively low-latency transition back to a working system.  No
state is lost (the CPU retains power), so the system easily starts up
operating state is lost (the CPU retains power), so the system easily starts up
again where it left off. 
again where it left off. 


We try to put devices in a low-power state equivalent to D1, which
In addition to freezing user space and putting all I/O devices into low-power
also offers low power savings, but low resume latency. Not all devices
states, which is done for Suspend-To-Idle too, nonboot CPUs are taken offline
support D1, and those that don't are left on. 
and all low-level system functions are suspended during transitions into this
state.  For this reason, it should allow more energy to be saved relative to
Suspend-To-Idle, but the resume latency will generally be greater than for that
state.




State:		Suspend-to-RAM
State:		Suspend-to-RAM
ACPI State:	S3
ACPI State:	S3
String:		"mem"
Label:		"mem"


This state offers significant power savings as everything in the
This state, if supported, offers significant power savings as everything in the
system is put into a low-power state, except for memory, which is
system is put into a low-power state, except for memory, which should be placed
placed in self-refresh mode to retain its contents. 
into the self-refresh mode to retain its contents.  All of the steps carried out
when entering Power-On Suspend are also carried out during transitions to STR.
Additional operations may take place depending on the platform capabilities.  In
particular, on ACPI systems the kernel passes control to the BIOS (platform
firmware) as the last step during STR transitions and that usually results in
powering down some more low-level components that aren't directly controlled by
the kernel.


System and device state is saved and kept in memory. All devices are
System and device state is saved and kept in memory.  All devices are suspended
suspended and put into D3. In many cases, all peripheral buses lose
and put into low-power states.  In many cases, all peripheral buses lose power
power when entering STR, so devices must be able to handle the
when entering STR, so devices must be able to handle the transition back to the
transition back to the On state. 
"on" state.


For at least ACPI, STR requires some minimal boot-strapping code to
For at least ACPI, STR requires some minimal boot-strapping code to resume the
resume the system from STR. This may be true on other platforms. 
system from it.  This may be the case on other platforms too.




State:		Suspend-to-disk
State:		Suspend-to-disk
ACPI State:	S4
ACPI State:	S4
String:		"disk"
Label:		"disk"


This state offers the greatest power savings, and can be used even in
This state offers the greatest power savings, and can be used even in
the absence of low-level platform support for power management. This
the absence of low-level platform support for power management. This
Loading