drm/rockchip: vop2: Fix the windows switch between different layers
[drm/drm-misc.git] / arch / x86 / kvm / irq.h
blob76d46b2f41ddc6a25e4ae4b0696e0a95d3041f42
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * irq.h: in kernel interrupt controller related definitions
4 * Copyright (c) 2007, Intel Corporation.
6 * Authors:
7 * Yaozu (Eddie) Dong <Eddie.dong@intel.com>
8 */
10 #ifndef __IRQ_H
11 #define __IRQ_H
13 #include <linux/mm_types.h>
14 #include <linux/hrtimer.h>
15 #include <linux/kvm_host.h>
16 #include <linux/spinlock.h>
18 #include <kvm/iodev.h>
19 #include "lapic.h"
21 #define PIC_NUM_PINS 16
22 #define SELECT_PIC(irq) \
23 ((irq) < 8 ? KVM_IRQCHIP_PIC_MASTER : KVM_IRQCHIP_PIC_SLAVE)
25 struct kvm;
26 struct kvm_vcpu;
28 struct kvm_kpic_state {
29 u8 last_irr; /* edge detection */
30 u8 irr; /* interrupt request register */
31 u8 imr; /* interrupt mask register */
32 u8 isr; /* interrupt service register */
33 u8 priority_add; /* highest irq priority */
34 u8 irq_base;
35 u8 read_reg_select;
36 u8 poll;
37 u8 special_mask;
38 u8 init_state;
39 u8 auto_eoi;
40 u8 rotate_on_auto_eoi;
41 u8 special_fully_nested_mode;
42 u8 init4; /* true if 4 byte init */
43 u8 elcr; /* PIIX edge/trigger selection */
44 u8 elcr_mask;
45 u8 isr_ack; /* interrupt ack detection */
46 struct kvm_pic *pics_state;
49 struct kvm_pic {
50 spinlock_t lock;
51 bool wakeup_needed;
52 unsigned pending_acks;
53 struct kvm *kvm;
54 struct kvm_kpic_state pics[2]; /* 0 is master pic, 1 is slave pic */
55 int output; /* intr from master PIC */
56 struct kvm_io_device dev_master;
57 struct kvm_io_device dev_slave;
58 struct kvm_io_device dev_elcr;
59 unsigned long irq_states[PIC_NUM_PINS];
62 int kvm_pic_init(struct kvm *kvm);
63 void kvm_pic_destroy(struct kvm *kvm);
64 int kvm_pic_read_irq(struct kvm *kvm);
65 void kvm_pic_update_irq(struct kvm_pic *s);
67 static inline int irqchip_split(struct kvm *kvm)
69 int mode = kvm->arch.irqchip_mode;
71 /* Matches smp_wmb() when setting irqchip_mode */
72 smp_rmb();
73 return mode == KVM_IRQCHIP_SPLIT;
76 static inline int irqchip_kernel(struct kvm *kvm)
78 int mode = kvm->arch.irqchip_mode;
80 /* Matches smp_wmb() when setting irqchip_mode */
81 smp_rmb();
82 return mode == KVM_IRQCHIP_KERNEL;
85 static inline int pic_in_kernel(struct kvm *kvm)
87 return irqchip_kernel(kvm);
90 static inline int irqchip_in_kernel(struct kvm *kvm)
92 int mode = kvm->arch.irqchip_mode;
94 /* Matches smp_wmb() when setting irqchip_mode */
95 smp_rmb();
96 return mode != KVM_IRQCHIP_NONE;
99 void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu);
100 void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu);
101 void kvm_apic_nmi_wd_deliver(struct kvm_vcpu *vcpu);
102 void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu);
103 void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu);
104 void __kvm_migrate_timers(struct kvm_vcpu *vcpu);
106 int apic_has_pending_timer(struct kvm_vcpu *vcpu);
108 int kvm_setup_default_irq_routing(struct kvm *kvm);
109 int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
110 struct kvm_lapic_irq *irq,
111 struct dest_map *dest_map);
113 #endif