* [PATCH 1/2] KVM: PIC: call ack notifiers for irqs that are dropped form irr
@ 2012-07-26 7:00 Gleb Natapov
2012-07-26 7:00 ` [PATCH 2/2] KVM: cleanup pic reset Gleb Natapov
2012-07-26 9:09 ` [PATCH 1/2] KVM: PIC: call ack notifiers for irqs that are dropped form irr Avi Kivity
0 siblings, 2 replies; 5+ messages in thread
From: Gleb Natapov @ 2012-07-26 7:00 UTC (permalink / raw)
To: kvm; +Cc: avi, mtosatti
After commit 242ec97c358256 PIT interrupts are no longer delivered after
PIC reset. It happens because PIT injects interrupt only if previous one
was acked, but since on PIC reset it is dropped from irr it will never
be delivered and hence acknowledged. Fix that by calling ack notifier on
PIC reset.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/i8259.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 81cf4fa..0147d16 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -305,6 +305,11 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
addr &= 1;
if (addr == 0) {
if (val & 0x10) {
+ u8 edge_irr = s->irr & ~s->elcr;
+ int i;
+ bool found;
+ struct kvm_vcpu *vcpu;
+
s->init4 = val & 1;
s->last_irr = 0;
s->irr &= s->elcr;
@@ -322,6 +327,18 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
if (val & 0x08)
pr_pic_unimpl(
"level sensitive irq not supported");
+
+ kvm_for_each_vcpu(i, vcpu, s->pics_state->kvm)
+ if (kvm_apic_accept_pic_intr(vcpu)) {
+ found = true;
+ break;
+ }
+
+
+ if (found)
+ for (irq = 0; irq < PIC_NUM_PINS/2; irq++)
+ if (edge_irr & (1 << irq))
+ pic_clear_isr(s, irq);
} else if (val & 0x08) {
if (val & 0x04)
s->poll = 1;
--
1.7.10
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] KVM: cleanup pic reset
2012-07-26 7:00 [PATCH 1/2] KVM: PIC: call ack notifiers for irqs that are dropped form irr Gleb Natapov
@ 2012-07-26 7:00 ` Gleb Natapov
2012-07-26 9:09 ` [PATCH 1/2] KVM: PIC: call ack notifiers for irqs that are dropped form irr Avi Kivity
1 sibling, 0 replies; 5+ messages in thread
From: Gleb Natapov @ 2012-07-26 7:00 UTC (permalink / raw)
To: kvm; +Cc: avi, mtosatti
kvm_pic_reset() is not used anywhere. Move reset logic from
pic_ioport_write() there.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/i8259.c | 52 +++++++++++---------------------------------------
1 file changed, 11 insertions(+), 41 deletions(-)
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 0147d16..14e9209 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -264,23 +264,20 @@ void kvm_pic_reset(struct kvm_kpic_state *s)
{
int irq, i;
struct kvm_vcpu *vcpu;
- u8 irr = s->irr, isr = s->imr;
+ u8 edge_irr = s->irr & ~s->elcr;
bool found = false;
s->last_irr = 0;
- s->irr = 0;
+ s->irr &= s->elcr;
s->imr = 0;
- s->isr = 0;
s->priority_add = 0;
- s->irq_base = 0;
- s->read_reg_select = 0;
- s->poll = 0;
s->special_mask = 0;
- s->init_state = 0;
- s->auto_eoi = 0;
- s->rotate_on_auto_eoi = 0;
- s->special_fully_nested_mode = 0;
- s->init4 = 0;
+ s->read_reg_select = 0;
+ if (!s->init4) {
+ s->special_fully_nested_mode = 0;
+ s->auto_eoi = 0;
+ }
+ s->init_state = 1;
kvm_for_each_vcpu(i, vcpu, s->pics_state->kvm)
if (kvm_apic_accept_pic_intr(vcpu)) {
@@ -293,7 +290,7 @@ void kvm_pic_reset(struct kvm_kpic_state *s)
return;
for (irq = 0; irq < PIC_NUM_PINS/2; irq++)
- if (irr & (1 << irq) || isr & (1 << irq))
+ if (edge_irr & (1 << irq))
pic_clear_isr(s, irq);
}
@@ -305,40 +302,13 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
addr &= 1;
if (addr == 0) {
if (val & 0x10) {
- u8 edge_irr = s->irr & ~s->elcr;
- int i;
- bool found;
- struct kvm_vcpu *vcpu;
-
s->init4 = val & 1;
- s->last_irr = 0;
- s->irr &= s->elcr;
- 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)
pr_pic_unimpl("single mode not supported");
if (val & 0x08)
pr_pic_unimpl(
- "level sensitive irq not supported");
-
- kvm_for_each_vcpu(i, vcpu, s->pics_state->kvm)
- if (kvm_apic_accept_pic_intr(vcpu)) {
- found = true;
- break;
- }
-
-
- if (found)
- for (irq = 0; irq < PIC_NUM_PINS/2; irq++)
- if (edge_irr & (1 << irq))
- pic_clear_isr(s, irq);
+ "level sensitive irq not supported");
+ kvm_pic_reset(s);
} else if (val & 0x08) {
if (val & 0x04)
s->poll = 1;
--
1.7.10
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] KVM: PIC: call ack notifiers for irqs that are dropped form irr
2012-07-26 7:00 [PATCH 1/2] KVM: PIC: call ack notifiers for irqs that are dropped form irr Gleb Natapov
2012-07-26 7:00 ` [PATCH 2/2] KVM: cleanup pic reset Gleb Natapov
@ 2012-07-26 9:09 ` Avi Kivity
2012-07-26 9:11 ` Gleb Natapov
1 sibling, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2012-07-26 9:09 UTC (permalink / raw)
To: Gleb Natapov; +Cc: kvm, mtosatti
On 07/26/2012 10:00 AM, Gleb Natapov wrote:
> After commit 242ec97c358256 PIT interrupts are no longer delivered after
> PIC reset. It happens because PIT injects interrupt only if previous one
> was acked, but since on PIC reset it is dropped from irr it will never
> be delivered and hence acknowledged. Fix that by calling ack notifier on
> PIC reset.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
> arch/x86/kvm/i8259.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
> index 81cf4fa..0147d16 100644
> --- a/arch/x86/kvm/i8259.c
> +++ b/arch/x86/kvm/i8259.c
> @@ -305,6 +305,11 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
> addr &= 1;
> if (addr == 0) {
> if (val & 0x10) {
> + u8 edge_irr = s->irr & ~s->elcr;
> + int i;
> + bool found;
> + struct kvm_vcpu *vcpu;
> +
> s->init4 = val & 1;
> s->last_irr = 0;
> s->irr &= s->elcr;
> @@ -322,6 +327,18 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
> if (val & 0x08)
> pr_pic_unimpl(
> "level sensitive irq not supported");
> +
> + kvm_for_each_vcpu(i, vcpu, s->pics_state->kvm)
> + if (kvm_apic_accept_pic_intr(vcpu)) {
> + found = true;
> + break;
> + }
> +
> +
> + if (found)
> + for (irq = 0; irq < PIC_NUM_PINS/2; irq++)
> + if (edge_irr & (1 << irq))
> + pic_clear_isr(s, irq);
> } else if (val & 0x08) {
This duplicates the code in pic_reset(). Please extract it into a
function (just the new code, since this is going into 3.6).
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] KVM: PIC: call ack notifiers for irqs that are dropped form irr
2012-07-26 9:09 ` [PATCH 1/2] KVM: PIC: call ack notifiers for irqs that are dropped form irr Avi Kivity
@ 2012-07-26 9:11 ` Gleb Natapov
2012-07-26 9:18 ` Avi Kivity
0 siblings, 1 reply; 5+ messages in thread
From: Gleb Natapov @ 2012-07-26 9:11 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, mtosatti
On Thu, Jul 26, 2012 at 12:09:36PM +0300, Avi Kivity wrote:
> On 07/26/2012 10:00 AM, Gleb Natapov wrote:
> > After commit 242ec97c358256 PIT interrupts are no longer delivered after
> > PIC reset. It happens because PIT injects interrupt only if previous one
> > was acked, but since on PIC reset it is dropped from irr it will never
> > be delivered and hence acknowledged. Fix that by calling ack notifier on
> > PIC reset.
> >
> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > ---
> > arch/x86/kvm/i8259.c | 17 +++++++++++++++++
> > 1 file changed, 17 insertions(+)
> >
> > diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
> > index 81cf4fa..0147d16 100644
> > --- a/arch/x86/kvm/i8259.c
> > +++ b/arch/x86/kvm/i8259.c
> > @@ -305,6 +305,11 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
> > addr &= 1;
> > if (addr == 0) {
> > if (val & 0x10) {
> > + u8 edge_irr = s->irr & ~s->elcr;
> > + int i;
> > + bool found;
> > + struct kvm_vcpu *vcpu;
> > +
> > s->init4 = val & 1;
> > s->last_irr = 0;
> > s->irr &= s->elcr;
> > @@ -322,6 +327,18 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
> > if (val & 0x08)
> > pr_pic_unimpl(
> > "level sensitive irq not supported");
> > +
> > + kvm_for_each_vcpu(i, vcpu, s->pics_state->kvm)
> > + if (kvm_apic_accept_pic_intr(vcpu)) {
> > + found = true;
> > + break;
> > + }
> > +
> > +
> > + if (found)
> > + for (irq = 0; irq < PIC_NUM_PINS/2; irq++)
> > + if (edge_irr & (1 << irq))
> > + pic_clear_isr(s, irq);
> > } else if (val & 0x08) {
>
>
> This duplicates the code in pic_reset(). Please extract it into a
> function (just the new code, since this is going into 3.6).
>
>
Extract what into a function? I specifically sent follow up patch to
cleanup duplicates.
--
Gleb.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] KVM: PIC: call ack notifiers for irqs that are dropped form irr
2012-07-26 9:11 ` Gleb Natapov
@ 2012-07-26 9:18 ` Avi Kivity
0 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2012-07-26 9:18 UTC (permalink / raw)
To: Gleb Natapov; +Cc: kvm, mtosatti
On 07/26/2012 12:11 PM, Gleb Natapov wrote:
> On Thu, Jul 26, 2012 at 12:09:36PM +0300, Avi Kivity wrote:
>> On 07/26/2012 10:00 AM, Gleb Natapov wrote:
>> > After commit 242ec97c358256 PIT interrupts are no longer delivered after
>> > PIC reset. It happens because PIT injects interrupt only if previous one
>> > was acked, but since on PIC reset it is dropped from irr it will never
>> > be delivered and hence acknowledged. Fix that by calling ack notifier on
>> > PIC reset.
>> >
>> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
>> > ---
>> > arch/x86/kvm/i8259.c | 17 +++++++++++++++++
>> > 1 file changed, 17 insertions(+)
>> >
>> > diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
>> > index 81cf4fa..0147d16 100644
>> > --- a/arch/x86/kvm/i8259.c
>> > +++ b/arch/x86/kvm/i8259.c
>> > @@ -305,6 +305,11 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
>> > addr &= 1;
>> > if (addr == 0) {
>> > if (val & 0x10) {
>> > + u8 edge_irr = s->irr & ~s->elcr;
>> > + int i;
>> > + bool found;
>> > + struct kvm_vcpu *vcpu;
>> > +
>> > s->init4 = val & 1;
>> > s->last_irr = 0;
>> > s->irr &= s->elcr;
>> > @@ -322,6 +327,18 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
>> > if (val & 0x08)
>> > pr_pic_unimpl(
>> > "level sensitive irq not supported");
>> > +
>> > + kvm_for_each_vcpu(i, vcpu, s->pics_state->kvm)
>> > + if (kvm_apic_accept_pic_intr(vcpu)) {
>> > + found = true;
>> > + break;
>> > + }
>> > +
>> > +
>> > + if (found)
>> > + for (irq = 0; irq < PIC_NUM_PINS/2; irq++)
>> > + if (edge_irr & (1 << irq))
>> > + pic_clear_isr(s, irq);
>> > } else if (val & 0x08) {
>>
>>
>> This duplicates the code in pic_reset(). Please extract it into a
>> function (just the new code, since this is going into 3.6).
>>
>>
> Extract what into a function? I specifically sent follow up patch to
> cleanup duplicates.
So you did. I didn't even look at it because I wasn't going to send
cleanup patches to 3.6.
I'll apply to master then. Please repost the cleanup once 3.6 is updated.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-07-26 9:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-26 7:00 [PATCH 1/2] KVM: PIC: call ack notifiers for irqs that are dropped form irr Gleb Natapov
2012-07-26 7:00 ` [PATCH 2/2] KVM: cleanup pic reset Gleb Natapov
2012-07-26 9:09 ` [PATCH 1/2] KVM: PIC: call ack notifiers for irqs that are dropped form irr Avi Kivity
2012-07-26 9:11 ` Gleb Natapov
2012-07-26 9:18 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).