Commit 90bca052 authored by David Hildenbrand's avatar David Hildenbrand Committed by Radim Krčmář

KVM: x86: get rid of pic_irqchip()

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: default avatarDavid Hildenbrand <david@redhat.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent f567080b
...@@ -239,7 +239,7 @@ static inline void pic_intack(struct kvm_kpic_state *s, int irq) ...@@ -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 kvm_pic_read_irq(struct kvm *kvm)
{ {
int irq, irq2, intno; int irq, irq2, intno;
struct kvm_pic *s = pic_irqchip(kvm); struct kvm_pic *s = kvm->arch.vpic;
s->output = 0; s->output = 0;
...@@ -576,7 +576,7 @@ static int picdev_eclr_read(struct kvm_vcpu *vcpu, struct kvm_io_device *dev, ...@@ -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) 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) if (!s->output)
s->wakeup_needed = true; s->wakeup_needed = true;
......
...@@ -60,7 +60,7 @@ static int kvm_cpu_has_extint(struct kvm_vcpu *v) ...@@ -60,7 +60,7 @@ static int kvm_cpu_has_extint(struct kvm_vcpu *v)
if (irqchip_split(v->kvm)) if (irqchip_split(v->kvm))
return pending_userspace_extint(v); return pending_userspace_extint(v);
else else
return pic_irqchip(v->kvm)->output; return v->kvm->arch.vpic->output;
} else } else
return 0; return 0;
} }
......
...@@ -78,11 +78,6 @@ void kvm_pic_destroy(struct kvm *kvm); ...@@ -78,11 +78,6 @@ void kvm_pic_destroy(struct kvm *kvm);
int kvm_pic_read_irq(struct kvm *kvm); int kvm_pic_read_irq(struct kvm *kvm);
void kvm_pic_update_irq(struct kvm_pic *s); 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) static inline int pic_in_kernel(struct kvm *kvm)
{ {
int mode = kvm->arch.irqchip_mode; int mode = kvm->arch.irqchip_mode;
......
...@@ -42,7 +42,7 @@ static int kvm_set_pic_irq(struct kvm_kernel_irq_routing_entry *e, ...@@ -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, struct kvm *kvm, int irq_source_id, int level,
bool line_status) 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); 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) ...@@ -236,7 +236,7 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id)
goto unlock; goto unlock;
kvm_ioapic_clear_all(kvm->arch.vioapic, irq_source_id); 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: unlock:
mutex_unlock(&kvm->irq_lock); mutex_unlock(&kvm->irq_lock);
} }
......
...@@ -3715,18 +3715,17 @@ static int kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm) ...@@ -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) static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
{ {
struct kvm_pic *pic = kvm->arch.vpic;
int r; int r;
r = 0; r = 0;
switch (chip->chip_id) { switch (chip->chip_id) {
case KVM_IRQCHIP_PIC_MASTER: case KVM_IRQCHIP_PIC_MASTER:
memcpy(&chip->chip.pic, memcpy(&chip->chip.pic, &pic->pics[0],
&pic_irqchip(kvm)->pics[0],
sizeof(struct kvm_pic_state)); sizeof(struct kvm_pic_state));
break; break;
case KVM_IRQCHIP_PIC_SLAVE: case KVM_IRQCHIP_PIC_SLAVE:
memcpy(&chip->chip.pic, memcpy(&chip->chip.pic, &pic->pics[1],
&pic_irqchip(kvm)->pics[1],
sizeof(struct kvm_pic_state)); sizeof(struct kvm_pic_state));
break; break;
case KVM_IRQCHIP_IOAPIC: case KVM_IRQCHIP_IOAPIC:
...@@ -3741,23 +3740,22 @@ static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip) ...@@ -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) static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
{ {
struct kvm_pic *pic = kvm->arch.vpic;
int r; int r;
r = 0; r = 0;
switch (chip->chip_id) { switch (chip->chip_id) {
case KVM_IRQCHIP_PIC_MASTER: case KVM_IRQCHIP_PIC_MASTER:
spin_lock(&pic_irqchip(kvm)->lock); spin_lock(&pic->lock);
memcpy(&pic_irqchip(kvm)->pics[0], memcpy(&pic->pics[0], &chip->chip.pic,
&chip->chip.pic,
sizeof(struct kvm_pic_state)); sizeof(struct kvm_pic_state));
spin_unlock(&pic_irqchip(kvm)->lock); spin_unlock(&pic->lock);
break; break;
case KVM_IRQCHIP_PIC_SLAVE: case KVM_IRQCHIP_PIC_SLAVE:
spin_lock(&pic_irqchip(kvm)->lock); spin_lock(&pic->lock);
memcpy(&pic_irqchip(kvm)->pics[1], memcpy(&pic->pics[1], &chip->chip.pic,
&chip->chip.pic,
sizeof(struct kvm_pic_state)); sizeof(struct kvm_pic_state));
spin_unlock(&pic_irqchip(kvm)->lock); spin_unlock(&pic->lock);
break; break;
case KVM_IRQCHIP_IOAPIC: case KVM_IRQCHIP_IOAPIC:
r = kvm_set_ioapic(kvm, &chip->chip.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) ...@@ -3766,7 +3764,7 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
r = -EINVAL; r = -EINVAL;
break; break;
} }
kvm_pic_update_irq(pic_irqchip(kvm)); kvm_pic_update_irq(pic);
return r; return r;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment