If the inject_irq callback detect that an interrupt is already queued
in some list register, do not insert it into the software queue, thus
coalesce the event like real hardware does.

The change in the return code of inject_irq is more cosmetic, to reflect
the meaning better.

Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/arch/arm/gic-v2.c  | 2 +-
 hypervisor/arch/arm/gic-v3.c  | 2 +-
 hypervisor/arch/arm/irqchip.c | 6 ++----
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/hypervisor/arch/arm/gic-v2.c b/hypervisor/arch/arm/gic-v2.c
index e47c142..6e939fa 100644
--- a/hypervisor/arch/arm/gic-v2.c
+++ b/hypervisor/arch/arm/gic-v2.c
@@ -248,7 +248,7 @@ static int gic_inject_irq(struct per_cpu *cpu_data, struct 
pending_irq *irq)
                /* Check that there is no overlapping */
                lr = gic_read_lr(i);
                if ((lr & GICH_LR_VIRT_ID_MASK) == irq->virt_id)
-                       return -EINVAL;
+                       return -EEXIST;
        }
 
        if (first_free == -1)
diff --git a/hypervisor/arch/arm/gic-v3.c b/hypervisor/arch/arm/gic-v3.c
index fe9c261..40526ea 100644
--- a/hypervisor/arch/arm/gic-v3.c
+++ b/hypervisor/arch/arm/gic-v3.c
@@ -367,7 +367,7 @@ static int gic_inject_irq(struct per_cpu *cpu_data, struct 
pending_irq *irq)
                 * should be sufficient.
                 */
                if ((u32)lr == irq->virt_id)
-                       return -EINVAL;
+                       return -EEXIST;
        }
 
        if (free_lr == -1)
diff --git a/hypervisor/arch/arm/irqchip.c b/hypervisor/arch/arm/irqchip.c
index 5187390..fb25744 100644
--- a/hypervisor/arch/arm/irqchip.c
+++ b/hypervisor/arch/arm/irqchip.c
@@ -135,10 +135,8 @@ void irqchip_set_pending(struct per_cpu *cpu_data, u32 
irq_id, bool try_inject)
 
        pending.virt_id = irq_id;
 
-       if (try_inject && irqchip.inject_irq(cpu_data, &pending) == 0)
-               return;
-
-       irqchip_insert_pending(cpu_data, &pending);
+       if (!try_inject || irqchip.inject_irq(cpu_data, &pending) == -EBUSY)
+               irqchip_insert_pending(cpu_data, &pending);
 }
 
 /*
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to