Re: [RFC PATCH v3 17/37] kvx: Add boot and setup routines

From: Thomas Gleixner
Date: Sat Jul 27 2024 - 10:31:13 EST


On Mon, Jul 22 2024 at 11:41, ysionneau@xxxxxxxxxxxxx wrote:
> diff --git a/arch/kvx/kernel/time.c b/arch/kvx/kernel/time.c

Any reason why this is not in drivers/clocksource/ ?

> +static unsigned int kvx_timer_frequency;
> +static unsigned int kvx_periodic_timer_value;
> +static unsigned int kvx_timer_irq;
> +
> +static void kvx_timer_set_value(unsigned long value, unsigned long reload_value)
> +{
> + kvx_sfr_set(T0R, reload_value);
> + kvx_sfr_set(T0V, value);
> + /* Enable timer */
> + kvx_sfr_set_field(TCR, T0CE, 1);
> +}
> +
> +static int kvx_clkevent_set_next_event(unsigned long cycles,
> + struct clock_event_device *dev)
> +{
> + /*
> + * Hardware does not support oneshot mode.
> + * In order to support it, set a really high reload value.
> + * Then, during the interrupt handler, disable the timer if
> + * in oneshot mode
> + */
> + kvx_timer_set_value(cycles - 1, KVX_TIMER_MAX_VALUE);
> +
> + return 0;
> +}
> +
> +static irqreturn_t kvx_timer_irq_handler(int irq, void *dev_id)
> +{
> + struct clock_event_device *evt = this_cpu_ptr(&kvx_clockevent_device);
> +
> + /* Disable timer if in oneshot mode before reloading */

The timer has already reloaded KVX_TIMER_MAX_VALUE, no?

> +
> +static int kvx_timer_dying_cpu(unsigned int cpu)
> +{
> + disable_percpu_irq(kvx_timer_irq);

What disables the timer itself?

> + return 0;
> +}

Thanks,

tglx