From 4d85f3d91cb9e37d52e770fbf266e110aa90c296 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Tue, 30 Apr 2024 16:45:49 -0700 Subject: [PATCH] pm: Deprecate z_pm_save_idle_exit Deprecate z_pm_save_idle_exit and promote pm_system_resume. Signed-off-by: Flavio Ceolin --- arch/arm/core/cortex_a_r/irq_manage.c | 2 +- arch/arm/core/cortex_m/irq_manage.c | 2 +- arch/arm/core/cortex_m/isr_wrapper.c | 4 ++-- arch/posix/core/swap.c | 2 +- include/zephyr/arch/x86/ia32/arch.h | 2 +- include/zephyr/pm/pm.h | 27 ++++++++++++++++++++++++++- kernel/include/kernel_internal.h | 20 -------------------- 7 files changed, 32 insertions(+), 27 deletions(-) diff --git a/arch/arm/core/cortex_a_r/irq_manage.c b/arch/arm/core/cortex_a_r/irq_manage.c index a381fad2a48..1dca75e297a 100644 --- a/arch/arm/core/cortex_a_r/irq_manage.c +++ b/arch/arm/core/cortex_a_r/irq_manage.c @@ -98,7 +98,7 @@ void _arch_isr_direct_pm(void) if (_kernel.idle) { _kernel.idle = 0; - z_pm_save_idle_exit(); + pm_system_resume(); } irq_unlock(key); diff --git a/arch/arm/core/cortex_m/irq_manage.c b/arch/arm/core/cortex_m/irq_manage.c index 3940d5246d4..b72332b32e8 100644 --- a/arch/arm/core/cortex_m/irq_manage.c +++ b/arch/arm/core/cortex_m/irq_manage.c @@ -131,7 +131,7 @@ void _arch_isr_direct_pm(void) if (_kernel.idle) { _kernel.idle = 0; - z_pm_save_idle_exit(); + pm_system_resume(); } #if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) diff --git a/arch/arm/core/cortex_m/isr_wrapper.c b/arch/arm/core/cortex_m/isr_wrapper.c index 6e6016508c6..46aac160c3b 100644 --- a/arch/arm/core/cortex_m/isr_wrapper.c +++ b/arch/arm/core/cortex_m/isr_wrapper.c @@ -42,7 +42,7 @@ void _isr_wrapper(void) * idle, this ensures that the calculation and programming of the * device for the next timer deadline is not interrupted. For * non-tickless idle, this ensures that the clearing of the kernel idle - * state is not interrupted. In each case, z_pm_save_idle_exit + * state is not interrupted. In each case, pm_system_resume * is called with interrupts disabled. */ @@ -59,7 +59,7 @@ void _isr_wrapper(void) if (_kernel.idle != 0) { /* clear kernel idle state */ _kernel.idle = 0; - z_pm_save_idle_exit(); + pm_system_resume(); } /* re-enable interrupts */ __enable_irq(); diff --git a/arch/posix/core/swap.c b/arch/posix/core/swap.c index 67ca4c5bb9b..d4ec5e50b5e 100644 --- a/arch/posix/core/swap.c +++ b/arch/posix/core/swap.c @@ -112,7 +112,7 @@ void posix_irq_check_idle_exit(void) { if (_kernel.idle) { _kernel.idle = 0; - z_pm_save_idle_exit(); + pm_system_resume(); } } #endif diff --git a/include/zephyr/arch/x86/ia32/arch.h b/include/zephyr/arch/x86/ia32/arch.h index e39e6c0cd65..490dfdb40f3 100644 --- a/include/zephyr/arch/x86/ia32/arch.h +++ b/include/zephyr/arch/x86/ia32/arch.h @@ -250,7 +250,7 @@ static inline void arch_irq_direct_pm(void) { if (_kernel.idle) { _kernel.idle = 0; - z_pm_save_idle_exit(); + pm_system_resume(); } } diff --git a/include/zephyr/pm/pm.h b/include/zephyr/pm/pm.h index 5c552947221..e1fb695415c 100644 --- a/include/zephyr/pm/pm.h +++ b/include/zephyr/pm/pm.h @@ -116,8 +116,28 @@ int pm_notifier_unregister(struct pm_notifier *notifier); */ const struct pm_state_info *pm_state_next_get(uint8_t cpu); +/** + * @brief Notify exit from kernel sleep. + * + * This function would notify exit from kernel idling if a corresponding + * pm_system_suspend() notification was handled and did not return + * PM_STATE_ACTIVE. + * + * This function should be called from the ISR context of the event + * that caused the exit from kernel idling. + * + * This is required for cpu power states that would require + * interrupts to be enabled while entering low power states. e.g. C1 in x86. In + * those cases, the ISR would be invoked immediately after the event wakes up + * the CPU, before code following the CPU wait, gets a chance to execute. This + * can be ignored if no operation needs to be done at the wake event + * notification. + */ +void pm_system_resume(void); + + /** @cond INTERNAL_HIDDEN */ -void z_pm_save_idle_exit(void); +__deprecated void z_pm_save_idle_exit(void); /** @endcond */ /** @@ -182,6 +202,11 @@ static inline const struct pm_state_info *pm_state_next_get(uint8_t cpu) static inline void z_pm_save_idle_exit(void) { } + +static inline void pm_system_resume(void) +{ +} + #endif /* CONFIG_PM */ #ifdef __cplusplus diff --git a/kernel/include/kernel_internal.h b/kernel/include/kernel_internal.h index b2e1ccf7068..bb9ee4b01f1 100644 --- a/kernel/include/kernel_internal.h +++ b/kernel/include/kernel_internal.h @@ -243,26 +243,6 @@ void z_handle_obj_poll_events(sys_dlist_t *events, uint32_t state); */ bool pm_system_suspend(int32_t ticks); -/** - * Notify exit from kernel idling after PM operations - * - * This function would notify exit from kernel idling if a corresponding - * pm_system_suspend() notification was handled and did not return - * PM_STATE_ACTIVE. - * - * This function would be called from the ISR context of the event - * that caused the exit from kernel idling. This will be called immediately - * after interrupts are enabled. This is called to give a chance to do - * any operations before the kernel would switch tasks or processes nested - * interrupts. This is required for cpu low power states that would require - * interrupts to be enabled while entering low power states. e.g. C1 in x86. In - * those cases, the ISR would be invoked immediately after the event wakes up - * the CPU, before code following the CPU wait, gets a chance to execute. This - * can be ignored if no operation needs to be done at the wake event - * notification. - */ -void pm_system_resume(void); - #endif /* CONFIG_PM */ #ifdef CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM