All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/2] riscv-to-apply queue
@ 2020-11-14  5:45 Alistair Francis
  2020-11-14  5:45 ` [PULL 1/2] intc/ibex_plic: Fix some typos in the comments Alistair Francis
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alistair Francis @ 2020-11-14  5:45 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: alistair23, Alistair Francis

The following changes since commit 5ececc3a0b0086c6168e12f4d032809477b30fe5:

  Merge remote-tracking branch 'remotes/dgilbert/tags/pull-hmp-20201113' into staging (2020-11-13 13:40:23 +0000)

are available in the Git repository at:

  git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20201113-1

for you to fetch changes up to deef3d2568a7fbaa62d9bee07708cf3a4dc3ac53:

  intc/ibex_plic: Ensure we don't loose interrupts (2020-11-13 21:43:48 -0800)

----------------------------------------------------------------
Two small additional fixes for the Ibex PLIC.

----------------------------------------------------------------
Alistair Francis (2):
      intc/ibex_plic: Fix some typos in the comments
      intc/ibex_plic: Ensure we don't loose interrupts

 include/hw/intc/ibex_plic.h |  1 +
 hw/intc/ibex_plic.c         | 21 ++++++++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PULL 1/2] intc/ibex_plic: Fix some typos in the comments
  2020-11-14  5:45 [PULL 0/2] riscv-to-apply queue Alistair Francis
@ 2020-11-14  5:45 ` Alistair Francis
  2020-11-14  5:45 ` [PULL 2/2] intc/ibex_plic: Ensure we don't loose interrupts Alistair Francis
  2020-11-14 15:25 ` [PULL 0/2] riscv-to-apply queue Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Alistair Francis @ 2020-11-14  5:45 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: alistair23, Alistair Francis

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 22d2fb0d7af5ca316c67ac909926368d1bcb7cf5.1605136387.git.alistair.francis@wdc.com
---
 hw/intc/ibex_plic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c
