[PATCH rtems] bsps/arm: Fix uninitialized value in generic timer
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Apr 16 12:29:57 UTC 2020
On 16/04/2020 14:21, Christian Mauderer wrote:
> _CPU_Counter_frequency() can be called by the rtems_counter
> initialization before arm_gt_clock_initialize() initializes the value
> used in _CPU_Counter_frequency().
>
> Update #3456.
> ---
> bsps/arm/shared/clock/clock-generic-timer.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/bsps/arm/shared/clock/clock-generic-timer.c b/bsps/arm/shared/clock/clock-generic-timer.c
> index 1f39632ba6..a0efb9c7ed 100644
> --- a/bsps/arm/shared/clock/clock-generic-timer.c
> +++ b/bsps/arm/shared/clock/clock-generic-timer.c
> @@ -161,7 +161,6 @@ static void arm_gt_clock_initialize(void)
> tc = &arm_gt_clock_instance.tc;
> tc->tc_get_timecount = arm_gt_clock_get_timecount;
> tc->tc_counter_mask = 0xffffffff;
> - tc->tc_frequency = frequency;
> tc->tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
> rtems_timecounter_install(tc);
> }
> @@ -178,12 +177,19 @@ CPU_Counter_ticks _CPU_Counter_read(void)
>
> static void arm_gt_clock_early_init(void)
> {
> + uint32_t frequency;
> arm_gt_clock_set_control(0x3);
>
> arm_generic_timer_get_config(
> - &arm_gt_clock_instance.interval,
> + &frequency,
> &arm_gt_clock_instance.irq
> );
> +
> + /* Used by _CPU_Counter_frequency before arm_gt_clock_initialize is called */
Please use func() in the comments.
> + arm_gt_clock_instance.tc.tc_frequency = frequency;
> +
> + /* overwritten with the calculated interval by arm_gt_clock_initialize */
> + arm_gt_clock_instance.interval = frequency;
I would remove this assignment here and read the frequency in
arm_gt_clock_initialize() like this:
tc = &arm_gt_clock_instance.tc;
frequency = (uint32_t) tc->tc_frequency;
> }
>
> RTEMS_SYSINIT_ITEM(
More information about the devel
mailing list