From 91499454c916fac04c73d752e83202b731f96be4 Mon Sep 17 00:00:00 2001 From: Dhruva Gole Date: Fri, 11 Jul 2025 16:09:50 +0530 Subject: [PATCH 1/2] feat(pm_cpuidle): add detailed documentation for AM62 standby mode Add comprehensive documentation for CPUIdle on AM62X, AM62AX, and AM62PX platforms explaining: - Standby mode implementation through CPUIdle WFI state - Integration between Linux CPUIdle framework and TF-A - PSCI interaction via cpu_standby and validate_power_state hooks - Source file references for both Linux and TF-A components - Kernel configuration options and usage information This documentation helps users understand that the TI "standby" mode is automatically handled by the CPUIdle framework without requiring special configuration. Signed-off-by: Dhruva Gole --- .../Power_Management/pm_cpuidle.rst | 137 ++++++++++++++++-- 1 file changed, 122 insertions(+), 15 deletions(-) diff --git a/source/linux/Foundational_Components/Power_Management/pm_cpuidle.rst b/source/linux/Foundational_Components/Power_Management/pm_cpuidle.rst index 3afc97673..014f26ad8 100644 --- a/source/linux/Foundational_Components/Power_Management/pm_cpuidle.rst +++ b/source/linux/Foundational_Components/Power_Management/pm_cpuidle.rst @@ -20,6 +20,114 @@ transition to the selected state. C-state. This state gets enabled by default in the CPUIdle driver without requiring any additional DT configuration. + .. rubric:: Standby Mode + + On |__PART_FAMILY_DEVICE_NAMES__| platforms, "Standby" mode is implemented through the Linux CPUIdle + framework. Standby is the default low-power state that the system enters automatically when idle, + using the WFI (Wait For Interrupt) C-state. This power-saving mechanism activates whenever the + system is "just sitting idle" without requiring any special configuration or activation from + the user. + + When your device appears inactive, it is actually cycling in and out of this standby state + many times per second, seamlessly managing power while remaining responsive. + + .. rubric:: Standby Implementation Architecture + + For |__PART_FAMILY_DEVICE_NAMES__|, the Standby implementation involves a multi-layer architecture: + + 1. **Linux CPUIdle Framework**: + - Determines when to place CPUs into idle states based on system activity + - Uses governors (like the menu governor) to predict how long CPUs will be idle + - Invokes platform-specific drivers to transition to appropriate C-states + + 2. **ARM Generic CPUIdle Driver**: + - Implements the Linux CPUIdle driver interface for ARM platforms + - Communicates with TF-A through PSCI SMC (Secure Monitor Call) interface + + 3. **PSCI Interface in Linux**: + - Provides a standardized method for the kernel to request power management operations + - Translates Linux-side requests into PSCI calls to TF-A + + 4. **TF-A PSCI Implementation**: + - Runs in secure world (EL3) + - Implements the PSCI specification + - Provides platform-specific handlers via the ``plat_psci_ops`` structure + + When your system goes idle, the following sequence occurs: + + - Linux idle loop detects no runnable tasks + - CPUIdle governor selects the appropriate C-state ("stby" for these platforms) + - CPUIdle driver communicates with TF-A via the PSCI interface + - TF-A's PSCI implementation validates the requested power state through ``validate_power_state()`` + - TF-A executes the ``cpu_standby()`` handler from ``plat_psci_ops`` + - The actual WFI instruction is executed within the TF-A's standby handler + - On interrupt: CPU automatically exits WFI state + - Control returns to Linux + + This automated process happens continuously during system operation, seamlessly + transitioning between active and idle states to save power whenever possible. + + .. rubric:: Standby vs. Deep Sleep: Understanding the Difference + + It's important to distinguish between the lightweight "standby" provided by CPUIdle and deeper sleep states: + + * **CPUIdle Standby (WFI)**: + - Processor-level power saving only + - Very fast entry and exit (microseconds) + - Occurs automatically hundreds of times per second + - No user intervention required + - All peripherals remain operational + - Perfect for normal "idle" periods + + * **Deep Sleep Modes**: + - System-wide power saving + - Slower entry and exit (milliseconds to seconds) + - Requires explicit software requests + - May require peripheral reconfiguration + - Suitable for extended inactive periods + + .. rubric:: Source Location + + **Linux Side**: + + - :file:`drivers/cpuidle/cpuidle-arm.c` - ARM CPU idle driver + - :file:`drivers/cpuidle/dt_idle_states.c` - Device tree parsing for idle states + - :file:`drivers/cpuidle/cpuidle.c` - Core CPUIdle framework + - :file:`kernel/sched/idle.c` - Kernel idle loop implementation + - :file:`drivers/firmware/psci.c` - PSCI interface to TF-A + + **TF-A Side** (not part of Linux kernel): + + - :file:`plat/ti/k3/common/k3_psci.c` - PSCI implementation for K3 platforms + + .. rubric:: Driver Usage + + CPUIdle works automatically once enabled in the kernel, with no user intervention required. + The CPUIdle framework statistics can be accessed through the sysfs interface: + + .. code-block:: console + + # ls -l /sys/devices/system/cpu/cpu0/cpuidle/ + drwxr-xr-x 2 root root 0 Jan 1 00:01 state0 + drwxr-xr-x 2 root root 0 Jan 1 00:01 state1 + + # ls -l /sys/devices/system/cpu/cpu0/cpuidle/state1/ + -r--r--r-- 1 root root 4096 Jan 1 00:02 desc + -r--r--r-- 1 root root 4096 Jan 1 00:02 latency + -r--r--r-- 1 root root 4096 Jan 1 00:02 name + -r--r--r-- 1 root root 4096 Jan 1 00:02 power + -r--r--r-- 1 root root 4096 Jan 1 00:02 time + -r--r--r-- 1 root root 4096 Jan 1 00:02 usage + + To view the current C-state statistics: + + .. code-block:: console + + # cat /sys/devices/system/cpu/cpu0/cpuidle/state1/name + stby + # cat /sys/devices/system/cpu/cpu0/cpuidle/state1/usage + 6245738 + .. ifconfig:: CONFIG_part_family in ('AM335X_family', 'AM437X_family') .. rubric:: Driver Features @@ -77,7 +185,6 @@ transition to the selected state. -*- Menu governor (for tickless system) ARM CPU Idle Drivers ---- - .. rubric:: DT Configuration .. code-block:: dts @@ -112,18 +219,18 @@ transition to the selected state. .. code-block:: console - # ls -l /sys/devices/system/cpu/cpu0/cpuidle/state0/ - -r--r--r-- 1 root root 4096 Jan 1 00:02 desc - -r--r--r-- 1 root root 4096 Jan 1 00:02 latency - -r--r--r-- 1 root root 4096 Jan 1 00:02 name - -r--r--r-- 1 root root 4096 Jan 1 00:02 power - -r--r--r-- 1 root root 4096 Jan 1 00:02 time - -r--r--r-- 1 root root 4096 Jan 1 00:02 usage - # ls -l /sys/devices/system/cpu/cpu0/cpuidle/state1/ - -r--r--r-- 1 root root 4096 Jan 1 00:05 desc - -r--r--r-- 1 root root 4096 Jan 1 00:05 latency - -r--r--r-- 1 root root 4096 Jan 1 00:03 name - -r--r--r-- 1 root root 4096 Jan 1 00:05 power - -r--r--r-- 1 root root 4096 Jan 1 00:05 time - -r--r--r-- 1 root root 4096 Jan 1 00:02 usage + # ls -l /sys/devices/system/cpu/cpu0/cpuidle/state0/ + -r--r--r-- 1 root root 4096 Jan 1 00:02 desc + -r--r--r-- 1 root root 4096 Jan 1 00:02 latency + -r--r--r-- 1 root root 4096 Jan 1 00:02 name + -r--r--r-- 1 root root 4096 Jan 1 00:02 power + -r--r--r-- 1 root root 4096 Jan 1 00:02 time + -r--r--r-- 1 root root 4096 Jan 1 00:02 usage + # ls -l /sys/devices/system/cpu/cpu0/cpuidle/state1/ + -r--r--r-- 1 root root 4096 Jan 1 00:05 desc + -r--r--r-- 1 root root 4096 Jan 1 00:05 latency + -r--r--r-- 1 root root 4096 Jan 1 00:03 name + -r--r--r-- 1 root root 4096 Jan 1 00:05 power + -r--r--r-- 1 root root 4096 Jan 1 00:05 time + -r--r--r-- 1 root root 4096 Jan 1 00:02 usage From a968ac4bbc04f3d334ed98d2ba14255c3692f9db Mon Sep 17 00:00:00 2001 From: Dhruva Gole Date: Mon, 14 Jul 2025 10:17:50 +0530 Subject: [PATCH 2/2] docs(linux): AM62PX, AM62X, AM62AX: Release Notes: standby mode Mention the standby power mode in the release summary pages for all relevant sitara devices. While at it, also replace the IO+DDR release specific note because it no longer applies as release specific for this particular release Signed-off-by: Dhruva Gole --- source/devices/AM62AX/linux/Release_Specific_Release_Notes.rst | 2 +- source/devices/AM62PX/linux/Release_Specific_Release_Notes.rst | 2 +- source/devices/AM62X/linux/Release_Specific_Release_Notes.rst | 1 + .../Foundational_Components/Power_Management/pm_cpuidle.rst | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/devices/AM62AX/linux/Release_Specific_Release_Notes.rst b/source/devices/AM62AX/linux/Release_Specific_Release_Notes.rst index 80e81da40..a3c541f4a 100644 --- a/source/devices/AM62AX/linux/Release_Specific_Release_Notes.rst +++ b/source/devices/AM62AX/linux/Release_Specific_Release_Notes.rst @@ -53,7 +53,7 @@ What's new - RT Kernel : Real-Time Linux Interrupt Latency numbers here :ref:`RT Interrupt Latencies ` - Support for streaming from OV2312 camera with `DS90UB954-Q1EVM `_ - - Power Management: :ref:`I/O Only Plus DDR ` mode + - How standby power mode works - :ref:`CPUIdle Documentation ` **Component version:** diff --git a/source/devices/AM62PX/linux/Release_Specific_Release_Notes.rst b/source/devices/AM62PX/linux/Release_Specific_Release_Notes.rst index a533430a3..2e4c9d1d0 100644 --- a/source/devices/AM62PX/linux/Release_Specific_Release_Notes.rst +++ b/source/devices/AM62PX/linux/Release_Specific_Release_Notes.rst @@ -55,7 +55,7 @@ What's new - RT Kernel : Real-Time Linux Interrupt Latency numbers here - :ref:`RT Interrupt Latencies ` - Support for streaming from multiple 0V5640 cameras with `Arducam V3Link (Fusion Mini) `_ - TISCI: A53 hosts default priv_id value updated to 1 from 4 (to match all other SOCs) - - Power Management: :ref:`I/O Only Plus DDR ` mode + - How standby power mode works - :ref:`CPUIdle Documentation ` - Out-of-Box TI Apps Launcher Application with Qt6 Framework - :ref:`TI Apps Launcher ` - Snagfactory Support - :ref:`Snagfactory Tool ` - Support for M2 CC33xx cards on Debian - `How to Enable M.2-CC33x1 in Linux `__ diff --git a/source/devices/AM62X/linux/Release_Specific_Release_Notes.rst b/source/devices/AM62X/linux/Release_Specific_Release_Notes.rst index 2a3b5f7ab..35442588c 100644 --- a/source/devices/AM62X/linux/Release_Specific_Release_Notes.rst +++ b/source/devices/AM62X/linux/Release_Specific_Release_Notes.rst @@ -56,6 +56,7 @@ What's new - Snagfactory Support - :ref:`Snagfactory Tool ` - Support for M2 CC33xx cards on Debian - `How to Enable M.2-CC33x1 in Linux `__ - How to Enable PRU RPMsg - `Read FAQ `__ + - How standby power mode works - :ref:`CPUIdle Documentation ` **Component version:** diff --git a/source/linux/Foundational_Components/Power_Management/pm_cpuidle.rst b/source/linux/Foundational_Components/Power_Management/pm_cpuidle.rst index 014f26ad8..a419dd3c2 100644 --- a/source/linux/Foundational_Components/Power_Management/pm_cpuidle.rst +++ b/source/linux/Foundational_Components/Power_Management/pm_cpuidle.rst @@ -1,3 +1,5 @@ +.. _cpuidle-guide: + ####### CPUIdle #######