Skip to content

Commit 29c2d6f

Browse files
Julien Grallchazy
authored andcommitted
KVM: arm/arm64: arch_timer: Rely on the arch timer to parse the firmware tables
The firmware table is currently parsed by the virtual timer code in order to retrieve the virtual timer interrupt. However, this is already done by the arch timer driver. To avoid code duplication, use the newly function arch_timer_get_kvm_info() which return all the information required by the virtual timer code. Signed-off-by: Julien Grall <julien.grall@arm.com> Acked-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
1 parent 1839e57 commit 29c2d6f

1 file changed

Lines changed: 11 additions & 29 deletions

File tree

‎virt/kvm/arm/arch_timer.c‎

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818

1919
#include <linux/cpu.h>
20-
#include <linux/of_irq.h>
2120
#include <linux/kvm.h>
2221
#include <linux/kvm_host.h>
2322
#include <linux/interrupt.h>
@@ -438,45 +437,29 @@ static struct notifier_block kvm_timer_cpu_nb = {
438437
.notifier_call = kvm_timer_cpu_notify,
439438
};
440439

441-
static const struct of_device_id arch_timer_of_match[] = {
442-
{ .compatible = "arm,armv7-timer", },
443-
{ .compatible = "arm,armv8-timer", },
444-
{},
445-
};
446-
447440
int kvm_timer_hyp_init(void)
448441
{
449-
struct device_node *np;
450-
unsigned int ppi;
442+
struct arch_timer_kvm_info *info;
451443
int err;
452444

453-
timecounter = arch_timer_get_timecounter();
454-
if (!timecounter)
455-
return -ENODEV;
445+
info = arch_timer_get_kvm_info();
446+
timecounter = &info->timecounter;
456447

457-
np = of_find_matching_node(NULL, arch_timer_of_match);
458-
if (!np) {
459-
kvm_err("kvm_arch_timer: can't find DT node\n");
448+
if (info->virtual_irq <= 0) {
449+
kvm_err("kvm_arch_timer: invalid virtual timer IRQ: %d\n",
450+
info->virtual_irq);
460451
return -ENODEV;
461452
}
453+
host_vtimer_irq = info->virtual_irq;
462454

463-
ppi = irq_of_parse_and_map(np, 2);
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,
455+
err = request_percpu_irq(host_vtimer_irq, kvm_arch_timer_handler,
471456
"kvm guest timer", kvm_get_running_vcpus());
472457
if (err) {
473458
kvm_err("kvm_arch_timer: can't request interrupt %d (%d)\n",
474-
ppi, err);
459+
host_vtimer_irq, err);
475460
goto out;
476461
}
477462

478-
host_vtimer_irq = ppi;
479-
480463
err = __register_cpu_notifier(&kvm_timer_cpu_nb);
481464
if (err) {
482465
kvm_err("Cannot register timer CPU notifier\n");
@@ -489,14 +472,13 @@ int kvm_timer_hyp_init(void)
489472
goto out_free;
490473
}
491474

492-
kvm_info("%s IRQ%d\n", np->name, ppi);
475+
kvm_info("virtual timer IRQ%d\n", host_vtimer_irq);
493476
on_each_cpu(kvm_timer_init_interrupt, NULL, 1);
494477

495478
goto out;
496479
out_free:
497-
free_percpu_irq(ppi, kvm_get_running_vcpus());
480+
free_percpu_irq(host_vtimer_irq, kvm_get_running_vcpus());
498481
out:
499-
of_node_put(np);
500482
return err;
501483
}
502484

0 commit comments

Comments
 (0)