Skip to content
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

Fix ta_wakes_up_on_or_before #2190

Merged
merged 2 commits into from
Jan 20, 2025

Conversation

peterharperuk
Copy link
Contributor

@peterharperuk peterharperuk commented Jan 17, 2025

Handle target in the past and running for > 2^32 us.

Fixes #2186

@kilograham
Copy link
Contributor

Hmm; i think the bug lies elsewhere...

does this help?

static inline bool ta_wakes_up_on_or_before(alarm_pool_timer_t *timer, uint alarm_num, int64_t target) {
    int64_t current = (int64_t)timer_time_us_64(timer_hw_from_timer(timer));
    int64_t time_til_target = target - current;
    uint32_t time_til_alarm = timer_hw_from_timer(timer)->alarm[alarm_num] - (uint32_t)current;
    return time_til_alarm <= time_til_target;
}

(it also should fix another fairly glaring error if you'd been running for > 2^32 us

@peterharperuk
Copy link
Contributor Author

@kilograham Your fix seems to work. I think my analysis was wrong? It was actually seems stuck on WFE? I'll use your fix instead.

Handle target in the past and running for > 2^32 us.

Fixes raspberrypi#2186
@peterharperuk peterharperuk changed the title async_context_poll can wait too long Fix ta_wakes_up_on_or_before Jan 20, 2025
@kilograham kilograham merged commit b8dc8c4 into raspberrypi:develop Jan 20, 2025
4 checks passed
@kilograham kilograham added this to the 2.1.1 milestone Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants