Linux Audio

Check our new training course

Loading...
v5.14.15
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 
 
 
 
 
 
 
 
 3 *
 4 * irqfd: Allows an fd to be used to inject an interrupt to the guest
 5 * Credit goes to Avi Kivity for the original idea.
 6 */
 7
 8#ifndef __LINUX_KVM_IRQFD_H
 9#define __LINUX_KVM_IRQFD_H
10
11#include <linux/kvm_host.h>
12#include <linux/poll.h>
13
14/*
15 * Resampling irqfds are a special variety of irqfds used to emulate
16 * level triggered interrupts.  The interrupt is asserted on eventfd
17 * trigger.  On acknowledgment through the irq ack notifier, the
18 * interrupt is de-asserted and userspace is notified through the
19 * resamplefd.  All resamplers on the same gsi are de-asserted
20 * together, so we don't need to track the state of each individual
21 * user.  We can also therefore share the same irq source ID.
22 */
23struct kvm_kernel_irqfd_resampler {
24	struct kvm *kvm;
25	/*
26	 * List of resampling struct _irqfd objects sharing this gsi.
27	 * RCU list modified under kvm->irqfds.resampler_lock
28	 */
29	struct list_head list;
30	struct kvm_irq_ack_notifier notifier;
31	/*
32	 * Entry in list of kvm->irqfd.resampler_list.  Use for sharing
33	 * resamplers among irqfds on the same gsi.
34	 * Accessed and modified under kvm->irqfds.resampler_lock
35	 */
36	struct list_head link;
37};
38
39struct kvm_kernel_irqfd {
40	/* Used for MSI fast-path */
41	struct kvm *kvm;
42	wait_queue_entry_t wait;
43	/* Update side is protected by irqfds.lock */
44	struct kvm_kernel_irq_routing_entry irq_entry;
45	seqcount_spinlock_t irq_entry_sc;
46	/* Used for level IRQ fast-path */
47	int gsi;
48	struct work_struct inject;
49	/* The resampler used by this irqfd (resampler-only) */
50	struct kvm_kernel_irqfd_resampler *resampler;
51	/* Eventfd notified on resample (resampler-only) */
52	struct eventfd_ctx *resamplefd;
53	/* Entry in list of irqfds for a resampler (resampler-only) */
54	struct list_head resampler_link;
55	/* Used for setup/shutdown */
56	struct eventfd_ctx *eventfd;
57	struct list_head list;
58	poll_table pt;
59	struct work_struct shutdown;
60	struct irq_bypass_consumer consumer;
61	struct irq_bypass_producer *producer;
62};
63
64#endif /* __LINUX_KVM_IRQFD_H */
v4.6
 
 1/*
 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.
 5 *
 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.
10 *
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.
13 */
14
15#ifndef __LINUX_KVM_IRQFD_H
16#define __LINUX_KVM_IRQFD_H
17
18#include <linux/kvm_host.h>
19#include <linux/poll.h>
20
21/*
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.
29 */
30struct kvm_kernel_irqfd_resampler {
31	struct kvm *kvm;
32	/*
33	 * List of resampling struct _irqfd objects sharing this gsi.
34	 * RCU list modified under kvm->irqfds.resampler_lock
35	 */
36	struct list_head list;
37	struct kvm_irq_ack_notifier notifier;
38	/*
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
42	 */
43	struct list_head link;
44};
45
46struct kvm_kernel_irqfd {
47	/* Used for MSI fast-path */
48	struct kvm *kvm;
49	wait_queue_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 */
54	int gsi;
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;
65	poll_table pt;
66	struct work_struct shutdown;
67	struct irq_bypass_consumer consumer;
68	struct irq_bypass_producer *producer;
69};
70
71#endif /* __LINUX_KVM_IRQFD_H */