KVM: x86: get rid of pic_irqchip()
authorDavid Hildenbrand <david@redhat.com>
Fri, 7 Apr 2017 08:50:23 +0000 (10:50 +0200)
committerRadim Krčmář <rkrcmar@redhat.com>
Wed, 12 Apr 2017 18:17:13 +0000 (20:17 +0200)
It seemed like a nice idea to encapsulate access to kvm->arch.vpic. But
as the usage is already mixed, internal locks are taken outside of i8259.c
and grepping for "vpic" only is much easier, let's just get rid of
pic_irqchip().

Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
arch/x86/kvm/i8259.c
arch/x86/kvm/irq.c
arch/x86/kvm/irq.h
arch/x86/kvm/irq_comm.c
arch/x86/kvm/x86.c

index 047b17a..af97c5a 100644 (file)
@@ -239,7 +239,7 @@ static inline void pic_intack(struct kvm_kpic_state *s, int irq)
 int kvm_pic_read_irq(struct kvm *kvm)
 {
        int irq, irq2, intno;
-       struct kvm_pic *s = pic_irqchip(kvm);
+       struct kvm_pic *s = kvm->arch.vpic;
 
        s->output = 0;
 
@@ -576,7 +576,7 @@ static int picdev_eclr_read(struct kvm_vcpu *vcpu, struct kvm_io_device *dev,
  */
 static void pic_irq_request(struct kvm *kvm, int level)
 {
-       struct kvm_pic *s = pic_irqchip(kvm);
+       struct kvm_pic *s = kvm->arch.vpic;
 
        if (!s->output)
                s->wakeup_needed = true;
index 60d91c9..5c24811 100644 (file)
@@ -60,7 +60,7 @@ static int kvm_cpu_has_extint(struct kvm_vcpu *v)
                if (irqchip_split(v->kvm))
                        return pending_userspace_extint(v);
                else
-                       return pic_irqchip(v->kvm)->output;
+                       return v->kvm->arch.vpic->output;
        } else
                return 0;
 }
index 26d8dd4..8fec66d 100644 (file)
@@ -78,11 +78,6 @@ void kvm_pic_destroy(struct kvm *kvm);
 int kvm_pic_read_irq(struct kvm *kvm);
 void kvm_pic_update_irq(struct kvm_pic *s);
 
-static inline struct kvm_pic *pic_irqchip(struct kvm *kvm)
-{
-       return kvm->arch.vpic;
-}
-
 static inline int pic_in_kernel(struct kvm *kvm)
 {
        int mode = kvm->arch.irqchip_mode;
index 2e5eec8..d82fc14 100644 (file)
@@ -42,7 +42,7 @@ static int kvm_set_pic_irq(struct kvm_kernel_irq_routing_entry *e,
                           struct kvm *kvm, int irq_source_id, int level,
                           bool line_status)
 {
-       struct kvm_pic *pic = pic_irqchip(kvm);
+       struct kvm_pic *pic = kvm->arch.vpic;
        return kvm_pic_set_irq(pic, e->irqchip.pin, irq_source_id, level);
 }
 
@@ -236,7 +236,7 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id)
                goto unlock;
 
        kvm_ioapic_clear_all(kvm->arch.vioapic, irq_source_id);
-       kvm_pic_clear_all(pic_irqchip(kvm), irq_source_id);
+       kvm_pic_clear_all(kvm->arch.vpic, irq_source_id);
 unlock:
        mutex_unlock(&kvm->irq_lock);
 }
index c7956ce..c50d6b6 100644 (file)
@@ -3715,18 +3715,17 @@ static int kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm)
 
 static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
 {
+       struct kvm_pic *pic = kvm->arch.vpic;
        int r;
 
        r = 0;
        switch (chip->chip_id) {
        case KVM_IRQCHIP_PIC_MASTER:
-               memcpy(&chip->chip.pic,
-                       &pic_irqchip(kvm)->pics[0],
+               memcpy(&chip->chip.pic, &pic->pics[0],
                        sizeof(struct kvm_pic_state));
                break;
        case KVM_IRQCHIP_PIC_SLAVE:
-               memcpy(&chip->chip.pic,
-                       &pic_irqchip(kvm)->pics[1],
+               memcpy(&chip->chip.pic, &pic->pics[1],
                        sizeof(struct kvm_pic_state));
                break;
        case KVM_IRQCHIP_IOAPIC:
@@ -3741,23 +3740,22 @@ static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
 
 static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
 {
+       struct kvm_pic *pic = kvm->arch.vpic;
        int r;
 
        r = 0;
        switch (chip->chip_id) {
        case KVM_IRQCHIP_PIC_MASTER:
-               spin_lock(&pic_irqchip(kvm)->lock);
-               memcpy(&pic_irqchip(kvm)->pics[0],
-                       &chip->chip.pic,
+               spin_lock(&pic->lock);
+               memcpy(&pic->pics[0], &chip->chip.pic,
                        sizeof(struct kvm_pic_state));
-               spin_unlock(&pic_irqchip(kvm)->lock);
+               spin_unlock(&pic->lock);
                break;
        case KVM_IRQCHIP_PIC_SLAVE:
-               spin_lock(&pic_irqchip(kvm)->lock);
-               memcpy(&pic_irqchip(kvm)->pics[1],
-                       &chip->chip.pic,
+               spin_lock(&pic->lock);
+               memcpy(&pic->pics[1], &chip->chip.pic,
                        sizeof(struct kvm_pic_state));
-               spin_unlock(&pic_irqchip(kvm)->lock);
+               spin_unlock(&pic->lock);
                break;
        case KVM_IRQCHIP_IOAPIC:
                r = kvm_set_ioapic(kvm, &chip->chip.ioapic);
@@ -3766,7 +3764,7 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
                r = -EINVAL;
                break;
        }
-       kvm_pic_update_irq(pic_irqchip(kvm));
+       kvm_pic_update_irq(pic);
        return r;
 }