Skip to contentSkip to conversation

pmdomain: Support system-suspend-only domain idle states

PATCH In review Maulik Shah 4 participants 10 messages Nov 13 – Nov 23

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover pmdomain: Support system-suspend-only domain idle states

To achieve the deepest CPUSS low power state, which can lead to chip rail power collapse (CxPC) on SoCs such as Lemans, Monaco and Nord, the CPU subsystem (CPUSS) and the Safety Island (SAIL) subsystem must be powered down together in a coordinated sequence. The Safety Island (SAIL) is a dedicated subsystem responsible for safety-critical monitoring and control functions, and can operate independently from the main CPU subsystem.

This transition is divided into two stages. First, firmware requests SAIL power-down through IPC, after which SAIL waits for hardware low power handshakes from CPUSS. If an interrupt or another condition aborts CPUSS entry into the deepest low power mode after the IPC request, firmware must bring SAIL back out of its low power sequence before any CPU can resume execution in the OS. This recovery can take a second or more.

Selecting this state during opportunistic CPU idle can therefore cause substantial wakeup delays and repeatedly interrupt SAIL operation whenever the CPUs become idle. SAIL must remain operational during normal system activity, so this coordinated power-down state should be reserved for system-wide suspend such as suspend-to-idle. Shallower domain states remain available for regular CPU and cluster idle power management.

This restriction concerns when SAIL may stop its work, in addition to the transition latency. Idle-state latency and residency values alone do not express that requirement. System suspend does not eliminate interrupts or aborted entry, but provides the context in which coordinated SAIL power-down is appropriate.

All domain idle states described in devicetree are currently considered during the regular idle path. This limits which states can be described in devicetree. Due to hardware constraints, some domain idle states are only applicable to system-wide suspend, including suspend-to-idle (s2idle).

To allow these states to be described in DT and used only during system suspend, this series adds a boolean system-state property to domain idle state bindings and a corresponding system_state boolean in genpd. The genpd governors skip these states during normal operation. The system suspend selection path remains unchanged, allowing these states during suspend while retaining the existing wakeup latency checks for s2idle.

This series applies to cluster idle states with the "domain-idle-state" compatible string managed by genpd and its governors, but can be extended to CPU idle states with the "arm,idle-state" compatible string if the same restriction is needed for CPUidle states too.

---
Changes in v2:
- Explain why the state is limited to the four-PMIC Monaco EVK and is
not supported on the two-PMIC Monaco AC EVK.
- Push binding example and DT latencie/residency to the realistic values
- Use lowercase hex for the PSCI suspend parameter.
- Link to v1: https://patch.msgid.link/[email protected]

To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: Ulf Hansson <[email protected]>
To: "Rafael J. Wysocki" <[email protected]>
To: Bjorn Andersson <[email protected]>
To: Konrad Dybcio <[email protected]>
To: Abel Vesa <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Maulik Shah (3):
dt-bindings: power: domain-idle-state: Add system-state
pmdomain: Add support for system-suspend-only states
arm64: dts: qcom: monaco-evk: Add suspend-only power collapse state

 .../devicetree/bindings/power/domain-idle-state.yaml    | 14 ++++++++++++++
 arch/arm64/boot/dts/qcom/monaco-evk.dts                 | 17 +++++++++++++++++
 drivers/pmdomain/core.c                                 |  2 ++
 drivers/pmdomain/governor.c                             |  6 ++++++
 include/linux/pm_domain.h                               |  1 +
 5 files changed, 40 insertions(+)

---
base-commit: aaa2f954c21b205a0bcd0961e5b2be4e82e58455
change-id: 20261001-s2idle_state-6484bbbf48fb

Best regards,

Signature · 1 line
Maulik Shah <[email protected]>
#1 lore raw

PATCH v2 1/3 dt-bindings: power: domain-idle-state: Add system-state

Some domain idle states require system-wide coordination and are not applicable while the platform is up and running.

Add a boolean system-state property to describe these states.

---
 .../devicetree/bindings/power/domain-idle-state.yaml       | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/power/domain-idle-state.yaml +14 -0
index 4dd4f59bbbec..b19952f6225d 100644
@@ -45,6 +45,12 @@ patternProperties:
           state will yield power benefits, after overcoming the overhead while
           entering the idle state.
 
+      system-state:
+        description:
+          When present, this state requires system-wide coordination and is
+          not applicable while the platform is up and running.
+        type: boolean
+
       arm,psci-suspend-param:
         $ref: /schemas/types.yaml#/definitions/uint32
         description: |
