-
Notifications
You must be signed in to change notification settings - Fork 8.4k
PM Policy Event: Update to use uptime ticks and be "sticky" #80580
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
PM Policy Event: Update to use uptime ticks and be "sticky" #80580
Conversation
679679c to
6e379e7
Compare
|
ping @ceolin |
ceolin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me. It is easier to read too.
include/zephyr/pm/policy.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it also valid to call pm_policy_event_update instead of unregister/register, or is that only allowed before the event time has passed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is also valid to call pm_policy_event_update instead of unregister/register :) I will update the desc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to:
* CPU is woken up before the time passed in cycle to minimize event handling
* latency. Once woken up, the CPU will be kept awake until the event has been
* handled, which is signaled by pm_policy_event_unregister() or moving event
* into the future using pm_policy_event_update().
include/zephyr/pm/policy.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify that if there is an unregistered past event, this function returns zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to:
/**
* @brief Returns the ticks until the next event
*
* If an event is registred, it will return the number of ticks until the next event, if the
* "next"/"oldest" registered event is in the past, it will return 0. Otherwise it returns -1.
*
* @retval >0 If next registered event is in the future
* @retval 0 If next registered event is now or in the past
* @retval -1 Otherwise
*/
6e379e7 to
8b3f619
Compare
Update events to use uptime ticks, which is a monotonic clock which in the same res as kernel ticks. This makes comparisons simple and removes the complexity of dealing with wrapping counter values. The wrapping is particularly problematic for events since this makes it quite complex to track if an event has occured in the past, or will occur in the future. This info is needed to know if an event has actually been handled or not. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
8b3f619 to
18f3e8f
Compare
Registering a pm policy event will now represent a single event in absolute time, which will remain active, preventing the system from suspending, until the event has been handled. To indicate an event has been handled, it must be updated to a time in the future, or unregistered.
To greatly simplify the events and the "sticky" logic, the time primitive used is updated to the monotonic uptime in ticks. This ensures an event can be determined to be in the past, since unlike the HW cycle, uptime can't wrap. Additionally, the kernel works in ticks, which aligns the resolution with the requirements of the kernel, and removes the need for conversions between pm and the kernel, see
pm_policy_next_event_ticks()before this PR.fixes: #80386