Skip to content

Commit

Permalink
pm: policy: add check for device busy in policy
Browse files Browse the repository at this point in the history
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 <leifu.zhao@intel.com>
  • Loading branch information
leifuzhao authored and nashif committed Sep 15, 2023
1 parent c0bf310 commit 61ab3a8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions soc/x86/intel_ish/intel_ish5/pm/Kconfig.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ config GDT_RESERVED_NUM_ENTRIES
config REBOOT
default y

config PM_NEED_ALL_DEVICES_IDLE
default y

endif
7 changes: 7 additions & 0 deletions subsys/pm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ 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
help
When this option is enabled, check that no devices are busy before
entering into system low power mode.

choice PM_POLICY
prompt "Idle State Power Management Policy"
default PM_POLICY_DEFAULT
Expand Down
7 changes: 7 additions & 0 deletions subsys/pm/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <zephyr/sys/time_units.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/toolchain.h>
#include <zephyr/pm/device.h>

#if DT_HAS_COMPAT_STATUS_OKAY(zephyr_power_state)

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 61ab3a8

Please sign in to comment.