Subject: RE: power hook and spl level
To: None <tech-kern@netbsd.org>
From: TAKEMURA Shin <takemura@netbsd.org>
List: tech-kern
Date: 11/24/2000 11:26:38
My apologies for taking so long to respond, but I've made the patch
(attached). If no one is aginst me, I'm going to commit it next sunday.
I will change some device drivers which use power hook appropriately.
Takemura
> -----Original Message-----
> From: augustss@augustsson.net [mailto:augustss@augustsson.net]On
> Behalf Of Lennart Augustsson
> Sent: Monday, September 11, 2000 1:26 AM
> Subject: Re: power hook and spl level
>
> TAKEMURA Shin wrote:
> > I propose introducing new power events which are
> > processed in lower level like below:
> >
> > dopowerhooks(PWR_SOFTSUSPEND);
> > apm_spl = splhigh();
> > dopowerhooks(PWR_SUSPEND);
> > /* suspned... */
> > dopowerhooks(PWR_RESUME);
> > splx(apm_spl);
> >
> > dopowerhooks(PWR_SOFTRESUME);
>
> Unless someone has a better idea, I think this looks good.
Index: share/man/man9/powerhook_establish.9
===================================================================
RCS file: /cvsroot/sharesrc/share/man/man9/powerhook_establish.9,v
retrieving revision 1.1
diff -c -r1.1 powerhook_establish.9
*** share/man/man9/powerhook_establish.9 1999/12/06 14:50:02 1.1
--- share/man/man9/powerhook_establish.9 2000/11/24 02:06:14
***************
*** 80,89 ****
--- 80,95 ----
resume. The reason is reflected in the
.Fa why
argument and the values
+ .Dv PWR_SOFTSUSPEND ,
.Dv PWR_SUSPEND ,
+ .Dv PWR_SOFTSTANDBY ,
.Dv PWR_STANDBY ,
+ .Dv PWR_SOFTRESUME ,
and
.Dv PWR_RESUME .
+ It calls with PWR_SOFTxxx in the normal priority level while the other
+ callings are protected with
+ .Xr splhigh 9 .
At suspend the system is going to lose (almost) all power, standby retains
some power (e.g., minimal power to USB devices), and at resume power is
back to normal.
Index: sys/arch/i386/i386/apm.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/apm.c,v
retrieving revision 1.55
diff -c -r1.55 apm.c
*** sys/arch/i386/i386/apm.c 2000/11/15 01:59:35 1.55
--- sys/arch/i386/i386/apm.c 2000/11/24 02:06:17
***************
*** 401,406 ****
--- 401,408 ----
}
sc->sc_power_state = PWR_SUSPEND;
+ dopowerhooks(PWR_SOFTSUSPEND);
+
apm_spl = splhigh();
dopowerhooks(PWR_SUSPEND);
***************
*** 423,428 ****
--- 425,432 ----
}
sc->sc_power_state = PWR_STANDBY;
+ dopowerhooks(PWR_SOFTSTANDBY);
+
apm_spl = splhigh();
dopowerhooks(PWR_STANDBY);
***************
*** 455,460 ****
--- 459,466 ----
dopowerhooks(PWR_RESUME);
splx(apm_spl);
+
+ dopowerhooks(PWR_SOFTRESUME);
apm_record_event(sc, regs->BX);
}
Index: sys/kern/kern_subr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/kern_subr.c,v
retrieving revision 1.72
diff -c -r1.72 kern_subr.c
*** sys/kern/kern_subr.c 2000/11/08 14:25:24 1.72
--- sys/kern/kern_subr.c 2000/11/24 02:06:20
***************
*** 426,432 ****
{
struct powerhook_desc *dp;
! if (why == PWR_RESUME) {
CIRCLEQ_FOREACH_REVERSE(dp, &powerhook_list, sfd_list) {
(*dp->sfd_fn)(why, dp->sfd_arg);
}
--- 426,432 ----
{
struct powerhook_desc *dp;
! if (why == PWR_RESUME || why == PWR_SOFTRESUME) {
CIRCLEQ_FOREACH_REVERSE(dp, &powerhook_list, sfd_list) {
(*dp->sfd_fn)(why, dp->sfd_arg);
}
<< END