aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/irq_comm.c
diff options
context:
space:
mode:
Diffstat (limited to 'virt/kvm/irq_comm.c')
-rw-r--r--virt/kvm/irq_comm.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index ff6d40e2c06d..e9073cf4d040 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -173,7 +173,6 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level)
173 struct kvm_kernel_irq_routing_entry *e, irq_set[KVM_NR_IRQCHIPS]; 173 struct kvm_kernel_irq_routing_entry *e, irq_set[KVM_NR_IRQCHIPS];
174 int ret = -1, i = 0; 174 int ret = -1, i = 0;
175 struct kvm_irq_routing_table *irq_rt; 175 struct kvm_irq_routing_table *irq_rt;
176 struct hlist_node *n;
177 176
178 trace_kvm_set_irq(irq, level, irq_source_id); 177 trace_kvm_set_irq(irq, level, irq_source_id);
179 178
@@ -184,7 +183,7 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level)
184 rcu_read_lock(); 183 rcu_read_lock();
185 irq_rt = rcu_dereference(kvm->irq_routing); 184 irq_rt = rcu_dereference(kvm->irq_routing);
186 if (irq < irq_rt->nr_rt_entries) 185 if (irq < irq_rt->nr_rt_entries)
187 hlist_for_each_entry(e, n, &irq_rt->map[irq], link) 186 hlist_for_each_entry(e, &irq_rt->map[irq], link)
188 irq_set[i++] = *e; 187 irq_set[i++] = *e;
189 rcu_read_unlock(); 188 rcu_read_unlock();
190 189
@@ -212,7 +211,6 @@ int kvm_set_irq_inatomic(struct kvm *kvm, int irq_source_id, u32 irq, int level)
212 struct kvm_kernel_irq_routing_entry *e; 211 struct kvm_kernel_irq_routing_entry *e;
213 int ret = -EINVAL; 212 int ret = -EINVAL;
214 struct kvm_irq_routing_table *irq_rt; 213 struct kvm_irq_routing_table *irq_rt;
215 struct hlist_node *n;
216 214
217 trace_kvm_set_irq(irq, level, irq_source_id); 215 trace_kvm_set_irq(irq, level, irq_source_id);
218 216
@@ -227,7 +225,7 @@ int kvm_set_irq_inatomic(struct kvm *kvm, int irq_source_id, u32 irq, int level)
227 rcu_read_lock(); 225 rcu_read_lock();
228 irq_rt = rcu_dereference(kvm->irq_routing); 226 irq_rt = rcu_dereference(kvm->irq_routing);
229 if (irq < irq_rt->nr_rt_entries) 227 if (irq < irq_rt->nr_rt_entries)
230 hlist_for_each_entry(e, n, &irq_rt->map[irq], link) { 228 hlist_for_each_entry(e, &irq_rt->map[irq], link) {
231 if (likely(e->type == KVM_IRQ_ROUTING_MSI)) 229 if (likely(e->type == KVM_IRQ_ROUTING_MSI))
232 ret = kvm_set_msi_inatomic(e, kvm); 230 ret = kvm_set_msi_inatomic(e, kvm);
233 else 231 else
@@ -241,13 +239,12 @@ int kvm_set_irq_inatomic(struct kvm *kvm, int irq_source_id, u32 irq, int level)
241bool kvm_irq_has_notifier(struct kvm *kvm, unsigned irqchip, unsigned pin) 239bool kvm_irq_has_notifier(struct kvm *kvm, unsigned irqchip, unsigned pin)
242{ 240{
243 struct kvm_irq_ack_notifier *kian; 241 struct kvm_irq_ack_notifier *kian;
244 struct hlist_node *n;
245 int gsi; 242 int gsi;
246 243
247 rcu_read_lock(); 244 rcu_read_lock();
248 gsi = rcu_dereference(kvm->irq_routing)->chip[irqchip][pin]; 245 gsi = rcu_dereference(kvm->irq_routing)->chip[irqchip][pin];
249 if (gsi != -1) 246 if (gsi != -1)
250 hlist_for_each_entry_rcu(kian, n, &kvm->irq_ack_notifier_list, 247 hlist_for_each_entry_rcu(kian, &kvm->irq_ack_notifier_list,
251 link) 248 link)
252 if (kian->gsi == gsi) { 249 if (kian->gsi == gsi) {
253 rcu_read_unlock(); 250 rcu_read_unlock();
@@ -263,7 +260,6 @@ EXPORT_SYMBOL_GPL(kvm_irq_has_notifier);
263void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin) 260void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin)
264{ 261{
265 struct kvm_irq_ack_notifier *kian; 262 struct kvm_irq_ack_notifier *kian;
266 struct hlist_node *n;
267 int gsi; 263 int gsi;
268 264
269 trace_kvm_ack_irq(irqchip, pin); 265 trace_kvm_ack_irq(irqchip, pin);
@@ -271,7 +267,7 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin)
271 rcu_read_lock(); 267 rcu_read_lock();
272 gsi = rcu_dereference(kvm->irq_routing)->chip[irqchip][pin]; 268 gsi = rcu_dereference(kvm->irq_routing)->chip[irqchip][pin];
273 if (gsi != -1) 269 if (gsi != -1)
274 hlist_for_each_entry_rcu(kian, n, &kvm->irq_ack_notifier_list, 270 hlist_for_each_entry_rcu(kian, &kvm->irq_ack_notifier_list,
275 link) 271 link)
276 if (kian->gsi == gsi) 272 if (kian->gsi == gsi)
277 kian->irq_acked(kian); 273 kian->irq_acked(kian);
@@ -369,13 +365,12 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin,
369 bool mask) 365 bool mask)
370{ 366{
371 struct kvm_irq_mask_notifier *kimn; 367 struct kvm_irq_mask_notifier *kimn;
372 struct hlist_node *n;
373 int gsi; 368 int gsi;
374 369
375 rcu_read_lock(); 370 rcu_read_lock();
376 gsi = rcu_dereference(kvm->irq_routing)->chip[irqchip][pin]; 371 gsi = rcu_dereference(kvm->irq_routing)->chip[irqchip][pin];
377 if (gsi != -1) 372 if (gsi != -1)
378 hlist_for_each_entry_rcu(kimn, n, &kvm->mask_notifier_list, link) 373 hlist_for_each_entry_rcu(kimn, &kvm->mask_notifier_list, link)
379 if (kimn->irq == gsi) 374 if (kimn->irq == gsi)
380 kimn->func(kimn, mask); 375 kimn->func(kimn, mask);
381 rcu_read_unlock(); 376 rcu_read_unlock();
@@ -396,13 +391,12 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt,
396 int delta; 391 int delta;
397 unsigned max_pin; 392 unsigned max_pin;
398 struct kvm_kernel_irq_routing_entry *ei; 393 struct kvm_kernel_irq_routing_entry *ei;
399 struct hlist_node *n;
400 394
401 /* 395 /*
402 * Do not allow GSI to be mapped to the same irqchip more than once. 396 * Do not allow GSI to be mapped to the same irqchip more than once.
403 * Allow only one to one mapping between GSI and MSI. 397 * Allow only one to one mapping between GSI and MSI.
404 */ 398 */
405 hlist_for_each_entry(ei, n, &rt->map[ue->gsi], link) 399 hlist_for_each_entry(ei, &rt->map[ue->gsi], link)
406 if (ei->type == KVM_IRQ_ROUTING_MSI || 400 if (ei->type == KVM_IRQ_ROUTING_MSI ||
407 ue->type == KVM_IRQ_ROUTING_MSI || 401 ue->type == KVM_IRQ_ROUTING_MSI ||
408 ue->u.irqchip.irqchip == ei->irqchip.irqchip) 402 ue->u.irqchip.irqchip == ei->irqchip.irqchip)