Skip to contentSkip to conversation

nvic: allow to set pending status for not active interrupts

PATCH Superseded [email protected] 2 participants 3 messages Oct 7, 2016 – Oct 17, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvic: allow to set pending status for not active interrupts

From: Marcin Krzeminski <[email protected]>

According to ARM DUI 0552A 4.2.10. NVIC set pending status also for disabled interrupts. This patch adds possibility to emulate this in Qemu.

---
 hw/intc/arm_gic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/intc/arm_gic.c +2 -1
index b30cc91..85be6e4 100644
@@ -147,7 +147,8 @@ static void gic_set_irq_11mpcore(GICState *s, int irq, int level,
 {
     if (level) {
         GIC_SET_LEVEL(irq, cm);
-        if (GIC_TEST_EDGE_TRIGGER(irq) || GIC_TEST_ENABLED(irq, cm)) {
+        if (GIC_TEST_EDGE_TRIGGER(irq) || GIC_TEST_ENABLED(irq, cm)
+                || (!GIC_TEST_ACTIVE(irq, cm) &&  s->revision == REV_NVIC)) {
             DPRINTF("Set %d pending mask %x\n", irq, target);
             GIC_SET_PENDING(irq, target);
         }
Signature · 1 line
2.7.4
#1 lore raw
Quoted 16 lines · On 7 October 2016 at 10:42, <[email protected]> wrote:

From: Marcin Krzeminski <[email protected]>

According to ARM DUI 0552A 4.2.10. NVIC set pending status also for disabled interrupts. This patch adds possibility to emulate this in Qemu.

---
 hw/intc/arm_gic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/intc/arm_gic.c +0 -0
index b30cc91..85be6e4 100644

hw/intc/arm_gic.c static void gic_set_irq_11mpcore(GICState *s, int irq, int level,

Quoted 10 lines
hw/intc/arm_gic.c +2 -2
@@ -147,7 +147,8 @@ static void gic_set_irq_11mpcore(GICState *s, int irq, int level,
 {
     if (level) {
         GIC_SET_LEVEL(irq, cm);
-        if (GIC_TEST_EDGE_TRIGGER(irq) || GIC_TEST_ENABLED(irq, cm)) {
+        if (GIC_TEST_EDGE_TRIGGER(irq) || GIC_TEST_ENABLED(irq, cm)
+                || (!GIC_TEST_ACTIVE(irq, cm) &&  s->revision == REV_NVIC)) {
             DPRINTF("Set %d pending mask %x\n", irq, target);
             GIC_SET_PENDING(irq, target);
         }
--

Thanks for this patch. I agree that the current behaviour isn't correct.

I think it would be cleaner to define a new gic_set_irq_nvic() which has the NVIC specific behaviour, rather than sticking an "if this is really an NVIC" check into this function.

You probably also want to check whether the logic for re-pending level triggered interrupts in gic_complete_irq() also needs a similar change:

    if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {
        /* Mark level triggered interrupts as pending if they are still
           raised.  */
        if (!GIC_TEST_EDGE_TRIGGER(irq) && GIC_TEST_ENABLED(irq, cm)
            && GIC_TEST_LEVEL(irq, cm) && (GIC_TARGET(irq) & cm) != 0) {
            DPRINTF("Set %d pending mask %x\n", irq, cm);
            GIC_SET_PENDING(irq, cm);
        }
    }

thanks
-- PMM

#2 lore raw

Hi Peter

Quoted 41 lines

-----Original Message-----
From: Peter Maydell [mailto:[email protected]]
Sent: Thursday, October 13, 2016 6:59 PM
To: Krzeminski, Marcin (Nokia - PL/Wroclaw) <[email protected]>
Cc: QEMU Developers <[email protected]>; qemu-arm <qemu- [email protected]>; [email protected]
Subject: Re: [PATCH] nvic: allow to set pending status for not active interrupts

Quoted 17 lines · On 7 October 2016 at 10:42, <[email protected]> wrote:

From: Marcin Krzeminski <[email protected]>

According to ARM DUI 0552A 4.2.10. NVIC set pending status also for disabled interrupts. This patch adds possibility to emulate this in Qemu.

---
 hw/intc/arm_gic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/intc/arm_gic.c index renamed from hw/intc/arm_gic.c +0 -0

b30cc91..85be6e4 100644

hw/intc/arm_gic.c +0 -0
@@ -147,7 +147,8 @@ static void gic_set_irq_11mpcore(GICState *s, int
 irq, int level,  {

hw/intc/arm_gic.c static void gic_set_irq_11mpcore(GICState *s, int

Quoted 10 lines
hw/intc/arm_gic.c +3 -2
     if (level) {
         GIC_SET_LEVEL(irq, cm);
-        if (GIC_TEST_EDGE_TRIGGER(irq) || GIC_TEST_ENABLED(irq, cm)) {
+        if (GIC_TEST_EDGE_TRIGGER(irq) || GIC_TEST_ENABLED(irq, cm)
+                || (!GIC_TEST_ACTIVE(irq, cm) &&  s->revision ==
+ REV_NVIC)) {
             DPRINTF("Set %d pending mask %x\n", irq, target);
             GIC_SET_PENDING(irq, target);
         }
--

Thanks for this patch. I agree that the current behaviour isn't correct.

Quoted 4 lines

I think it would be cleaner to define a new gic_set_irq_nvic() which has the NVIC specific behaviour, rather than sticking an "if this is really an NVIC" check into this function.

Sure.

Quoted 12 lines

You probably also want to check whether the logic for re-pending level triggered interrupts in gic_complete_irq() also needs a similar change:

    if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {
        /* Mark level triggered interrupts as pending if they are still
           raised.  */
        if (!GIC_TEST_EDGE_TRIGGER(irq) && GIC_TEST_ENABLED(irq, cm)
            && GIC_TEST_LEVEL(irq, cm) && (GIC_TARGET(irq) & cm) != 0) {
            DPRINTF("Set %d pending mask %x\n", irq, cm);
            GIC_SET_PENDING(irq, cm);
        }
    }

It seem thet level triggered interrupt could be removed from fi for NVIC. I do not have guest to model that, but I will at least check if this do not brake anything.

Thanks,
Marcin

Quoted 3 lines

thanks
-- PMM