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 Apply PMR optimizations from gicv3



details:   https://anonhg.NetBSD.org/src/rev/4f2abce34c58
branches:  trunk
changeset: 952940:4f2abce34c58
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Feb 21 15:45:30 2021 +0000

description:
Apply PMR optimizations from gicv3

diffstat:

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

diffs (64 lines):

diff -r d9a23f767084 -r 4f2abce34c58 sys/arch/arm/cortex/gic.c
--- a/sys/arch/arm/cortex/gic.c Sun Feb 21 15:42:21 2021 +0000
+++ b/sys/arch/arm/cortex/gic.c Sun Feb 21 15:45:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gic.c,v 1.44 2021/02/09 14:24:14 jakllsch Exp $        */
+/*     $NetBSD: gic.c,v 1.45 2021/02/21 15:45:30 jmcneill Exp $        */
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
 #define _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.44 2021/02/09 14:24:14 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.45 2021/02/21 15:45:30 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -222,9 +222,14 @@
 armgic_set_priority(struct pic_softc *pic, int ipl)
 {
        struct armgic_softc * const sc = PICTOSOFTC(pic);
+       struct cpu_info * const ci = curcpu();
 
        const uint32_t priority = armgic_ipl_to_priority(ipl);
-       gicc_write(sc, GICC_PMR, priority);
+       if (priority > ci->ci_hwpl) {
+               /* Lowering priority mask */
+               ci->ci_hwpl = priority;
+               gicc_write(sc, GICC_PMR, priority);
+       }
 }
 
 #ifdef MULTIPROCESSOR
@@ -322,6 +327,12 @@
 
        ci->ci_data.cpu_nintr++;
 
+       const uint32_t priority = armgic_ipl_to_priority(old_ipl);
+       if (ci->ci_hwpl != priority) {
+               ci->ci_hwpl = priority;
+               gicc_write(sc, GICC_PMR, priority);
+       }
+
        for (;;) {
                uint32_t iar = gicc_read(sc, GICC_IAR);
                uint32_t irq = __SHIFTOUT(iar, GICC_IAR_IRQ);
@@ -365,7 +376,7 @@
                            ipl, ci->ci_cpl,
                            gicc_read(sc, GICC_PMR));
                        gicc_write(sc, GICC_PMR, armgic_ipl_to_priority(ipl));
-                       ci->ci_cpl = ipl;
+                       ci->ci_hwpl = ci->ci_cpl = ipl;
                }
                ENABLE_INTERRUPT();
                pic_dispatch(is, tf);
@@ -527,6 +538,7 @@
                            sc->sc_enabled_local);
                }
        }
+       ci->ci_hwpl = armgic_ipl_to_priority(ci->ci_cpl);
        gicc_write(sc, GICC_PMR, armgic_ipl_to_priority(ci->ci_cpl));   // set PMR
        gicc_write(sc, GICC_CTRL, GICC_CTRL_V1_Enable); // enable interrupt
        ENABLE_INTERRUPT();                             // allow IRQ exceptions



Home | Main Index | Thread Index | Old Index