Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hppa/hppa hppa: Membar audit in ipifuncs.c.



details:   https://anonhg.NetBSD.org/src/rev/c3daaf717db0
branches:  trunk
changeset: 361156:c3daaf717db0
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Feb 12 17:09:07 2022 +0000

description:
hppa: Membar audit in ipifuncs.c.

diffstat:

 sys/arch/hppa/hppa/ipifuncs.c |  23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diffs (59 lines):

diff -r c4c3fd84903a -r c3daaf717db0 sys/arch/hppa/hppa/ipifuncs.c
--- a/sys/arch/hppa/hppa/ipifuncs.c     Sat Feb 12 16:31:06 2022 +0000
+++ b/sys/arch/hppa/hppa/ipifuncs.c     Sat Feb 12 17:09:07 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipifuncs.c,v 1.5 2019/04/15 20:45:08 skrll Exp $       */
+/*     $NetBSD: ipifuncs.c,v 1.6 2022/02/12 17:09:07 riastradh Exp $   */
 /*     $OpenBSD: ipi.c,v 1.4 2011/01/14 13:20:06 jsing Exp $   */
 
 /*
@@ -83,6 +83,7 @@
 
        /* Handle an IPI. */
        ipi_pending = atomic_swap_ulong(&ci->ci_ipi, 0);
+       membar_enter(); /* matches membar_exit in xc_send_ipi, cpu_ipi */
 
        KASSERT(ipi_pending);
 
@@ -108,10 +109,22 @@
 
        atomic_or_ulong(&ci->ci_ipi, (1L << ipi));
 
-       /* Send an IPI to the specified CPU by triggering EIR{1} (irq 30). */
+       /*
+        * Send an IPI to the specified CPU by triggering EIR{1} (irq 30).
+        *
+        * The `load-acquire operation' matching this store-release is
+        * somewhere inside the silicon or firmware -- the point is
+        * that the store to ci->ci_ipi above must happen before
+        * writing to EIR{1}; there is conceptually some magic inside
+        * the silicon or firmware on the target CPU that effectively
+        * does
+        *
+        *      if (atomic_load_acquire(&cpu->io_eir)) {
+        *              enter_interrupt_vector();
+        *      }
+        */
        cpu = (struct iomod *)(ci->ci_hpa);
-       cpu->io_eir = 1;
-       membar_sync();
+       atomic_store_release(&cpu->io_eir, 1);
 
        return 0;
 }
@@ -156,6 +169,7 @@
        KASSERT(kpreempt_disabled());
        KASSERT(curcpu() != ci);
 
+       membar_exit();          /* matches membar_enter in hppa_ipi_intr */
        if (ci) {
                /* Unicast: remote CPU. */
                hppa_ipi_send(ci, HPPA_IPI_XCALL);
@@ -171,6 +185,7 @@
        KASSERT(kpreempt_disabled());
        KASSERT(curcpu() != ci);
 
+       membar_exit();          /* matches membar_enter in hppa_ipi_intr */
        if (ci) {
                /* Unicast: remote CPU. */
                hppa_ipi_send(ci, HPPA_IPI_GENERIC);



Home | Main Index | Thread Index | Old Index