summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2020-08-30 19:07:01 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2020-08-30 19:07:01 +0000
commit8a5d8c291a2cffb0a8d3e8c933452ccb5a409b12 (patch)
treea415983f27c0eaac27d834358c4e240a2667c4d3 /sys
parent22db31089800953256fad419e0573802744010cd (diff)
Reorganize the interrupt handler code to avoid a potential bogus KASSERT,
handle the priority levels better and guarantee ordering of restoring the priority level after running an interrupt handler and checking for a new interrupt.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/powerpc64/dev/xive.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/arch/powerpc64/dev/xive.c b/sys/arch/powerpc64/dev/xive.c
index babe34a9a3d..0271b605f17 100644
--- a/sys/arch/powerpc64/dev/xive.c
+++ b/sys/arch/powerpc64/dev/xive.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xive.c,v 1.10 2020/08/23 12:48:53 kettenis Exp $ */
+/* $OpenBSD: xive.c,v 1.11 2020/08/30 19:07:00 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
*
@@ -379,12 +379,6 @@ xive_hvi(struct trapframe *frame)
while (1) {
ack = xive_read_2(sc, XIVE_TM_SPC_ACK_HV);
- /* Synchronize software state to hardware state. */
- cppr = ack;
- new = xive_ipl(cppr);
- KASSERT(new >= ci->ci_cpl);
- ci->ci_cpl = new;
-
he = (ack & XIVE_TM_SPC_ACK_HE_MASK);
if (he == XIVE_TM_SPC_ACK_HE_NONE)
break;
@@ -392,6 +386,12 @@ xive_hvi(struct trapframe *frame)
eieio();
+ /* Synchronize software state to hardware state. */
+ cppr = ack;
+ new = xive_ipl(cppr);
+ ci->ci_cpl = new;
+ KASSERT(new > old);
+
KASSERT(cppr < XIVE_NUM_PRIORITIES);
eq = &sc->sc_eq[ci->ci_cpuid][cppr];
event = XIVE_DMA_KVA(eq->eq_queue);
@@ -428,10 +428,12 @@ xive_hvi(struct trapframe *frame)
if (eq->eq_idx == 0)
eq->eq_gen ^= XIVE_EQ_GEN_MASK;
}
- }
- ci->ci_cpl = old;
- xive_write_1(sc, XIVE_TM_CPPR_HV, xive_prio(old));
+ ci->ci_cpl = old;
+ xive_write_1(sc, XIVE_TM_CPPR_HV, xive_prio(old));
+
+ eieio();
+ }
}
struct xive_dmamem *