svn commit: r231797 - in head/sys/amd64: acpica amd64
Jung-uk Kim
jkim at FreeBSD.org
Wed Feb 15 23:33:22 UTC 2012
Author: jkim
Date: Wed Feb 15 23:33:22 2012
New Revision: 231797
URL: http://svn.freebsd.org/changeset/base/231797
Log:
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:
head/sys/amd64/acpica/acpi_wakeup.c
head/sys/amd64/amd64/mp_machdep.c
Modified: head/sys/amd64/acpica/acpi_wakeup.c
==============================================================================
--- head/sys/amd64/acpica/acpi_wakeup.c Wed Feb 15 23:13:29 2012 (r231796)
+++ head/sys/amd64/acpica/acpi_wakeup.c Wed Feb 15 23:33:22 2012 (r231797)
@@ -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;
@@ -255,17 +254,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
@@ -304,6 +295,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
@@ -319,10 +311,9 @@ out:
restart_cpus(wakeup_cpus);
#endif
- load_cr3(cr3);
mca_resume();
intr_resume();
- intr_restore(rf);
+ spinlock_exit();
AcpiSetFirmwareWakingVector(0);
@@ -346,7 +337,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: head/sys/amd64/amd64/mp_machdep.c
==============================================================================
--- head/sys/amd64/amd64/mp_machdep.c Wed Feb 15 23:13:29 2012 (r231796)
+++ head/sys/amd64/amd64/mp_machdep.c Wed Feb 15 23:33:22 2012 (r231797)
@@ -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-head
mailing list