commit 855ccb8292f0a6d5d8c83b8c95cd7939992ebc97 Author: Wei Huang Date: Mon Oct 6 11:43:07 2014 -0400 ARM/KVM: remove DT parsing in KVMfor arch_timer virt PPI Current KVM parses arch_timer virt PPI from device tree. But such info has been made available by arm_arch_timer driver during booting. This patch retrieves PPI from arm_arch_timer driver to avoid calling DT functions again. More importantly this patch eliminates the dependency on DT or ACPI. So when ACPI code is added to arm_arch_timer, KVM code doesn't need change. Signed-off-by: Wei Huang diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 5163ec1..6d3225e 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -53,22 +53,22 @@ struct arch_timer { static u32 arch_timer_rate; -enum ppi_nr { - PHYS_SECURE_PPI, - PHYS_NONSECURE_PPI, - VIRT_PPI, - HYP_PPI, - MAX_TIMER_PPI -}; - -static int arch_timer_ppi[MAX_TIMER_PPI]; - static struct clock_event_device __percpu *arch_timer_evt; static bool arch_timer_use_virtual = true; static bool arch_timer_c3stop; static bool arch_timer_mem_use_virtual; +static int arch_timer_ppi[MAX_TIMER_PPI]; + +int arch_timer_get_ppi(enum ppi_nr idx) +{ + if (idx < MAX_TIMER_PPI) + return arch_timer_ppi[idx]; + + return 0; +} + /* * Architected system timer support. */ diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h index 6d26b40..6efb4b4 100644 --- a/include/clocksource/arm_arch_timer.h +++ b/include/clocksource/arm_arch_timer.h @@ -28,6 +28,14 @@ enum arch_timer_reg { ARCH_TIMER_REG_TVAL, }; +enum ppi_nr { + PHYS_SECURE_PPI, + PHYS_NONSECURE_PPI, + VIRT_PPI, + HYP_PPI, + MAX_TIMER_PPI +}; + #define ARCH_TIMER_PHYS_ACCESS 0 #define ARCH_TIMER_VIRT_ACCESS 1 #define ARCH_TIMER_MEM_PHYS_ACCESS 2 @@ -48,6 +56,7 @@ enum arch_timer_reg { extern u32 arch_timer_get_rate(void); extern u64 (*arch_timer_read_counter)(void); extern struct timecounter *arch_timer_get_timecounter(void); +extern int arch_timer_get_ppi(enum ppi_nr idx); #else diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 22fa819..7e0cc81 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -17,7 +17,6 @@ */ #include -#include #include #include #include @@ -238,15 +237,8 @@ static struct notifier_block kvm_timer_cpu_nb = { .notifier_call = kvm_timer_cpu_notify, }; -static const struct of_device_id arch_timer_of_match[] = { - { .compatible = "arm,armv7-timer", }, - { .compatible = "arm,armv8-timer", }, - {}, -}; - int kvm_timer_hyp_init(void) { - struct device_node *np; unsigned int ppi; int err; @@ -254,13 +246,7 @@ int kvm_timer_hyp_init(void) if (!timecounter) return -ENODEV; - np = of_find_matching_node(NULL, arch_timer_of_match); - if (!np) { - kvm_err("kvm_arch_timer: can't find DT node\n"); - return -ENODEV; - } - - ppi = irq_of_parse_and_map(np, 2); + ppi = arch_timer_get_ppi(VIRT_PPI); if (!ppi) { kvm_err("kvm_arch_timer: no virtual timer interrupt\n"); err = -EINVAL; @@ -289,14 +275,13 @@ int kvm_timer_hyp_init(void) goto out_free; } - kvm_info("%s IRQ%d\n", np->name, ppi); + kvm_info("timer IRQ%d\n", ppi); on_each_cpu(kvm_timer_init_interrupt, NULL, 1); goto out; out_free: free_percpu_irq(ppi, kvm_get_running_vcpus()); out: - of_node_put(np); return err; }