From 32d275ee42c15ca61e174aabb2b46ccc90a1fcb9 Mon Sep 17 00:00:00 2001 From: Leifu Zhao Date: Tue, 22 Aug 2023 16:42:51 +0800 Subject: [PATCH] subsys: pm: add check for device busy in policy Add check for device busy when CONFIG_PM_NEED_ALL_DEVICES_IDLE is set to y because one or more devices may still in busy and causes problem when system go into low power in Intel ISH platform. Signed-off-by: Leifu Zhao --- soc/x86/intel_ish/intel_ish5/pm/Kconfig.pm | 3 +++ subsys/pm/Kconfig | 8 ++++++++ subsys/pm/policy.c | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/soc/x86/intel_ish/intel_ish5/pm/Kconfig.pm b/soc/x86/intel_ish/intel_ish5/pm/Kconfig.pm index d4decc82f7d3ae7..d50e435c13e3664 100644 --- a/soc/x86/intel_ish/intel_ish5/pm/Kconfig.pm +++ b/soc/x86/intel_ish/intel_ish5/pm/Kconfig.pm @@ -18,4 +18,7 @@ config GDT_RESERVED_NUM_ENTRIES config REBOOT default y +config PM_NEED_ALL_DEVICES_IDLE + default y + endif diff --git a/subsys/pm/Kconfig b/subsys/pm/Kconfig index 36535e383a10a6b..78f2269c9139af0 100644 --- a/subsys/pm/Kconfig +++ b/subsys/pm/Kconfig @@ -37,6 +37,14 @@ config PM_S2RAM help This option enables suspend-to-RAM (S2RAM). +config PM_NEED_ALL_DEVICES_IDLE + bool "System Low Power Mode Needs All Devices Idle" + depends on PM_DEVICE && !SMP + default n + help + This option enables checking no device is busy before enter into + system low power mode. + choice PM_POLICY prompt "Idle State Power Management Policy" default PM_POLICY_DEFAULT diff --git a/subsys/pm/policy.c b/subsys/pm/policy.c index 4c3012db2cc7c4e..fa44a7069f73c4f 100644 --- a/subsys/pm/policy.c +++ b/subsys/pm/policy.c @@ -14,6 +14,7 @@ #include #include #include +#include #if DT_HAS_COMPAT_STATUS_OKAY(zephyr_power_state) @@ -136,6 +137,12 @@ const struct pm_state_info *pm_policy_next_state(uint8_t cpu, int32_t ticks) uint8_t num_cpu_states; const struct pm_state_info *cpu_states; +#ifdef CONFIG_PM_NEED_ALL_DEVICES_IDLE + if (pm_device_is_any_busy()) { + return NULL; + } +#endif + if (ticks != K_TICKS_FOREVER) { cyc = k_ticks_to_cyc_ceil32(ticks); }