svn commit: r302415 - in projects/powernv/powerpc: aim powerpc pseries

Nathan Whitehorn nwhitehorn at FreeBSD.org
Fri Jul 8 01:31:30 UTC 2016


Author: nwhitehorn
Date: Fri Jul  8 01:31:28 2016
New Revision: 302415
URL: https://svnweb.freebsd.org/changeset/base/302415

Log:
  Handle case when boot CPU is not CPU 0.

Modified:
  projects/powernv/powerpc/aim/mmu_oea64.c
  projects/powernv/powerpc/powerpc/machdep.c
  projects/powernv/powerpc/powerpc/mp_machdep.c
  projects/powernv/powerpc/pseries/platform_chrp.c

Modified: projects/powernv/powerpc/aim/mmu_oea64.c
==============================================================================
--- projects/powernv/powerpc/aim/mmu_oea64.c	Fri Jul  8 00:54:21 2016	(r302414)
+++ projects/powernv/powerpc/aim/mmu_oea64.c	Fri Jul  8 01:31:28 2016	(r302415)
@@ -853,6 +853,7 @@ moea64_late_bootstrap(mmu_t mmup, vm_off
 	int		i;
 	vm_offset_t	pa, va;
 	void		*dpcpu;
+	struct cpuref	bsp;
 
 	/*
 	 * Set up the Open Firmware pmap and add its mappings if not in real
@@ -951,6 +952,8 @@ moea64_late_bootstrap(mmu_t mmup, vm_off
 	 */
 	pa = moea64_bootstrap_alloc(DPCPU_SIZE, PAGE_SIZE);
 	dpcpu = (void *)virtual_avail;
+	if (platform_smp_get_bsp(&bsp) != 0)
+		bsp.cr_cpuid = 0;
 	va = virtual_avail;
 	virtual_avail += DPCPU_SIZE;
 	while (va < virtual_avail) {
@@ -958,7 +961,7 @@ moea64_late_bootstrap(mmu_t mmup, vm_off
 		pa += PAGE_SIZE;
 		va += PAGE_SIZE;
 	}
-	dpcpu_init(dpcpu, 0);
+	dpcpu_init(dpcpu, bsp.cr_cpuid);
 
 	/*
 	 * Allocate some things for page zeroing. We put this directly

Modified: projects/powernv/powerpc/powerpc/machdep.c
==============================================================================
--- projects/powernv/powerpc/powerpc/machdep.c	Fri Jul  8 00:54:21 2016	(r302414)
+++ projects/powernv/powerpc/powerpc/machdep.c	Fri Jul  8 01:31:28 2016	(r302415)
@@ -233,6 +233,7 @@ uintptr_t
 powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
 {
 	struct		pcpu *pc;
+	struct cpuref	bsp;
 	vm_offset_t	startkernel, endkernel;
 	void		*kmdp;
         char		*env;
@@ -305,21 +306,11 @@ powerpc_init(vm_offset_t fdt, vm_offset_
 	 */
 	proc_linkup0(&proc0, &thread0);
 	thread0.td_frame = &frame0;
-
-	/*
-	 * Set up per-cpu data.
-	 */
-	pc = __pcpu;
-	pcpu_init(pc, 0, sizeof(struct pcpu));
-	pc->pc_curthread = &thread0;
 #ifdef __powerpc64__
-	__asm __volatile("mr 13,%0" :: "r"(pc->pc_curthread));
+	__asm __volatile("mr 13,%0" :: "r"(&thread0));
 #else
-	__asm __volatile("mr 2,%0" :: "r"(pc->pc_curthread));
+	__asm __volatile("mr 2,%0" :: "r"(&thread0));
 #endif
-	pc->pc_cpuid = 0;
-
-	__asm __volatile("mtsprg 0, %0" :: "r"(pc));
 
 	/*
 	 * Init mutexes, which we use heavily in PMAP
@@ -367,6 +358,17 @@ powerpc_init(vm_offset_t fdt, vm_offset_
 	platform_probe_and_attach();
 
 	/*
+	 * Set up per-cpu data.
+	 */
+	pc = __pcpu;
+	if (platform_smp_get_bsp(&bsp) != 0)
+		bsp.cr_cpuid = 0;
+	pcpu_init(pc, bsp.cr_cpuid, sizeof(struct pcpu));
+	pc->pc_curthread = &thread0;
+	pc->pc_cpuid = bsp.cr_cpuid;
+	__asm __volatile("mtsprg 0, %0" :: "r"(pc));
+
+	/*
 	 * Bring up MMU
 	 */
 	pmap_bootstrap(startkernel, endkernel);

Modified: projects/powernv/powerpc/powerpc/mp_machdep.c
==============================================================================
--- projects/powernv/powerpc/powerpc/mp_machdep.c	Fri Jul  8 00:54:21 2016	(r302414)
+++ projects/powernv/powerpc/powerpc/mp_machdep.c	Fri Jul  8 01:31:28 2016	(r302415)
@@ -144,7 +144,6 @@ cpu_mp_start(void)
 
 	error = platform_smp_get_bsp(&bsp);
 	KASSERT(error == 0, ("Don't know BSP"));
-	KASSERT(bsp.cr_cpuid == 0, ("%s: cpuid != 0", __func__));
 
 	error = platform_smp_first_cpu(&cpu);
 	while (!error) {
@@ -184,7 +183,7 @@ cpu_mp_announce(void)
 	struct pcpu *pc;
 	int i;
 
-	for (i = 0; i <= mp_maxid; i++) {
+	CPU_FOREACH(i) {
 		pc = pcpu_find(i);
 		if (pc == NULL)
 			continue;

Modified: projects/powernv/powerpc/pseries/platform_chrp.c
==============================================================================
--- projects/powernv/powerpc/pseries/platform_chrp.c	Fri Jul  8 00:54:21 2016	(r302414)
+++ projects/powernv/powerpc/pseries/platform_chrp.c	Fri Jul  8 01:31:28 2016	(r302415)
@@ -458,7 +458,7 @@ chrp_smp_topo(platform_t plat)
 
 	ncores = ncpus = 0;
 	last_pc = NULL;
-	for (i = 0; i <= mp_maxid; i++) {
+	CPU_FOREACH(i) {
 		pc = pcpu_find(i);
 		if (pc == NULL)
 			continue;


More information about the svn-src-projects mailing list