@@ -77,5 +83,13 @@ examples:
         exit-latency-us = <40>;
         min-residency-us = <80>;
       };
+
+      domain_power_off: domain-power-off {
+        compatible = "domain-idle-state";
+        entry-latency-us = <706562>;
+        exit-latency-us = <706562>;
+        min-residency-us = <1414124>;
+        system-state;
+      };
     };
 ...
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: power: domain-idle-state: Add system-state

Quoted 2 lines · Maulik Shah

Some domain idle states require system-wide coordination and are not applicable while the platform is up and running.

You repeated the property description. Say something more. Why they are not applicable when platform is running? So if not running, when are they applicable? Why?

Quoted 14 lines

Add a boolean system-state property to describe these states.

---
 .../devicetree/bindings/power/domain-idle-state.yaml       | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/power/domain-idle-state.yaml +0 -0
index 4dd4f59bbbec..b19952f6225d 100644

Documentation/devicetree/bindings/power/domain-idle-state.yaml patternProperties: · line 51

Quoted 7 lines
Documentation/devicetree/bindings/power/domain-idle-state.yaml +4 -0
@@ -45,6 +45,12 @@ patternProperties:
           state will yield power benefits, after overcoming the overhead while
           entering the idle state.
 
+      system-state:
+        description:
+          When present, this state requires system-wide coordination and is
+          not applicable while the platform is up and running.

So when is it applicable if not when up and running?

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH v2 1/3] dt-bindings: power: domain-idle-state: Add system-state

Quoted 6 lines · Krzysztof Kozlowski
Quoted 2 lines · Maulik Shah

Some domain idle states require system-wide coordination and are not applicable while the platform is up and running.

You repeated the property description. Say something more. Why they are not applicable when platform is running? So if not running, when are they applicable? Why?

On certain platforms CPU subsystem deepest idle state requires co-ordination with SAIL subsystem such that both must be powered down in coordinated sequence. During wakeup SAIL subsystem must be powered up before CPU can resume. The wakeup can take a second or more.

Selecting this state during opportunistic CPU idle can therefore cause substantial wakeup delays and repeatedly interrupt SAIL operation whenever the CPUs become idle.

Add system-state property to describe the state is reserved for system wide suspend.

I will update same in v3.

Quoted 17 lines
Quoted 17 lines

Add a boolean system-state property to describe these states.

---
 .../devicetree/bindings/power/domain-idle-state.yaml       | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/power/domain-idle-state.yaml +0 -0
index 4dd4f59bbbec..b19952f6225d 100644
@@ -45,6 +45,12 @@ patternProperties:
           state will yield power benefits, after overcoming the overhead while
           entering the idle state.
 
Quoted 5 lines

Documentation/devicetree/bindings/power/domain-idle-state.yaml patternProperties: · line 51

Quoted 4 lines
Documentation/devicetree/bindings/power/domain-idle-state.yaml +4 -0
+      system-state:
+        description:
+          When present, this state requires system-wide coordination and is
+          not applicable while the platform is up and running.

So when is it applicable if not when up and running?

I will update in v3.

Thanks,
Maulik

#4 lore raw

Re: [PATCH v2 1/3] dt-bindings: power: domain-idle-state: Add system-state

Quoted 10 lines · Maulik Shah
Quoted 6 lines · Krzysztof Kozlowski
Quoted 2 lines · Maulik Shah

Some domain idle states require system-wide coordination and are not applicable while the platform is up and running.

You repeated the property description. Say something more. Why they are not applicable when platform is running? So if not running, when are they applicable? Why?

Quoted 6 lines

On certain platforms CPU subsystem deepest idle state requires co-ordination with SAIL subsystem such that both must be powered down in coordinated sequence. During wakeup SAIL subsystem must be powered up before CPU can resume. The wakeup can take a second or more.

Selecting this state during opportunistic CPU idle can therefore cause substantial wakeup delays and repeatedly interrupt SAIL operation whenever the CPUs become idle.

The idle state latency times define that. No need for a new property.

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH v2 1/3] dt-bindings: power: domain-idle-state: Add system-state

Quoted 11 lines · Krzysztof Kozlowski
Quoted 10 lines · Maulik Shah
Quoted 6 lines · Krzysztof Kozlowski
Quoted 2 lines · Maulik Shah

Some domain idle states require system-wide coordination and are not applicable while the platform is up and running.

You repeated the property description. Say something more. Why they are not applicable when platform is running? So if not running, when are they applicable? Why?

