tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: apm(4) fixes

In article <>,
Manuel Bouyer  <> wrote:
>after updating my old laptop to netbsd-5, I did need to have a working
>APM again. I came up with the following patch, which makes standby,
>suspend to ram and suspend to disk work again for me.
>There are 2 problems:
>- apm_suspend() and apm_standby() will call splhhigh() before entering
>  standby or suspend. After resume, the system go back tsleep()ing
>  in the apm thread without restoring the ipl (this is done in
>  apm_resume()), and calling tlseep() at IPL_HIGH cause a DIAGOSCTIC
>  panic (and other bad things, I guess).
>  My fix is to call apm_resume() from within apm_suspend() or
>  apm_standby(), after aa_set_powstate() has returned.
>  Another option would be to set another global variable apm_in_sleep
>  and not call tsleep in the apm thread when this variable is not 0.
>  Not sure which one is better.
>- In apm_event_handle(), we test (apm_standbys || apm_suspends) to set
>  apm_damn_fool_bios to 1 and break the while() loop in apm_periodic_check().
>  But we set apm_standbys or apm_suspends to non-0 only if apm_op_inprog
>  is 0 and we failed to record the apm event. With apmd listening
>  we usually succeed recording the event, so apm_standbys/apm_suspends remains
>  0 and we never go out of the while() loop.
>  My fix is to check apm_op_inprog instead of (apm_standbys || apm_suspends)
>  to break the loop. This one is always set when an event is being
>  handled.
>Comments ?
>PS: on this laptop the pfm handler are harmfull and I had to disable them:
>on reboot, the laptop gets stuck in BIOS, and on wakeup after a
>suspend/standby, the kernel is completely dead. But that's a different

Looks good to me.


Home | Main Index | Thread Index | Old Index