Subject: Re: CVS commit: src/sys/arch/i386/acpi
To: Jared D. McNeill <jmcneill@invisible.ca>
From: Andrew Doran <ad@netbsd.org>
List: port-i386
Date: 08/03/2007 10:56:43
On Thu, Aug 02, 2007 at 11:55:35PM -0400, Jared D. McNeill wrote:

> >I wonder if that's enough for dual core laptops. Do we need to reinitialize
> >the lapic on the other core?
> 
> I think you're right. I can almost fully bring back this VAIO (except 
> for the network and wireless device drivers) from S3 on a UP kernel by 
> doing the following at resume:
> 
> 	i8259_reinit();
> 	lapic_enable();
> 	lapic_initclocks();
> 	ioapic_enable();
> 	lapic_set_lvt();
>
> What else should I do to ensure that things are configured properly in 
> the MULTIPROCESSOR case?

Without the lapic or interrupts we can't use IPIs, and we can't use threads
since the scheduler depends on IPIs and interrupts working. So any kind of
cross call is out of the question.

I guess it depends on what happens to the second core when it suspends,
enters SMM via ACPI or somesuch? I don't know how the power management parts
of ACPI/APM work. Does the kernel enter sleep from an interrupt handler or
from process context?

On the way back in the other cores would probably need to sit in a spin loop
and wait for the boot CPU to release them. See cpu_hatch() and similar. I
also think that before shutting down, we'd want to force the other CPUs to
go idle, perhaps forced to spin in the idle thread. If we have an MI way to
offline / online CPUs that would keep them sitting in idle_loop() that would
be fairly easy to do. I'll have a look into that.

Andrew