From 1c9b71a7311ed99635a2d007fc8a856879537a05 Mon Sep 17 00:00:00 2001 From: Eric Auger Date: Mon, 6 Jul 2015 12:15:13 -0600 Subject: kvm: rename kvm_irqchip_[add,remove]_irqfd_notifier with gsi suffix Anticipating for the introduction of new add/remove functions taking a qemu_irq parameter, let's rename existing ones with a gsi suffix. Signed-off-by: Eric Auger Tested-by: Vikram Sethi Acked-by: Paolo Bonzini Reviewed-by: Peter Maydell Signed-off-by: Alex Williamson --- kvm-all.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'kvm-all.c') diff --git a/kvm-all.c b/kvm-all.c index df57da0..de73b35 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1328,14 +1328,15 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg) } #endif /* !KVM_CAP_IRQ_ROUTING */ -int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n, - EventNotifier *rn, int virq) +int kvm_irqchip_add_irqfd_notifier_gsi(KVMState *s, EventNotifier *n, + EventNotifier *rn, int virq) { return kvm_irqchip_assign_irqfd(s, event_notifier_get_fd(n), rn ? event_notifier_get_fd(rn) : -1, virq, true); } -int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq) +int kvm_irqchip_remove_irqfd_notifier_gsi(KVMState *s, EventNotifier *n, + int virq) { return kvm_irqchip_assign_irqfd(s, event_notifier_get_fd(n), -1, virq, false); -- cgit v1.1 From 197e35249a7360534e1aea0f2268ad0e1aa27121 Mon Sep 17 00:00:00 2001 From: Eric Auger Date: Mon, 6 Jul 2015 12:15:13 -0600 Subject: kvm-all.c: add qemu_irq/gsi hash table and utility routines VFIO platform device needs to setup irqfd but it does not know the gsi corresponding to the device qemu_irq. This patch proposes to store a hash table in kvm_state using the qemu_irq as key and the gsi as a value. kvm_irqchip_set_qemuirq_gsi allows to insert such a pair. The interrupt controller is supposed to use it. kvm_irqchip_[add, remove]_irqfd_notifier allows to setup/tear down irqfd directly from the qemu_irq. Signed-off-by: Eric Auger Tested-by: Vikram Sethi Acked-by: Paolo Bonzini Reviewed-by: Peter Maydell Signed-off-by: Alex Williamson --- kvm-all.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'kvm-all.c') diff --git a/kvm-all.c b/kvm-all.c index de73b35..cb83187 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -37,6 +37,7 @@ #include "exec/address-spaces.h" #include "qemu/event_notifier.h" #include "trace.h" +#include "hw/irq.h" #include "hw/boards.h" @@ -98,6 +99,7 @@ struct KVMState * unsigned, and treating them as signed here can break things */ unsigned irq_set_ioctl; unsigned int sigmask_len; + GHashTable *gsimap; #ifdef KVM_CAP_IRQ_ROUTING struct kvm_irq_routing *irq_routes; int nr_allocated_irq_routes; @@ -1342,6 +1344,35 @@ int kvm_irqchip_remove_irqfd_notifier_gsi(KVMState *s, EventNotifier *n, false); } +int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n, + EventNotifier *rn, qemu_irq irq) +{ + gpointer key, gsi; + gboolean found = g_hash_table_lookup_extended(s->gsimap, irq, &key, &gsi); + + if (!found) { + return -ENXIO; + } + return kvm_irqchip_add_irqfd_notifier_gsi(s, n, rn, GPOINTER_TO_INT(gsi)); +} + +int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, + qemu_irq irq) +{ + gpointer key, gsi; + gboolean found = g_hash_table_lookup_extended(s->gsimap, irq, &key, &gsi); + + if (!found) { + return -ENXIO; + } + return kvm_irqchip_remove_irqfd_notifier_gsi(s, n, GPOINTER_TO_INT(gsi)); +} + +void kvm_irqchip_set_qemuirq_gsi(KVMState *s, qemu_irq irq, int gsi) +{ + g_hash_table_insert(s->gsimap, irq, GINT_TO_POINTER(gsi)); +} + static int kvm_irqchip_create(MachineState *machine, KVMState *s) { int ret; @@ -1374,6 +1405,8 @@ static int kvm_irqchip_create(MachineState *machine, KVMState *s) kvm_init_irq_routing(s); + s->gsimap = g_hash_table_new(g_direct_hash, g_direct_equal); + return 0; } -- cgit v1.1