diff mbox

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

Message ID 4F1ECE59.5020803@siemens.com
State New
Headers show

Commit Message

Jan Kiszka Jan. 24, 2012, 3:29 p.m. UTC
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.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/i8259.c        |    2 +-
 hw/i8259_common.c |    2 +-
 hw/kvm/i8259.c    |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Comments

Gleb Natapov Jan. 24, 2012, 4:11 p.m. UTC | #1
On Tue, Jan 24, 2012 at 04:29:29PM +0100, Jan Kiszka wrote:
> 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.

> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  hw/i8259.c        |    2 +-
>  hw/i8259_common.c |    2 +-
>  hw/kvm/i8259.c    |    2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/i8259.c b/hw/i8259.c
> index 3005ce2..264bfc6 100644
> --- a/hw/i8259.c
> +++ b/hw/i8259.c
> @@ -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,
> diff --git a/hw/i8259_common.c b/hw/i8259_common.c
> index e515876..37aeee2 100644
> --- a/hw/i8259_common.c
> +++ b/hw/i8259_common.c
> @@ -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;
> diff --git a/hw/kvm/i8259.c b/hw/kvm/i8259.c
> index 64bb5c2..298d9ca 100644
> --- a/hw/kvm/i8259.c
> +++ b/hw/kvm/i8259.c
> @@ -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);
>  }
> -- 
> 1.7.3.4

--
			Gleb.
Jan Kiszka Feb. 13, 2012, 11:37 a.m. UTC | #2
On 2012-01-24 16:29, Jan Kiszka wrote:
> 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.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  hw/i8259.c        |    2 +-
>  hw/i8259_common.c |    2 +-
>  hw/kvm/i8259.c    |    2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/i8259.c b/hw/i8259.c
> index 3005ce2..264bfc6 100644
> --- a/hw/i8259.c
> +++ b/hw/i8259.c
> @@ -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,
> diff --git a/hw/i8259_common.c b/hw/i8259_common.c
> index e515876..37aeee2 100644
> --- a/hw/i8259_common.c
> +++ b/hw/i8259_common.c
> @@ -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;
> diff --git a/hw/kvm/i8259.c b/hw/kvm/i8259.c
> index 64bb5c2..298d9ca 100644
> --- a/hw/kvm/i8259.c
> +++ b/hw/kvm/i8259.c
> @@ -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
Anthony Liguori Feb. 17, 2012, 6:17 p.m. UTC | #3
On 01/24/2012 09:29 AM, Jan Kiszka wrote:
> 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.
>
> Signed-off-by: Jan Kiszka<jan.kiszka@siemens.com>

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   hw/i8259.c        |    2 +-
>   hw/i8259_common.c |    2 +-
>   hw/kvm/i8259.c    |    2 +-
>   3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/i8259.c b/hw/i8259.c
> index 3005ce2..264bfc6 100644
> --- a/hw/i8259.c
> +++ b/hw/i8259.c
> @@ -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,
> diff --git a/hw/i8259_common.c b/hw/i8259_common.c
> index e515876..37aeee2 100644
> --- a/hw/i8259_common.c
> +++ b/hw/i8259_common.c
> @@ -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;
> diff --git a/hw/kvm/i8259.c b/hw/kvm/i8259.c
> index 64bb5c2..298d9ca 100644
> --- a/hw/kvm/i8259.c
> +++ b/hw/kvm/i8259.c
> @@ -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);
>   }
diff mbox

Patch

diff --git a/hw/i8259.c b/hw/i8259.c
index 3005ce2..264bfc6 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -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,
diff --git a/hw/i8259_common.c b/hw/i8259_common.c
index e515876..37aeee2 100644
--- a/hw/i8259_common.c
+++ b/hw/i8259_common.c
@@ -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;
diff --git a/hw/kvm/i8259.c b/hw/kvm/i8259.c
index 64bb5c2..298d9ca 100644
--- a/hw/kvm/i8259.c
+++ b/hw/kvm/i8259.c
@@ -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);
 }