[PATCH] bsps/clock: Fix fast idle mode

Gedare Bloom gedare at rtems.org
Mon Jan 22 16:52:20 UTC 2024


On Tue, Jan 16, 2024 at 8:44 AM Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
>
> Switch back to the idle thread if no watchdogs are active.  In some tests, the
> idle thread may do some non-blocking work.
> ---
>  bsps/shared/dev/clock/clockimpl.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/bsps/shared/dev/clock/clockimpl.h b/bsps/shared/dev/clock/clockimpl.h
> index e922c0b320..ec56e175f5 100644
> --- a/bsps/shared/dev/clock/clockimpl.h
> +++ b/bsps/shared/dev/clock/clockimpl.h
> @@ -139,6 +139,21 @@ volatile uint32_t    Clock_driver_ticks;
>  #error "Clock_driver_support_shutdown_hardware() is no longer supported"
>  #endif
>
> +#if CLOCK_DRIVER_USE_FAST_IDLE
> +static bool Clock_Has_watchdogs(const Per_CPU_Control *cpu)
> +{

nit: if this cannot be overridden by BSPs and is purely internal to
this header file implementation, it should not use "Clock_"

> +  size_t i;
> +
> +  for (i = 0; i < RTEMS_ARRAY_SIZE(cpu->Watchdog.Header); ++i) {
> +    if (_Watchdog_Header_first(&cpu->Watchdog.Header[i]) != NULL) {
> +      return true;
> +    }
> +  }
> +
> +  return false;
> +}
> +#endif
> +
>  /**
>   *  @brief Clock_isr
>   *
> @@ -182,6 +197,7 @@ rtems_isr Clock_isr(
>            cpu_self->thread_dispatch_disable_level == cpu_self->isr_nest_level
>              && cpu_self->heir == cpu_self->executing
>              && cpu_self->executing->is_idle
> +            && Clock_Has_watchdogs(cpu_self)
>          ) {
>            ISR_lock_Context lock_context;
>
> --
> 2.35.3
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list