svn commit: r331909 - in stable/11/sys: kern sys x86/acpica x86/x86

Andriy Gapon avg at FreeBSD.org
Tue Apr 3 07:31:24 UTC 2018


Author: avg
Date: Tue Apr  3 07:31:22 2018
New Revision: 331909
URL: https://svnweb.freebsd.org/changeset/base/331909

Log:
  MFC r327056: Use resume_cpus() instead of restart_cpus() to resume from ACPI suspension.

Modified:
  stable/11/sys/kern/subr_smp.c
  stable/11/sys/sys/smp.h
  stable/11/sys/x86/acpica/acpi_wakeup.c
  stable/11/sys/x86/x86/mp_x86.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/subr_smp.c
==============================================================================
--- stable/11/sys/kern/subr_smp.c	Tue Apr  3 06:46:26 2018	(r331908)
+++ stable/11/sys/kern/subr_smp.c	Tue Apr  3 07:31:22 2018	(r331909)
@@ -348,13 +348,18 @@ generic_restart_cpus(cpuset_t map, u_int type)
 
 #if X86
 	if (type == IPI_SUSPEND)
-		cpus = &suspended_cpus;
+		cpus = &resuming_cpus;
 	else
 #endif
 		cpus = &stopped_cpus;
 
 	/* signal other cpus to restart */
-	CPU_COPY_STORE_REL(&map, &started_cpus);
+#if X86
+	if (type == IPI_SUSPEND)
+		CPU_COPY_STORE_REL(&map, &toresume_cpus);
+	else
+#endif
+		CPU_COPY_STORE_REL(&map, &started_cpus);
 
 #if X86
 	if (!nmi_is_broadcast || nmi_kdb_lock == 0) {

Modified: stable/11/sys/sys/smp.h
==============================================================================
--- stable/11/sys/sys/smp.h	Tue Apr  3 06:46:26 2018	(r331908)
+++ stable/11/sys/sys/smp.h	Tue Apr  3 07:31:22 2018	(r331909)
@@ -136,10 +136,13 @@ struct cpu_group *smp_topo_find(struct cpu_group *top,
 
 extern void (*cpustop_restartfunc)(void);
 extern int smp_cpus;
-extern volatile cpuset_t started_cpus;
-extern volatile cpuset_t stopped_cpus;
-extern volatile cpuset_t suspended_cpus;
-extern cpuset_t hlt_cpus_mask;
+/* The suspend/resume cpusets are x86 only, but minimize ifdefs. */
+extern volatile cpuset_t resuming_cpus;	/* woken up cpus in suspend pen */
+extern volatile cpuset_t started_cpus;	/* cpus to let out of stop pen */
+extern volatile cpuset_t stopped_cpus;	/* cpus in stop pen */
+extern volatile cpuset_t suspended_cpus; /* cpus [near] sleeping in susp pen */
+extern volatile cpuset_t toresume_cpus;	/* cpus to let out of suspend pen */
+extern cpuset_t hlt_cpus_mask;		/* XXX 'mask' is detail in old impl */
 extern cpuset_t logical_cpus_mask;
 #endif /* SMP */
 

Modified: stable/11/sys/x86/acpica/acpi_wakeup.c
==============================================================================
--- stable/11/sys/x86/acpica/acpi_wakeup.c	Tue Apr  3 06:46:26 2018	(r331908)
+++ stable/11/sys/x86/acpica/acpi_wakeup.c	Tue Apr  3 07:31:22 2018	(r331909)
@@ -284,7 +284,7 @@ acpi_wakeup_machdep(struct acpi_softc *sc, int state, 
 
 #ifdef SMP
 		if (!CPU_EMPTY(&suspcpus))
-			restart_cpus(suspcpus);
+			resume_cpus(suspcpus);
 #endif
 		mca_resume();
 #ifdef __amd64__

Modified: stable/11/sys/x86/x86/mp_x86.c
==============================================================================
--- stable/11/sys/x86/x86/mp_x86.c	Tue Apr  3 06:46:26 2018	(r331908)
+++ stable/11/sys/x86/x86/mp_x86.c	Tue Apr  3 07:31:22 2018	(r331909)
@@ -114,6 +114,9 @@ struct cpu_ops cpu_ops;
 
 static volatile cpuset_t ipi_stop_nmi_pending;
 
+volatile cpuset_t resuming_cpus;
+volatile cpuset_t toresume_cpus;
+
 /* used to hold the AP's until we are ready to release them */
 struct mtx ap_boot_mtx;
 
@@ -1316,6 +1319,13 @@ cpususpend_handler(void)
 #endif
 		wbinvd();
 		CPU_SET_ATOMIC(cpu, &suspended_cpus);
+		/*
+		 * Hack for xen, which does not use resumectx() so never
+		 * uses the next clause: set resuming_cpus early so that
+		 * resume_cpus() can wait on the same bitmap for acpi and
+		 * xen.  resuming_cpus now means eventually_resumable_cpus.
+		 */
+		CPU_SET_ATOMIC(cpu, &resuming_cpus);
 	} else {
 #ifdef __amd64__
 		fpuresume(susppcbs[cpu]->sp_fpususpend);
@@ -1327,12 +1337,12 @@ cpususpend_handler(void)
 		PCPU_SET(switchtime, 0);
 		PCPU_SET(switchticks, ticks);
 
-		/* Indicate that we are resumed */
+		/* Indicate that we are resuming */
 		CPU_CLR_ATOMIC(cpu, &suspended_cpus);
 	}
 
-	/* Wait for resume */
-	while (!CPU_ISSET(cpu, &started_cpus))
+	/* Wait for resume directive */
+	while (!CPU_ISSET(cpu, &toresume_cpus))
 		ia32_pause();
 
 	if (cpu_ops.cpu_resume)
@@ -1348,8 +1358,9 @@ cpususpend_handler(void)
 	lapic_setup(0);
 
 	/* Indicate that we are resumed */
+	CPU_CLR_ATOMIC(cpu, &resuming_cpus);
 	CPU_CLR_ATOMIC(cpu, &suspended_cpus);
-	CPU_CLR_ATOMIC(cpu, &started_cpus);
+	CPU_CLR_ATOMIC(cpu, &toresume_cpus);
 }
 
 


More information about the svn-src-stable-11 mailing list