diff mbox series

[v1,1/1] intc/ibex_plic: Clear interrupts that occur during claim process

Message ID 4e9786084a86f220689123cc8a7837af8fa071cf.1607100423.git.alistair.francis@wdc.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/1] intc/ibex_plic: Clear interrupts that occur during claim process | expand

Commit Message

Alistair Francis Dec. 4, 2020, 4:47 p.m. UTC
Previously if an interrupt occured during the claim process (after the
interrupt is claimed but before it's completed) it would never be
cleared.
This patch ensures that we also clear the hidden_pending bits as well.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 hw/intc/ibex_plic.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Jackie Ke Dec. 5, 2020, 8:09 a.m. UTC | #1
Tested-by: Jackie Ke <jackieke724@hotmail.com>


Best Regards,
Jackie Ke

> On Dec 5, 2020, at 12:47 AM, Alistair Francis <alistair.francis@wdc.com> wrote:
> 
> ´╗┐Previously if an interrupt occured during the claim process (after the
> interrupt is claimed but before it's completed) it would never be
> cleared.
> This patch ensures that we also clear the hidden_pending bits as well.
> 
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> ---
> hw/intc/ibex_plic.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c
> index 341c9db405..c1b72fcab0 100644
> --- a/hw/intc/ibex_plic.c
> +++ b/hw/intc/ibex_plic.c
> @@ -43,16 +43,23 @@ static void ibex_plic_irqs_set_pending(IbexPlicState *s, int irq, bool level)
> {
>     int pending_num = irq / 32;
> 
> +    if (!level) {
> +        /*
> +         * If the level is low make sure we clear the hidden_pending.
> +         */
> +        s->hidden_pending[pending_num] &= ~(1 << (irq % 32));
> +    }
> +
>     if (s->claimed[pending_num] & 1 << (irq % 32)) {
>         /*
>          * The interrupt has been claimed, but not completed.
>          * The pending bit can't be set.
> +         * Save the pending level for after the interrupt is completed.
>          */
>         s->hidden_pending[pending_num] |= level << (irq % 32);
> -        return;
> +    } else {
> +        s->pending[pending_num] |= level << (irq % 32);
>     }
> -
> -    s->pending[pending_num] |= level << (irq % 32);
> }
> 
> static bool ibex_plic_irqs_pending(IbexPlicState *s, uint32_t context)
> -- 
> 2.29.2
>
diff mbox series

Patch

diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c
index 341c9db405..c1b72fcab0 100644
--- a/hw/intc/ibex_plic.c
+++ b/hw/intc/ibex_plic.c
@@ -43,16 +43,23 @@  static void ibex_plic_irqs_set_pending(IbexPlicState *s, int irq, bool level)
 {
     int pending_num = irq / 32;
 
+    if (!level) {
+        /*
+         * If the level is low make sure we clear the hidden_pending.
+         */
+        s->hidden_pending[pending_num] &= ~(1 << (irq % 32));
+    }
+
     if (s->claimed[pending_num] & 1 << (irq % 32)) {
         /*
          * The interrupt has been claimed, but not completed.
          * The pending bit can't be set.
+         * Save the pending level for after the interrupt is completed.
          */
         s->hidden_pending[pending_num] |= level << (irq % 32);
-        return;
+    } else {
+        s->pending[pending_num] |= level << (irq % 32);
     }
-
-    s->pending[pending_num] |= level << (irq % 32);
 }
 
 static bool ibex_plic_irqs_pending(IbexPlicState *s, uint32_t context)