aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-10-28 13:52:02 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2015-11-04 10:24:36 -0500
commit8a22f234a81ab4d1de5d948c3478608f08a9b844 (patch)
treeba10ea82eef7a5d94a9cc96cfa2ea6decb1cc654
parent7695405698d011c05a95288f1f3c0a3dd252dccc (diff)
KVM: x86: move kvm_set_irq_inatomic to legacy device assignment
The function is not used outside device assignment, and kvm_arch_set_irq_inatomic has a different prototype. Move it here and make it static to avoid confusion. Reviewed-by: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/kvm/assigned-dev.c37
-rw-r--r--arch/x86/kvm/irq_comm.c34
-rw-r--r--include/linux/kvm_host.h1
3 files changed, 37 insertions, 35 deletions
diff --git a/arch/x86/kvm/assigned-dev.c b/arch/x86/kvm/assigned-dev.c
index 1c17ee807ef7..9dc091acd5fb 100644
--- a/arch/x86/kvm/assigned-dev.c
+++ b/arch/x86/kvm/assigned-dev.c
@@ -21,6 +21,7 @@
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include "irq.h" 22#include "irq.h"
23#include "assigned-dev.h" 23#include "assigned-dev.h"
24#include "trace/events/kvm.h"
24 25
25struct kvm_assigned_dev_kernel { 26struct kvm_assigned_dev_kernel {
26 struct kvm_irq_ack_notifier ack_notifier; 27 struct kvm_irq_ack_notifier ack_notifier;
@@ -131,6 +132,42 @@ static irqreturn_t kvm_assigned_dev_thread_intx(int irq, void *dev_id)
131 return IRQ_HANDLED; 132 return IRQ_HANDLED;
132} 133}
133 134
135/*
136 * Deliver an IRQ in an atomic context if we can, or return a failure,
137 * user can retry in a process context.
138 * Return value:
139 * -EWOULDBLOCK - Can't deliver in atomic context: retry in a process context.
140 * Other values - No need to retry.
141 */
142static int kvm_set_irq_inatomic(struct kvm *kvm, int irq_source_id, u32 irq,
143 int level)
144{
145 struct kvm_kernel_irq_routing_entry entries[KVM_NR_IRQCHIPS];
146 struct kvm_kernel_irq_routing_entry *e;
147 int ret = -EINVAL;
148 int idx;
149
150 trace_kvm_set_irq(irq, level, irq_source_id);
151
152 /*
153 * Injection into either PIC or IOAPIC might need to scan all CPUs,
154 * which would need to be retried from thread context; when same GSI
155 * is connected to both PIC and IOAPIC, we'd have to report a
156 * partial failure here.
157 * Since there's no easy way to do this, we only support injecting MSI
158 * which is limited to 1:1 GSI mapping.
159 */
160 idx = srcu_read_lock(&kvm->irq_srcu);
161 if (kvm_irq_map_gsi(kvm, entries, irq) > 0) {
162 e = &entries[0];
163 ret = kvm_arch_set_irq_inatomic(e, kvm, irq_source_id,
164 irq, level);
165 }
166 srcu_read_unlock(&kvm->irq_srcu, idx);
167 return ret;
168}
169
170
134static irqreturn_t kvm_assigned_dev_msi(int irq, void *dev_id) 171static irqreturn_t kvm_assigned_dev_msi(int irq, void *dev_id)
135{ 172{
136 struct kvm_assigned_dev_kernel *assigned_dev = dev_id; 173 struct kvm_assigned_dev_kernel *assigned_dev = dev_id;
diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
index 75dc633c48dc..84b96d319909 100644
--- a/arch/x86/kvm/irq_comm.c
+++ b/arch/x86/kvm/irq_comm.c
@@ -142,40 +142,6 @@ int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e,
142 return -EWOULDBLOCK; 142 return -EWOULDBLOCK;
143} 143}
144 144
145/*
146 * Deliver an IRQ in an atomic context if we can, or return a failure,
147 * user can retry in a process context.
148 * Return value:
149 * -EWOULDBLOCK - Can't deliver in atomic context: retry in a process context.
150 * Other values - No need to retry.
151 */
152int kvm_set_irq_inatomic(struct kvm *kvm, int irq_source_id, u32 irq, int level)
153{
154 struct kvm_kernel_irq_routing_entry entries[KVM_NR_IRQCHIPS];
155 struct kvm_kernel_irq_routing_entry *e;
156 int ret = -EINVAL;
157 int idx;
158
159 trace_kvm_set_irq(irq, level, irq_source_id);
160
161 /*
162 * Injection into either PIC or IOAPIC might need to scan all CPUs,
163 * which would need to be retried from thread context; when same GSI
164 * is connected to both PIC and IOAPIC, we'd have to report a
165 * partial failure here.
166 * Since there's no easy way to do this, we only support injecting MSI
167 * which is limited to 1:1 GSI mapping.
168 */
169 idx = srcu_read_lock(&kvm->irq_srcu);
170 if (kvm_irq_map_gsi(kvm, entries, irq) > 0) {
171 e = &entries[0];
172 ret = kvm_arch_set_irq_inatomic(e, kvm, irq_source_id,
173 irq, level);
174 }
175 srcu_read_unlock(&kvm->irq_srcu, idx);
176 return ret;
177}
178
179int kvm_request_irq_source_id(struct kvm *kvm) 145int kvm_request_irq_source_id(struct kvm *kvm)
180{ 146{
181 unsigned long *bitmap = &kvm->arch.irq_sources_bitmap; 147 unsigned long *bitmap = &kvm->arch.irq_sources_bitmap;
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 15c78f320678..242a6d2b53ff 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -827,7 +827,6 @@ int kvm_irq_map_chip_pin(struct kvm *kvm, unsigned irqchip, unsigned pin);
827 827
828int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level, 828int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level,
829 bool line_status); 829 bool line_status);
830int kvm_set_irq_inatomic(struct kvm *kvm, int irq_source_id, u32 irq, int level);
831int kvm_set_msi(struct kvm_kernel_irq_routing_entry *irq_entry, struct kvm *kvm, 830int kvm_set_msi(struct kvm_kernel_irq_routing_entry *irq_entry, struct kvm *kvm,
832 int irq_source_id, int level, bool line_status); 831 int irq_source_id, int level, bool line_status);
833int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e, 832int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e,