Merge branch 'bugzilla-21212' into release
[firefly-linux-kernel-4.4.55.git] / arch / x86 / kvm / i8259.c
index 4b7b73ce209894442eddd9df2b8f076408389b12..3cece05e4ac4622853c8eeb20e3bd04a02f851c7 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2003-2004 Fabrice Bellard
  * Copyright (c) 2007 Intel Corporation
- * Copyright 2009 Red Hat, Inc. and/or its affilates.
+ * Copyright 2009 Red Hat, Inc. and/or its affiliates.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +39,7 @@ static void pic_irq_request(struct kvm *kvm, int level);
 static void pic_lock(struct kvm_pic *s)
        __acquires(&s->lock)
 {
-       raw_spin_lock(&s->lock);
+       spin_lock(&s->lock);
 }
 
 static void pic_unlock(struct kvm_pic *s)
@@ -51,7 +51,7 @@ static void pic_unlock(struct kvm_pic *s)
 
        s->wakeup_needed = false;
 
-       raw_spin_unlock(&s->lock);
+       spin_unlock(&s->lock);
 
        if (wakeup) {
                kvm_for_each_vcpu(i, vcpu, s->kvm) {
@@ -67,6 +67,7 @@ static void pic_unlock(struct kvm_pic *s)
                if (!found)
                        return;
 
+               kvm_make_request(KVM_REQ_EVENT, found);
                kvm_vcpu_kick(found);
        }
 }
@@ -308,13 +309,17 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
        addr &= 1;
        if (addr == 0) {
                if (val & 0x10) {
-                       kvm_pic_reset(s);       /* init */
-                       /*
-                        * deassert a pending interrupt
-                        */
-                       pic_irq_request(s->pics_state->kvm, 0);
-                       s->init_state = 1;
                        s->init4 = val & 1;
+                       s->last_irr = 0;
+                       s->imr = 0;
+                       s->priority_add = 0;
+                       s->special_mask = 0;
+                       s->read_reg_select = 0;
+                       if (!s->init4) {
+                               s->special_fully_nested_mode = 0;
+                               s->auto_eoi = 0;
+                       }
+                       s->init_state = 1;
                        if (val & 0x02)
                                printk(KERN_ERR "single mode not supported");
                        if (val & 0x08)
@@ -564,12 +569,14 @@ struct kvm_pic *kvm_create_pic(struct kvm *kvm)
        s = kzalloc(sizeof(struct kvm_pic), GFP_KERNEL);
        if (!s)
                return NULL;
-       raw_spin_lock_init(&s->lock);
+       spin_lock_init(&s->lock);
        s->kvm = kvm;
        s->pics[0].elcr_mask = 0xf8;
        s->pics[1].elcr_mask = 0xde;
        s->pics[0].pics_state = s;
        s->pics[1].pics_state = s;
+       s->pics[0].isr_ack = 0xff;
+       s->pics[1].isr_ack = 0xff;
 
        /*
         * Initialize PIO device