Commit 073d4613 authored by Avi Kivity's avatar Avi Kivity

KVM: i8259: reduce excessive abstraction for pic_irq_request()

Part of the i8259 code pretends it isn't part of kvm, but we know better.
Reduce excessive abstraction, eliminating callbacks and void pointers.
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent b74a07be
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <linux/kvm_host.h> #include <linux/kvm_host.h>
#include "trace.h" #include "trace.h"
static void pic_irq_request(struct kvm *kvm, int level);
static void pic_lock(struct kvm_pic *s) static void pic_lock(struct kvm_pic *s)
__acquires(&s->lock) __acquires(&s->lock)
{ {
...@@ -175,9 +177,9 @@ static void pic_update_irq(struct kvm_pic *s) ...@@ -175,9 +177,9 @@ static void pic_update_irq(struct kvm_pic *s)
} }
irq = pic_get_irq(&s->pics[0]); irq = pic_get_irq(&s->pics[0]);
if (irq >= 0) if (irq >= 0)
s->irq_request(s->irq_request_opaque, 1); pic_irq_request(s->kvm, 1);
else else
s->irq_request(s->irq_request_opaque, 0); pic_irq_request(s->kvm, 0);
} }
void kvm_pic_update_irq(struct kvm_pic *s) void kvm_pic_update_irq(struct kvm_pic *s)
...@@ -262,8 +264,7 @@ int kvm_pic_read_irq(struct kvm *kvm) ...@@ -262,8 +264,7 @@ int kvm_pic_read_irq(struct kvm *kvm)
void kvm_pic_reset(struct kvm_kpic_state *s) void kvm_pic_reset(struct kvm_kpic_state *s)
{ {
int irq; int irq;
struct kvm *kvm = s->pics_state->irq_request_opaque; struct kvm_vcpu *vcpu0 = s->pics_state->kvm->bsp_vcpu;
struct kvm_vcpu *vcpu0 = kvm->bsp_vcpu;
u8 irr = s->irr, isr = s->imr; u8 irr = s->irr, isr = s->imr;
s->last_irr = 0; s->last_irr = 0;
...@@ -302,8 +303,7 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val) ...@@ -302,8 +303,7 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
/* /*
* deassert a pending interrupt * deassert a pending interrupt
*/ */
s->pics_state->irq_request(s->pics_state-> pic_irq_request(s->pics_state->kvm, 0);
irq_request_opaque, 0);
s->init_state = 1; s->init_state = 1;
s->init4 = val & 1; s->init4 = val & 1;
if (val & 0x02) if (val & 0x02)
...@@ -519,9 +519,8 @@ static int picdev_read(struct kvm_io_device *this, ...@@ -519,9 +519,8 @@ static int picdev_read(struct kvm_io_device *this,
/* /*
* callback when PIC0 irq status changed * callback when PIC0 irq status changed
*/ */
static void pic_irq_request(void *opaque, int level) static void pic_irq_request(struct kvm *kvm, int level)
{ {
struct kvm *kvm = opaque;
struct kvm_vcpu *vcpu = kvm->bsp_vcpu; struct kvm_vcpu *vcpu = kvm->bsp_vcpu;
struct kvm_pic *s = pic_irqchip(kvm); struct kvm_pic *s = pic_irqchip(kvm);
int irq = pic_get_irq(&s->pics[0]); int irq = pic_get_irq(&s->pics[0]);
...@@ -550,8 +549,6 @@ struct kvm_pic *kvm_create_pic(struct kvm *kvm) ...@@ -550,8 +549,6 @@ struct kvm_pic *kvm_create_pic(struct kvm *kvm)
s->kvm = kvm; s->kvm = kvm;
s->pics[0].elcr_mask = 0xf8; s->pics[0].elcr_mask = 0xf8;
s->pics[1].elcr_mask = 0xde; s->pics[1].elcr_mask = 0xde;
s->irq_request = pic_irq_request;
s->irq_request_opaque = kvm;
s->pics[0].pics_state = s; s->pics[0].pics_state = s;
s->pics[1].pics_state = s; s->pics[1].pics_state = s;
......
...@@ -38,8 +38,6 @@ ...@@ -38,8 +38,6 @@
struct kvm; struct kvm;
struct kvm_vcpu; struct kvm_vcpu;
typedef void irq_request_func(void *opaque, int level);
struct kvm_kpic_state { struct kvm_kpic_state {
u8 last_irr; /* edge detection */ u8 last_irr; /* edge detection */
u8 irr; /* interrupt request register */ u8 irr; /* interrupt request register */
...@@ -67,8 +65,6 @@ struct kvm_pic { ...@@ -67,8 +65,6 @@ struct kvm_pic {
unsigned pending_acks; unsigned pending_acks;
struct kvm *kvm; struct kvm *kvm;
struct kvm_kpic_state pics[2]; /* 0 is master pic, 1 is slave pic */ struct kvm_kpic_state pics[2]; /* 0 is master pic, 1 is slave pic */
irq_request_func *irq_request;
void *irq_request_opaque;
int output; /* intr from master PIC */ int output; /* intr from master PIC */
struct kvm_io_device dev; struct kvm_io_device dev;
void (*ack_notifier)(void *opaque, int irq); void (*ack_notifier)(void *opaque, int irq);
......
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