[PATCH 1/2] powerpc/time: Use clockevents_register_device(), fixing an issue with large decrementer

Michael Ellerman mpe at ellerman.id.au
Sun Oct 14 23:39:56 AEDT 2018


Anton Blanchard <anton at ozlabs.org> writes:

> diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
> index 70f145e02487..6a1f0a084ca3 100644
> --- a/arch/powerpc/kernel/time.c
> +++ b/arch/powerpc/kernel/time.c
> @@ -1035,18 +1035,7 @@ static void __init set_decrementer_max(void)
>  
>  static void __init init_decrementer_clockevent(void)
>  {
> -	int cpu = smp_processor_id();
> -
> -	clockevents_calc_mult_shift(&decrementer_clockevent, ppc_tb_freq, 4);
> -
> -	decrementer_clockevent.max_delta_ns =
> -		clockevent_delta2ns(decrementer_max, &decrementer_clockevent);
> -	decrementer_clockevent.max_delta_ticks = decrementer_max;
> -	decrementer_clockevent.min_delta_ns =
> -		clockevent_delta2ns(2, &decrementer_clockevent);
> -	decrementer_clockevent.min_delta_ticks = 2;
> -
> -	register_decrementer_clockevent(cpu);
> +	register_decrementer_clockevent(smp_processor_id());
>  }

This broke KVM PR :)

Because we no longer set the mult/shift in decrementer_clockevent, which
is used in kvmppc_emulate_dec().

The patch below fixes it, though it'd be nice to come up with something
cleaner eventually.

cheers


diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 6a1f0a084ca3..d21b2b88c0a7 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -1036,6 +1036,9 @@ static void __init set_decrementer_max(void)
 static void __init init_decrementer_clockevent(void)
 {
 	register_decrementer_clockevent(smp_processor_id());
+
+	/* Set values for KVM, see kvm_emulate_dec() */
+	decrementer_clockevent = *dec;
 }
 
 void secondary_cpu_time_init(void)



More information about the Linuxppc-dev mailing list