In order to understand and appreciate the SW considerations better, we ought to understand the fundamentals of power consumption, followed by the philosophy applied to power saving or optimizations.
Power Consumption of a System
Roughly speaking, systems have two modes when powered on: the first is the active mode when the system is actively being used and the second mode is when the system is on but it’s on standby and waiting for input from the user. In the standby mode, to save power, most of the system components can be turned off since they are idle. To effectively manage the power and state transition, the Advanced Configuration and Power Interface (ACPI) standard defines various system states and device states in detail. Generally speaking, the device/IP is nonfunctional in low-power states. In order to use the device/IP again, one needs to bring the device/
IP back to a functional state from the low-power, nonfunctional state. The time taken in the process is called wake-up latency. Again, a general rule of thumb is, the lower the power state, the longer it takes to bring the device/
IP to a fully functional state (the greater the wake-up latency).
So, speaking of the power consumed by a system, as shown in Figure 6- 8, the total power consumed is a summation of active mode power consumption, standby (sleep) mode power consumption, and wake-up power. Wake-up power is the power wasted during wake-up. In a nutshell, there are three categories of power consumption as listed below and shown in Figure 6-8, and separate strategies are applied to optimize them in a system:
1. Power consumption in active mode 2. Power consumption in standby mode 3. Power wastage during system wake
Figure 6-8. Power consumption of a system across active, standby, and transit modes
Power Optimization at the System Level
While discussing power optimization at the system level, we will discuss the optimization on three fronts: active power management, idle power management, and connected standby power management.
Active Power Management
Active power management refers to the management of power when the system is being used. The main thing to understand about APM is the fact that even when the system is in use, only a few of the subsystems are active; therefore, the rest of the system components can be turned off. To this end, the system is designed with use cases in mind, such that when a system is in use in a particular way, only the resources required for that use case are active and the rest can be power-gated to save maximum power.
Idle Power Management
Idle power management is the set of policies that are employed to save power when the system is idle. In modern systems, it is also desirable that the system is able to resume a normal full functional state as soon as there is need for it. The need may arise from an incoming call or the user’s desire to wake the system for normal usage. The idle power management requires that the system is in a state where it consumes as little power as possible.
However, the components must be able to become functional in very little time. To this end, there is a lot of effort on the part of the system designers, hardware IP designers, and OS designers.
Connected Standby Power Management
Modern systems are not only supposed to be using little power when idle and come back up to working state when required, but there is a third dimension to it. That is, even when idle, the system is connected to the world and keeps up to date with all that is happening. For example, the system keeps the stock tab, news, and social media notifications all up to date so that when a user opens it up, the user finds everything up to date.
In addition, the system should be able to notify the user of the events the user has subscribed to. Towards this end, the whole system is designed in such a way that
1. System components (at least some) have a state where they consume very little power, all the functional parts are shut down, but they have a portion that is always on and connected.
2. The entry and exit to the low power state is limited and predictable.
3. Offload: System components have built-in intelligence such that they can function and do some basic jobs without involving other system components. For example, the network devices in a connected standby platform must be capable of protocol offloads. Specifically, the network device must be capable of offloading the Address Resolution Protocol (ARP), Name Solicitation (NS), and several other WiFi-specific protocols. And for another example, audio playback can be offloaded such that during audio playback only the audio controller is active and everybody else can go to low-power states (after setting things up for the audio controller, of course).
4. Wake: System components have a mechanism to wake the system when required. This occurs in three cases:
4.1. One of the offloaded components has discovered some event for which it needs to involve other system components.
4.2. One of the offloaded components needs assistance from another component to carry out further instructions.
4.3. The user has requested the system to come up for action via any of the interfaces (typically buttons).
5. The OS and software are designed in such a way that at every small interval the system comes up online, does routine housekeeping, updates the relevant tabs, and goes back to sleep. In this context, modern operating systems have introduced a new concept, time coalescing, which simply means that the recurring booking jobs are aligned such that the system is able to carry out all tasks in one wakeup instance and they don’t require a separate wakeup for each of them, which would be counterproductive to say the least.
ACPI States
In order to facilitate optimal power management at the system level, ACPI has defined standard states for system, devices, processors, and so on.
Figure 6-9 shows the various states defined by ACPI and the transitions between them. In the following sections, we talk about them and explain what they all mean.
Global and System States
ACPI defines four global states and a total of six system states. The global states are marked G0–G3 while the system states are marked as S0–S5. It must be noted that even though S6 is mentioned in some motherboard documents, it is not an ACPI-defined state. S6, wherever mentioned, corresponds to G3.
ACPI defines a mechanism to transition the system between the working state (G0) and a sleeping state (G1) or the soft-off (G2) state.
During transitions between the working and sleeping states, the context of the user’s operating environment is maintained. ACPI defines the quality of the G1 sleeping state by defining the system attributes of four types of ACPI sleeping states (S1, S2, S3, and S4). Each sleeping state is defined to allow implementations that can trade off cost, power, and wake latencies.
Figure 6-9. Global system power states and transitions
1. G0/S0: In the G0 state, work is being performed by the OS/application software and the hardware. The CPU or any particular hardware device could be in any one of the defined power states (C0-C3 or D0- D3); however, some work will be taking place in the system.
a. S0: The system is in a fully working state.
2. G1: In the G1 state, the system is assumed to be doing no work. Prior to entering the G1 state, the OSPM will place devices in a device power state compatible with the system sleeping state to be entered; if a device is enabled to wake the system, then the OSPM will place these devices into the lowest Dx state from which the device supports wake.
a. S1: The S1 state is defined as a low wake-latency sleeping state. In this state, the entire system context is preserved with the exception of CPU caches. Before entering S1, the OSPM will flush the system caches.
b. S2: The S2 state is defined as a low wake latency sleep state. This state is similar to the S1 sleeping state where any context except for system memory may be lost. Additionally, control starts from the processor’s reset vector after the wake event.
c. S3: Commonly referred to as standby, sleep, or suspend to RAM (STR), the S3 state is defined