Contributed by marco on from the ACPI-interrupts-are-more-complex-than-they-should-be dept.
1. During autoconf create a deferred thread to deal with interrupts while retaining context. 2. In the kernel thread initialize the GPEs by writing all zeros to the GPE_ENABLE register and ones to GPE_STATUS. 3. In the kernel thread initialize which GPEs you want, we for now only care about 0x1d events (button events) 4. Go to sleep waiting for an event ... a while later ... 5. We receive an event in the ACPI ISR. 6. Disable all ACPI interrupts (shit you not) 7. Wakeup the kernel thread 8. In the kernel thread figure out who gets the interrupt 9. In the kernel thread execute the AML code associated with the interrupt 10. In the kernel thread acknowledge the interrupt 11. Re-enable the interrupts and go to step 4Phew, that's a lot of work for a stupid power or sleep button event. Besides the amount of code it is quite unforgiving too. The only positive news here is that the device drivers that gets these events are extremely simple since a lot of the magic was handled in the kernel thread. Anyway after this started working it was simple to rig the ACPI button driver with for example the power down code. So why in the world isn't it working while we are receiving the interrupts?
This is a screamer... Some boxes were powering down and some were not. Since our laptops were working we had not yet gotten around to figure out why some people's computers were acting up. Alexander (grange@) just committed some code to clean up the set state code so he immediately got blamed :-) Jordan and I started debugging this, went back and forth with old and new code but it was unreliable and Alex's code really seemed good. Many reboots later we figure out that the values we are sending to the power down function is garbage. Hmmm so how did it get corrupted? Ah a good old struct sleeptype that should have been struct sleeptype; crap an off by one in the array declaration. So tons of debug code later it all makes sense suddenly and a 1 line commit. HA! and now we have powerdown when we hit the button, schaweet!!
(Comments are closed)