mirror of
https://github.com/qemu/qemu.git
synced 2025-08-09 01:50:43 +00:00
kvm: add KVM_IRQFD_FLAG_RESAMPLE support
Added an EventNotifier* parameter to kvm-all.c:kvm_irqchip_add_irqfd_notifier(), in order to give KVM another eventfd to be used as "resamplefd". See the documentation in the linux kernel sources in Documentation/virtual/kvm/api.txt (section 4.75) for more details. When the added parameter is passed NULL, the behaviour of the function is unchanged with respect to the previous versions. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Vincenzo Maffione <v.maffione@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
0d89436786
commit
ca916d3729
@ -646,7 +646,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
|
|||||||
vector->virq = msg ? kvm_irqchip_add_msi_route(kvm_state, *msg) : -1;
|
vector->virq = msg ? kvm_irqchip_add_msi_route(kvm_state, *msg) : -1;
|
||||||
if (vector->virq < 0 ||
|
if (vector->virq < 0 ||
|
||||||
kvm_irqchip_add_irqfd_notifier(kvm_state, &vector->interrupt,
|
kvm_irqchip_add_irqfd_notifier(kvm_state, &vector->interrupt,
|
||||||
vector->virq) < 0) {
|
NULL, vector->virq) < 0) {
|
||||||
if (vector->virq >= 0) {
|
if (vector->virq >= 0) {
|
||||||
kvm_irqchip_release_virq(kvm_state, vector->virq);
|
kvm_irqchip_release_virq(kvm_state, vector->virq);
|
||||||
vector->virq = -1;
|
vector->virq = -1;
|
||||||
@ -814,7 +814,7 @@ retry:
|
|||||||
vector->virq = kvm_irqchip_add_msi_route(kvm_state, msg);
|
vector->virq = kvm_irqchip_add_msi_route(kvm_state, msg);
|
||||||
if (vector->virq < 0 ||
|
if (vector->virq < 0 ||
|
||||||
kvm_irqchip_add_irqfd_notifier(kvm_state, &vector->interrupt,
|
kvm_irqchip_add_irqfd_notifier(kvm_state, &vector->interrupt,
|
||||||
vector->virq) < 0) {
|
NULL, vector->virq) < 0) {
|
||||||
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
|
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
|
||||||
vfio_msi_interrupt, NULL, vector);
|
vfio_msi_interrupt, NULL, vector);
|
||||||
}
|
}
|
||||||
|
@ -508,7 +508,7 @@ static int kvm_virtio_pci_irqfd_use(VirtIOPCIProxy *proxy,
|
|||||||
VirtQueue *vq = virtio_get_queue(proxy->vdev, queue_no);
|
VirtQueue *vq = virtio_get_queue(proxy->vdev, queue_no);
|
||||||
EventNotifier *n = virtio_queue_get_guest_notifier(vq);
|
EventNotifier *n = virtio_queue_get_guest_notifier(vq);
|
||||||
int ret;
|
int ret;
|
||||||
ret = kvm_irqchip_add_irqfd_notifier(kvm_state, n, irqfd->virq);
|
ret = kvm_irqchip_add_irqfd_notifier(kvm_state, n, NULL, irqfd->virq);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +309,8 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg);
|
|||||||
int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg);
|
int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg);
|
||||||
void kvm_irqchip_release_virq(KVMState *s, int virq);
|
void kvm_irqchip_release_virq(KVMState *s, int virq);
|
||||||
|
|
||||||
int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n, int virq);
|
int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n,
|
||||||
|
EventNotifier *rn, int virq);
|
||||||
int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq);
|
int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq);
|
||||||
void kvm_pc_gsi_handler(void *opaque, int n, int level);
|
void kvm_pc_gsi_handler(void *opaque, int n, int level);
|
||||||
void kvm_pc_setup_irq_routing(bool pci_enabled);
|
void kvm_pc_setup_irq_routing(bool pci_enabled);
|
||||||
|
17
kvm-all.c
17
kvm-all.c
@ -1230,7 +1230,8 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
|
|||||||
return kvm_update_routing_entry(s, &kroute);
|
return kvm_update_routing_entry(s, &kroute);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int virq, bool assign)
|
static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int rfd, int virq,
|
||||||
|
bool assign)
|
||||||
{
|
{
|
||||||
struct kvm_irqfd irqfd = {
|
struct kvm_irqfd irqfd = {
|
||||||
.fd = fd,
|
.fd = fd,
|
||||||
@ -1238,6 +1239,11 @@ static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int virq, bool assign)
|
|||||||
.flags = assign ? 0 : KVM_IRQFD_FLAG_DEASSIGN,
|
.flags = assign ? 0 : KVM_IRQFD_FLAG_DEASSIGN,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (rfd != -1) {
|
||||||
|
irqfd.flags |= KVM_IRQFD_FLAG_RESAMPLE;
|
||||||
|
irqfd.resamplefd = rfd;
|
||||||
|
}
|
||||||
|
|
||||||
if (!kvm_irqfds_enabled()) {
|
if (!kvm_irqfds_enabled()) {
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
@ -1276,14 +1282,17 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
|
|||||||
}
|
}
|
||||||
#endif /* !KVM_CAP_IRQ_ROUTING */
|
#endif /* !KVM_CAP_IRQ_ROUTING */
|
||||||
|
|
||||||
int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n, int virq)
|
int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n,
|
||||||
|
EventNotifier *rn, int virq)
|
||||||
{
|
{
|
||||||
return kvm_irqchip_assign_irqfd(s, event_notifier_get_fd(n), virq, true);
|
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(KVMState *s, EventNotifier *n, int virq)
|
||||||
{
|
{
|
||||||
return kvm_irqchip_assign_irqfd(s, event_notifier_get_fd(n), virq, false);
|
return kvm_irqchip_assign_irqfd(s, event_notifier_get_fd(n), -1, virq,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int kvm_irqchip_create(KVMState *s)
|
static int kvm_irqchip_create(KVMState *s)
|
||||||
|
Loading…
Reference in New Issue
Block a user