1e706d7ffSWing LiPSCI OS-initiated mode 2e706d7ffSWing Li====================== 3e706d7ffSWing Li 4e706d7ffSWing Li:Author: Maulik Shah & Wing Li 5e706d7ffSWing Li:Organization: Qualcomm Innovation Center, Inc. & Google LLC 6e706d7ffSWing Li:Contact: Maulik Shah <quic_mkshah@quicinc.com> & Wing Li <wingers@google.com> 7*d3488614SWing Li:Status: Accepted 8e706d7ffSWing Li 9e706d7ffSWing Li.. contents:: Table of Contents 10e706d7ffSWing Li 11e706d7ffSWing LiIntroduction 12e706d7ffSWing Li------------ 13e706d7ffSWing Li 14e706d7ffSWing LiPower state coordination 15e706d7ffSWing Li^^^^^^^^^^^^^^^^^^^^^^^^ 16e706d7ffSWing Li 17e706d7ffSWing LiA power domain topology is a logical hierarchy of power domains in a system that 18e706d7ffSWing Liarises from the physical dependencies between power domains. 19e706d7ffSWing Li 20e706d7ffSWing LiLocal power states describe power states for an individual node, and composite 21e706d7ffSWing Lipower states describe the combined power states for an individual node and its 22e706d7ffSWing Liparent node(s). 23e706d7ffSWing Li 24e706d7ffSWing LiEntry into low-power states for a topology node above the core level requires 25e706d7ffSWing Licoordinating its children nodes. For example, in a system with a power domain 26e706d7ffSWing Lithat encompasses a shared cache, and a separate power domain for each core that 27e706d7ffSWing Liuses the shared cache, the core power domains must be powered down before the 28e706d7ffSWing Lishared cache power domain can be powered down. 29e706d7ffSWing Li 30e706d7ffSWing LiPSCI supports two modes of power state coordination: platform-coordinated and 31e706d7ffSWing LiOS-initiated. 32e706d7ffSWing Li 33e706d7ffSWing LiPlatform-coordinated 34e706d7ffSWing Li~~~~~~~~~~~~~~~~~~~~ 35e706d7ffSWing Li 36e706d7ffSWing LiPlatform-coordinated mode is the default mode of power state coordination, and 37e706d7ffSWing Liis currently the only supported mode in TF-A. 38e706d7ffSWing Li 39e706d7ffSWing LiIn platform-coordinated mode, the platform is responsible for coordinating power 40e706d7ffSWing Listates, and chooses the deepest power state for a topology node that can be 41e706d7ffSWing Litolerated by its children. 42e706d7ffSWing Li 43e706d7ffSWing LiOS-initiated 44e706d7ffSWing Li~~~~~~~~~~~~ 45e706d7ffSWing Li 46e706d7ffSWing LiOS-initiated mode is optional. 47e706d7ffSWing Li 48e706d7ffSWing LiIn OS-initiated mode, the calling OS is responsible for coordinating power 49e706d7ffSWing Listates, and may request for a topology node to enter a low-power state when 50e706d7ffSWing Liits last child enters the low-power state. 51e706d7ffSWing Li 52e706d7ffSWing LiMotivation 53e706d7ffSWing Li---------- 54e706d7ffSWing Li 55e706d7ffSWing LiThere are two reasons why OS-initiated mode might be a more suitable option than 56e706d7ffSWing Liplatform-coordinated mode for a platform. 57e706d7ffSWing Li 58e706d7ffSWing LiScalability 59e706d7ffSWing Li^^^^^^^^^^^ 60e706d7ffSWing Li 61e706d7ffSWing LiIn platform-coordinated mode, each core independently selects their own local 62e706d7ffSWing Lipower states, and doesn't account for composite power states that are shared 63e706d7ffSWing Libetween cores. 64e706d7ffSWing Li 65e706d7ffSWing LiIn OS-initiated mode, the OS has knowledge of the next wakeup event for each 66e706d7ffSWing Licore, and can have more precise control over the entry, exit, and wakeup 67e706d7ffSWing Lilatencies when deciding if a composite power state (e.g. for a cluster) is 68e706d7ffSWing Liappropriate. This is especially important for multi-cluster SMP systems and 69e706d7ffSWing Liheterogeneous systems like big.LITTLE, where different processor types can have 70e706d7ffSWing Lidifferent power efficiencies. 71e706d7ffSWing Li 72e706d7ffSWing LiSimplicity 73e706d7ffSWing Li^^^^^^^^^^ 74e706d7ffSWing Li 75e706d7ffSWing LiIn platform-coordinated mode, the OS doesn't have visibility when the last core 76e706d7ffSWing Liat a power level enters a low-power state. If the OS wants to perform last man 77e706d7ffSWing Liactivity (e.g. powering off a shared resource when it is no longer needed), it 78e706d7ffSWing Liwould have to communicate with an API side channel to know when it can do so. 79e706d7ffSWing LiThis could result in a design smell where the platform is using 80e706d7ffSWing Liplatform-coordinated mode when it should be using OS-initiated mode instead. 81e706d7ffSWing Li 82e706d7ffSWing LiIn OS-initiated mode, the OS can perform last man activity if it selects a 83e706d7ffSWing Licomposite power state when the last core enters a low-power state. This 84e706d7ffSWing Lieliminates the need for a side channel, and uses the well documented API between 85e706d7ffSWing Lithe OS and the platform. 86e706d7ffSWing Li 87e706d7ffSWing LiCurrent vendor implementations and workarounds 88e706d7ffSWing Li^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 89e706d7ffSWing Li 90e706d7ffSWing Li* STMicroelectronics 91e706d7ffSWing Li 92e706d7ffSWing Li * For their ARM32 platforms, they're using OS-initiated mode implemented in 93e706d7ffSWing Li OP-TEE. 94e706d7ffSWing Li * For their future ARM64 platforms, they are interested in using OS-initiated 95e706d7ffSWing Li mode in TF-A. 96e706d7ffSWing Li 97e706d7ffSWing Li* Qualcomm 98e706d7ffSWing Li 99e706d7ffSWing Li * For their mobile platforms, they're using OS-initiated mode implemented in 100e706d7ffSWing Li their own custom secure monitor firmware. 101e706d7ffSWing Li * For their Chrome OS platforms, they're using platform-coordinated mode in 102e706d7ffSWing Li TF-A with custom driver logic to perform last man activity. 103e706d7ffSWing Li 104e706d7ffSWing Li* Google 105e706d7ffSWing Li 106e706d7ffSWing Li * They're using platform-coordinated mode in TF-A with custom driver logic to 107e706d7ffSWing Li perform last man activity. 108e706d7ffSWing Li 109e706d7ffSWing LiBoth Qualcomm and Google would like to be able to use OS-initiated mode in TF-A 110e706d7ffSWing Liin order to simplify custom driver logic. 111e706d7ffSWing Li 112e706d7ffSWing LiRequirements 113e706d7ffSWing Li------------ 114e706d7ffSWing Li 115e706d7ffSWing LiPSCI_FEATURES 116e706d7ffSWing Li^^^^^^^^^^^^^ 117e706d7ffSWing Li 118e706d7ffSWing LiPSCI_FEATURES is for checking whether or not a PSCI function is implemented and 119e706d7ffSWing Liwhat its properties are. 120e706d7ffSWing Li 121e706d7ffSWing Li.. c:macro:: PSCI_FEATURES 122e706d7ffSWing Li 123e706d7ffSWing Li :param func_id: 0x8400_000A. 124e706d7ffSWing Li :param psci_func_id: the function ID of a PSCI function. 125e706d7ffSWing Li :retval NOT_SUPPORTED: if the function is not implemented. 126e706d7ffSWing Li :retval feature flags associated with the function: if the function is 127e706d7ffSWing Li implemented. 128e706d7ffSWing Li 129e706d7ffSWing LiCPU_SUSPEND feature flags 130e706d7ffSWing Li~~~~~~~~~~~~~~~~~~~~~~~~~ 131e706d7ffSWing Li 132e706d7ffSWing Li* Reserved, bits[31:2] 133e706d7ffSWing Li* Power state parameter format, bit[1] 134e706d7ffSWing Li 135e706d7ffSWing Li * A value of 0 indicates the original format is used. 136e706d7ffSWing Li * A value of 1 indicates the extended format is used. 137e706d7ffSWing Li 138e706d7ffSWing Li* OS-initiated mode, bit[0] 139e706d7ffSWing Li 140e706d7ffSWing Li * A value of 0 indicates OS-initiated mode is not supported. 141e706d7ffSWing Li * A value of 1 indicates OS-initiated mode is supported. 142e706d7ffSWing Li 143e706d7ffSWing LiSee sections 5.1.14 and 5.15 of the PSCI spec (DEN0022D.b) for more details. 144e706d7ffSWing Li 145e706d7ffSWing LiPSCI_SET_SUSPEND_MODE 146e706d7ffSWing Li^^^^^^^^^^^^^^^^^^^^^ 147e706d7ffSWing Li 148e706d7ffSWing LiPSCI_SET_SUSPEND_MODE is for switching between the two different modes of power 149e706d7ffSWing Listate coordination. 150e706d7ffSWing Li 151e706d7ffSWing Li.. c:macro:: PSCI_SET_SUSPEND_MODE 152e706d7ffSWing Li 153e706d7ffSWing Li :param func_id: 0x8400_000F. 154e706d7ffSWing Li :param mode: 0 indicates platform-coordinated mode, 1 indicates OS-initiated 155e706d7ffSWing Li mode. 156e706d7ffSWing Li :retval SUCCESS: if the request is successful. 157e706d7ffSWing Li :retval NOT_SUPPORTED: if OS-initiated mode is not supported. 158e706d7ffSWing Li :retval INVALID_PARAMETERS: if the requested mode is not a valid value (0 or 159e706d7ffSWing Li 1). 160e706d7ffSWing Li :retval DENIED: if the cores are not in the correct state. 161e706d7ffSWing Li 162e706d7ffSWing LiSwitching from platform-coordinated to OS-initiated is only allowed if the 163e706d7ffSWing Lifollowing conditions are met: 164e706d7ffSWing Li 165e706d7ffSWing Li* All cores are in one of the following states: 166e706d7ffSWing Li 167e706d7ffSWing Li * Running. 168e706d7ffSWing Li * Off, through a call to CPU_OFF or not yet booted. 169e706d7ffSWing Li * Suspended, through a call to CPU_DEFAULT_SUSPEND. 170e706d7ffSWing Li 171e706d7ffSWing Li* None of the cores has called CPU_SUSPEND since the last change of mode or 172e706d7ffSWing Li boot. 173e706d7ffSWing Li 174e706d7ffSWing LiSwitching from OS-initiated to platform-coordinated is only allowed if all cores 175e706d7ffSWing Liother than the calling core are off, either through a call to CPU_OFF or not yet 176e706d7ffSWing Libooted. 177e706d7ffSWing Li 178e706d7ffSWing LiIf these conditions are not met, the PSCI implementation must return DENIED. 179e706d7ffSWing Li 180e706d7ffSWing LiSee sections 5.1.19 and 5.20 of the PSCI spec (DEN0022D.b) for more details. 181e706d7ffSWing Li 182e706d7ffSWing LiCPU_SUSPEND 183e706d7ffSWing Li^^^^^^^^^^^ 184e706d7ffSWing Li 185e706d7ffSWing LiCPU_SUSPEND is for moving a topology node into a low-power state. 186e706d7ffSWing Li 187e706d7ffSWing Li.. c:macro:: CPU_SUSPEND 188e706d7ffSWing Li 189e706d7ffSWing Li :param func_id: 0xC400_0001. 190e706d7ffSWing Li :param power_state: the requested low-power state to enter. 191e706d7ffSWing Li :param entry_point_address: the address at which the core must resume 192e706d7ffSWing Li execution following wakeup from a powerdown state. 193e706d7ffSWing Li :param context_id: this field specifies a pointer to the saved context that 194e706d7ffSWing Li must be restored on a core following wakeup from a powerdown state. 195e706d7ffSWing Li :retval SUCCESS: if the request is successful. 196e706d7ffSWing Li :retval INVALID_PARAMETERS: in OS-initiated mode, this error is returned when 197e706d7ffSWing Li a low-power state is requested for a topology node above the core level, 198e706d7ffSWing Li and at least one of the node's children is in a local low-power state 199e706d7ffSWing Li that is incompatible with the request. 200e706d7ffSWing Li :retval INVALID_ADDRESS: if the entry_point_address argument is invalid. 201e706d7ffSWing Li :retval DENIED: only in OS-initiated mode; this error is returned when a 202e706d7ffSWing Li low-power state is requested for a topology node above the core level, 203e706d7ffSWing Li and at least one of the node's children is running, i.e. not in a 204e706d7ffSWing Li low-power state. 205e706d7ffSWing Li 206e706d7ffSWing LiIn platform-coordinated mode, the PSCI implementation coordinates requests from 207e706d7ffSWing Liall cores to determine the deepest power state to enter. 208e706d7ffSWing Li 209e706d7ffSWing LiIn OS-initiated mode, the calling OS is making an explicit request for a 210e706d7ffSWing Lispecific power state, as opposed to expressing a vote. The PSCI implementation 211e706d7ffSWing Limust comply with the request, unless the request is not consistent with the 212e706d7ffSWing Liimplementation's view of the system's state, in which case, the implementation 213e706d7ffSWing Limust return INVALID_PARAMETERS or DENIED. 214e706d7ffSWing Li 215e706d7ffSWing LiSee sections 5.1.2 and 5.4 of the PSCI spec (DEN0022D.b) for more details. 216e706d7ffSWing Li 217e706d7ffSWing LiPower state formats 218e706d7ffSWing Li~~~~~~~~~~~~~~~~~~~ 219e706d7ffSWing Li 220e706d7ffSWing LiOriginal format 221e706d7ffSWing Li 222e706d7ffSWing Li* Power Level, bits[25:24] 223e706d7ffSWing Li 224e706d7ffSWing Li * The requested level in the power domain topology to enter a low-power 225e706d7ffSWing Li state. 226e706d7ffSWing Li 227e706d7ffSWing Li* State Type, bit[16] 228e706d7ffSWing Li 229e706d7ffSWing Li * A value of 0 indicates a standby or retention state. 230e706d7ffSWing Li * A value of 1 indicates a powerdown state. 231e706d7ffSWing Li 232e706d7ffSWing Li* State ID, bits[15:0] 233e706d7ffSWing Li 234e706d7ffSWing Li * Field to specify the requested composite power state. 235e706d7ffSWing Li * The state ID encodings must uniquely describe every possible composite 236e706d7ffSWing Li power state. 237e706d7ffSWing Li * In OS-initiated mode, the state ID encoding must allow expressing the 238e706d7ffSWing Li power level at which the calling core is the last to enter a powerdown 239e706d7ffSWing Li state. 240e706d7ffSWing Li 241e706d7ffSWing LiExtended format 242e706d7ffSWing Li 243e706d7ffSWing Li* State Type, bit[30] 244e706d7ffSWing Li* State ID, bits[27:0] 245e706d7ffSWing Li 246e706d7ffSWing LiRaces in OS-initiated mode 247e706d7ffSWing Li~~~~~~~~~~~~~~~~~~~~~~~~~~ 248e706d7ffSWing Li 249e706d7ffSWing LiIn OS-initiated mode, there are race windows where the OS's view and 250e706d7ffSWing Liimplementation's view of the system's state differ. It is possible for the OS to 251e706d7ffSWing Limake requests that are invalid given the implementation's view of the system's 252e706d7ffSWing Listate. For example, the OS might request a powerdown state for a node from one 253e706d7ffSWing Licore, while at the same time, the implementation observes that another core in 254e706d7ffSWing Lithat node is powering up. 255e706d7ffSWing Li 256e706d7ffSWing LiTo address potential race conditions in power state requests: 257e706d7ffSWing Li 258e706d7ffSWing Li* The calling OS must specify in each CPU_SUSPEND request the deepest power 259e706d7ffSWing Li level for which it sees the calling core as the last running core (last man). 260e706d7ffSWing Li This is required even if the OS doesn't want the node at that power level to 261e706d7ffSWing Li enter a low-power state. 262e706d7ffSWing Li* The implementation must validate that the requested power states in the 263e706d7ffSWing Li CPU_SUSPEND request are consistent with the system's state, and that the 264e706d7ffSWing Li calling core is the last core running at the requested power level, or deny 265e706d7ffSWing Li the request otherwise. 266e706d7ffSWing Li 267e706d7ffSWing LiSee sections 4.2.3.2, 6.2, and 6.3 of the PSCI spec (DEN0022D.b) for more 268e706d7ffSWing Lidetails. 269e706d7ffSWing Li 270e706d7ffSWing LiCaveats 271e706d7ffSWing Li------- 272e706d7ffSWing Li 273e706d7ffSWing LiCPU_OFF 274e706d7ffSWing Li^^^^^^^ 275e706d7ffSWing Li 276e706d7ffSWing LiCPU_OFF is always platform-coordinated, regardless of whether the power state 277e706d7ffSWing Licoordination mode for suspend is platform-coordinated or OS-initiated. If all 278e706d7ffSWing Licores in a topology node call CPU_OFF, the last core will power down the node. 279e706d7ffSWing Li 280e706d7ffSWing LiIn OS-initiated mode, if a subset of the cores in a topology node has called 281e706d7ffSWing LiCPU_OFF, the last running core may call CPU_SUSPEND to request a powerdown state 282e706d7ffSWing Liat or above that node's power level. 283e706d7ffSWing Li 284e706d7ffSWing LiSee section 5.5.2 of the PSCI spec (DEN0022D.b) for more details. 285e706d7ffSWing Li 286e706d7ffSWing LiImplementation 287e706d7ffSWing Li-------------- 288e706d7ffSWing Li 289e706d7ffSWing LiCurrent implementation of platform-coordinated mode 290e706d7ffSWing Li^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 291e706d7ffSWing Li 292e706d7ffSWing LiPlatform-coordinated is currently the only supported power state coordination 293e706d7ffSWing Limode in TF-A. 294e706d7ffSWing Li 295e706d7ffSWing LiThe functions of interest in the ``psci_cpu_suspend`` call stack are as follows: 296e706d7ffSWing Li 297e706d7ffSWing Li* ``psci_validate_power_state`` 298e706d7ffSWing Li 299e706d7ffSWing Li * This function calls a platform specific ``validate_power_state`` handler, 300e706d7ffSWing Li which takes the ``power_state`` parameter, and updates the ``state_info`` 301e706d7ffSWing Li object with the requested states for each power level. 302e706d7ffSWing Li 303e706d7ffSWing Li* ``psci_find_target_suspend_lvl`` 304e706d7ffSWing Li 305e706d7ffSWing Li * This function takes the ``state_info`` object containing the requested power 306e706d7ffSWing Li states for each power level, and returns the deepest power level that was 307e706d7ffSWing Li requested to enter a low power state, i.e. the target power level. 308e706d7ffSWing Li 309e706d7ffSWing Li* ``psci_do_state_coordination`` 310e706d7ffSWing Li 311e706d7ffSWing Li * This function takes the target power level and the ``state_info`` object 312e706d7ffSWing Li containing the requested power states for each power level, and updates the 313e706d7ffSWing Li ``state_info`` object with the coordinated target power state for each 314e706d7ffSWing Li level. 315e706d7ffSWing Li 316e706d7ffSWing Li* ``pwr_domain_suspend`` 317e706d7ffSWing Li 318e706d7ffSWing Li * This is a platform specific handler that takes the ``state_info`` object 319e706d7ffSWing Li containing the target power states for each power level, and transitions 320e706d7ffSWing Li each power level to the specified power state. 321e706d7ffSWing Li 322e706d7ffSWing LiProposed implementation of OS-initiated mode 323e706d7ffSWing Li^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 324e706d7ffSWing Li 325e706d7ffSWing LiTo add support for OS-initiated mode, the following changes are proposed: 326e706d7ffSWing Li 327e706d7ffSWing Li* Add a boolean build option ``PSCI_OS_INIT_MODE`` for a platform to enable 328e706d7ffSWing Li optional support for PSCI OS-initiated mode. This build option defaults to 0. 329e706d7ffSWing Li 330e706d7ffSWing Li.. note:: 331e706d7ffSWing Li 332e706d7ffSWing Li If ``PSCI_OS_INIT_MODE=0``, the following changes will not be compiled into 333e706d7ffSWing Li the build. 334e706d7ffSWing Li 335e706d7ffSWing Li* Update ``psci_features`` to return 1 in bit[0] to indicate support for 336e706d7ffSWing Li OS-initiated mode for CPU_SUSPEND. 337e706d7ffSWing Li* Define a ``suspend_mode`` enum: ``PLAT_COORD`` and ``OS_INIT``. 338e706d7ffSWing Li* Define a ``psci_suspend_mode`` global variable with a default value of 339e706d7ffSWing Li ``PLAT_COORD``. 340e706d7ffSWing Li* Implement a new function handler ``psci_set_suspend_mode`` for 341e706d7ffSWing Li PSCI_SET_SUSPEND_MODE. 342e706d7ffSWing Li* Since ``psci_validate_power_state`` calls a platform specific 343e706d7ffSWing Li ``validate_power_state`` handler, the platform implementation should populate 344e706d7ffSWing Li the ``state_info`` object based on the state ID from the given ``power_state`` 345e706d7ffSWing Li parameter. 346e706d7ffSWing Li* ``psci_find_target_suspend_lvl`` remains unchanged. 347e706d7ffSWing Li* Implement a new function ``psci_validate_state_coordination`` that ensures the 348e706d7ffSWing Li request satisfies the following conditions, and denies any requests 349e706d7ffSWing Li that don't: 350e706d7ffSWing Li 351e706d7ffSWing Li * The requested power states for each power level are consistent with the 352e706d7ffSWing Li system's state 353e706d7ffSWing Li * The calling core is the last core running at the requested power level 354e706d7ffSWing Li 355e706d7ffSWing Li This function differs from ``psci_do_state_coordination`` in that: 356e706d7ffSWing Li 357e706d7ffSWing Li * The ``psci_req_local_pwr_states`` map is not modified if the request were to 358e706d7ffSWing Li be denied 359e706d7ffSWing Li * The ``state_info`` argument is never modified since it contains the power 360e706d7ffSWing Li states requested by the calling OS 361e706d7ffSWing Li 362e706d7ffSWing Li* Update ``psci_cpu_suspend_start`` to do the following: 363e706d7ffSWing Li 364e706d7ffSWing Li * If ``PSCI_SUSPEND_MODE`` is ``PLAT_COORD``, call 365e706d7ffSWing Li ``psci_do_state_coordination``. 366e706d7ffSWing Li * If ``PSCI_SUSPEND_MODE`` is ``OS_INIT``, call 367e706d7ffSWing Li ``psci_validate_state_coordination``. If validation fails, propagate the 368e706d7ffSWing Li error up the call stack. 369e706d7ffSWing Li 370*d3488614SWing Li* Add a new optional member ``pwr_domain_validate_suspend`` to 371*d3488614SWing Li ``plat_psci_ops_t`` to allow the platform to optionally perform validations 372*d3488614SWing Li based on hardware states. 373*d3488614SWing Li 374*d3488614SWing Li* The platform specific ``pwr_domain_suspend`` handler remains unchanged. 375e706d7ffSWing Li 376e706d7ffSWing Li.. image:: ../resources/diagrams/psci-osi-mode.png 377e706d7ffSWing Li 378e706d7ffSWing LiTesting 379e706d7ffSWing Li------- 380e706d7ffSWing Li 381e706d7ffSWing LiThe proposed patches can be found at 382e706d7ffSWing Lihttps://review.trustedfirmware.org/q/topic:psci-osi. 383e706d7ffSWing Li 384e706d7ffSWing LiTesting on FVP and Google platforms 385e706d7ffSWing Li^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 386e706d7ffSWing Li 387e706d7ffSWing LiThe proposed patches add a new CPU Suspend in OSI mode test suite to TF-A Tests. 388e706d7ffSWing LiThis has been enabled and verified on the FVP_Base_RevC-2xAEMvA platform and 389e706d7ffSWing LiGoogle platforms, and excluded from all other platforms via the build option 390e706d7ffSWing Li``PLAT_TESTS_SKIP_LIST``. 391e706d7ffSWing Li 392e706d7ffSWing LiTesting on STM32MP15 393e706d7ffSWing Li^^^^^^^^^^^^^^^^^^^^ 394e706d7ffSWing Li 395e706d7ffSWing LiThe proposed patches have been tested and verified on the STM32MP15 platform, 396e706d7ffSWing Liwhich has a single cluster with 2 CPUs, by Gabriel Fernandez 397e706d7ffSWing Li<gabriel.fernandez@st.com> from STMicroelectronics with this device tree 398e706d7ffSWing Liconfiguration: 399e706d7ffSWing Li 400e706d7ffSWing Li.. code-block:: devicetree 401e706d7ffSWing Li 402e706d7ffSWing Li cpus { 403e706d7ffSWing Li #address-cells = <1>; 404e706d7ffSWing Li #size-cells = <0>; 405e706d7ffSWing Li 406e706d7ffSWing Li cpu0: cpu@0 { 407e706d7ffSWing Li device_type = "cpu"; 408e706d7ffSWing Li compatible = "arm,cortex-a7"; 409e706d7ffSWing Li reg = <0>; 410e706d7ffSWing Li enable-method = "psci"; 411e706d7ffSWing Li power-domains = <&CPU_PD0>; 412e706d7ffSWing Li power-domain-names = "psci"; 413e706d7ffSWing Li }; 414e706d7ffSWing Li cpu1: cpu@1 { 415e706d7ffSWing Li device_type = "cpu"; 416e706d7ffSWing Li compatible = "arm,cortex-a7"; 417e706d7ffSWing Li reg = <1>; 418e706d7ffSWing Li enable-method = "psci"; 419e706d7ffSWing Li power-domains = <&CPU_PD1>; 420e706d7ffSWing Li power-domain-names = "psci"; 421e706d7ffSWing Li }; 422e706d7ffSWing Li 423e706d7ffSWing Li idle-states { 424e706d7ffSWing Li cpu_retention: cpu-retention { 425e706d7ffSWing Li compatible = "arm,idle-state"; 426e706d7ffSWing Li arm,psci-suspend-param = <0x00000001>; 427e706d7ffSWing Li entry-latency-us = <130>; 428e706d7ffSWing Li exit-latency-us = <620>; 429e706d7ffSWing Li min-residency-us = <700>; 430e706d7ffSWing Li local-timer-stop; 431e706d7ffSWing Li }; 432e706d7ffSWing Li }; 433e706d7ffSWing Li 434e706d7ffSWing Li domain-idle-states { 435e706d7ffSWing Li CLUSTER_STOP: core-power-domain { 436e706d7ffSWing Li compatible = "domain-idle-state"; 437e706d7ffSWing Li arm,psci-suspend-param = <0x01000001>; 438e706d7ffSWing Li entry-latency-us = <230>; 439e706d7ffSWing Li exit-latency-us = <720>; 440e706d7ffSWing Li min-residency-us = <2000>; 441e706d7ffSWing Li local-timer-stop; 442e706d7ffSWing Li }; 443e706d7ffSWing Li }; 444e706d7ffSWing Li }; 445e706d7ffSWing Li 446e706d7ffSWing Li psci { 447e706d7ffSWing Li compatible = "arm,psci-1.0"; 448e706d7ffSWing Li method = "smc"; 449e706d7ffSWing Li 450e706d7ffSWing Li CPU_PD0: power-domain-cpu0 { 451e706d7ffSWing Li #power-domain-cells = <0>; 452e706d7ffSWing Li power-domains = <&pd_core>; 453e706d7ffSWing Li domain-idle-states = <&cpu_retention>; 454e706d7ffSWing Li }; 455e706d7ffSWing Li 456e706d7ffSWing Li CPU_PD1: power-domain-cpu1 { 457e706d7ffSWing Li #power-domain-cells = <0>; 458e706d7ffSWing Li power-domains = <&pd_core>; 459e706d7ffSWing Li domain-idle-states = <&cpu_retention>; 460e706d7ffSWing Li }; 461e706d7ffSWing Li 462e706d7ffSWing Li pd_core: power-domain-cluster { 463e706d7ffSWing Li #power-domain-cells = <0>; 464e706d7ffSWing Li domain-idle-states = <&CLUSTER_STOP>; 465e706d7ffSWing Li }; 466e706d7ffSWing Li }; 467e706d7ffSWing Li 468e706d7ffSWing LiTesting on Qualcomm SC7280 469e706d7ffSWing Li^^^^^^^^^^^^^^^^^^^^^^^^^^ 470e706d7ffSWing Li 471e706d7ffSWing LiThe proposed patches have been tested and verified on the SC7280 platform by 472e706d7ffSWing LiMaulik Shah <quic_mkshah@quicinc.com> from Qualcomm with this device tree 473e706d7ffSWing Liconfiguration: 474e706d7ffSWing Li 475e706d7ffSWing Li.. code-block:: devicetree 476e706d7ffSWing Li 477e706d7ffSWing Li cpus { 478e706d7ffSWing Li #address-cells = <2>; 479e706d7ffSWing Li #size-cells = <0>; 480e706d7ffSWing Li 481e706d7ffSWing Li CPU0: cpu@0 { 482e706d7ffSWing Li device_type = "cpu"; 483e706d7ffSWing Li compatible = "arm,kryo"; 484e706d7ffSWing Li reg = <0x0 0x0>; 485e706d7ffSWing Li enable-method = "psci"; 486e706d7ffSWing Li power-domains = <&CPU_PD0>; 487e706d7ffSWing Li power-domain-names = "psci"; 488e706d7ffSWing Li }; 489e706d7ffSWing Li 490e706d7ffSWing Li CPU1: cpu@100 { 491e706d7ffSWing Li device_type = "cpu"; 492e706d7ffSWing Li compatible = "arm,kryo"; 493e706d7ffSWing Li reg = <0x0 0x100>; 494e706d7ffSWing Li enable-method = "psci"; 495e706d7ffSWing Li power-domains = <&CPU_PD1>; 496e706d7ffSWing Li power-domain-names = "psci"; 497e706d7ffSWing Li }; 498e706d7ffSWing Li 499e706d7ffSWing Li CPU2: cpu@200 { 500e706d7ffSWing Li device_type = "cpu"; 501e706d7ffSWing Li compatible = "arm,kryo"; 502e706d7ffSWing Li reg = <0x0 0x200>; 503e706d7ffSWing Li enable-method = "psci"; 504e706d7ffSWing Li power-domains = <&CPU_PD2>; 505e706d7ffSWing Li power-domain-names = "psci"; 506e706d7ffSWing Li }; 507e706d7ffSWing Li 508e706d7ffSWing Li CPU3: cpu@300 { 509e706d7ffSWing Li device_type = "cpu"; 510e706d7ffSWing Li compatible = "arm,kryo"; 511e706d7ffSWing Li reg = <0x0 0x300>; 512e706d7ffSWing Li enable-method = "psci"; 513e706d7ffSWing Li power-domains = <&CPU_PD3>; 514e706d7ffSWing Li power-domain-names = "psci"; 515e706d7ffSWing Li } 516e706d7ffSWing Li 517e706d7ffSWing Li CPU4: cpu@400 { 518e706d7ffSWing Li device_type = "cpu"; 519e706d7ffSWing Li compatible = "arm,kryo"; 520e706d7ffSWing Li reg = <0x0 0x400>; 521e706d7ffSWing Li enable-method = "psci"; 522e706d7ffSWing Li power-domains = <&CPU_PD4>; 523e706d7ffSWing Li power-domain-names = "psci"; 524e706d7ffSWing Li }; 525e706d7ffSWing Li 526e706d7ffSWing Li CPU5: cpu@500 { 527e706d7ffSWing Li device_type = "cpu"; 528e706d7ffSWing Li compatible = "arm,kryo"; 529e706d7ffSWing Li reg = <0x0 0x500>; 530e706d7ffSWing Li enable-method = "psci"; 531e706d7ffSWing Li power-domains = <&CPU_PD5>; 532e706d7ffSWing Li power-domain-names = "psci"; 533e706d7ffSWing Li }; 534e706d7ffSWing Li 535e706d7ffSWing Li CPU6: cpu@600 { 536e706d7ffSWing Li device_type = "cpu"; 537e706d7ffSWing Li compatible = "arm,kryo"; 538e706d7ffSWing Li reg = <0x0 0x600>; 539e706d7ffSWing Li enable-method = "psci"; 540e706d7ffSWing Li power-domains = <&CPU_PD6>; 541e706d7ffSWing Li power-domain-names = "psci"; 542e706d7ffSWing Li }; 543e706d7ffSWing Li 544e706d7ffSWing Li CPU7: cpu@700 { 545e706d7ffSWing Li device_type = "cpu"; 546e706d7ffSWing Li compatible = "arm,kryo"; 547e706d7ffSWing Li reg = <0x0 0x700>; 548e706d7ffSWing Li enable-method = "psci"; 549e706d7ffSWing Li power-domains = <&CPU_PD7>; 550e706d7ffSWing Li power-domain-names = "psci"; 551e706d7ffSWing Li }; 552e706d7ffSWing Li 553e706d7ffSWing Li idle-states { 554e706d7ffSWing Li entry-method = "psci"; 555e706d7ffSWing Li 556e706d7ffSWing Li LITTLE_CPU_SLEEP_0: cpu-sleep-0-0 { 557e706d7ffSWing Li compatible = "arm,idle-state"; 558e706d7ffSWing Li idle-state-name = "little-power-down"; 559e706d7ffSWing Li arm,psci-suspend-param = <0x40000003>; 560e706d7ffSWing Li entry-latency-us = <549>; 561e706d7ffSWing Li exit-latency-us = <901>; 562e706d7ffSWing Li min-residency-us = <1774>; 563e706d7ffSWing Li local-timer-stop; 564e706d7ffSWing Li }; 565e706d7ffSWing Li 566e706d7ffSWing Li LITTLE_CPU_SLEEP_1: cpu-sleep-0-1 { 567e706d7ffSWing Li compatible = "arm,idle-state"; 568e706d7ffSWing Li idle-state-name = "little-rail-power-down"; 569e706d7ffSWing Li arm,psci-suspend-param = <0x40000004>; 570e706d7ffSWing Li entry-latency-us = <702>; 571e706d7ffSWing Li exit-latency-us = <915>; 572e706d7ffSWing Li min-residency-us = <4001>; 573e706d7ffSWing Li local-timer-stop; 574e706d7ffSWing Li }; 575e706d7ffSWing Li 576e706d7ffSWing Li BIG_CPU_SLEEP_0: cpu-sleep-1-0 { 577e706d7ffSWing Li compatible = "arm,idle-state"; 578e706d7ffSWing Li idle-state-name = "big-power-down"; 579e706d7ffSWing Li arm,psci-suspend-param = <0x40000003>; 580e706d7ffSWing Li entry-latency-us = <523>; 581e706d7ffSWing Li exit-latency-us = <1244>; 582e706d7ffSWing Li min-residency-us = <2207>; 583e706d7ffSWing Li local-timer-stop; 584e706d7ffSWing Li }; 585e706d7ffSWing Li 586e706d7ffSWing Li BIG_CPU_SLEEP_1: cpu-sleep-1-1 { 587e706d7ffSWing Li compatible = "arm,idle-state"; 588e706d7ffSWing Li idle-state-name = "big-rail-power-down"; 589e706d7ffSWing Li arm,psci-suspend-param = <0x40000004>; 590e706d7ffSWing Li entry-latency-us = <526>; 591e706d7ffSWing Li exit-latency-us = <1854>; 592e706d7ffSWing Li min-residency-us = <5555>; 593e706d7ffSWing Li local-timer-stop; 594e706d7ffSWing Li }; 595e706d7ffSWing Li }; 596e706d7ffSWing Li 597e706d7ffSWing Li domain-idle-states { 598e706d7ffSWing Li CLUSTER_SLEEP_0: cluster-sleep-0 { 599e706d7ffSWing Li compatible = "arm,idle-state"; 600e706d7ffSWing Li idle-state-name = "cluster-power-down"; 601e706d7ffSWing Li arm,psci-suspend-param = <0x40003444>; 602e706d7ffSWing Li entry-latency-us = <3263>; 603e706d7ffSWing Li exit-latency-us = <6562>; 604e706d7ffSWing Li min-residency-us = <9926>; 605e706d7ffSWing Li local-timer-stop; 606e706d7ffSWing Li }; 607e706d7ffSWing Li }; 608e706d7ffSWing Li }; 609e706d7ffSWing Li 610e706d7ffSWing Li psci { 611e706d7ffSWing Li compatible = "arm,psci-1.0"; 612e706d7ffSWing Li method = "smc"; 613e706d7ffSWing Li 614e706d7ffSWing Li CPU_PD0: cpu0 { 615e706d7ffSWing Li #power-domain-cells = <0>; 616e706d7ffSWing Li power-domains = <&CLUSTER_PD>; 617e706d7ffSWing Li domain-idle-states = <&LITTLE_CPU_SLEEP_0 &LITTLE_CPU_SLEEP_1>; 618e706d7ffSWing Li }; 619e706d7ffSWing Li 620e706d7ffSWing Li CPU_PD1: cpu1 { 621e706d7ffSWing Li #power-domain-cells = <0>; 622e706d7ffSWing Li power-domains = <&CLUSTER_PD>; 623e706d7ffSWing Li domain-idle-states = <&LITTLE_CPU_SLEEP_0 &LITTLE_CPU_SLEEP_1>; 624e706d7ffSWing Li }; 625e706d7ffSWing Li 626e706d7ffSWing Li CPU_PD2: cpu2 { 627e706d7ffSWing Li #power-domain-cells = <0>; 628e706d7ffSWing Li power-domains = <&CLUSTER_PD>; 629e706d7ffSWing Li domain-idle-states = <&LITTLE_CPU_SLEEP_0 &LITTLE_CPU_SLEEP_1>; 630e706d7ffSWing Li }; 631e706d7ffSWing Li 632e706d7ffSWing Li CPU_PD3: cpu3 { 633e706d7ffSWing Li #power-domain-cells = <0>; 634e706d7ffSWing Li power-domains = <&CLUSTER_PD>; 635e706d7ffSWing Li domain-idle-states = <&LITTLE_CPU_SLEEP_0 &LITTLE_CPU_SLEEP_1>; 636e706d7ffSWing Li }; 637e706d7ffSWing Li 638e706d7ffSWing Li CPU_PD4: cpu4 { 639e706d7ffSWing Li #power-domain-cells = <0>; 640e706d7ffSWing Li power-domains = <&CLUSTER_PD>; 641e706d7ffSWing Li domain-idle-states = <&BIG_CPU_SLEEP_0 &BIG_CPU_SLEEP_1>; 642e706d7ffSWing Li }; 643e706d7ffSWing Li 644e706d7ffSWing Li CPU_PD5: cpu5 { 645e706d7ffSWing Li #power-domain-cells = <0>; 646e706d7ffSWing Li power-domains = <&CLUSTER_PD>; 647e706d7ffSWing Li domain-idle-states = <&BIG_CPU_SLEEP_0 &BIG_CPU_SLEEP_1>; 648e706d7ffSWing Li }; 649e706d7ffSWing Li 650e706d7ffSWing Li CPU_PD6: cpu6 { 651e706d7ffSWing Li #power-domain-cells = <0>; 652e706d7ffSWing Li power-domains = <&CLUSTER_PD>; 653e706d7ffSWing Li domain-idle-states = <&BIG_CPU_SLEEP_0 &BIG_CPU_SLEEP_1>; 654e706d7ffSWing Li }; 655e706d7ffSWing Li 656e706d7ffSWing Li CPU_PD7: cpu7 { 657e706d7ffSWing Li #power-domain-cells = <0>; 658e706d7ffSWing Li power-domains = <&CLUSTER_PD>; 659e706d7ffSWing Li domain-idle-states = <&BIG_CPU_SLEEP_0 &BIG_CPU_SLEEP_1>; 660e706d7ffSWing Li }; 661e706d7ffSWing Li 662e706d7ffSWing Li CLUSTER_PD: cpu-cluster0 { 663e706d7ffSWing Li #power-domain-cells = <0>; 664e706d7ffSWing Li domain-idle-states = <&CLUSTER_SLEEP_0>; 665e706d7ffSWing Li }; 666e706d7ffSWing Li }; 667e706d7ffSWing Li 668e706d7ffSWing LiComparisons on Qualcomm SC7280 669e706d7ffSWing Li^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 670e706d7ffSWing Li 671e706d7ffSWing LiCPUIdle states 672e706d7ffSWing Li~~~~~~~~~~~~~~ 673e706d7ffSWing Li 674e706d7ffSWing Li* 8 CPUs, 1 L3 cache 675e706d7ffSWing Li* Platform-coordinated mode 676e706d7ffSWing Li 677e706d7ffSWing Li * CPUIdle states 678e706d7ffSWing Li 679e706d7ffSWing Li * State0 - WFI 680e706d7ffSWing Li * State1 - Core collapse 681e706d7ffSWing Li * State2 - Rail collapse 682e706d7ffSWing Li * State3 - L3 cache off and system resources voted off 683e706d7ffSWing Li 684e706d7ffSWing Li* OS-initiated mode 685e706d7ffSWing Li 686e706d7ffSWing Li * CPUIdle states 687e706d7ffSWing Li 688e706d7ffSWing Li * State0 - WFI 689e706d7ffSWing Li * State1 - Core collapse 690e706d7ffSWing Li * State2 - Rail collapse 691e706d7ffSWing Li 692e706d7ffSWing Li * Cluster domain idle state 693e706d7ffSWing Li 694e706d7ffSWing Li * State3 - L3 cache off and system resources voted off 695e706d7ffSWing Li 696e706d7ffSWing Li.. image:: ../resources/diagrams/psci-flattened-vs-hierarchical-idle-states.png 697e706d7ffSWing Li 698e706d7ffSWing LiResults 699e706d7ffSWing Li~~~~~~~ 700e706d7ffSWing Li 701e706d7ffSWing Li* The following stats have been captured with fixed CPU frequencies from the use 702e706d7ffSWing Li case of 10 seconds of device idle with the display turned on and Wi-Fi and 703e706d7ffSWing Li modem turned off. 704e706d7ffSWing Li* Count refers to the number of times a CPU or cluster entered power collapse. 705e706d7ffSWing Li* Residency refers to the time in seconds a CPU or cluster stayed in power 706e706d7ffSWing Li collapse. 707e706d7ffSWing Li* The results are an average of 3 iterations of actual counts and residencies. 708e706d7ffSWing Li 709e706d7ffSWing Li.. image:: ../resources/diagrams/psci-pc-mode-vs-osi-mode.png 710e706d7ffSWing Li 711e706d7ffSWing LiOS-initiated mode was able to scale better than platform-coordinated mode for 712e706d7ffSWing Limultiple CPUs. The count and residency results for state3 (i.e. a cluster domain 713e706d7ffSWing Liidle state) in OS-initiated mode for multiple CPUs were much closer to the 714e706d7ffSWing Liresults for a single CPU than in platform-coordinated mode. 715e706d7ffSWing Li 716e706d7ffSWing Li-------------- 717e706d7ffSWing Li 718e706d7ffSWing Li*Copyright (c) 2023, Arm Limited and Contributors. All rights reserved.* 719