Merge tag 'iwlwifi-for-kalle-2015-12-16' of https://git.kernel.org/pub/scm/linux...
[firefly-linux-kernel-4.4.55.git] / arch / x86 / kvm / irq_comm.c
index c8922898023083545474e522a5bee5a0cbcd9310..84b96d319909414fd3aba1e7b7888486843f86b8 100644 (file)
@@ -124,12 +124,16 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
 }
 
 
-static int kvm_set_msi_inatomic(struct kvm_kernel_irq_routing_entry *e,
-                        struct kvm *kvm)
+int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e,
+                             struct kvm *kvm, int irq_source_id, int level,
+                             bool line_status)
 {
        struct kvm_lapic_irq irq;
        int r;
 
+       if (unlikely(e->type != KVM_IRQ_ROUTING_MSI))
+               return -EWOULDBLOCK;
+
        kvm_set_msi_irq(e, &irq);
 
        if (kvm_irq_delivery_to_apic_fast(kvm, NULL, &irq, &r, NULL))
@@ -138,42 +142,6 @@ static int kvm_set_msi_inatomic(struct kvm_kernel_irq_routing_entry *e,
                return -EWOULDBLOCK;
 }
 
-/*
- * Deliver an IRQ in an atomic context if we can, or return a failure,
- * user can retry in a process context.
- * Return value:
- *  -EWOULDBLOCK - Can't deliver in atomic context: retry in a process context.
- *  Other values - No need to retry.
- */
-int kvm_set_irq_inatomic(struct kvm *kvm, int irq_source_id, u32 irq, int level)
-{
-       struct kvm_kernel_irq_routing_entry entries[KVM_NR_IRQCHIPS];
-       struct kvm_kernel_irq_routing_entry *e;
-       int ret = -EINVAL;
-       int idx;
-
-       trace_kvm_set_irq(irq, level, irq_source_id);
-
-       /*
-        * Injection into either PIC or IOAPIC might need to scan all CPUs,
-        * which would need to be retried from thread context;  when same GSI
-        * is connected to both PIC and IOAPIC, we'd have to report a
-        * partial failure here.
-        * Since there's no easy way to do this, we only support injecting MSI
-        * which is limited to 1:1 GSI mapping.
-        */
-       idx = srcu_read_lock(&kvm->irq_srcu);
-       if (kvm_irq_map_gsi(kvm, entries, irq) > 0) {
-               e = &entries[0];
-               if (likely(e->type == KVM_IRQ_ROUTING_MSI))
-                       ret = kvm_set_msi_inatomic(e, kvm);
-               else
-                       ret = -EWOULDBLOCK;
-       }
-       srcu_read_unlock(&kvm->irq_srcu, idx);
-       return ret;
-}
-
 int kvm_request_irq_source_id(struct kvm *kvm)
 {
        unsigned long *bitmap = &kvm->arch.irq_sources_bitmap;
@@ -389,13 +357,15 @@ void kvm_scan_ioapic_routes(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap)
        for (i = 0; i < nr_ioapic_pins; ++i) {
                hlist_for_each_entry(entry, &table->map[i], link) {
                        u32 dest_id, dest_mode;
+                       bool level;
 
                        if (entry->type != KVM_IRQ_ROUTING_MSI)
                                continue;
                        dest_id = (entry->msi.address_lo >> 12) & 0xff;
                        dest_mode = (entry->msi.address_lo >> 2) & 0x1;
-                       if (kvm_apic_match_dest(vcpu, NULL, 0, dest_id,
-                                               dest_mode)) {
+                       level = entry->msi.data & MSI_DATA_TRIGGER_LEVEL;
+                       if (level && kvm_apic_match_dest(vcpu, NULL, 0,
+                                               dest_id, dest_mode)) {
                                u32 vector = entry->msi.data & 0xff;
 
                                __set_bit(vector,