Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/cortex Fix some conditionals to match gicv3 and...



details:   https://anonhg.NetBSD.org/src/rev/ff8fc36523a1
branches:  trunk
changeset: 1024379:ff8fc36523a1
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Oct 21 04:47:57 2021 +0000

description:
Fix some conditionals to match gicv3 and add some comments to describe
what's going on.

Fixes PR port-evbarm/56420

diffstat:

 sys/arch/arm/cortex/gic.c |  18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diffs (52 lines):

diff -r 1bddd6db8357 -r ff8fc36523a1 sys/arch/arm/cortex/gic.c
--- a/sys/arch/arm/cortex/gic.c Thu Oct 21 02:47:17 2021 +0000
+++ b/sys/arch/arm/cortex/gic.c Thu Oct 21 04:47:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gic.c,v 1.50 2021/09/26 13:38:50 jmcneill Exp $        */
+/*     $NetBSD: gic.c,v 1.51 2021/10/21 04:47:57 skrll Exp $   */
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
 #define _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.50 2021/09/26 13:38:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.51 2021/10/21 04:47:57 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -331,9 +331,17 @@
 
        ci->ci_data.cpu_nintr++;
 
-       if (ci->ci_hwpl != old_ipl) {
+       /*
+        * Raise ci_hwpl (and PMR) to ci_cpl and IAR will tell us if the
+        * interrupt that got us here can have its handler run or not.
+        */
+       if (ci->ci_hwpl <= old_ipl) {
                ci->ci_hwpl = old_ipl;
                gicc_write(sc, GICC_PMR, armgic_ipl_to_priority(old_ipl));
+               /*
+                * we'll get no interrupts when PMR is IPL_HIGH, so bail
+                * early.
+                */
                if (old_ipl == IPL_HIGH) {
                        return;
                }
@@ -373,11 +381,13 @@
                 *
                 * However, if are just raising ipl, we can just update ci_cpl.
                 */
+
+               /* Surely we can KASSERT(ipl < ci->ci_cpl); */
                const int ipl = is->is_ipl;
                if (__predict_false(ipl < ci->ci_cpl)) {
                        pic_do_pending_ints(I32_bit, ipl, tf);
                        KASSERT(ci->ci_cpl == ipl);
-               } else {
+               } else if (ci->ci_cpl != ipl) {
                        KASSERTMSG(ipl > ci->ci_cpl, "ipl %d cpl %d hw-ipl %#x",
                            ipl, ci->ci_cpl,
                            gicc_read(sc, GICC_PMR));



Home | Main Index | Thread Index | Old Index