Quoted 8 lines
Quoted 6 lines

On certain platforms CPU subsystem deepest idle state requires co-ordination with SAIL subsystem such that both must be powered down in coordinated sequence. During wakeup SAIL subsystem must be powered up before CPU can resume. The wakeup can take a second or more.

Selecting this state during opportunistic CPU idle can therefore cause substantial wakeup delays and repeatedly interrupt SAIL operation whenever the CPUs become idle.

The idle state latency times define that. No need for a new property.

And honestly, you already got similar review, which you just ignored.

Keep sending the same, while ignoring review, till it gets accepted -> NAK

Best regards,
Krzysztof

#6 lore raw

Re: [PATCH v2 1/3] dt-bindings: power: domain-idle-state: Add system-state

In reply to Krzysztof Kozlowski
Quoted 12 lines · Krzysztof Kozlowski
Quoted 10 lines · Maulik Shah
Quoted 6 lines · Krzysztof Kozlowski
Quoted 2 lines · Maulik Shah

Some domain idle states require system-wide coordination and are not applicable while the platform is up and running.

You repeated the property description. Say something more. Why they are not applicable when platform is running? So if not running, when are they applicable? Why?

Quoted 8 lines
Quoted 6 lines

On certain platforms CPU subsystem deepest idle state requires co-ordination with SAIL subsystem such that both must be powered down in coordinated sequence. During wakeup SAIL subsystem must be powered up before CPU can resume. The wakeup can take a second or more.

Selecting this state during opportunistic CPU idle can therefore cause substantial wakeup delays and repeatedly interrupt SAIL operation whenever the CPUs become idle.

The idle state latency times define that. No need for a new property.

Unfortunately they don't. The extended coordination that is needed in the FW to reach these states has nothing to do with latency.

We simply can't reach these states unless the entire system becomes suspended. From the PSCI point of view this can be compared with the PSCI SYSTEM SUSPEND call, that we use for suspend-to-ram.

If a "system state" would be voted for from cpuidle in runtime and when using PSCI OSI mode, the FW would always return an error code. In PSCI PC mode, the FW would typically downgrade the vote and pick a shallower state.

In regards to ACPI, this can be compared with the S-states.

Please have a look at the discussion [1] I had with Sudeep around this to get more details.

That said, I will work with Maulik to clarify this. Seems like we could improve the commit message and the description of the property a bit more.

Kind regards
Uffe

[1]
https://lore.kernel.org/all/[email protected]/

#7 lore raw

PATCH v2 2/3 pmdomain: Add support for system-suspend-only states

In reply to Maulik Shah

Some domain idle states require system-wide coordination and should not be selected during regular CPU idle. However those states remain valid for system-wide suspend like s2idle.

Add a per-state system_state boolean and populate it from the system-state property. Make the genpd governor skip these states during CPU idle. Leave the system wide suspend path unchanged so s2idle can select them.

---
 drivers/pmdomain/core.c     | 2 ++
 drivers/pmdomain/governor.c | 6 ++++++
 include/linux/pm_domain.h   | 1 +
 3 files changed, 9 insertions(+)
drivers/pmdomain/core.c +2 -0
index 964e44c2f78f..288c0deb2340 100644
@@ -3701,6 +3701,8 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state,
 	if (!err)
 		genpd_state->residency_ns = 1000LL * residency;
 
+	genpd_state->system_state = of_property_read_bool(state_node, "system-state");
+
 	err = of_property_read_string(state_node, "idle-state-name",
 				      &genpd_state->name);
 	if (err)
