Skip to content

[nrf fromlist] drivers: timer: nrf_grtc: Fix for optimization #3059

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

Merged
merged 2 commits into from
Jul 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions drivers/timer/nrf_grtc_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,6 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
{
ARG_UNUSED(idle);

if (ticks == 0) {
return;
}

if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL)) {
return;
}
Expand All @@ -562,6 +558,15 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
if ((cc_value == expired_cc) && (ticks < MAX_REL_TICKS)) {
uint32_t cyc = ticks * CYC_PER_TICK;

if (cyc == 0) {
/* GRTC will expire anyway since HW ensures that past value triggers an
* event but we need to ensure to always progress the cc_value as this
* if condition expects that cc_value will change after each call to
* set_timeout function.
*/
cyc = 1;
}

/* If it's the first timeout setting after previous expiration and timeout
* is short so fast method can be used which utilizes relative CC configuration.
*/
Expand Down