From owner-svn-src-stable-9@FreeBSD.ORG Thu Feb 23 22:20:53 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6322B106566C; Thu, 23 Feb 2012 22:20:53 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 515A28FC13; Thu, 23 Feb 2012 22:20:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q1NMKrO7027633; Thu, 23 Feb 2012 22:20:53 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1NMKrb1027630; Thu, 23 Feb 2012 22:20:53 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201202232220.q1NMKrb1027630@svn.freebsd.org> From: Jung-uk Kim Date: Thu, 23 Feb 2012 22:20:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232085 - in stable/9/sys/amd64: acpica amd64 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2012 22:20:53 -0000 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); } /*