Since we want to be able to call kvm_pic_set_irq() in interrupt context, convert the uses of spin_lock() to spin_lock_irqsave() as appropriate in i8259.c Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx> --- arch/x86/kvm/i8259.c | 34 ++++++++++++++++++++++------------ 1 files changed, 22 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c index 59a8a68..8285f0d 100644 --- a/arch/x86/kvm/i8259.c +++ b/arch/x86/kvm/i8259.c @@ -52,10 +52,12 @@ static void pic_clear_isr(struct kvm_kpic_state *s, int irq) void kvm_pic_clear_isr_ack(struct kvm *kvm) { struct kvm_pic *s = pic_irqchip(kvm); - spin_lock(&s->lock); + unsigned long flags; + + spin_lock_irqsave(&s->lock, flags); s->pics[0].isr_ack = 0xff; s->pics[1].isr_ack = 0xff; - spin_unlock(&s->lock); + spin_unlock_irqrestore(&s->lock, flags); } /* @@ -156,24 +158,27 @@ static void pic_update_irq(struct kvm_pic *s) void kvm_pic_update_irq(struct kvm_pic *s) { - spin_lock(&s->lock); + unsigned long flags; + + spin_lock_irqsave(&s->lock, flags); pic_update_irq(s); - spin_unlock(&s->lock); + spin_unlock_irqrestore(&s->lock, flags); } int kvm_pic_set_irq(void *opaque, int irq, int level) { struct kvm_pic *s = opaque; int ret = -1; + unsigned long flags; - spin_lock(&s->lock); + spin_lock_irqsave(&s->lock, flags); if (irq >= 0 && irq < PIC_NUM_PINS) { ret = pic_set_irq1(&s->pics[irq >> 3], irq & 7, level); pic_update_irq(s); trace_kvm_pic_set_irq(irq >> 3, irq & 7, s->pics[irq >> 3].elcr, s->pics[irq >> 3].imr, ret == 0); } - spin_unlock(&s->lock); + spin_unlock_irqrestore(&s->lock, flags); return ret; } @@ -202,8 +207,9 @@ int kvm_pic_read_irq(struct kvm *kvm) { int irq, irq2, intno; struct kvm_pic *s = pic_irqchip(kvm); + unsigned long flags; - spin_lock(&s->lock); + spin_lock_irqsave(&s->lock, flags); irq = pic_get_irq(&s->pics[0]); if (irq >= 0) { pic_intack(&s->pics[0], irq); @@ -228,7 +234,7 @@ int kvm_pic_read_irq(struct kvm *kvm) intno = s->pics[0].irq_base + irq; } pic_update_irq(s); - spin_unlock(&s->lock); + spin_unlock_irqrestore(&s->lock, flags); return intno; } @@ -434,6 +440,8 @@ static int picdev_write(struct kvm_io_device *this, { struct kvm_pic *s = to_pic(this); unsigned char data = *(unsigned char *)val; + unsigned long flags; + if (!picdev_in_range(addr)) return -EOPNOTSUPP; @@ -442,7 +450,7 @@ static int picdev_write(struct kvm_io_device *this, printk(KERN_ERR "PIC: non byte write\n"); return 0; } - spin_lock(&s->lock); + spin_lock_irqsave(&s->lock, flags); switch (addr) { case 0x20: case 0x21: @@ -455,7 +463,7 @@ static int picdev_write(struct kvm_io_device *this, elcr_ioport_write(&s->pics[addr & 1], addr, data); break; } - spin_unlock(&s->lock); + spin_unlock_irqrestore(&s->lock, flags); return 0; } @@ -464,6 +472,8 @@ static int picdev_read(struct kvm_io_device *this, { struct kvm_pic *s = to_pic(this); unsigned char data = 0; + unsigned long flags; + if (!picdev_in_range(addr)) return -EOPNOTSUPP; @@ -472,7 +482,7 @@ static int picdev_read(struct kvm_io_device *this, printk(KERN_ERR "PIC: non byte read\n"); return 0; } - spin_lock(&s->lock); + spin_lock_irqsave(&s->lock, flags); switch (addr) { case 0x20: case 0x21: @@ -486,7 +496,7 @@ static int picdev_read(struct kvm_io_device *this, break; } *(unsigned char *)val = data; - spin_unlock(&s->lock); + spin_unlock_irqrestore(&s->lock, flags); return 0; } -- 1.6.5.2 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html