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 gicv3: Treat all IPLs below IPL_VM as IP...



details:   https://anonhg.NetBSD.org/src/rev/185d6a1f02d7
branches:  trunk
changeset: 368144:185d6a1f02d7
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Jun 25 18:05:09 2022 +0000

description:
gicv3: Treat all IPLs below IPL_VM as IPL_NONE for hwpl mappings

diffstat:

 sys/arch/arm/cortex/gicv3.c |  22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diffs (70 lines):

diff -r f2c5423867f7 -r 185d6a1f02d7 sys/arch/arm/cortex/gicv3.c
--- a/sys/arch/arm/cortex/gicv3.c       Sat Jun 25 17:46:05 2022 +0000
+++ b/sys/arch/arm/cortex/gicv3.c       Sat Jun 25 18:05:09 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3.c,v 1.52 2022/06/25 13:24:34 jmcneill Exp $ */
+/* $NetBSD: gicv3.c,v 1.53 2022/06/25 18:05:09 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -32,7 +32,7 @@
 #define        _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.52 2022/06/25 13:24:34 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.53 2022/06/25 18:05:09 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -60,6 +60,7 @@
 
 #define        IPL_TO_PRIORITY(sc, ipl)        (((0xff - (ipl)) << (sc)->sc_priority_shift) & 0xff)
 #define        IPL_TO_PMR(sc, ipl)             (((0xff - (ipl)) << (sc)->sc_pmr_shift) & 0xff)
+#define        IPL_TO_HWPL(ipl)                ((ipl) >= IPL_VM ? (ipl) : IPL_NONE)
 
 #define        GIC_SUPPORTS_1OFN(sc)           (((sc)->sc_gicd_typer & GICD_TYPER_No1N) == 0)
 
@@ -232,12 +233,13 @@
 {
        struct gicv3_softc * const sc = PICTOSOFTC(pic);
        struct cpu_info * const ci = curcpu();
+       const int hwpl = IPL_TO_HWPL(ipl);
 
-       while (ipl < ci->ci_hwpl) {
+       while (hwpl < ci->ci_hwpl) {
                /* Lowering priority mask */
-               ci->ci_hwpl = ipl;
+               ci->ci_hwpl = hwpl;
                __insn_barrier();
-               icc_pmr_write(IPL_TO_PMR(sc, ipl));
+               icc_pmr_write(IPL_TO_PMR(sc, hwpl));
        }
        __insn_barrier();
        ci->ci_cpl = ipl;
@@ -729,13 +731,14 @@
        struct gicv3_softc * const sc = gicv3_softc;
        struct pic_softc *pic;
        const int oldipl = ci->ci_cpl;
+       const int oldhwpl = IPL_TO_HWPL(oldipl);
 
        ci->ci_data.cpu_nintr++;
 
-       if (ci->ci_hwpl != oldipl) {
-               ci->ci_hwpl = oldipl;
-               icc_pmr_write(IPL_TO_PMR(sc, oldipl));
-               if (oldipl == IPL_HIGH) {
+       if (ci->ci_hwpl != oldhwpl) {
+               ci->ci_hwpl = oldhwpl;
+               icc_pmr_write(IPL_TO_PMR(sc, oldhwpl));
+               if (oldhwpl == IPL_HIGH) {
                        return;
                }
        }
@@ -760,6 +763,7 @@
                if (__predict_false(ipl < ci->ci_cpl)) {
                        pic_do_pending_ints(I32_bit, ipl, frame);
                } else if (ci->ci_cpl != ipl) {
+                       KASSERT(ipl >= IPL_VM);
                        icc_pmr_write(IPL_TO_PMR(sc, ipl));
                        ci->ci_hwpl = ci->ci_cpl = ipl;
                }



Home | Main Index | Thread Index | Old Index