-
Notifications
You must be signed in to change notification settings - Fork 7.6k
drivers: timer: nrf_grtc_timer: add last_count initialization #91432
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
drivers: timer: nrf_grtc_timer: add last_count initialization #91432
Conversation
drivers/timer/nrf_grtc_timer.c
Outdated
@@ -485,6 +485,7 @@ static int sys_clock_driver_init(void) | |||
} | |||
#endif /* CONFIG_NRF_GRTC_START_SYSCOUNTER */ | |||
|
|||
last_count = counter(); |
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.
shouldn't be wrapped in Kconfig-equivalent of NRFX_GRTC_CLEAR_AT_INIT
? or this feature is not configurable via Kconfig ?
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.
There is another PR for that: #89664
ad3f2da
ad3f2da
to
86c221f
Compare
drivers/timer/nrf_grtc_timer.c
Outdated
last_count = sys_clock_tick_get() * CYC_PER_TICK; | ||
grtc_start_value = last_count; |
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 there a potential race between here and sys_clock_timeout_handler
for last_count
?
If that is not the case and sys_clock_announce
is not expected to be called at this point, could this code be simplified and skip sys_clock_tick_get
logic to just call counter()
?
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's definitely better to use counter()
here to initialize both these variables than to involve sys_clock_tick_get()
(calling this function from the system timer driver doesn't actually seem to be appropriate).
The GRTC counter is not cleared at startup, therefore the `last_count` variable needs to be initialized accordingly. This change: - Prevents overflow of the `sys_clock_announce()` int32_t parameter - Ensures the correct uptime value, which should be reset during initialization Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
Update GRTC tests to reflect uptime reset at startup. Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
86c221f
to
6248aac
Compare
|
The GRTC counter is not cleared at startup, therefore the
last_count
variable needs to be initialized accordingly. This change:sys_clock_announce()
int32_t parameterFixes nRF54L: uptime does not reset across reboots #89147