Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Aug 2016 15:48:34 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r304042 - projects/powernv/kern
Message-ID:  <201608131548.u7DFmYsR037038@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Sat Aug 13 15:48:34 2016
New Revision: 304042
URL: https://svnweb.freebsd.org/changeset/base/304042

Log:
  More fixes and extra debugging for systems that have sparse CPU maps and on
  which the BSP is not CPU 0 (and CPU 0 may not even exist).

Modified:
  projects/powernv/kern/kern_clock.c
  projects/powernv/kern/kern_clocksource.c
  projects/powernv/kern/kern_shutdown.c
  projects/powernv/kern/subr_pcpu.c

Modified: projects/powernv/kern/kern_clock.c
==============================================================================
--- projects/powernv/kern/kern_clock.c	Sat Aug 13 15:41:04 2016	(r304041)
+++ projects/powernv/kern/kern_clock.c	Sat Aug 13 15:48:34 2016	(r304042)
@@ -608,7 +608,9 @@ hardclock_cnt(int cnt, int usermode)
 void
 hardclock_sync(int cpu)
 {
-	int	*t = DPCPU_ID_PTR(cpu, pcputicks);
+	int *t;
+	KASSERT(!CPU_ABSENT(cpu), ("Absent CPU %d", cpu));
+	t = DPCPU_ID_PTR(cpu, pcputicks);
 
 	*t = ticks;
 }

Modified: projects/powernv/kern/kern_clocksource.c
==============================================================================
--- projects/powernv/kern/kern_clocksource.c	Sat Aug 13 15:41:04 2016	(r304041)
+++ projects/powernv/kern/kern_clocksource.c	Sat Aug 13 15:48:34 2016	(r304042)
@@ -823,6 +823,8 @@ cpu_new_callout(int cpu, sbintime_t bt, 
 	CTR6(KTR_SPARE2, "new co at %d:    on %d at %d.%08x - %d.%08x",
 	    curcpu, cpu, (int)(bt_opt >> 32), (u_int)(bt_opt & 0xffffffff),
 	    (int)(bt >> 32), (u_int)(bt & 0xffffffff));
+
+	KASSERT(!CPU_ABSENT(cpu), ("Absent CPU %d", cpu));
 	state = DPCPU_ID_PTR(cpu, timerstate);
 	ET_HW_LOCK(state);
 

Modified: projects/powernv/kern/kern_shutdown.c
==============================================================================
--- projects/powernv/kern/kern_shutdown.c	Sat Aug 13 15:41:04 2016	(r304041)
+++ projects/powernv/kern/kern_shutdown.c	Sat Aug 13 15:48:34 2016	(r304042)
@@ -322,15 +322,16 @@ kern_reboot(int howto)
 
 #if defined(SMP)
 	/*
-	 * Bind us to CPU 0 so that all shutdown code runs there.  Some
+	 * Bind us to the first CPU so that all shutdown code runs there.  Some
 	 * systems don't shutdown properly (i.e., ACPI power off) if we
 	 * run on another processor.
 	 */
 	if (!SCHEDULER_STOPPED()) {
 		thread_lock(curthread);
-		sched_bind(curthread, 0);
+		sched_bind(curthread, CPU_FIRST());
 		thread_unlock(curthread);
-		KASSERT(PCPU_GET(cpuid) == 0, ("boot: not running on cpu 0"));
+		KASSERT(PCPU_GET(cpuid) == CPU_FIRST(),
+		    ("boot: not running on cpu 0"));
 	}
 #endif
 	/* We're in the process of rebooting. */

Modified: projects/powernv/kern/subr_pcpu.c
==============================================================================
--- projects/powernv/kern/subr_pcpu.c	Sat Aug 13 15:41:04 2016	(r304041)
+++ projects/powernv/kern/subr_pcpu.c	Sat Aug 13 15:48:34 2016	(r304042)
@@ -277,6 +277,8 @@ pcpu_destroy(struct pcpu *pcpu)
 struct pcpu *
 pcpu_find(u_int cpuid)
 {
+	KASSERT(cpuid_to_pcpu[cpuid] != NULL,
+	    ("Getting unitialized PCPU %d", cpuid));
 
 	return (cpuid_to_pcpu[cpuid]);
 }
@@ -407,7 +409,7 @@ DB_SHOW_ALL_COMMAND(pcpu, db_show_cpu_al
 	int id;
 
 	db_printf("Current CPU: %d\n\n", PCPU_GET(cpuid));
-	for (id = 0; id <= mp_maxid; id++) {
+	CPU_FOREACH(id) {
 		pc = pcpu_find(id);
 		if (pc != NULL) {
 			show_pcpu(pc);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608131548.u7DFmYsR037038>