Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MTL-006] kernel: idle: clock switch refactor #70

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions kernel/idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <zephyr/drivers/timer/system_timer.h>
#include <zephyr/wait_q.h>
#include <zephyr/pm/pm.h>
#include <zephyr/pm/policy.h>
#include <stdbool.h>
#include <zephyr/logging/log.h>
#include <ksched.h>
Expand Down Expand Up @@ -65,12 +66,6 @@ void idle(void *unused1, void *unused2, void *unused3)

#ifdef CONFIG_PM
_kernel.idle = z_get_next_timeout_expiry();
#if CONFIG_SOC_SERIES_INTEL_ACE
(void)atomic_inc(&_cpus_idleing);
if (_cpus_idleing == _cpus_active)
adsp_clock_idle_entry();
#endif

/*
* Call the suspend hook function of the soc interface
* to allow entry into a low power state. The function
Expand All @@ -87,14 +82,16 @@ void idle(void *unused1, void *unused2, void *unused3)
* logic.
*/
if (k_is_pre_kernel() || !pm_system_suspend(_kernel.idle)) {
#if CONFIG_SOC_SERIES_INTEL_ACE
pm_policy_state_lock_put(PM_STATE_ACTIVE, 1);
adsp_clock_idle_entry();
#endif
k_cpu_idle();
}
#if CONFIG_SOC_SERIES_INTEL_ACE
if (_cpus_idleing == _cpus_active)
pm_policy_state_lock_get(PM_STATE_ACTIVE, 1);
adsp_clock_idle_exit();

(void)atomic_dec(&_cpus_idleing);
#endif
}
#else
k_cpu_idle();
#endif
Expand Down
3 changes: 0 additions & 3 deletions kernel/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ struct z_kernel _kernel;
__pinned_bss
atomic_t _cpus_active;

__pinned_bss
atomic_t _cpus_idleing;

/* init/main and idle threads */
K_THREAD_PINNED_STACK_DEFINE(z_main_stack, CONFIG_MAIN_STACK_SIZE);
struct k_thread z_main_thread;
Expand Down
2 changes: 0 additions & 2 deletions soc/xtensa/intel_adsp/ace/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ void pm_state_set(enum pm_state state, uint8_t substate_id)
/* save interrupt state and turn off all interrupts */
core_desc[cpu].intenable = XTENSA_RSR("INTENABLE");
z_xt_ints_off(0xffffffff);
(void)atomic_dec(&_cpus_idleing);

if (state == PM_STATE_SOFT_OFF) {
core_desc[cpu].bctl = DSPCS.bootctl[cpu].bctl;
Expand Down Expand Up @@ -369,7 +368,6 @@ void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
__ASSERT(false, "invalid argument - unsupported power state");
}

(void)atomic_inc(&_cpus_idleing);
z_xt_ints_on(core_desc[cpu].intenable);
}

Expand Down
Loading