All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean-Christophe Dubois <jcd@tribudubois.net>
To: chouteau@adacore.com
Cc: Jean-Christophe Dubois <jcd@tribudubois.net>,
	qemu-devel@nongnu.org, mark.cave-ayland@ilande.co.uk
Subject: [Qemu-devel] [PATCH] LEON3 IRQMP: Fix IRQ software ack
Date: Wed, 10 Jan 2018 21:43:27 +0100	[thread overview]
Message-ID: <20180110204327.22510-1-jcd@tribudubois.net> (raw)

With the LEON3 IRQ controller IRQs can be acknoledged 2 ways:
* Explicitely by software writing to the CLEAR_OFFSET register
* Implicitely when the procesor is done running the trap handler attached
  to the IRQ.

The actual IRQMP code only allows the implicit processor triggered IRQ ack.
If software write explicitely to the CLEAR_OFFSET register, this will clear
the pending bit in the register value but this will not lower the onloing
raised IRQ with the processor. The IRQ will be kept raised to the LEON
processor until the related trap handler is run and the processor implicitely
ack the interrupt. So with the actual IRQMP code trap hadler have to be run
even if the software has already done its job by clearing the pending bit.

This feature has been tested on another LEON3 simulator (tsim_leon3 from
Gaisler) and it turns out that the Qemu implementation is not equivalent to
the tsim one. In tsim, if software does clear a pending interrupt before
the related interrupt handler is triggered the said interrupt handler will
not be called.

This patch bring the Qemu IRQMP implementation in line with the tsim
implementation by allowing IRQ to be acknoledged by software only.

Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
---
 hw/intc/grlib_irqmp.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/hw/intc/grlib_irqmp.c b/hw/intc/grlib_irqmp.c
index 94659ee256..d6f9cb3692 100644
--- a/hw/intc/grlib_irqmp.c
+++ b/hw/intc/grlib_irqmp.c
@@ -106,6 +106,15 @@ static void grlib_irqmp_check_irqs(IRQMPState *state)
     }
 }
 
+static void grlib_irqmp_ack_mask(IRQMPState *state, uint32_t mask)
+{
+    /* Clear registers */
+    state->pending  &= ~mask;
+    state->force[0] &= ~mask; /* Only CPU 0 (No SMP support) */
+
+    grlib_irqmp_check_irqs(state);
+}
+
 void grlib_irqmp_ack(DeviceState *dev, int intno)
 {
     IRQMP        *irqmp = GRLIB_IRQMP(dev);
@@ -120,11 +129,7 @@ void grlib_irqmp_ack(DeviceState *dev, int intno)
 
     trace_grlib_irqmp_ack(intno);
 
-    /* Clear registers */
-    state->pending  &= ~mask;
-    state->force[0] &= ~mask; /* Only CPU 0 (No SMP support) */
-
-    grlib_irqmp_check_irqs(state);
+    grlib_irqmp_ack_mask(state, mask);
 }
 
 void grlib_irqmp_set_irq(void *opaque, int irq, int level)
@@ -251,7 +256,7 @@ static void grlib_irqmp_write(void *opaque, hwaddr addr,
 
     case CLEAR_OFFSET:
         value &= ~1; /* clean up the value */
-        state->pending &= ~value;
+        grlib_irqmp_ack_mask(state, value);
         return;
 
     case MP_STATUS_OFFSET:
-- 
2.14.1

             reply	other threads:[~2018-01-10 20:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10 20:43 Jean-Christophe Dubois [this message]
2018-01-11 11:48 ` [Qemu-devel] [PATCH] LEON3 IRQMP: Fix IRQ software ack Fabien Chouteau
2018-01-11 12:35   ` Jean-Christophe Dubois
2018-01-12 10:55     ` Fabien Chouteau
2018-01-12 14:10       ` Jean-Christophe Dubois
2018-01-15 11:09         ` Fabien Chouteau
2018-01-15 13:45           ` Jean-Christophe Dubois
2018-01-15 17:27             ` Jean-Christophe Dubois
2018-01-16 10:31               ` Fabien Chouteau
2018-01-17  0:08               ` Alistair Francis
2018-01-15 18:16   ` Mark Cave-Ayland
2018-01-16 10:21     ` Fabien Chouteau
2018-01-16 19:35       ` Mark Cave-Ayland
2018-01-24 19:51   ` Mark Cave-Ayland
2018-01-25 14:50     ` Fabien Chouteau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180110204327.22510-1-jcd@tribudubois.net \
    --to=jcd@tribudubois.net \
    --cc=chouteau@adacore.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.