Module Name:    src
Committed By:   simonb
Date:           Tue Jul 28 00:35:38 UTC 2020

Modified Files:
        src/sys/arch/evbmips/cavium: machdep.c
        src/sys/arch/mips/cavium: octeon_cpunode.c octeonvar.h
        src/sys/arch/mips/mips: locore_octeon.S

Log Message:
Change cpus_booted back to a simple variable instead of a kcpuset.
octeon_cpu_spinup() was trying to set CPU status immediately on kernel
startup _well_ before the kcpuset was initialised.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/evbmips/cavium/machdep.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/mips/cavium/octeon_cpunode.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/mips/cavium/octeonvar.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/mips/locore_octeon.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbmips/cavium/machdep.c
diff -u src/sys/arch/evbmips/cavium/machdep.c:1.21 src/sys/arch/evbmips/cavium/machdep.c:1.22
--- src/sys/arch/evbmips/cavium/machdep.c:1.21	Wed Jul 22 13:24:17 2020
+++ src/sys/arch/evbmips/cavium/machdep.c	Tue Jul 28 00:35:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.21 2020/07/22 13:24:17 simonb Exp $	*/
+/*	$NetBSD: machdep.c,v 1.22 2020/07/28 00:35:38 simonb Exp $	*/
 
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -114,7 +114,7 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.21 2020/07/22 13:24:17 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.22 2020/07/28 00:35:38 simonb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -457,10 +457,6 @@ int	waittime = -1;
 void
 cpu_startup(void)
 {
-#ifdef MULTIPROCESSOR
-	// Create a kcpuset so we can see on which CPUs the kernel was started.
-	kcpuset_create(&cpus_booted, true);
-#endif
 
 	/*
 	 * Do the common startup items.

Index: src/sys/arch/mips/cavium/octeon_cpunode.c
diff -u src/sys/arch/mips/cavium/octeon_cpunode.c:1.17 src/sys/arch/mips/cavium/octeon_cpunode.c:1.18
--- src/sys/arch/mips/cavium/octeon_cpunode.c:1.17	Wed Jul 22 15:01:18 2020
+++ src/sys/arch/mips/cavium/octeon_cpunode.c	Tue Jul 28 00:35:38 2020
@@ -29,7 +29,7 @@
 #define __INTR_PRIVATE
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: octeon_cpunode.c,v 1.17 2020/07/22 15:01:18 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_cpunode.c,v 1.18 2020/07/28 00:35:38 simonb Exp $");
 
 #include "locators.h"
 #include "cpunode.h"
@@ -81,7 +81,10 @@ CFATTACH_DECL_NEW(cpunode, sizeof(struct
 CFATTACH_DECL_NEW(cpu_cpunode, 0,
     cpu_cpunode_match, cpu_cpunode_attach, NULL, NULL);
 
-kcpuset_t *cpus_booted;
+#ifdef MULTIPROCESSOR
+CTASSERT(MAXCPUS <= sizeof(uint64_t) * NBBY);
+volatile uint64_t cpus_booted = __BIT(0);	/* cpu0 is always booted */
+#endif
 
 static void wdog_cpunode_poke(void *arg);
 
@@ -125,9 +128,7 @@ cpunode_mainbus_attach(device_t parent, 
 	if (cvmctl & CP0_CVMCTL_REPUN)
 		aprint_normal(", unaligned-access ok");
 #ifdef MULTIPROCESSOR
-	uint32_t booted[1];
-	kcpuset_export_u32(cpus_booted, booted, sizeof(booted));
-	aprint_normal(", booted %#" PRIx32, booted[0]);
+	aprint_normal(", booted %#" PRIx64, cpus_booted);
 #endif
 	aprint_normal("\n");
 
@@ -308,7 +309,7 @@ cpu_cpunode_attach(device_t parent, devi
 		return;
 	}
 
-	if (!kcpuset_isset(cpus_booted, cpunum)) {
+	if (!(cpus_booted & __BIT(cpunum))) {
 		aprint_naive(" disabled\n");
 		aprint_normal(" disabled (unresponsive)\n");
 		return;

Index: src/sys/arch/mips/cavium/octeonvar.h
diff -u src/sys/arch/mips/cavium/octeonvar.h:1.16 src/sys/arch/mips/cavium/octeonvar.h:1.17
--- src/sys/arch/mips/cavium/octeonvar.h:1.16	Fri Jul 17 21:59:30 2020
+++ src/sys/arch/mips/cavium/octeonvar.h	Tue Jul 28 00:35:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeonvar.h,v 1.16 2020/07/17 21:59:30 jmcneill Exp $	*/
+/*	$NetBSD: octeonvar.h,v 1.17 2020/07/28 00:35:38 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -201,9 +201,6 @@ struct octfau_map {
 
 #ifdef _KERNEL
 extern struct octeon_config	octeon_configuration;
-#ifdef MULTIPROCESSOR
-extern kcpuset_t		*cpus_booted;
-#endif
 
 const char	*octeon_cpu_model(mips_prid_t);
 

Index: src/sys/arch/mips/mips/locore_octeon.S
diff -u src/sys/arch/mips/mips/locore_octeon.S:1.12 src/sys/arch/mips/mips/locore_octeon.S:1.13
--- src/sys/arch/mips/mips/locore_octeon.S:1.12	Sun Jul 26 07:47:27 2020
+++ src/sys/arch/mips/mips/locore_octeon.S	Tue Jul 28 00:35:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore_octeon.S,v 1.12 2020/07/26 07:47:27 simonb Exp $	*/
+/*	$NetBSD: locore_octeon.S,v 1.13 2020/07/28 00:35:38 simonb Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <mips/asm.h>
-RCSID("$NetBSD: locore_octeon.S,v 1.12 2020/07/26 07:47:27 simonb Exp $")
+RCSID("$NetBSD: locore_octeon.S,v 1.13 2020/07/28 00:35:38 simonb Exp $")
 
 #include "cpunode.h"			/* for NWDOG */
 #include "opt_cputype.h"
@@ -37,7 +37,7 @@ RCSID("$NetBSD: locore_octeon.S,v 1.12 2
 #include <mips/cpuregs.h>
 #include <arch/mips/cavium/dev/octeon_corereg.h>
 
-RCSID("$NetBSD: locore_octeon.S,v 1.12 2020/07/26 07:47:27 simonb Exp $")
+RCSID("$NetBSD: locore_octeon.S,v 1.13 2020/07/28 00:35:38 simonb Exp $")
 
 #include "assym.h"
 
@@ -132,13 +132,10 @@ NESTED_NOPROFILE(octeon_cpu_spinup, 0, r
 	COP0_SYNC
 
 	// Indicate this CPU was started by u-boot
-	PTR_LA	t0, _C_LABEL(cpus_booted) # get addr for kcpuset
-1:	sync
-	PTR_L	a0, (t0)		# get kcpuset
-	beqz	a0, 1b			# loop until not NULL
-	 nop
-	jal	_C_LABEL(kcpuset_atomic_set)
-	 move	a1, s0			# pass it our cpu number
+	PTR_LA	a0, _C_LABEL(cpus_booted)
+	li	a1, 1
+	jal	_C_LABEL(atomic_or_64)
+	 sllv	a1, a1, s0		# shift cpu number to bit position
 
 	// Wait until cpuid_infos[cpunum] is not NULL.
 	PTR_LA	a1, _C_LABEL(cpuid_infos)

Reply via email to