svn commit: r232085 - in stable/9/sys/amd64: acpica amd64

Jung-uk Kim jkim at FreeBSD.org
Thu Feb 23 22:20:53 UTC 2012


Author: jkim
Date: Thu Feb 23 22:20:52 2012
New Revision: 232085
URL: http://svn.freebsd.org/changeset/base/232085

Log:
  MFC:	r231797
  
  Clean up RFLAG and CR3 register handling and nearby comments.  For BSP, use
  spinlock_enter()/spinlock_exit() to save/restore RFLAGS.  We know interrupt
  is disabled when returning from S3.  For AP, we do not have to save/restore
  it because IRET will do it for us any way.  Do not save CR3 locally because
  savectx() does it and BSP does not have to switch to kernel map for amd64.
  Change contigmalloc(9) flag while I am in the neighborhood.

Modified:
  stable/9/sys/amd64/acpica/acpi_wakeup.c
  stable/9/sys/amd64/amd64/mp_machdep.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/amd64/acpica/acpi_wakeup.c
==============================================================================
--- stable/9/sys/amd64/acpica/acpi_wakeup.c	Thu Feb 23 22:15:56 2012	(r232084)
+++ stable/9/sys/amd64/acpica/acpi_wakeup.c	Thu Feb 23 22:20:52 2012	(r232085)
@@ -223,7 +223,6 @@ acpi_sleep_machdep(struct acpi_softc *sc
 #ifdef SMP
 	cpuset_t	wakeup_cpus;
 #endif
-	register_t	cr3, rf;
 	ACPI_STATUS	status;
 	int		ret;
 
@@ -242,17 +241,9 @@ acpi_sleep_machdep(struct acpi_softc *sc
 
 	AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc));
 
-	rf = intr_disable();
+	spinlock_enter();
 	intr_suspend();
 
-	/*
-	 * Temporarily switch to the kernel pmap because it provides
-	 * an identity mapping (setup at boot) for the low physical
-	 * memory region containing the wakeup code.
-	 */
-	cr3 = rcr3();
-	load_cr3(KPML4phys);
-
 	if (savectx(susppcbs[0])) {
 		ctx_fpusave(suspfpusave[0]);
 #ifdef SMP
@@ -291,6 +282,7 @@ acpi_sleep_machdep(struct acpi_softc *sc
 			ia32_pause();
 	} else {
 		pmap_init_pat();
+		load_cr3(susppcbs[0]->pcb_cr3);
 		PCPU_SET(switchtime, 0);
 		PCPU_SET(switchticks, ticks);
 #ifdef SMP
@@ -306,10 +298,9 @@ out:
 		restart_cpus(wakeup_cpus);
 #endif
 
-	load_cr3(cr3);
 	mca_resume();
 	intr_resume();
-	intr_restore(rf);
+	spinlock_exit();
 
 	AcpiSetFirmwareWakingVector(0);
 
@@ -333,7 +324,7 @@ acpi_alloc_wakeup_handler(void)
 	 * and ROM area (0xa0000 and above).  The temporary page tables must be
 	 * page-aligned.
 	 */
-	wakeaddr = contigmalloc(4 * PAGE_SIZE, M_DEVBUF, M_NOWAIT, 0x500,
+	wakeaddr = contigmalloc(4 * PAGE_SIZE, M_DEVBUF, M_WAITOK, 0x500,
 	    0xa0000, PAGE_SIZE, 0ul);
 	if (wakeaddr == NULL) {
 		printf("%s: can't alloc wake memory\n", __func__);

Modified: stable/9/sys/amd64/amd64/mp_machdep.c
==============================================================================
--- stable/9/sys/amd64/amd64/mp_machdep.c	Thu Feb 23 22:15:56 2012	(r232084)
+++ stable/9/sys/amd64/amd64/mp_machdep.c	Thu Feb 23 22:20:52 2012	(r232085)
@@ -1414,20 +1414,17 @@ cpustop_handler(void)
 void
 cpususpend_handler(void)
 {
-	register_t cr3, rf;
 	u_int cpu;
 
 	cpu = PCPU_GET(cpuid);
 
-	rf = intr_disable();
-	cr3 = rcr3();
-
 	if (savectx(susppcbs[cpu])) {
 		ctx_fpusave(suspfpusave[cpu]);
 		wbinvd();
 		CPU_SET_ATOMIC(cpu, &stopped_cpus);
 	} else {
 		pmap_init_pat();
+		load_cr3(susppcbs[cpu]->pcb_cr3);
 		PCPU_SET(switchtime, 0);
 		PCPU_SET(switchticks, ticks);
 	}
@@ -1439,11 +1436,9 @@ cpususpend_handler(void)
 	CPU_CLR_ATOMIC(cpu, &started_cpus);
 	CPU_CLR_ATOMIC(cpu, &stopped_cpus);
 
-	/* Restore CR3 and enable interrupts */
-	load_cr3(cr3);
+	/* Resume MCA and local APIC */
 	mca_resume();
 	lapic_setup(0);
-	intr_restore(rf);
 }
 
 /*


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