Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mips/mips mips: Fix cpuids synchronization at boot.



details:   https://anonhg.NetBSD.org/src/rev/311df4722a7a
branches:  trunk
changeset: 368584:311df4722a7a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 20 10:07:49 2022 +0000

description:
mips: Fix cpuids synchronization at boot.

diffstat:

 sys/arch/mips/mips/cpu_subr.c      |  10 ++++++----
 sys/arch/mips/mips/locore_octeon.S |  12 +++++++-----
 2 files changed, 13 insertions(+), 9 deletions(-)

diffs (73 lines):

diff -r c37e014354a7 -r 311df4722a7a sys/arch/mips/mips/cpu_subr.c
--- a/sys/arch/mips/mips/cpu_subr.c     Wed Jul 20 10:01:10 2022 +0000
+++ b/sys/arch/mips/mips/cpu_subr.c     Wed Jul 20 10:07:49 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_subr.c,v 1.61 2022/03/28 12:38:58 riastradh Exp $  */
+/*     $NetBSD: cpu_subr.c,v 1.62 2022/07/20 10:07:49 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2010, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.61 2022/03/28 12:38:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.62 2022/07/20 10:07:49 riastradh Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -273,10 +273,12 @@
        if (ci != &cpu_info_store) {
                /*
                 * Tail insert this onto the list of cpu_info's.
+                * atomic_store_release matches PTR_L/SYNC_ACQ in
+                * locore_octeon.S (XXX what about non-Octeon?).
                 */
                KASSERT(cpuid_infos[ci->ci_cpuid] == NULL);
-               cpuid_infos[ci->ci_cpuid] = ci;
-               membar_producer();
+               atomic_store_release(&cpuid_infos[ci->ci_cpuid], ci);
+               membar_producer(); /* Cavium sync plunger */
        }
        KASSERT(cpuid_infos[ci->ci_cpuid] != NULL);
        evcnt_attach_dynamic(&ci->ci_evcnt_synci_activate_rqst,
diff -r c37e014354a7 -r 311df4722a7a sys/arch/mips/mips/locore_octeon.S
--- a/sys/arch/mips/mips/locore_octeon.S        Wed Jul 20 10:01:10 2022 +0000
+++ b/sys/arch/mips/mips/locore_octeon.S        Wed Jul 20 10:07:49 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore_octeon.S,v 1.13 2020/07/28 00:35:38 simonb Exp $        */
+/*     $NetBSD: locore_octeon.S,v 1.14 2022/07/20 10:07:49 riastradh Exp $     */
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <mips/asm.h>
-RCSID("$NetBSD: locore_octeon.S,v 1.13 2020/07/28 00:35:38 simonb Exp $")
+RCSID("$NetBSD: locore_octeon.S,v 1.14 2022/07/20 10:07:49 riastradh Exp $")
 
 #include "cpunode.h"                   /* for NWDOG */
 #include "opt_cputype.h"
@@ -37,7 +37,7 @@
 #include <mips/cpuregs.h>
 #include <arch/mips/cavium/dev/octeon_corereg.h>
 
-RCSID("$NetBSD: locore_octeon.S,v 1.13 2020/07/28 00:35:38 simonb Exp $")
+RCSID("$NetBSD: locore_octeon.S,v 1.14 2022/07/20 10:07:49 riastradh Exp $")
 
 #include "assym.h"
 
@@ -141,8 +141,10 @@
        PTR_LA  a1, _C_LABEL(cpuid_infos)
        dsll    v0, s0, PTR_SCALESHIFT  # cpunum -> array index
        PTR_ADD t0, a1, v0              # add to array start
-1:     sync
-       PTR_L   a1, (t0)                # get cpu_info pointer
+1:     PTR_L   a1, (t0)                # get cpu_info pointer
+       SYNC_ACQ                        # PTR_L/SYNC_ACQ matches
+                                       #   atomic_store_release in
+                                       #   cpu_attach_common
        beqz    a1, 1b                  # loop until non-NULL
         nop
 



Home | Main Index | Thread Index | Old Index