From owner-freebsd-mobile@FreeBSD.ORG Mon Oct 2 22:03:15 2006 Return-Path: X-Original-To: freebsd-mobile@freebsd.org Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CADF016A40F; Mon, 2 Oct 2006 22:03:15 +0000 (UTC) (envelope-from nate@root.org) Received: from ylpvm15.prodigy.net (ylpvm15-ext.prodigy.net [207.115.57.46]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2D63F43D55; Mon, 2 Oct 2006 22:03:13 +0000 (GMT) (envelope-from nate@root.org) X-ORBL: [67.119.74.222] Received: from [10.0.0.44] (adsl-67-119-74-222.dsl.sntc01.pacbell.net [67.119.74.222]) by ylpvm15.prodigy.net (8.13.8 out.dk.spool/8.13.8) with ESMTP id k92M39cG003075; Mon, 2 Oct 2006 18:03:10 -0400 Message-ID: <45218C97.5050802@root.org> Date: Mon, 02 Oct 2006 15:03:03 -0700 From: Nate Lawson User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: John Baldwin References: <20060921000628.GA1832@shorty.sorbonet.org> <200610021424.18562.jhb@freebsd.org> In-Reply-To: <200610021424.18562.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-acpi@freebsd.org, Andrea Bittau , freebsd-mobile@freebsd.org Subject: Re: hack for getting suspend/resume to half work on an IBM Thinkpad x60s [SMP] X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Oct 2006 22:03:15 -0000 John Baldwin wrote: > On Wednesday 20 September 2006 20:06, Andrea Bittau wrote: >> This is a half working hack for getting suspend/resume to "work" on an IBM >> >> ... >> >> 2) apic. FreeBSD reconfigures the io apic upon resume, but not the local > apic. >> The patch attached to this mail fixes this. Indeed, it almost does so in > the >> "proper" way and not so much of a hack =D. > > I actually have made a full patch for APIC I think (thanks for your work as it > reminded me about needing to resume lapic). You can find it at > http://www.FreeBSD.org/~jhb/patches/apic_resume.patch It changes the x86 > interrupt code to resume interrupt controllers, not interrupt sources. It > then uses this to make sure the 8259A PICs are properly reset on resume as > well as resuming the local APIC. Can you test this w/o SMP and make sure it > works? Great to see this work going on. I just got a Core Duo laptop so this would be great to see fixed. I'm kinda disappointed you're not using newbus for your device methods, but I think I mentioned that before. On the reset code, shouldn't there be some delays between writes to the registers? + outb(IO_ICU1, ICW1_RESET | ICW1_IC4); + outb(IO_ICU1 + ICU_IMR_OFFSET, IDT_IO_INTS); [delay?] + outb(IO_ICU1 + ICU_IMR_OFFSET, 1 << 2); [delay?] + outb(IO_ICU1 + ICU_IMR_OFFSET, ICW4_8086); [delay?] + outb(IO_ICU1 + ICU_IMR_OFFSET, 0xff); + outb(IO_ICU1, OCW3_SEL | OCW3_RR); + + outb(IO_ICU2, ICW1_RESET | ICW1_IC4); + outb(IO_ICU2 + ICU_IMR_OFFSET, IDT_IO_INTS + 8); [delay?] + outb(IO_ICU2 + ICU_IMR_OFFSET, 2); [delay?] + outb(IO_ICU2 + ICU_IMR_OFFSET, ICW4_8086); [delay?] + outb(IO_ICU2 + ICU_IMR_OFFSET, 0xff); + outb(IO_ICU2, OCW3_SEL | OCW3_RR); >> 3) SMP. The second core needs to be killed and woken up as appropriate. > The >> way I do this is quite lame. >> - Force the second core in the idle loop by setting machdep.hlt_cpus=2. >> - make system look like UP instead of SMP [i.e. deactivate SMP] & > suspend. >> - resume, wake up other core [which will run idle process] and activate > SMP. > > Probably we need to get onto the BSP via sched_bind() during suspend and then > stop the other CPUs using stop_cpus(). The hard part, however, is properly > resuming the darn things. Do you know what mode the CPUs come back up in? > It looks like we need to resend startup IPIs to them from your patch. The writes to the PM registers should happen from the BSP anyway, so sched_bind() is the right way to go. I think you need to start them up the same as boot, including startup IPI and then enabling scheduling on them. -- Nate