diff options
author | Richard Cochran <rcochran@linutronix.de> | 2016-07-13 13:16:47 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-07-15 04:40:27 -0400 |
commit | b3c9950a5c75983c0a2fcc93760f53ba52da3c85 (patch) | |
tree | 1b22359d785732c9e4d1dc5963a536889da55cdf | |
parent | 42ec50b5f257b19bd5653c40933b0803d5c4179a (diff) |
arm/kvm/arch_timer: Convert to hotplug state machine
Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.
Signed-off-by: Richard Cochran <rcochran@linutronix.de>
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Radim Krcmar <rkrcmar@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: kvm@vger.kernel.org
Cc: kvmarm@lists.cs.columbia.edu
Cc: linux-arm-kernel@lists.infradead.org
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160713153336.634155707@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | include/linux/cpuhotplug.h | 1 | ||||
-rw-r--r-- | virt/kvm/arm/arch_timer.c | 35 |
2 files changed, 12 insertions, 24 deletions
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index ff37caccafce..88986c979b0f 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h | |||
@@ -43,6 +43,7 @@ enum cpuhp_state { | |||
43 | CPUHP_AP_MIPS_GIC_TIMER_STARTING, | 43 | CPUHP_AP_MIPS_GIC_TIMER_STARTING, |
44 | CPUHP_AP_KVM_STARTING, | 44 | CPUHP_AP_KVM_STARTING, |
45 | CPUHP_AP_KVM_ARM_VGIC_STARTING, | 45 | CPUHP_AP_KVM_ARM_VGIC_STARTING, |
46 | CPUHP_AP_KVM_ARM_TIMER_STARTING, | ||
46 | CPUHP_AP_LEDTRIG_STARTING, | 47 | CPUHP_AP_LEDTRIG_STARTING, |
47 | CPUHP_AP_NOTIFY_STARTING, | 48 | CPUHP_AP_NOTIFY_STARTING, |
48 | CPUHP_AP_ONLINE, | 49 | CPUHP_AP_ONLINE, |
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index e2d5b6f988fb..4fde8c7dfcfe 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c | |||
@@ -405,26 +405,17 @@ u64 kvm_arm_timer_get_reg(struct kvm_vcpu *vcpu, u64 regid) | |||
405 | return (u64)-1; | 405 | return (u64)-1; |
406 | } | 406 | } |
407 | 407 | ||
408 | static int kvm_timer_cpu_notify(struct notifier_block *self, | 408 | static int kvm_timer_starting_cpu(unsigned int cpu) |
409 | unsigned long action, void *cpu) | ||
410 | { | 409 | { |
411 | switch (action) { | 410 | kvm_timer_init_interrupt(NULL); |
412 | case CPU_STARTING: | 411 | return 0; |
413 | case CPU_STARTING_FROZEN: | ||
414 | kvm_timer_init_interrupt(NULL); | ||
415 | break; | ||
416 | case CPU_DYING: | ||
417 | case CPU_DYING_FROZEN: | ||
418 | disable_percpu_irq(host_vtimer_irq); | ||
419 | break; | ||
420 | } | ||
421 | |||
422 | return NOTIFY_OK; | ||
423 | } | 412 | } |
424 | 413 | ||
425 | static struct notifier_block kvm_timer_cpu_nb = { | 414 | static int kvm_timer_dying_cpu(unsigned int cpu) |
426 | .notifier_call = kvm_timer_cpu_notify, | 415 | { |
427 | }; | 416 | disable_percpu_irq(host_vtimer_irq); |
417 | return 0; | ||
418 | } | ||
428 | 419 | ||
429 | int kvm_timer_hyp_init(void) | 420 | int kvm_timer_hyp_init(void) |
430 | { | 421 | { |
@@ -449,12 +440,6 @@ int kvm_timer_hyp_init(void) | |||
449 | goto out; | 440 | goto out; |
450 | } | 441 | } |
451 | 442 | ||
452 | err = __register_cpu_notifier(&kvm_timer_cpu_nb); | ||
453 | if (err) { | ||
454 | kvm_err("Cannot register timer CPU notifier\n"); | ||
455 | goto out_free; | ||
456 | } | ||
457 | |||
458 | wqueue = create_singlethread_workqueue("kvm_arch_timer"); | 443 | wqueue = create_singlethread_workqueue("kvm_arch_timer"); |
459 | if (!wqueue) { | 444 | if (!wqueue) { |
460 | err = -ENOMEM; | 445 | err = -ENOMEM; |
@@ -462,8 +447,10 @@ int kvm_timer_hyp_init(void) | |||
462 | } | 447 | } |
463 | 448 | ||
464 | kvm_info("virtual timer IRQ%d\n", host_vtimer_irq); | 449 | kvm_info("virtual timer IRQ%d\n", host_vtimer_irq); |
465 | on_each_cpu(kvm_timer_init_interrupt, NULL, 1); | ||
466 | 450 | ||
451 | cpuhp_setup_state(CPUHP_AP_KVM_ARM_TIMER_STARTING, | ||
452 | "AP_KVM_ARM_TIMER_STARTING", kvm_timer_starting_cpu, | ||
453 | kvm_timer_dying_cpu); | ||
467 | goto out; | 454 | goto out; |
468 | out_free: | 455 | out_free: |
469 | free_percpu_irq(host_vtimer_irq, kvm_get_running_vcpus()); | 456 | free_percpu_irq(host_vtimer_irq, kvm_get_running_vcpus()); |