arch/arm64: Optimize the initialization of the timer.

This commit optimized the initialization of the ARM generic timer for each cpu core.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
ouyangxiangzhen 2025-02-08 19:37:09 +08:00 committed by Xiang Xiao
parent c4a84e30b7
commit a121c059c4
13 changed files with 96 additions and 13 deletions

View file

@ -36,3 +36,8 @@ void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View file

@ -35,3 +35,7 @@ void up_timer_initialize(void)
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View file

@ -72,7 +72,6 @@ struct arm64_oneshot_lowerhalf_s
void *arg; /* Argument that is passed to the handler */
uint64_t cycle_per_tick; /* cycle per tick */
oneshot_callback_t callback; /* Internal handler that receives callback */
bool init[CONFIG_SMP_NCPUS]; /* True: timer is init */
/* which cpu timer is running, -1 indicate timer stoppd */
@ -274,18 +273,6 @@ static int arm64_tick_start(struct oneshot_lowerhalf_s *lower,
priv->callback = callback;
priv->arg = arg;
if (!priv->init[this_cpu()])
{
/* Enable int */
up_enable_irq(ARM_ARCH_TIMER_IRQ);
/* Start timer */
arm64_arch_timer_enable(true);
priv->init[this_cpu()] = true;
}
priv->running = this_cpu();
next_cycle =
@ -388,7 +375,31 @@ struct oneshot_lowerhalf_s *arm64_oneshot_initialize(void)
irq_attach(ARM_ARCH_TIMER_IRQ,
arm64_arch_timer_compare_isr, priv);
arm64_oneshot_secondary_init();
tmrinfo("oneshot_initialize ok %p \n", &priv->lh);
return &priv->lh;
}
/****************************************************************************
* Name: arm64_arch_timer_secondary_init
*
* Description:
* Initialize the ARM generic timer for secondary CPUs.
*
* Returned Value:
* None
*
****************************************************************************/
void arm64_oneshot_secondary_init(void)
{
/* Enable int */
up_enable_irq(ARM_ARCH_TIMER_IRQ);
/* Start timer */
arm64_arch_timer_enable(true);
}

View file

@ -49,4 +49,17 @@
struct oneshot_lowerhalf_s *arm64_oneshot_initialize(void);
/****************************************************************************
* Name: arm64_oneshot_secondary_init
*
* Description:
* Initialize the ARM generic timer for secondary CPUs.
*
* Returned Value:
* None
*
****************************************************************************/
void arm64_oneshot_secondary_init(void);
#endif /* __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H */

View file

@ -235,5 +235,7 @@ void arm64_boot_secondary_c_routine(void)
arm64_gic_secondary_init();
arm64_timer_secondary_init();
arm64_smp_init_top();
}

View file

@ -80,6 +80,19 @@ void arm64_cpu_boot(int cpu);
void arm64_enable_smp(int cpu);
/****************************************************************************
* Name: arm64_timer_secondary_init
*
* Description:
* Initialize the ARM timer for secondary CPUs.
*
* Returned Value:
* None
*
****************************************************************************/
void arm64_timer_secondary_init(void);
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_SMP */
#endif /* __ARCH_ARM64_SRC_COMMON_ARM64_SMP_H */

View file

@ -36,3 +36,8 @@ void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View file

@ -36,3 +36,8 @@ void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View file

@ -36,3 +36,8 @@ void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View file

@ -36,3 +36,8 @@ void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View file

@ -36,3 +36,8 @@ void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View file

@ -36,3 +36,8 @@ void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View file

@ -36,3 +36,8 @@ void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}