drivers/pmdomain/governor.c +6 -0
index 38bba24ec26e..7684f9eecf85 100644
@@ -185,6 +185,9 @@ static bool __default_power_down_ok(struct dev_pm_domain *pd,
 	s64 min_off_time_ns;
 	s64 off_on_time_ns;
 
+	if (genpd->states[state].system_state)
+		return false;
+
 	off_on_time_ns = genpd->states[state].power_off_latency_ns +
 		genpd->states[state].power_on_latency_ns;
 
@@ -407,6 +410,9 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd)
 	 */
 	i = genpd->state_idx;
 	do {
+		if (genpd->states[i].system_state)
+			continue;
+
 		if ((idle_duration_ns >= (genpd->states[i].residency_ns +
 		    genpd->states[i].power_off_latency_ns)) &&
 		    (global_constraint >= (genpd->states[i].power_on_latency_ns +
include/linux/pm_domain.h +1 -0
index 14e0e346c610..d9b3e67042e5 100644
@@ -188,6 +188,7 @@ struct genpd_power_state {
 	s64 power_off_latency_ns;
 	s64 power_on_latency_ns;
 	s64 residency_ns;
+	bool system_state;
 	u64 usage;
 	u64 rejected;
 	u64 above;
Signature · 1 line
2.43.0
#8 lore raw

Re: [PATCH v2 2/3] pmdomain: Add support for system-suspend-only states

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] pmdomain: unfiltered system_state in genpd_reflect_residency() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] pmdomain: unfiltered system_state in genpd_reflect_residency()
--

commit 1997c1201917b38c7d4bd3614225f7a62b53a68b
Author: Maulik Shah <[email protected]>

pmdomain: Add support for system-suspend-only states

This commit adds a system_state boolean to struct genpd_power_state, populated from the "system-state" DT property, so the genpd governor skips system-suspend-only states during regular CPU and runtime idle while keeping them selectable during system-wide suspend.

Quoted 4 lines
drivers/pmdomain/governor.c +0 -0
index 38bba24ec26e3..7684f9eecf853 100644

[ ... ]

drivers/pmdomain/governor.c static bool cpu_power_down_ok(struct dev_pm_domain *pd) · line 418

Quoted 10 lines
drivers/pmdomain/governor.c +3 -0
@@ -407,6 +410,9 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd)
 	 */
 	i = genpd->state_idx;
 	do {
+		if (genpd->states[i].system_state)
+			continue;
+
 		if ((idle_duration_ns >= (genpd->states[i].residency_ns +
 		    genpd->states[i].power_off_latency_ns)) &&
 		    (global_constraint >= (genpd->states[i].power_on_latency_ns +

[Severity: Medium]
Should genpd_reflect_residency() also skip next_state when next_state->system_state is set?

When cpu_power_down_ok() skips a system_state idle state and selects a shallower state, it sets genpd->gd->reflect_residency = true. On wakeup, genpd_power_on() calls genpd_reflect_residency(), which checks the next deeper state unconditionally:

drivers/pmdomain/core.c:genpd_reflect_residency() {
    ...
	} else if (state_idx < (genpd->state_count -1)) {
		next_state = &genpd->states[state_idx + 1];
		target_ns = next_state->power_off_latency_ns +
			next_state->residency_ns;

		if (sleep_ns >= target_ns)
			state->below++;
	}
    ...
}

If genpd->states[state_idx + 1] has system_state set, it is not eligible for regular CPU idle, yet any CPU idle sleep reaching its target_ns will falsely increment state->below in the debugfs idle_states statistics.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#9 lore raw

PATCH v2 3/3 arm64: dts: qcom: monaco-evk: Add suspend-only power collapse state

In reply to Maulik Shah

To achieve SoC low power mode like chip rail power collapse (CxPC), the Monaco EVK board with four PMICs requires coordinated power-down of CPUSS and the Safety Island (SAIL) subsystem. This deepest system power collapse state is reserved for system-wide suspend (s2idle).

Only the Monaco EVK with four PMICs supports this deepest state. The Monaco AC EVK described by monaco-ac-evk.dts has two PMICs and does not support powering down SAIL. Define the state in monaco-evk.dts instead of the shared monaco.dtsi so it is only available on the supported board.

Add the system_suspend domain idle state, mark it with system-state, and reference it from the system power domain.

---
 arch/arm64/boot/dts/qcom/monaco-evk.dts | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm64/boot/dts/qcom/monaco-evk.dts +17 -0
index 539c9c80a808..5e6206bcc97f 100644
@@ -80,6 +80,19 @@ m2_e_uart_ep: endpoint@0 {
 		};
 	};
 
+	cpus {
+		domain-idle-states {
+			system_suspend: domain-suspend {
+				compatible = "domain-idle-state";
+				arm,psci-suspend-param = <0x4200c344>;
+				entry-latency-us = <706562>;
+				exit-latency-us = <706562>;
+				min-residency-us = <1414124>;
+				system-state;
+			};
+		};
+	};
+
 	dmic: audio-codec-0 {
 		compatible = "dmic-codec";
 		#sound-dai-cells = <0>;
@@ -772,6 +785,10 @@ tpm@0 {
 	};
 };
 
+&system_pd {
+	domain-idle-states = <&system_sleep>, <&system_suspend>;
+};
+
 &tlmm {
 	pcie0_default_state: pcie0-default-state {
 		wake-pins {
Signature · 1 line
2.43.0