2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
11 * irqfd: Allows an fd to be used to inject an interrupt to the guest
12 * Credit goes to Avi Kivity for the original idea.
15 #ifndef __LINUX_KVM_IRQFD_H
16 #define __LINUX_KVM_IRQFD_H
18 #include <linux/kvm_host.h>
19 #include <linux/poll.h>
22 * Resampling irqfds are a special variety of irqfds used to emulate
23 * level triggered interrupts. The interrupt is asserted on eventfd
24 * trigger. On acknowledgment through the irq ack notifier, the
25 * interrupt is de-asserted and userspace is notified through the
26 * resamplefd. All resamplers on the same gsi are de-asserted
27 * together, so we don't need to track the state of each individual
28 * user. We can also therefore share the same irq source ID.
30 struct kvm_kernel_irqfd_resampler {
33 * List of resampling struct _irqfd objects sharing this gsi.
34 * RCU list modified under kvm->irqfds.resampler_lock
36 struct list_head list;
37 struct kvm_irq_ack_notifier notifier;
39 * Entry in list of kvm->irqfd.resampler_list. Use for sharing
40 * resamplers among irqfds on the same gsi.
41 * Accessed and modified under kvm->irqfds.resampler_lock
43 struct list_head link;
46 struct kvm_kernel_irqfd {
47 /* Used for MSI fast-path */
49 wait_queue_entry_t wait;
50 /* Update side is protected by irqfds.lock */
51 struct kvm_kernel_irq_routing_entry irq_entry;
52 seqcount_t irq_entry_sc;
53 /* Used for level IRQ fast-path */
55 struct work_struct inject;
56 /* The resampler used by this irqfd (resampler-only) */
57 struct kvm_kernel_irqfd_resampler *resampler;
58 /* Eventfd notified on resample (resampler-only) */
59 struct eventfd_ctx *resamplefd;
60 /* Entry in list of irqfds for a resampler (resampler-only) */
61 struct list_head resampler_link;
62 /* Used for setup/shutdown */
63 struct eventfd_ctx *eventfd;
64 struct list_head list;
66 struct work_struct shutdown;
67 struct irq_bypass_consumer consumer;
68 struct irq_bypass_producer *producer;
71 #endif /* __LINUX_KVM_IRQFD_H */