[PATCH rtems v2] bsps/arm: Fix uninitialized value in generic timer
Christian Mauderer
christian.mauderer at embedded-brains.de
Thu Apr 16 13:29:58 UTC 2020
_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 | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/bsps/arm/shared/clock/clock-generic-timer.c b/bsps/arm/shared/clock/clock-generic-timer.c
index 1f39632ba6..072583473e 100644
--- a/bsps/arm/shared/clock/clock-generic-timer.c
+++ b/bsps/arm/shared/clock/clock-generic-timer.c
@@ -148,7 +148,8 @@ static void arm_gt_clock_initialize(void)
uint64_t cval;
struct timecounter *tc;
- frequency = arm_gt_clock_instance.interval;
+ tc = &arm_gt_clock_instance.tc;
+ frequency = tc->tc_frequency;
us_per_tick = rtems_configuration_get_microseconds_per_tick();
interval = (uint32_t) ((frequency * us_per_tick) / 1000000);
cval = arm_gt_clock_get_count();
@@ -158,10 +159,8 @@ static void arm_gt_clock_initialize(void)
arm_gt_clock_gt_init(cval);
arm_gt_clock_secondary_initialization(cval);
- 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.
+ */
+ arm_gt_clock_instance.tc.tc_frequency = frequency;
}
RTEMS_SYSINIT_ITEM(
--
2.16.4
More information about the devel
mailing list