Skip to contentSkip to conversation

i8259: Do not clear level-triggered lines in IRR on init

PATCH Applied Jan Kiszka 3 participants 4 messages Jan 24, 2012 – Feb 17, 2012

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 i8259: Do not clear level-triggered lines in IRR on init

When an input line is handled as level-triggered, it will immediately raise an IRQ on the output of a PIC again that goes through an init reset. So only clear the edge-triggered inputs from IRR in that scenario.

---
 hw/i8259.c        |    2 +-
 hw/i8259_common.c |    2 +-
 hw/kvm/i8259.c    |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/i8259.c +1 -1
index 3005ce2..264bfc6 100644
@@ -231,8 +231,8 @@ static void pic_reset(DeviceState *dev)
 {
     PICCommonState *s = DO_UPCAST(PICCommonState, dev.qdev, dev);
 
-    pic_init_reset(s);
     s->elcr = 0;
+    pic_init_reset(s);
 }
 
 static void pic_ioport_write(void *opaque, target_phys_addr_t addr64,
hw/i8259_common.c +1 -1
index e515876..37aeee2 100644
@@ -28,7 +28,7 @@
 void pic_reset_common(PICCommonState *s)
 {
     s->last_irr = 0;
-    s->irr = 0;
+    s->irr &= s->elcr;
     s->imr = 0;
     s->isr = 0;
     s->priority_add = 0;
hw/kvm/i8259.c +1 -1
index 64bb5c2..298d9ca 100644
@@ -84,8 +84,8 @@ static void kvm_pic_reset(DeviceState *dev)
 {
     PICCommonState *s = DO_UPCAST(PICCommonState, dev.qdev, dev);
 
-    pic_reset_common(s);
     s->elcr = 0;
+    pic_reset_common(s);
 
     kvm_pic_put(s);
 }
Signature · 1 line
1.7.3.4
#1 lore raw
Quoted 5 lines · Jan Kiszka

When an input line is handled as level-triggered, it will immediately raise an IRQ on the output of a PIC again that goes through an init reset. So only clear the edge-triggered inputs from IRR in that scenario.

Looks good to me.

Quoted 50 lines
---
 hw/i8259.c        |    2 +-
 hw/i8259_common.c |    2 +-
 hw/kvm/i8259.c    |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/i8259.c +1 -1
index 3005ce2..264bfc6 100644
@@ -231,8 +231,8 @@ static void pic_reset(DeviceState *dev)
 {
     PICCommonState *s = DO_UPCAST(PICCommonState, dev.qdev, dev);
 
-    pic_init_reset(s);
     s->elcr = 0;
+    pic_init_reset(s);
 }
 
 static void pic_ioport_write(void *opaque, target_phys_addr_t addr64,
hw/i8259_common.c +1 -1
index e515876..37aeee2 100644
@@ -28,7 +28,7 @@
 void pic_reset_common(PICCommonState *s)
 {
     s->last_irr = 0;
-    s->irr = 0;
+    s->irr &= s->elcr;
     s->imr = 0;
     s->isr = 0;
     s->priority_add = 0;
hw/kvm/i8259.c +1 -1
index 64bb5c2..298d9ca 100644
@@ -84,8 +84,8 @@ static void kvm_pic_reset(DeviceState *dev)
 {
     PICCommonState *s = DO_UPCAST(PICCommonState, dev.qdev, dev);
 
-    pic_reset_common(s);
     s->elcr = 0;
+    pic_reset_common(s);
 
     kvm_pic_put(s);
 }
Signature · 1 line
1.7.3.4

--
Gleb.

author
#2 lore raw
In reply to Jan Kiszka
Quoted 44 lines · Jan Kiszka

When an input line is handled as level-triggered, it will immediately raise an IRQ on the output of a PIC again that goes through an init reset. So only clear the edge-triggered inputs from IRR in that scenario.

---
 hw/i8259.c        |    2 +-
 hw/i8259_common.c |    2 +-
 hw/kvm/i8259.c    |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/i8259.c +1 -1
index 3005ce2..264bfc6 100644
@@ -231,8 +231,8 @@ static void pic_reset(DeviceState *dev)
 {
     PICCommonState *s = DO_UPCAST(PICCommonState, dev.qdev, dev);
 
-    pic_init_reset(s);
     s->elcr = 0;
+    pic_init_reset(s);
 }
 
 static void pic_ioport_write(void *opaque, target_phys_addr_t addr64,
hw/i8259_common.c +1 -1
index e515876..37aeee2 100644
@@ -28,7 +28,7 @@
 void pic_reset_common(PICCommonState *s)
 {
     s->last_irr = 0;
-    s->irr = 0;
+    s->irr &= s->elcr;
     s->imr = 0;
     s->isr = 0;
     s->priority_add = 0;
hw/kvm/i8259.c +0 -0
index 64bb5c2..298d9ca 100644

hw/kvm/i8259.c static void kvm_pic_reset(DeviceState *dev) · line 91

Quoted 9 lines
hw/kvm/i8259.c +1 -1
@@ -84,8 +84,8 @@ static void kvm_pic_reset(DeviceState *dev)
 {
     PICCommonState *s = DO_UPCAST(PICCommonState, dev.qdev, dev);
 
-    pic_reset_common(s);
     s->elcr = 0;
+    pic_reset_common(s);
 
     kvm_pic_put(s);
 }

Ping.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#3 lore raw
In reply to Jan Kiszka
Quoted 6 lines · Jan Kiszka

When an input line is handled as level-triggered, it will immediately raise an IRQ on the output of a PIC again that goes through an init reset. So only clear the edge-triggered inputs from IRR in that scenario.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 47 lines
---
  hw/i8259.c        |    2 +-
  hw/i8259_common.c |    2 +-
  hw/kvm/i8259.c    |    2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)
hw/i8259.c +1 -1
index 3005ce2..264bfc6 100644
@@ -231,8 +231,8 @@ static void pic_reset(DeviceState *dev)
  {
      PICCommonState *s = DO_UPCAST(PICCommonState, dev.qdev, dev);
 
-    pic_init_reset(s);
      s->elcr = 0;
+    pic_init_reset(s);
  }
 
  static void pic_ioport_write(void *opaque, target_phys_addr_t addr64,
hw/i8259_common.c +1 -1
index e515876..37aeee2 100644
@@ -28,7 +28,7 @@
  void pic_reset_common(PICCommonState *s)
  {
      s->last_irr = 0;
-    s->irr = 0;
+    s->irr&= s->elcr;
      s->imr = 0;
      s->isr = 0;
      s->priority_add = 0;
hw/kvm/i8259.c +1 -1
index 64bb5c2..298d9ca 100644
@@ -84,8 +84,8 @@ static void kvm_pic_reset(DeviceState *dev)
  {
      PICCommonState *s = DO_UPCAST(PICCommonState, dev.qdev, dev);
 
-    pic_reset_common(s);
      s->elcr = 0;
+    pic_reset_common(s);
 
      kvm_pic_put(s);
  }