index 235e6b88ff..db9e0aa25f 100644
--- a/hw/intc/ibex_plic.c
+++ b/hw/intc/ibex_plic.c
@@ -45,7 +45,7 @@ static void ibex_plic_irqs_set_pending(IbexPlicState *s, int irq, bool level)
 
     if (s->claimed[pending_num] & 1 << (irq % 32)) {
         /*
-         * The interrupt has been claimed, but not compelted.
+         * The interrupt has been claimed, but not completed.
          * The pending bit can't be set.
          */
         return;
@@ -133,7 +133,7 @@ static uint64_t ibex_plic_read(void *opaque, hwaddr addr,
         int pending_num = s->claim / 32;
         s->pending[pending_num] &= ~(1 << (s->claim % 32));
 
-        /* Set the interrupt as claimed, but not compelted */
+        /* Set the interrupt as claimed, but not completed */
         s->claimed[pending_num] |= 1 << (s->claim % 32);
 
         /* Return the current claimed interrupt */
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PULL 2/2] intc/ibex_plic: Ensure we don't loose interrupts
  2020-11-14  5:45 [PULL 0/2] riscv-to-apply queue Alistair Francis
  2020-11-14  5:45 ` [PULL 1/2] intc/ibex_plic: Fix some typos in the comments Alistair Francis
@ 2020-11-14  5:45 ` Alistair Francis
  2020-11-14 15:25 ` [PULL 0/2] riscv-to-apply queue Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Alistair Francis @ 2020-11-14  5:45 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: alistair23, Alistair Francis

If an interrupt occurs between when we claim and complete an interrupt
we currently drop the interrupt in ibex_plic_irqs_set_pending(). This
somewhat matches hardware that also ignore the interrupt between the
claim and complete process.

In the case of hardware though the physical interrupt line will still
be asserted after we have completed the interrupt. This means we will
still act on the interrupt after the complete process. In QEMU we don't
and instead we drop the interrupt as it is never recorded.

This patch changed the behaviour of the Ibex PLIC so that we save all
interrupts that occur while we are between claiming and completing an
interrupt so that we can act on them after the completition process.

This fixes interrupts being dropped when running Tock on OpenTitain in
QEMU.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: e7bcf98c6925b1e6e7828e7c3f85293a09a65b12.1605136387.git.alistair.francis@wdc.com
---
 include/hw/intc/ibex_plic.h |  1 +
 hw/intc/ibex_plic.c         | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/include/hw/intc/ibex_plic.h b/include/hw/intc/ibex_plic.h
index 37f03356b3..7fc495db99 100644
--- a/include/hw/intc/ibex_plic.h
+++ b/include/hw/intc/ibex_plic.h
@@ -33,6 +33,7 @@ struct IbexPlicState {
     MemoryRegion mmio;
 
     uint32_t *pending;
+    uint32_t *hidden_pending;
     uint32_t *claimed;
     uint32_t *source;
     uint32_t *priority;
diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c
index db9e0aa25f..341c9db405 100644
--- a/hw/intc/ibex_plic.c
+++ b/hw/intc/ibex_plic.c
@@ -48,6 +48,7 @@ static void ibex_plic_irqs_set_pending(IbexPlicState *s, int irq, bool level)
          * The interrupt has been claimed, but not completed.
          * The pending bit can't be set.
          */
+        s->hidden_pending[pending_num] |= level << (irq % 32);
         return;
     }
 
@@ -176,8 +177,21 @@ static void ibex_plic_write(void *opaque, hwaddr addr,
             s->claim = 0;
         }
         if (s->claimed[value / 32] & 1 << (value % 32)) {
+            int pending_num = value / 32;
+
             /* This value was already claimed, clear it. */
-            s->claimed[value / 32] &= ~(1 << (value % 32));
+            s->claimed[pending_num] &= ~(1 << (value % 32));
+
+            if (s->hidden_pending[pending_num] & (1 << (value % 32))) {
+                /*
+                 * If the bit in hidden_pending is set then that means we
+                 * received an interrupt between claiming and completing
+                 * the interrupt that hasn't since been de-asserted.
+                 * On hardware this would trigger an interrupt, so let's
+                 * trigger one here as well.
+                 */
+                s->pending[pending_num] |= 1 << (value % 32);
+            }
         }
     }
 
@@ -239,6 +253,7 @@ static void ibex_plic_realize(DeviceState *dev, Error **errp)
     int i;
 
     s->pending = g_new0(uint32_t, s->pending_num);
+    s->hidden_pending = g_new0(uint32_t, s->pending_num);
     s->claimed = g_new0(uint32_t, s->pending_num);
     s->source = g_new0(uint32_t, s->source_num);
     s->priority = g_new0(uint32_t, s->priority_num);
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PULL 0/2] riscv-to-apply queue
  2020-11-14  5:45 [PULL 0/2] riscv-to-apply queue Alistair Francis
  2020-11-14  5:45 ` [PULL 1/2] intc/ibex_plic: Fix some typos in the comments Alistair Francis
  2020-11-14  5:45 ` [PULL 2/2] intc/ibex_plic: Ensure we don't loose interrupts Alistair Francis
@ 2020-11-14 15:25 ` Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2020-11-14 15:25 UTC (permalink / raw)
  To: Alistair Francis; +Cc: Alistair Francis, QEMU Developers

On Sat, 14 Nov 2020 at 05:56, Alistair Francis <alistair.francis@wdc.com> wrote:
>
> The following changes since commit 5ececc3a0b0086c6168e12f4d032809477b30fe5:
>
>   Merge remote-tracking branch 'remotes/dgilbert/tags/pull-hmp-20201113' into staging (2020-11-13 13:40:23 +0000)
>
> are available in the Git repository at:
>
>   git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20201113-1
>
> for you to fetch changes up to deef3d2568a7fbaa62d9bee07708cf3a4dc3ac53:
>
>   intc/ibex_plic: Ensure we don't loose interrupts (2020-11-13 21:43:48 -0800)
>
> ----------------------------------------------------------------
> Two small additional fixes for the Ibex PLIC.
>
> ----------------------------------------------------------------
> Alistair Francis (2):
>       intc/ibex_plic: Fix some typos in the comments
>       intc/ibex_plic: Ensure we don't loose interrupts


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.2
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-14 15:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-14  5:45 [PULL 0/2] riscv-to-apply queue Alistair Francis
2020-11-14  5:45 ` [PULL 1/2] intc/ibex_plic: Fix some typos in the comments Alistair Francis
2020-11-14  5:45 ` [PULL 2/2] intc/ibex_plic: Ensure we don't loose interrupts Alistair Francis
2020-11-14 15:25 ` [PULL 0/2] riscv-to-apply queue Peter Maydell

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.