-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: idle: introduce idle enter/exit hooks
To allow for custom SoC idle/sleep/pm behavior in a scalable manner, introduce hooks for implementing idle enter and idle exit (post idle enter) behavior. The current idle thread implementation is moved to "default" enter and exit hooks, selected by the same criteria as the existing ifdefs, but with the selection logic moved to Kconfig to ensure non conflicting hook implementations. With these hooks, default behavior should be unchanged. SoCs can now select the Kconfig option IDLE_ENTER_HOOK_CUSTOM and IDLE_EXIT_HOOK_CUSTOM and implement the hooks. Next step will be to move these "default" hooks to their respective owners if possible, like moving the PM hook to the PM subsystem. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
- Loading branch information
1 parent
5aeda6f
commit f74d2f2
Showing
4 changed files
with
163 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1078,3 +1078,4 @@ endmenu | |
rsource "Kconfig.device" | ||
rsource "Kconfig.vm" | ||
rsource "Kconfig.init" | ||
rsource "Kconfig.idle" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright (c) 2025 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
menu "Kernel idle options" | ||
|
||
choice IDLE_ENTER_HOOK | ||
prompt "Idle enter hook implementation" | ||
help | ||
The implementation of the optional idle_enter_hook() | ||
hook executed when idle thread is entered. | ||
default IDLE_ENTER_HOOK_PM | ||
default IDLE_ENTER_HOOK_LOOP | ||
default IDLE_ENTER_HOOK_CPU_IDLE | ||
|
||
config IDLE_ENTER_HOOK_CUSTOM | ||
bool "Custom idle enter hook implementation" | ||
|
||
config IDLE_ENTER_HOOK_LOOP | ||
bool "Relaxed loop idle enter hook implementation" | ||
depends on SMP | ||
depends on !SCHED_IPI_SUPPORTED | ||
|
||
config IDLE_ENTER_HOOK_CPU_IDLE | ||
bool "CPU idle idle enter hook implementation" | ||
|
||
config IDLE_ENTER_HOOK_PM | ||
bool "PM idle enter hook implementation" | ||
depends on PM | ||
|
||
endchoice # IDLE_ENTER_HOOK | ||
|
||
choice IDLE_EXIT_HOOK | ||
prompt "Idle exit hook implementation" | ||
depends on IDLE_ENTER_HOOK | ||
help | ||
The implementation of the optional idle_exit_hook() | ||
hook executed after idle_enter_hook() returns. | ||
default IDLE_EXIT_HOOK_YIELD | ||
|
||
config IDLE_EXIT_HOOK_CUSTOM | ||
bool "Custom idle exit hook implementation" | ||
help | ||
SoC will implement idle_exit_hook() | ||
|
||
config IDLE_EXIT_HOOK_YIELD | ||
bool "Yield idle exit hook implementation" | ||
depends on !PREEMPT_ENABLED | ||
depends on !USE_SWITCH || SPARC | ||
|
||
endchoice # IDLE_EXIT_HOOK | ||
|
||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters