-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
power: subsystem: Application hangs when logging is enabled after entering deep sleep #23274
Comments
if enabled CONFIG_KERNEL_DEBUG, it will use printk to output debug message. But for your test case, you also enable logging system with CONFIG_LOG=y, I think we should use same mechanism to do the output, so could you please try below patch with latest commit, and I test it locally, there is no hang like the description.
|
@wentongwu are you saying that the problem is due to wrong combination of debug options in KConfig? I will try the PR |
@albertofloyd yes, please try it, thanks. |
z_power_soc_deep_sleep() is called with interrupt locked already so restoring BASEPRI is pointless here, as it would only allow exceptions afterwards. The situation is complicated by the fact that kernel/idle.c:idle() only locks interrupt without unlocking which means the BASEBRI at entry of z_power_soc_deep_sleep() is already set to allow exceptions only but not lower priority interrupts like timer. So when, e.g. timer, interrupt fires, the SoC would come out of deep sleep but the waking interrupts are never delivered since they are masked, and idle() will try to sleep again. And now it gets into a loop of going into deep sleep briefly and waking up immediately and it goes on and on. The solution is not to restore BASEPRI and simply leave it at zero. This is a workaround as a proper fix would involve invasion changes to the PM subsystem. Also, _sys_pm_power_state_exit_post_ops() is not being called when deep sleep is involved, so PRIMASK needs to be reset after coming out of deep sleep. Fixes zephyrproject-rtos#23274 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
z_power_soc_deep_sleep() is called with interrupt locked already so restoring BASEPRI is pointless here, as it would only allow exceptions afterwards. The situation is complicated by the fact that kernel/idle.c:idle() only locks interrupt without unlocking which means the BASEBRI at entry of z_power_soc_deep_sleep() is already set to allow exceptions only but not lower priority interrupts like timer. So when, e.g. timer, interrupt fires, the SoC would come out of deep sleep but the waking interrupts are never delivered since they are masked, and idle() will try to sleep again. And now it gets into a loop of going into deep sleep briefly and waking up immediately and it goes on and on. The solution is not to restore BASEPRI and simply leave it at zero. This is a workaround as a proper fix would involve invasion changes to the PM subsystem. Also, _sys_pm_power_state_exit_post_ops() is not being called when deep sleep is involved, so PRIMASK needs to be reset after coming out of deep sleep. Fixes #23274 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
z_power_soc_deep_sleep() is called with interrupt locked already so restoring BASEPRI is pointless here, as it would only allow exceptions afterwards. The situation is complicated by the fact that kernel/idle.c:idle() only locks interrupt without unlocking which means the BASEBRI at entry of z_power_soc_deep_sleep() is already set to allow exceptions only but not lower priority interrupts like timer. So when, e.g. timer, interrupt fires, the SoC would come out of deep sleep but the waking interrupts are never delivered since they are masked, and idle() will try to sleep again. And now it gets into a loop of going into deep sleep briefly and waking up immediately and it goes on and on. The solution is not to restore BASEPRI and simply leave it at zero. This is a workaround as a proper fix would involve invasion changes to the PM subsystem. Also, _sys_pm_power_state_exit_post_ops() is not being called when deep sleep is involved, so PRIMASK needs to be reset after coming out of deep sleep. Fixes zephyrproject-rtos#23274 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
z_power_soc_deep_sleep() is called with interrupt locked already so restoring BASEPRI is pointless here, as it would only allow exceptions afterwards. The situation is complicated by the fact that kernel/idle.c:idle() only locks interrupt without unlocking which means the BASEBRI at entry of z_power_soc_deep_sleep() is already set to allow exceptions only but not lower priority interrupts like timer. So when, e.g. timer, interrupt fires, the SoC would come out of deep sleep but the waking interrupts are never delivered since they are masked, and idle() will try to sleep again. And now it gets into a loop of going into deep sleep briefly and waking up immediately and it goes on and on. The solution is not to restore BASEPRI and simply leave it at zero. This is a workaround as a proper fix would involve invasion changes to the PM subsystem. Also, _sys_pm_power_state_exit_post_ops() is not being called when deep sleep is involved, so PRIMASK needs to be reset after coming out of deep sleep. Fixes zephyrproject-rtos#23274 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
When logging is enabled and used in app that sleeps periodically for enough time to enter deep sleep (Sleep time higher than minimum residency)
After entering deep sleep the application thread never execute again which can be perceived as application hang.
Note: from kernel debug traces, deep sleep is exited but immediately re-entered, giving no opportunity for other threads to run.
Steps to reproduce the behavior:
"Wake from light sleep" will be seen,
"Wake from deep sleep" won't be seen
Expected behavior
Board test sleeps for different duration in a loop.
1st case app sleeps for 500 ms more than minimum light sleep residency.
2nd case app sleeps for 500 ms more than minimum deep sleep residency.
Note: Issue is not reproducible if logging is either completely disabled or not used in between k_sleep() during the test.
Impact
High cannot enable/use logging simultaneously with deep sleep.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: