From 33314eb60acc23e4a98c9f037631b6f35513d511 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 23 Jul 2020 08:42:59 +0200 Subject: bsps/clock: Fix fast idle clock tick support If we interrupt a thread dispatch critical section (thread dispatch disable level != ISR nest level), then we should not do the fast idle mode since this may delay an ongoing system call forever. --- bsps/shared/dev/clock/clockimpl.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'bsps/shared/dev/clock') diff --git a/bsps/shared/dev/clock/clockimpl.h b/bsps/shared/dev/clock/clockimpl.h index f3b2565c56..dad71307f4 100644 --- a/bsps/shared/dev/clock/clockimpl.h +++ b/bsps/shared/dev/clock/clockimpl.h @@ -143,16 +143,23 @@ rtems_isr Clock_isr( #if CLOCK_DRIVER_USE_FAST_IDLE { - struct timecounter *tc = _Timecounter; - uint64_t us_per_tick = rtems_configuration_get_microseconds_per_tick(); - uint32_t interval = (uint32_t) - ((tc->tc_frequency * us_per_tick) / 1000000); - Clock_driver_timecounter_tick(); if (_SMP_Get_processor_maximum() == 1) { + struct timecounter *tc; + uint64_t us_per_tick; + uint32_t interval; + Per_CPU_Control *cpu_self; + + cpu_self = _Per_CPU_Get(); + tc = _Timecounter; + us_per_tick = rtems_configuration_get_microseconds_per_tick(); + interval = (uint32_t) ((tc->tc_frequency * us_per_tick) / 1000000); + while ( - _Thread_Heir == _Thread_Executing && _Thread_Executing->is_idle + cpu_self->thread_dispatch_disable_level == cpu_self->isr_nest_level + && cpu_self->heir == cpu_self->executing + && cpu_self->executing->is_idle ) { ISR_lock_Context lock_context; -- cgit v1.2.3