Skip to content

arm_arch_timer: Move timer enablement after comparison value set #93692

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

khayash1
Copy link
Contributor

The timer is enabled before comparison value is set, which can lead to unexpected behavior if the registers contain uninitialized values.

Should call arm_arch_timer_enable() after arm_arch_timer_set_compare().

The function calling order in sys_clock_driver_init() is as follows (unsafe):

arm_arch_timer_enable(true)
arm_arch_timer_set_compare()
irq_enable()

On the other hand, in smp_timer_init() (safe):

arm_arch_timer_set_compare()
arm_arch_timer_enable(true)
irq_enable()

… set

The timer is enabled before comparison value is set, which can lead to
unexpected behavior if the registers contain uninitialized values.

Should call arm_arch_timer_enable() after arm_arch_timer_set_compare().

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
@zephyrbot zephyrbot added area: Timer Timer size: XS A PR changing only a single line of code labels Jul 25, 2025
@zephyrbot zephyrbot requested review from andyross and teburd July 25, 2025 00:54
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Timer Timer size: XS A PR changing only a single line of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants