aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/arm/arch_timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'virt/kvm/arm/arch_timer.c')
-rw-r--r--virt/kvm/arm/arch_timer.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
index 9aaa35dd9144..409db3304471 100644
--- a/virt/kvm/arm/arch_timer.c
+++ b/virt/kvm/arm/arch_timer.c
@@ -17,7 +17,6 @@
17 */ 17 */
18 18
19#include <linux/cpu.h> 19#include <linux/cpu.h>
20#include <linux/of_irq.h>
21#include <linux/kvm.h> 20#include <linux/kvm.h>
22#include <linux/kvm_host.h> 21#include <linux/kvm_host.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
@@ -438,45 +437,29 @@ static struct notifier_block kvm_timer_cpu_nb = {
438 .notifier_call = kvm_timer_cpu_notify, 437 .notifier_call = kvm_timer_cpu_notify,
439}; 438};
440 439
441static const struct of_device_id arch_timer_of_match[] = {
442 { .compatible = "arm,armv7-timer", },
443 { .compatible = "arm,armv8-timer", },
444 {},
445};
446
447int kvm_timer_hyp_init(void) 440int kvm_timer_hyp_init(void)
448{ 441{
449 struct device_node *np; 442 struct arch_timer_kvm_info *info;
450 unsigned int ppi;
451 int err; 443 int err;
452 444
453 timecounter = arch_timer_get_timecounter(); 445 info = arch_timer_get_kvm_info();
454 if (!timecounter) 446 timecounter = &info->timecounter;
455 return -ENODEV;
456 447
457 np = of_find_matching_node(NULL, arch_timer_of_match); 448 if (info->virtual_irq <= 0) {
458 if (!np) { 449 kvm_err("kvm_arch_timer: invalid virtual timer IRQ: %d\n",
459 kvm_err("kvm_arch_timer: can't find DT node\n"); 450 info->virtual_irq);
460 return -ENODEV; 451 return -ENODEV;
461 } 452 }
453 host_vtimer_irq = info->virtual_irq;
462 454
463 ppi = irq_of_parse_and_map(np, 2); 455 err = request_percpu_irq(host_vtimer_irq, kvm_arch_timer_handler,
464 if (!ppi) {
465 kvm_err("kvm_arch_timer: no virtual timer interrupt\n");
466 err = -EINVAL;
467 goto out;
468 }
469
470 err = request_percpu_irq(ppi, kvm_arch_timer_handler,
471 "kvm guest timer", kvm_get_running_vcpus()); 456 "kvm guest timer", kvm_get_running_vcpus());
472 if (err) { 457 if (err) {
473 kvm_err("kvm_arch_timer: can't request interrupt %d (%d)\n", 458 kvm_err("kvm_arch_timer: can't request interrupt %d (%d)\n",
474 ppi, err); 459 host_vtimer_irq, err);
475 goto out; 460 goto out;
476 } 461 }
477 462
478 host_vtimer_irq = ppi;
479
480 err = __register_cpu_notifier(&kvm_timer_cpu_nb); 463 err = __register_cpu_notifier(&kvm_timer_cpu_nb);
481 if (err) { 464 if (err) {
482 kvm_err("Cannot register timer CPU notifier\n"); 465 kvm_err("Cannot register timer CPU notifier\n");
@@ -489,14 +472,13 @@ int kvm_timer_hyp_init(void)
489 goto out_free; 472 goto out_free;
490 } 473 }
491 474
492 kvm_info("%s IRQ%d\n", np->name, ppi); 475 kvm_info("virtual timer IRQ%d\n", host_vtimer_irq);
493 on_each_cpu(kvm_timer_init_interrupt, NULL, 1); 476 on_each_cpu(kvm_timer_init_interrupt, NULL, 1);
494 477
495 goto out; 478 goto out;
496out_free: 479out_free:
497 free_percpu_irq(ppi, kvm_get_running_vcpus()); 480 free_percpu_irq(host_vtimer_irq, kvm_get_running_vcpus());
498out: 481out:
499 of_node_put(np);
500 return err; 482 return err;
501} 483}
502 484