linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Let init know user wants to shutdown
@ 2001-04-12 17:25 David Balazic
  2001-04-16  7:03 ` Pavel Machek
  0 siblings, 1 reply; 69+ messages in thread
From: David Balazic @ 2001-04-12 17:25 UTC (permalink / raw)
  To: pavel; +Cc: linux-kernel

Pavel Machek (pavel@suse.cz) wrote :

> Hi! 
> 
> Init should get to know that user pressed power button (so it can do 
> shutdown and poweroff). Plus, it is nice to let user know that we can 
> read such event. [I hunted bug for few hours, thinking that kernel 
> does not get the event at all]. 
> 
> Here's patch to do that. Please apply, 
>                                                                 Pavel 

Isn't it better to just send the event to userspace , where
is it caught by apmd ( or whatever has replaced it ).
Then it can decide what to do about it, instead of dictating
a shutdown from kernel ( policy alert ;-) )


-- 
David Balazic
--------------
"Be excellent to each other." - Bill & Ted
- - - - - - - - - - - - - - - - - - - - - -

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-12 17:25 Let init know user wants to shutdown David Balazic
@ 2001-04-16  7:03 ` Pavel Machek
  0 siblings, 0 replies; 69+ messages in thread
From: Pavel Machek @ 2001-04-16  7:03 UTC (permalink / raw)
  To: David Balazic; +Cc: pavel, linux-kernel


Hi!

> > Init should get to know that user pressed power button (so it can do 
> > shutdown and poweroff). Plus, it is nice to let user know that we can 
> > read such event. [I hunted bug for few hours, thinking that kernel 
> > does not get the event at all]. 
> > 
> > Here's patch to do that. Please apply, 
> >                                                                 Pavel 
> 
> Isn't it better to just send the event to userspace , where
> is it caught by apmd ( or whatever has replaced it ).
> Then it can decide what to do about it, instead of dictating
> a shutdown from kernel ( policy alert ;-) )


I'm not dictating policy: init is free to do anything it is configured
to, including /sbin/apmd --button_came or echo "Don't you dare to
plpress that button again".

> 
> 

-- 
The best software in life is free (not shareware)!		Pavel
GCM d? s-: !g p?:+ au- a--@ w+ v- C++@ UL+++ L++ N++ E++ W--- M- Y- R+

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-20 17:02         ` Pavel Machek
@ 2001-05-02 16:52           ` John Fremlin
  0 siblings, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-05-02 16:52 UTC (permalink / raw)
  To: Pavel Machek; +Cc: sfr, linux-laptop, linux-kernel, apenwarr

Pavel Machek <pavel@suse.cz> writes:

> > > > I'm wondering if that veto business is really needed. Why not reject
> > > > *all* APM rejectable events, and then let the userspace event handler
> > > > send the system to sleep or turn it off? Anybody au fait with the APM
> > > > spec?
> > > 
> > > Because apmd is optional
> > 
> > The veto stuff only comes into action, iff someone has registered as
> > willing to exercise this power. We would not break compatibility with
> > any std kernel by instead having a apmd send a "reject all" ioctl
> > instead, and so deal with events without having the pressure of having
> > to reject or accept them, and let us remove all the veto code from the
> > kernel driver. Or am I missing something?
> 
> No, this looks reasonable.

What do you think Stephen and Avery? Are you happy with this idea?

If anybody wants to test it, my latest pmevent patch will reject *all*
APM events it can. It would be easy to adapt that to turn on and off
with an ioctl. I am happy to do that if Stephen would accept
it. (Personally would like it if events were rejected by default but
that breaks backward compatibility and there is always someone who
would get bitten.)

The latest pmevent patch (v3) with various APM cleanups is available
at

        http://ape.n3.net/programs/linux/offbutton/download

Note that it currently shares no code with the pmpolicy patch.
For more information see

        http://ape.n3.net/programs/linux/offbutton/

-- 

	http://ape.n3.net

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
  2001-04-18 22:52 Grover, Andrew
@ 2001-04-26 22:10 ` David S. Miller
  0 siblings, 0 replies; 69+ messages in thread
From: David S. Miller @ 2001-04-26 22:10 UTC (permalink / raw)
  To: Grover, Andrew
  Cc: 'John Fremlin', 'Simon Richter', Acpi-PM (E-mail),
	'Pavel Machek',
	Andreas Ferber, linux-kernel


Grover, Andrew writes:
 > A generalized interface is more work, and I see no
 > benefit *right now*. We'll see when someone designs one, I guess.

If the whole world were ACPI, yes I would not see a benefit either,
but for PPC, UltraSPARC-III etc. systems there is going to be a gain.

These systems do power management in a way that is in many ways quite
different from the models provided by ACPI.

You can break the whole power management problem down to "here are
the levels of low-power provided by the hardware, here are the
idleness triggers that may be monitored".  That's it, nothing more.
This is powerful enough to do all the things you could want a pm layer
to do:

	1) CPU's have been in their idle threads for X percent of
	   of the past measurement quantum, half clock the processors.

	2) The user has hit the "sleep" trigger, spin down the disks,
	   reduce clock the cpus, bus, PCI controller and PCI devices.

This kind of pm model with triggers and available low power states can
be used to solve problems PM was not designed to solve.  For example,
if fans begin to fail and temperature indicates we might begin to
overheat, we can reduce clock the cpus to reduce the heat before doing
something more drastic like shutting the system down.  Basically,
environment control problems can be expressed within this framework.

You get the idea.  And none of it has anything to do with ACPI, Sun's
Ultra-III platform power management scheme, or what Apple uses in the
iBook.

This is the kind of model I like because it doesn't "look" like any
particular implementation of power management, it "is" power
management.  I can plug any hardware PM scheme into that.

Later,
David S. Miller
davem@redhat.com


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-24 10:06           ` Pavel Machek
  2001-04-25 14:28             ` Jamie Lokier
@ 2001-04-25 16:11             ` Richard Gooch
  1 sibling, 0 replies; 69+ messages in thread
From: Richard Gooch @ 2001-04-25 16:11 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: Pavel Machek, John Fremlin, Acpi-PM (E-mail), linux-kernel

Jamie Lokier writes:
> Hmm.  Perhaps apmd needs a "do not sync" option, for when you don't care.

Alternatively, use my pmeventd (previously suspendd) from my pmutils
package. You get complete control over all PM events. The daemon sets
no policy (unlike apmd).
http://www.atnf.csiro.au/~rgooch/linux/
ftp://ftp.atnf.csiro.au/pub/people/rgooch/linux/daemons/pmutils.tar.gz

				Regards,

					Richard....
Permanent: rgooch@atnf.csiro.au
Current:   rgooch@ras.ucalgary.ca

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-24 10:06           ` Pavel Machek
@ 2001-04-25 14:28             ` Jamie Lokier
  2001-04-25 16:11             ` Richard Gooch
  1 sibling, 0 replies; 69+ messages in thread
From: Jamie Lokier @ 2001-04-25 14:28 UTC (permalink / raw)
  To: Pavel Machek; +Cc: John Fremlin, Acpi-PM (E-mail), linux-kernel

Pavel Machek wrote:
> > Are you sure? A suspend takes about 5-10 seconds on my laptop.
> 
> Ouch? Really?

No, I was thinking of one of the earlier 2.4 kernels.  2.4.3 seems
faster again.

> What  I do is killall apmd, then apm -s and it is more or less
> instant. [Are you using suspend-to-disk? AFAICS my toshiba can not do
> suspend to disk, that's why I'm interested].

Mind doesn't do suspend-to-disk either.  I think it can with Windows but
I've never run Windows on it to find out :-)

I've always presumed the disk activity that starts after closing the lid
and before powering down is due to the kernel, or maybe apmd, calling
sync().

> > (It was noticably faster with  2.3 kernels, btw. Now it spends a second
> > or two apparently not noticing the APM event (though the BIOS is making
> > the speaker beep ), then syncing the disk, then maybe another pause, then
> > maybe some more disk activity, then finally shutting down. 2.3 started
> > t he disk activity immediately and didn't pause. Perhaps 2.4.3 mm
> > problems?)
> 
> Take a look what apmd does. I'm killing it before apm -s.

Hmm.  Perhaps apmd needs a "do not sync" option, for when you don't care.

-- Jamie

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-24  0:17         ` Jamie Lokier
  2001-04-24  1:08           ` John Fremlin
@ 2001-04-24 10:06           ` Pavel Machek
  2001-04-25 14:28             ` Jamie Lokier
  2001-04-25 16:11             ` Richard Gooch
  1 sibling, 2 replies; 69+ messages in thread
From: Pavel Machek @ 2001-04-24 10:06 UTC (permalink / raw)
  To: Jamie Lokier, John Fremlin; +Cc: Pavel Machek, Acpi-PM (E-mail), linux-kernel

Hi!

> > > > I'm wondering if that veto business is really needed. Why not reject
> > > > *all* APM rejectable events, and then let the userspace event handler
> > > > send the system to sleep or turn it off? Anybody au fait with the APM
> > > > spec?
> > > 
> > > My thinkpad actually started blinking with some LED when you pressed
> > > the button. LED went off when you rejected or when sleep was
> > > completed.
> > 
> > Does the led start blinking when the system sends an apm suspend? In
> > that case I don't think you'd notice the brief period between the
> > REJECT and the following suspend from userspace ;-)
> 
> Are you sure? A suspend takes about 5-10 seconds on my laptop.

Ouch? Really?

What  I do is killall apmd, then apm -s and it is more or less
instant. [Are you using suspend-to-disk? AFAICS my toshiba can not do
suspend to disk, that's why I'm interested].

> (It was noticably faster with  2.3 kernels, btw. Now it spends a second
> or two apparently not noticing the APM event (though the BIOS is making
> the speaker beep ), then syncing the disk, then maybe another pause, then
> maybe some more disk activity, then finally shutting down. 2.3 started
> t he disk activity immediately and didn't pause. Perhaps 2.4.3 mm
> problems?)

Take a look what apmd does. I'm killing it before apm -s.
								Pavel

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-24  0:17         ` Jamie Lokier
@ 2001-04-24  1:08           ` John Fremlin
  2001-04-24 10:06           ` Pavel Machek
  1 sibling, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-24  1:08 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: linux-kernel

Jamie Lokier <lk@tantalophile.demon.co.uk> writes:

[...]

> Are you sure?  A suspend takes about 5-10 seconds on my laptop.

You mean when you tell the apm driver from userspace to suspend?

> (It was noticably faster with 2.3 kernels, btw.  Now it spends a second
> or two apparently not noticing the APM event (though the BIOS is making
> the speaker beep), then syncing the disk, 

The BIOS got the event, problem is in BIOS surely?

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-20 23:41       ` John Fremlin
  2001-04-21  7:54         ` Pavel Machek
@ 2001-04-24  0:17         ` Jamie Lokier
  2001-04-24  1:08           ` John Fremlin
  2001-04-24 10:06           ` Pavel Machek
  1 sibling, 2 replies; 69+ messages in thread
From: Jamie Lokier @ 2001-04-24  0:17 UTC (permalink / raw)
  To: John Fremlin; +Cc: Pavel Machek, Acpi-PM (E-mail), linux-kernel

John Fremlin wrote:
> > > I'm wondering if that veto business is really needed. Why not reject
> > > *all* APM rejectable events, and then let the userspace event handler
> > > send the system to sleep or turn it off? Anybody au fait with the APM
> > > spec?
> > 
> > My thinkpad actually started blinking with some LED when you pressed
> > the button. LED went off when you rejected or when sleep was
> > completed.
> 
> Does the led start blinking when the system sends an apm suspend? In
> that case I don't think you'd notice the brief period between the
> REJECT and the following suspend from userspace ;-)

Are you sure?  A suspend takes about 5-10 seconds on my laptop.

(It was noticably faster with 2.3 kernels, btw.  Now it spends a second
or two apparently not noticing the APM event (though the BIOS is making
the speaker beep), then syncing the disk, then maybe another pause, then
maybe some more disk activity, then finally shutting down.  2.3 started
the disk activity immediately and didn't pause.  Perhaps 2.4.3 mm
problems?)

-- Jamie


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-20 23:41       ` John Fremlin
@ 2001-04-21  7:54         ` Pavel Machek
  2001-04-24  0:17         ` Jamie Lokier
  1 sibling, 0 replies; 69+ messages in thread
From: Pavel Machek @ 2001-04-21  7:54 UTC (permalink / raw)
  To: John Fremlin; +Cc: Acpi-PM (E-mail), linux-kernel

Hi!

> > > I'm wondering if that veto business is really needed. Why not reject
> > > *all* APM rejectable events, and then let the userspace event handler
> > > send the system to sleep or turn it off? Anybody au fait with the APM
> > > spec?
> > 
> > My thinkpad actually started blinking with some LED when you pressed
> > the button. LED went off when you rejected or when sleep was
> > completed.
> 
> Does the led start blinking when the system sends an apm suspend? In
> that case I don't think you'd notice the brief period between the
> REJECT and the following suspend from userspace ;-)

Not so brief -- suspend to disk takes quite a lot of time. However, it
is probably not too important if user can see blinking led or not.

								Pavel
-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-20 17:01     ` Pavel Machek
@ 2001-04-20 23:41       ` John Fremlin
  2001-04-21  7:54         ` Pavel Machek
  2001-04-24  0:17         ` Jamie Lokier
  0 siblings, 2 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-20 23:41 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Acpi-PM (E-mail), linux-kernel

 Pavel Machek <pavel@suse.cz> writes:

[...]

> > I'm wondering if that veto business is really needed. Why not reject
> > *all* APM rejectable events, and then let the userspace event handler
> > send the system to sleep or turn it off? Anybody au fait with the APM
> > spec?
> 
> My thinkpad actually started blinking with some LED when you pressed
> the button. LED went off when you rejected or when sleep was
> completed.

Does the led start blinking when the system sends an apm suspend? In
that case I don't think you'd notice the brief period between the
REJECT and the following suspend from userspace ;-)

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 19:10       ` John Fremlin
  2001-04-18 20:10         ` Alan Cox
@ 2001-04-20 17:02         ` Pavel Machek
  2001-05-02 16:52           ` John Fremlin
  1 sibling, 1 reply; 69+ messages in thread
From: Pavel Machek @ 2001-04-20 17:02 UTC (permalink / raw)
  To: John Fremlin, Alan Cox; +Cc: sfr, linux-kernel, apenwarr

Hi!

> > > I'm wondering if that veto business is really needed. Why not reject
> > > *all* APM rejectable events, and then let the userspace event handler
> > > send the system to sleep or turn it off? Anybody au fait with the APM
> > > spec?
> > 
> > Because apmd is optional
> 
> The veto stuff only comes into action, iff someone has registered as
> willing to exercise this power. We would not break compatibility with
> any std kernel by instead having a apmd send a "reject all" ioctl
> instead, and so deal with events without having the pressure of having
> to reject or accept them, and let us remove all the veto code from the
> kernel driver. Or am I missing something?

No, this looks reasonable.
								Pavel
-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18  1:56   ` John Fremlin
  2001-04-18 11:55     ` Alan Cox
@ 2001-04-20 17:01     ` Pavel Machek
  2001-04-20 23:41       ` John Fremlin
  1 sibling, 1 reply; 69+ messages in thread
From: Pavel Machek @ 2001-04-20 17:01 UTC (permalink / raw)
  To: John Fremlin, Alan Cox
  Cc: Grover, Andrew, Acpi-PM (E-mail), 'Pavel Machek',
	Simon Richter, Andreas Ferber, linux-kernel

Hi!

> [...]
> 
> > I would tend to agree here. If you want to wire it to init the fine
> > but pm is basically message passing kernel->user and possibly
> > message reply to allow veto/approve. APM provides a good API for
> > this and there is a definite incentive to make ACPI use the same
> > messages, behaviour and extend it.
> 
> I'm wondering if that veto business is really needed. Why not reject
> *all* APM rejectable events, and then let the userspace event handler
> send the system to sleep or turn it off? Anybody au fait with the APM
> spec?

My thinkpad actually started blinking with some LED when you pressed
the button. LED went off when you rejected or when sleep was
completed. So you would loose visual indication of "system is now
going to sleep". But I guess that is very little loose for the loose
of complexity.
								Pavel
-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 21:46 Grover, Andrew
                   ` (2 preceding siblings ...)
  2001-04-19  2:16 ` Jeff Garzik
@ 2001-04-19 12:04 ` David Woodhouse
  3 siblings, 0 replies; 69+ messages in thread
From: David Woodhouse @ 2001-04-19 12:04 UTC (permalink / raw)
  To: Grover, Andrew
  Cc: 'John Fremlin', 'Simon Richter', Acpi-PM (E-mail),
	'Pavel Machek',
	Andreas Ferber, linux-kernel


andrew.grover@intel.com said:
>  IMHO an abstracted interface at this point is overengineering. Maybe
> later it will make sense, though. 

Absolutely not. It makes sense now. The abstracted interface is not required
just to combine the interface to APM and ACPI. What John said was 
"ACPI != PM". Note that APM != PM either. 

We have people who write _real_ code (esp. for embedded systems) to do power 
management. None of this UDI-written-in-bytecode style stuff - real C code. 
I.e. "the preferred form of the work for making modifications to it" :) 

_That_ is the first-class citizen here, and _that_ is the thing for which we
require a generic power management API, allowing userspace to set and manage
the power management policies for individual devices, etc., as well as 
managing the system-wide sleep macrostates.

It may happen that ACPI and the real native power management code can
happily share an interface. Where there's a conflict, though, the native
implementations should define the interface, and ACPI needs to try to fit
in.

--
dwmw2



^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 21:46 Grover, Andrew
  2001-04-18 22:09 ` David S. Miller
  2001-04-18 22:30 ` John Fremlin
@ 2001-04-19  2:16 ` Jeff Garzik
  2001-04-19 12:04 ` David Woodhouse
  3 siblings, 0 replies; 69+ messages in thread
From: Jeff Garzik @ 2001-04-19  2:16 UTC (permalink / raw)
  To: Grover, Andrew; +Cc: Acpi-PM (E-mail), linux-kernel

"Grover, Andrew" wrote:
> ACPI has by far the richest set of capabilities. It is a superset of APM.
> Therefore a combined APM/ACPI interface is going to look a lot like an ACPI
> interface.
> 
> IMHO an abstracted interface at this point is overengineering. Maybe later
> it will make sense, though.

IMHO We want to be able to support at least three cases:  APM, ACPI, and
native PM.

-- 
Jeff Garzik       | "The universe is like a safe to which there is a
Building 1024     |  combination -- but the combination is locked up
MandrakeSoft      |  in the safe."    -- Peter DeVries

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
@ 2001-04-18 22:52 Grover, Andrew
  2001-04-26 22:10 ` David S. Miller
  0 siblings, 1 reply; 69+ messages in thread
From: Grover, Andrew @ 2001-04-18 22:52 UTC (permalink / raw)
  To: 'David S. Miller'
  Cc: 'John Fremlin', 'Simon Richter', Acpi-PM (E-mail),
	'Pavel Machek',
	Andreas Ferber, linux-kernel

> From: David S. Miller [mailto:davem@redhat.com]
>  > IMHO an abstracted interface at this point is overengineering.
> 
> ACPI is the epitome of overengineering.

Hi David,

I definitely set myself up for that one. ;-) And, you're not wrong. But,
let's be clear on one thing, there are two interfaces under consideration:
1) How the kernel interacts with the platform to do power
management/configuration and 2) How the OS exposes its PM interface to ring
3.

#1 is defined by ACPI and it's too late to improve it - it's the standard. I
think it's a net improvement (by getting rid of several ugly existing
interfaces like APM, pnpbios, and MPS tables) but also realize that *we have
stepped up* to implement ACPI support, a not inconsiderable effort. You may
think this is cleaning up a mess we made ourselves but there are clear,
large, advantages that ACPI-enabled systems will have over non-ACPI ones.
Windows 2000 is a great mobile OS in large part due to ACPI.

#2 was what I was referring to with the overengineering comment. Basically,
we want to put PM policy in userspace because that's where Unix puts these
things, right? We have more functionality than other PM options, therefore
we need the most elaborate PM kernel<-->user interface. My point was that we
don't even have a functional PM policy daemon at this point, so it's a
little early to start generalizing the interface, in my opinion, but a
generalized PM interface is OK, as long as it exposes at least the level of
functionality ACPI does. A generalized interface is more work, and I see no
benefit *right now*. We'll see when someone designs one, I guess.

> An abstracted interface would allow simpler systems to avoid all of
> the bloated garbage ACPI brings with it.  Sorry, Alan hit it right on
> the head, ACPI is not much more than keeping speedstep proprietary.

This is not correct. ACPI 1.0 existed before SpeedStep was even conceived
of. The 1.0 spec contains no mention of processor performance states, or
device performance states. ACPI 2.0 does, but it provides a generic
interface for the OS to control processor performance, thus commoditizing
SpeedStep-type functionality in the future.

Clear?

Regards -- Andy


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 21:46 Grover, Andrew
  2001-04-18 22:09 ` David S. Miller
@ 2001-04-18 22:30 ` John Fremlin
  2001-04-19  2:16 ` Jeff Garzik
  2001-04-19 12:04 ` David Woodhouse
  3 siblings, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-18 22:30 UTC (permalink / raw)
  To: Grover, Andrew
  Cc: 'Simon Richter', Acpi-PM (E-mail), 'Pavel Machek',
	Andreas Ferber, linux-kernel

"Grover, Andrew" <andrew.grover@intel.com> writes:

[...]

> > ACPI != PM. I don't see why ACPI details should be exposed to PM
> > interface at all.
> 
> ACPI has by far the richest set of capabilities. It is a superset of
> APM.  Therefore a combined APM/ACPI interface is going to look a lot
> like an ACPI interface.

First, lets stop being so Intel/x86 centric ;-)
There are more PM interfaces than APM/ACPI as Stephen Rothwell pointed
out to me: more are already supported by the kernel. PPC has one, ARM
has one, etc. And that's not even touching on UPSs and miscellaneous
portable whatnots with their own special PM bits and pieces like IBM
laptops.

ACPI might be able to handle all that but it would require a very
complex interface, if what I've seen of ACPI is anything to go by. Is
this correct?

A much simpler interface might not lose much functionality.

> IMHO an abstracted interface at this point is overengineering. Maybe
> later it will make sense, though.

Each PM scheme has its own daemon and suspend/sleep tools at the
moment. It makes sense to have just one daemon and toolset so that
advanced functionality can be shared. Should the kernel present a
common interface like HID, or should the daemon be able to understand
all the various protocols (like gpm for mice)?

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
  2001-04-18 21:46 Grover, Andrew
@ 2001-04-18 22:09 ` David S. Miller
  2001-04-18 22:30 ` John Fremlin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 69+ messages in thread
From: David S. Miller @ 2001-04-18 22:09 UTC (permalink / raw)
  To: Grover, Andrew
  Cc: 'John Fremlin', 'Simon Richter', Acpi-PM (E-mail),
	'Pavel Machek',
	Andreas Ferber, linux-kernel


Grover, Andrew writes:
 > IMHO an abstracted interface at this point is overengineering.

ACPI is the epitome of overengineering.

An abstracted interface would allow simpler systems to avoid all of
the bloated garbage ACPI brings with it.  Sorry, Alan hit it right on
the head, ACPI is not much more than keeping speedstep proprietary.

Later,
David S. Miller
davem@redhat.com

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
@ 2001-04-18 21:46 Grover, Andrew
  2001-04-18 22:09 ` David S. Miller
                   ` (3 more replies)
  0 siblings, 4 replies; 69+ messages in thread
From: Grover, Andrew @ 2001-04-18 21:46 UTC (permalink / raw)
  To: 'John Fremlin'
  Cc: 'Simon Richter', Acpi-PM (E-mail), 'Pavel Machek',
	Andreas Ferber, linux-kernel

> From: John Fremlin [mailto:chief@bandits.org]
> [...]
> 
> > Fair enough. I don't think I would be out of line to say that our
> > resources are focused on enabling full ACPI functionality for Linux,
> > including a full-featured PM policy daemon. That said, I don't think
> > there's anything precluding the use of another daemon (or whatever)
> > from using the ACPI driver's interface.
> 
> ACPI != PM. I don't see why ACPI details should be exposed to PM
> interface at all.

ACPI has by far the richest set of capabilities. It is a superset of APM.
Therefore a combined APM/ACPI interface is going to look a lot like an ACPI
interface.

IMHO an abstracted interface at this point is overengineering. Maybe later
it will make sense, though.

Regards -- Andy


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 21:05           ` Avery Pennarun
@ 2001-04-18 21:34             ` John Fremlin
  0 siblings, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-18 21:34 UTC (permalink / raw)
  To: Avery Pennarun; +Cc: Alan Cox, sfr, linux-kernel

 Avery Pennarun <apenwarr@worldvisions.ca> writes:

> On Wed, Apr 18, 2001 at 09:10:37PM +0100, Alan Cox wrote:
> 
> > > willing to exercise this power. We would not break compatibility with
> > > any std kernel by instead having a apmd send a "reject all" ioctl
> > > instead, and so deal with events without having the pressure of having
> > > to reject or accept them, and let us remove all the veto code from the
> > > kernel driver. Or am I missing something?
> > 
> > That sounds workable. But the same program could reply to the events just
> > as well as issue the ioctl 8)
> 
> AFAICT some APM BIOSes get impatient if you don't acknowledge/reject
> the requests fast enough, and start to go bananas.  By always
> rejecting requests and then making user requests instead at some
> time later, we might eliminate this problem (or just cause new
> ones).

Indeed. Neither proposal has however received wide testing as far as I
know. The userspace ACCEPT/REJECT method was available as a patch from
Stephen for a while though.

> Also, I don't think the "critical suspend" message can be rejected
> at all, so it would have to be a special case where currently I
> don't think it's too bad.

ATM it is a "special case" - we print a message if we try to reject a
critical suspend. However the case is not so special that it requires
more than a line or two ;-)

I don't think there is any cause for concern on that front.

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 20:10         ` Alan Cox
  2001-04-18 20:21           ` John Fremlin
@ 2001-04-18 21:05           ` Avery Pennarun
  2001-04-18 21:34             ` John Fremlin
  1 sibling, 1 reply; 69+ messages in thread
From: Avery Pennarun @ 2001-04-18 21:05 UTC (permalink / raw)
  To: Alan Cox; +Cc: John Fremlin, sfr, linux-kernel

On Wed, Apr 18, 2001 at 09:10:37PM +0100, Alan Cox wrote:

> > willing to exercise this power. We would not break compatibility with
> > any std kernel by instead having a apmd send a "reject all" ioctl
> > instead, and so deal with events without having the pressure of having
> > to reject or accept them, and let us remove all the veto code from the
> > kernel driver. Or am I missing something?
> 
> That sounds workable. But the same program could reply to the events just
> as well as issue the ioctl 8)

AFAICT some APM BIOSes get impatient if you don't acknowledge/reject the
requests fast enough, and start to go bananas.  By always rejecting requests
and then making user requests instead at some time later, we might eliminate
this problem (or just cause new ones).

Also, I don't think the "critical suspend" message can be rejected at all,
so it would have to be a special case where currently I don't think it's too
bad.

Have fun,

Avery

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 20:10         ` Alan Cox
@ 2001-04-18 20:21           ` John Fremlin
  2001-04-18 21:05           ` Avery Pennarun
  1 sibling, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-18 20:21 UTC (permalink / raw)
  To: Alan Cox; +Cc: sfr, linux-kernel, apenwarr

Alan Cox <alan@lxorguk.ukuu.org.uk> writes:

> > willing to exercise this power. We would not break compatibility
> > with any std kernel by instead having a apmd send a "reject all"
> > ioctl instead, and so deal with events without having the pressure
> > of having to reject or accept them, and let us remove all the veto
> > code from the kernel driver. Or am I missing something?
> 
> That sounds workable. But the same program could reply to the events
> just as well as issue the ioctl 8)

Having more than one program holding the veto on each event is a bit
of a hassle. Keeping track of "replies" is also a bit of a
hassle. It'd be simpler to let userspace handle everything in line
with e.g. the ACPI power button press, and suspend or turn off the
machine in the normal manner.

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 19:10       ` John Fremlin
@ 2001-04-18 20:10         ` Alan Cox
  2001-04-18 20:21           ` John Fremlin
  2001-04-18 21:05           ` Avery Pennarun
  2001-04-20 17:02         ` Pavel Machek
  1 sibling, 2 replies; 69+ messages in thread
From: Alan Cox @ 2001-04-18 20:10 UTC (permalink / raw)
  To: John Fremlin; +Cc: Alan Cox, sfr, linux-kernel, apenwarr

> willing to exercise this power. We would not break compatibility with
> any std kernel by instead having a apmd send a "reject all" ioctl
> instead, and so deal with events without having the pressure of having
> to reject or accept them, and let us remove all the veto code from the
> kernel driver. Or am I missing something?

That sounds workable. But the same program could reply to the events just
as well as issue the ioctl 8)



^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 15:26 ` Simon Richter
@ 2001-04-18 19:51   ` John Fremlin
  0 siblings, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-18 19:51 UTC (permalink / raw)
  To: Simon Richter
  Cc: Grover, Andrew, 'Pavel Machek', Andreas Ferber, linux-kernel

 Simon Richter <Simon.Richter@phobos.fachschaften.tu-muenchen.de> writes:

[...]

> Yes, that will be a separate daemon that will also get the
> events. But I think it's a good idea to have a simple interface that
> allows the user to run arbitrary commands when ACPI events occur,
> even without acpid running (think of singleuser mode, embedded
> systems, ...).

The pmpolicy patch presents such a simple interface. An executable
(the location of which is configurable) is run from the kernel with
certain arguments.

The advantages of this: 

(1) No nasty magic number binary interface, everything is text ->

(2) Any sysadmin can easily write an event handler in sh, perl, or
whatever scripting language, i.e. the userspace handler is much
simpler.

(3) No events, no bloat. 

(4) Kernel code is probably shorter (tho' less standard) than having a
special device or procfs node.

(5) Efficiency: the alternative is to have a program like APMD
decoding the nasty binary interface and then spawning a shell script
to deal with it.

I myself am starting to dislike the idea: it was mostly motivated by
the need to exercise a veto on APM events. This is in fact not
necessary, if I understand correctly. An interface allowing multiple
listeners is preferable.

It remains to contact all the maintainers of the various PM and UPS
systems to flesh out exactly what the interface should be capable of
;-)

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 18:28 Grover, Andrew
  2001-04-18 18:45 ` Jeff Garzik
@ 2001-04-18 19:36 ` John Fremlin
  1 sibling, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-18 19:36 UTC (permalink / raw)
  To: Grover, Andrew
  Cc: 'Simon Richter', Acpi-PM (E-mail), 'Pavel Machek',
	Andreas Ferber, linux-kernel

 "Grover, Andrew" <andrew.grover@intel.com> writes:

[...]

> Fair enough. I don't think I would be out of line to say that our
> resources are focused on enabling full ACPI functionality for Linux,
> including a full-featured PM policy daemon. That said, I don't think
> there's anything precluding the use of another daemon (or whatever)
> from using the ACPI driver's interface.

ACPI != PM. I don't see why ACPI details should be exposed to PM
interface at all.

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 11:55     ` Alan Cox
@ 2001-04-18 19:10       ` John Fremlin
  2001-04-18 20:10         ` Alan Cox
  2001-04-20 17:02         ` Pavel Machek
  0 siblings, 2 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-18 19:10 UTC (permalink / raw)
  To: Alan Cox; +Cc: sfr, linux-kernel, apenwarr

Alan Cox <alan@lxorguk.ukuu.org.uk> writes:

> > I'm wondering if that veto business is really needed. Why not reject
> > *all* APM rejectable events, and then let the userspace event handler
> > send the system to sleep or turn it off? Anybody au fait with the APM
> > spec?
> 
> Because apmd is optional

The veto stuff only comes into action, iff someone has registered as
willing to exercise this power. We would not break compatibility with
any std kernel by instead having a apmd send a "reject all" ioctl
instead, and so deal with events without having the pressure of having
to reject or accept them, and let us remove all the veto code from the
kernel driver. Or am I missing something?

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18 18:28 Grover, Andrew
@ 2001-04-18 18:45 ` Jeff Garzik
  2001-04-18 19:36 ` John Fremlin
  1 sibling, 0 replies; 69+ messages in thread
From: Jeff Garzik @ 2001-04-18 18:45 UTC (permalink / raw)
  To: Grover, Andrew; +Cc: 'Simon Richter', Acpi-PM (E-mail), linux-kernel

"Grover, Andrew" wrote:
> 
> > From: Simon Richter
> > > We are going to need some software that handles button
> > events, as well as
> > > thermal events, battery events, polling the battery, AC
> > adapter status
> > > changes, sleeping the system, and more.
> >
> > Yes, that will be a separate daemon that will also get the
> > events. But I
> > think it's a good idea to have a simple interface that allows
> > the user to
> > run arbitrary commands when ACPI events occur, even without
> > acpid running
> > (think of singleuser mode, embedded systems, ...).
> 
> Fair enough. I don't think I would be out of line to say that our resources
> are focused on enabling full ACPI functionality for Linux, including a
> full-featured PM policy daemon. That said, I don't think there's anything
> precluding the use of another daemon (or whatever) from using the ACPI
> driver's interface.

There's a ton of stuff to focus on :)

For example, if you focused on suspend and resume, I could start
implementing and testing that in the drivers :)

-- 
Jeff Garzik       | "The universe is like a safe to which there is a
Building 1024     |  combination -- but the combination is locked up
MandrakeSoft      |  in the safe."    -- Peter DeVries

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
@ 2001-04-18 18:28 Grover, Andrew
  2001-04-18 18:45 ` Jeff Garzik
  2001-04-18 19:36 ` John Fremlin
  0 siblings, 2 replies; 69+ messages in thread
From: Grover, Andrew @ 2001-04-18 18:28 UTC (permalink / raw)
  To: 'Simon Richter', Acpi-PM (E-mail)
  Cc: 'Pavel Machek', Andreas Ferber, linux-kernel

> From: Simon Richter
> > We are going to need some software that handles button 
> events, as well as
> > thermal events, battery events, polling the battery, AC 
> adapter status
> > changes, sleeping the system, and more.
> 
> Yes, that will be a separate daemon that will also get the 
> events. But I
> think it's a good idea to have a simple interface that allows 
> the user to
> run arbitrary commands when ACPI events occur, even without 
> acpid running
> (think of singleuser mode, embedded systems, ...).

Fair enough. I don't think I would be out of line to say that our resources
are focused on enabling full ACPI functionality for Linux, including a
full-featured PM policy daemon. That said, I don't think there's anything
precluding the use of another daemon (or whatever) from using the ACPI
driver's interface.

> > Unix philosophy: "do one thing and do it well".
> 
> Another Unix philosophy: "keep it simple, stupid". :-)

OK one more silly aphorism and I'll shut up. ;-) "Make it as simple as
possible, but no simpler."

Regards -- Andy


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
  2001-04-17 16:45 Grover, Andrew
  2001-04-17 19:54 ` Pavel Machek
  2001-04-17 22:23 ` John Fremlin
@ 2001-04-18 15:26 ` Simon Richter
  2001-04-18 19:51   ` John Fremlin
  2 siblings, 1 reply; 69+ messages in thread
From: Simon Richter @ 2001-04-18 15:26 UTC (permalink / raw)
  To: Grover, Andrew; +Cc: 'Pavel Machek', Andreas Ferber, linux-kernel

On Tue, 17 Apr 2001, Grover, Andrew wrote:

> We are going to need some software that handles button events, as well as
> thermal events, battery events, polling the battery, AC adapter status
> changes, sleeping the system, and more.

Yes, that will be a separate daemon that will also get the events. But I
think it's a good idea to have a simple interface that allows the user to
run arbitrary commands when ACPI events occur, even without acpid running
(think of singleuser mode, embedded systems, ...).

> Unix philosophy: "do one thing and do it well".

Another Unix philosophy: "keep it simple, stupid". :-)

   Simon

-- 
GPG public key available from http://phobos.fs.tum.de/pgp/Simon.Richter.asc
 Fingerprint: DC26 EB8D 1F35 4F44 2934  7583 DBB6 F98D 9198 3292
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18  1:56   ` John Fremlin
@ 2001-04-18 11:55     ` Alan Cox
  2001-04-18 19:10       ` John Fremlin
  2001-04-20 17:01     ` Pavel Machek
  1 sibling, 1 reply; 69+ messages in thread
From: Alan Cox @ 2001-04-18 11:55 UTC (permalink / raw)
  To: John Fremlin
  Cc: Alan Cox, Grover Andrew, "Acpi-PM (E-mail)",
	'Pavel Machek',
	Simon Richter, Andreas Ferber, linux-kernel

> I'm wondering if that veto business is really needed. Why not reject
> *all* APM rejectable events, and then let the userspace event handler
> send the system to sleep or turn it off? Anybody au fait with the APM
> spec?

Because apmd is optional

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18  0:51 ` Alan Cox
@ 2001-04-18  1:56   ` John Fremlin
  2001-04-18 11:55     ` Alan Cox
  2001-04-20 17:01     ` Pavel Machek
  0 siblings, 2 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-18  1:56 UTC (permalink / raw)
  To: Alan Cox
  Cc: Grover, Andrew, Acpi-PM (E-mail), 'Pavel Machek',
	Simon Richter, Andreas Ferber, linux-kernel

Alan Cox <alan@lxorguk.ukuu.org.uk> writes:

[...]

> I would tend to agree here. If you want to wire it to init the fine
> but pm is basically message passing kernel->user and possibly
> message reply to allow veto/approve. APM provides a good API for
> this and there is a definite incentive to make ACPI use the same
> messages, behaviour and extend it.

I'm wondering if that veto business is really needed. Why not reject
*all* APM rejectable events, and then let the userspace event handler
send the system to sleep or turn it off? Anybody au fait with the APM
spec?

This would have the advantage that the veto stuff could be ripped out
and things made simpler.

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18  0:07 Grover, Andrew
  2001-04-18  0:51 ` Alan Cox
@ 2001-04-18  1:54 ` John Fremlin
  1 sibling, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-18  1:54 UTC (permalink / raw)
  To: Grover, Andrew
  Cc: Acpi-PM (E-mail), 'Pavel Machek',
	Simon Richter, Andreas Ferber, linux-kernel

"Grover, Andrew" <andrew.grover@intel.com> writes:

> [do we want to move this to linux-power?]

I'm happy to as long as I'm cc'd.

[...]

IMHO the pm interface should be split up as following:

        (1) Battery status, power status, UPS status polling. It
        should be possible for lots of processes to do this
        simultaneously. [That does not prohibit a single process
        querying the kernel and all the others querying it.]

        (2) Funky events happening to the physical machine, like a
        button being pressed, the case being closed, etc. [Should this
        include battery low warnings, power status changes? I don't
        know.]

        (3) Sending the machine to sleep, turning it off. It should be
        possible to do this from userspace ;-)

Am I missing anything? Of course (1) and (2) could be combined into a
single daemon.

ATM the area is fraught with incompatibility. There are a ridiculous
number of power management systems - one per architecture almost. Each
has a different kernel-userspace interface. Every UPS has its own
interface too (?) ;-)

> There should be only one PM policy agent on the system. 

Why?

As far as I see it, only some people need polling capabilities -
i.e. those on battery or UPS. Why should they be subjected to the
bloat etc. And those on battery might want multiple policies as Alan
pointed out.

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-18  0:07 Grover, Andrew
@ 2001-04-18  0:51 ` Alan Cox
  2001-04-18  1:56   ` John Fremlin
  2001-04-18  1:54 ` John Fremlin
  1 sibling, 1 reply; 69+ messages in thread
From: Alan Cox @ 2001-04-18  0:51 UTC (permalink / raw)
  To: Grover, Andrew
  Cc: 'John Fremlin', "Acpi-PM (E-mail)",
	'Pavel Machek',
	Simon Richter, Andreas Ferber, linux-kernel

> There should be only one PM policy agent on the system. I don't care about
> other processes that query for display purposes, but someone needs to be

The kernel pm code assumes there is a single agent issuing power management
requests via pm_* calls. User space is a different matter. There are numerous
good arguments for multiple policy agents, be they multiple applications or
multiple state machines in one system. Most power management seems to best
be modelled by multiple very simple algorithms running in parallel.

> solution, but I hope I have been able to be clear on why I believe an actual
> daemon is justified. 

I would tend to agree here. If you want to wire it to init the fine but 
pm is basically message passing kernel->user and possibly message reply to
allow veto/approve. APM provides a good API for this and there is a definite
incentive to make ACPI use the same messages, behaviour and extend it. 



^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
@ 2001-04-18  0:07 Grover, Andrew
  2001-04-18  0:51 ` Alan Cox
  2001-04-18  1:54 ` John Fremlin
  0 siblings, 2 replies; 69+ messages in thread
From: Grover, Andrew @ 2001-04-18  0:07 UTC (permalink / raw)
  To: 'John Fremlin', Acpi-PM (E-mail)
  Cc: 'Pavel Machek', Simon Richter, Andreas Ferber, linux-kernel

[do we want to move this to linux-power?]

> From: John Fremlin [mailto:chief@bandits.org]
> > We are going to need some software that handles button events, as
> > well as thermal events, battery events, polling the battery, AC
> > adapter status changes, sleeping the system, and more.
> 
> Dealing with events should be disjoint from polling the battery or
> powerstatus. Many processes might reasonably simultaneously want to
> provide a display to the user of the current power status.

There should be only one PM policy agent on the system. I don't care about
other processes that query for display purposes, but someone needs to be
alive and checking all the time in order to act on the user's wishes, and
shut down or sleep when the battery hits x minutes remaining, for example.
Let us call this "powerd", for sake of argument.

> However, button presses and so on should be handled by a single
> process. Otherwise the kernel is unreasonably complicated by having to
> deal with multiple processes' veto power, which could just as well and
> more flexibly be handled in userspace.

Exactly, only one entity can be in charge of setting the system's power
policy. So, let's not multiply entities needlessly -- let's make the button
policy manager also be powerd.

> I don't why there needs to be an additional daemon constantly running
> to deal with button presses and power status changes. Apparently init
> is already handling similar things: why should it not be extended to
> include button presses?

Unix philosophy: do one task and do it well. Now that power management is
big enough to be a task in itself (instead of just a minor feature) we
should break it out from unrelated functionality.

> Alternatively, why not forgo a daemon altogether? (This scheme is
> already implemented in the pmpolicy patch, i.e. it is already
> working.)

Because power policy needs to run continuously. Why? Because we need to poll
the battery for battery remaining, and we need to keep a moving average,
because the battery only provides instantaneous power consumption numbers.
Centralizing this means every UI applet can query it, and will show the same
battery remaining value.

Also, because thermal control is not 100% event driven - when we start
passive cooling on the CPU because of a thermal zone overheat, we have to
throttle, and then sample the temperature periodically until the temp goes
below the threshold. (ref: ACPI 2.0 spec chapter 12)

> > We need WAY more flexibility than init provides. 
> 
> Examples please.

See above. I know you may have an affinity for a call_usermodehelper-based
solution, but I hope I have been able to be clear on why I believe an actual
daemon is justified.

Regards -- Andy

PS apm already has apmd (which we would be replacing), so there will be no
net increase in system daemons.


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-17 16:45 Grover, Andrew
  2001-04-17 19:54 ` Pavel Machek
@ 2001-04-17 22:23 ` John Fremlin
  2001-04-18 15:26 ` Simon Richter
  2 siblings, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-17 22:23 UTC (permalink / raw)
  To: Grover, Andrew
  Cc: 'Pavel Machek', Simon Richter, Andreas Ferber, linux-kernel

 "Grover, Andrew" <andrew.grover@intel.com> writes:

> Hi Pavel,
> 
> I think init is doing a perfect job WRT UPSs because this is a
> trivial application of power management. init wasn't really meant
> for this.  According to its man page:
> 
> "init...it's primary role is to create processes from a script in
> the file /etc/inittab...It also controls autonomous processes
> required by any particular system"
> 
> We are going to need some software that handles button events, as
> well as thermal events, battery events, polling the battery, AC
> adapter status changes, sleeping the system, and more.

Dealing with events should be disjoint from polling the battery or
powerstatus. Many processes might reasonably simultaneously want to
provide a display to the user of the current power status.

However, button presses and so on should be handled by a single
process. Otherwise the kernel is unreasonably complicated by having to
deal with multiple processes' veto power, which could just as well and
more flexibly be handled in userspace.

I don't why there needs to be an additional daemon constantly running
to deal with button presses and power status changes. Apparently init
is already handling similar things: why should it not be extended to
include button presses?

Alternatively, why not forgo a daemon altogether? (This scheme is
already implemented in the pmpolicy patch, i.e. it is already
working.)

> We need WAY more flexibility than init provides. 

Examples please.

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-17 16:45 Grover, Andrew
@ 2001-04-17 19:54 ` Pavel Machek
  2001-04-17 22:23 ` John Fremlin
  2001-04-18 15:26 ` Simon Richter
  2 siblings, 0 replies; 69+ messages in thread
From: Pavel Machek @ 2001-04-17 19:54 UTC (permalink / raw)
  To: Grover, Andrew, Simon Richter, Andreas Ferber; +Cc: linux-kernel

Hi, Andy!

> > > I would think that it would make sense to keep shutdown 
> > with all the other
> > > power management events. Perhaps it will makes more sense 
> > to handle UPS's
> > > through the power management code.
> > 
> > Yes, that would be another acceptable solution. Situation where half
> > of power managment (UPS) is done with init and half with acpid is not
> > acceptable. [I doubt UPS users will want to switch. Why invent new
> > daemon when init is doing perfect job?]
> 
> I think init is doing a perfect job WRT UPSs because this is a trivial
> application of power management. init wasn't really meant for this.
> According to its man page:
> 
> "init...it's primary role is to create processes from a script in the file
> /etc/inittab...It also controls autonomous processes required by any
> particular system"
> 
> We are going to need some software that handles button events, as well as
> thermal events, battery events, polling the battery, AC adapter status
> changes, sleeping the system, and more.

I do not want to put battery/thermal/AC adapter status through
init. On *many* machines, button is only usefull device from ACPI (for
example all desktop machines). On desktop machine, you probably will
not want to configure/run acpid. Init should be able to do its job.

I agree that for notebooks where you want to handle thermal events
etc., acpid will be neccessary. I just do not want desktop people to
be forced to run acpid.

> We need WAY more flexibility than init provides. I find the argument that
> init is already handling one minor power-related thing an unconvincing
> reason why we should cram all power management through it.

It is doing UPS and c-a-d handling, which is *very* similar to what
you want to do on power button press 99% of time.
								Pavel
PS: About thermal events -- do I need to do something special in order
for temperature to be measured?

I can send _TMP, and get temperature reading, but it does not change
with time -- I get the same value from boot on.

BTW here are hacks I use for easy control of ACPI. That way, I can
just for A in device_*; do echo -n '_TMP' > $A; done and get
temperature reading in syslog ;-).

Do you think some way to reflect acpi structure in proc would be good
idea?

diff -ur -x .dep* -x .hdep* -x *.[oas] -x *~ -x #* -x *CVS* -x *.orig -x *.rej -x *.old -x .menu* -x asm -x local.h -x System.map -x autoconf.h -x compile.h -x version.h -x .version -x defkeymap.c -x uni_hash.tbl -x zImage -x vmlinu?* -x TAGS -x bootsect -x *RCS* -x conmakehash -x map -x build -x build -x configure -x *target* -x *.flags -x *.bak clean/drivers/acpi/common/cmeval.c linux/drivers/acpi/common/cmeval.c
--- clean/drivers/acpi/common/cmeval.c	Wed Jan 31 16:14:27 2001
+++ linux/drivers/acpi/common/cmeval.c	Fri Apr  6 08:45:21 2001
@@ -262,9 +262,10 @@
  ***************************************************************************/
 
 ACPI_STATUS
-acpi_cm_execute_STA (
+acpi_cm_execute_rint (
 	ACPI_NAMESPACE_NODE     *device_node,
-	u32                     *flags)
+	u32                     *flags,
+	char			*name)
 {
 	ACPI_OPERAND_OBJECT     *obj_desc;
 	ACPI_STATUS             status;
@@ -273,14 +274,12 @@
 	/* Execute the method */
 
 	status = acpi_ns_evaluate_relative (device_node,
-			 METHOD_NAME__STA, NULL, &obj_desc);
-	if (AE_NOT_FOUND == status) {
-		*flags = 0x0F;
-		status = AE_OK;
-	}
-
+			 name, NULL, &obj_desc);
+	if (ACPI_FAILURE (status))
+		return (status);
 
-	else /* success */ {
+	/* I guess it used to be subtle bug here, on AE_NOT_FOUND, it did cm_remove_reference, anyway */
+	{
 		/* Did we get a return object? */
 
 		if (!obj_desc) {
@@ -306,3 +305,71 @@
 
 	return (status);
 }
+
+
+ACPI_STATUS
+acpi_cm_execute_STA (
+	ACPI_NAMESPACE_NODE     *device_node,
+	u32                     *flags)
+{
+	ACPI_STATUS             status;
+
+	status = acpi_cm_execute_rint(device_node, flags, "_STA");
+	if (status == AE_NOT_FOUND) {
+		*flags = 0x0F;
+		return AE_OK;
+	}
+	return status;
+}
+
+
+ACPI_STATUS
+acpi_cm_execute_any (
+	ACPI_NAMESPACE_NODE     *device_node,
+	char                    *res,
+	char			*name)
+{
+	ACPI_OPERAND_OBJECT     *obj_desc;
+	ACPI_STATUS             status;
+
+
+	/* Execute the method */
+
+	status = acpi_ns_evaluate_relative (device_node,
+			 name, NULL, &obj_desc);
+	sprintf(res, "error");
+	if (ACPI_FAILURE (status))
+		return (status);
+
+	/* I guess it used to be subtle bug here, on AE_NOT_FOUND, it did cm_remove_reference, anyway */
+	{
+		/* Did we get a return object? */
+
+		if (!obj_desc) {
+			sprintf(res, "no return");
+			return (AE_OK);
+		}
+
+		/* Is the return object of the correct type? */
+
+		switch (obj_desc->common.type) {
+		case ACPI_TYPE_INTEGER:
+			sprintf(res, "int: %d", obj_desc->integer.value);
+			break;
+		case ACPI_TYPE_STRING:
+			sprintf(res, "string: %20s", obj_desc->string.pointer);
+			break;
+		deafult:
+			sprintf(res, "unknown", obj_desc->string.pointer);
+			break;
+		}
+
+		/* On exit, we must delete the return object */
+
+		acpi_cm_remove_reference (obj_desc);
+	}
+
+	return (status);
+}
+
+
diff -ur -x .dep* -x .hdep* -x *.[oas] -x *~ -x #* -x *CVS* -x *.orig -x *.rej -x *.old -x .menu* -x asm -x local.h -x System.map -x autoconf.h -x compile.h -x version.h -x .version -x defkeymap.c -x uni_hash.tbl -x zImage -x vmlinu?* -x TAGS -x bootsect -x *RCS* -x conmakehash -x map -x build -x build -x configure -x *target* -x *.flags -x *.bak clean/drivers/acpi/events/evevent.c linux/drivers/acpi/events/evevent.c
--- clean/drivers/acpi/events/evevent.c	Sun Apr  1 00:22:57 2001
+++ linux/drivers/acpi/events/evevent.c	Wed Apr  4 01:08:11 2001
@@ -30,6 +30,8 @@
 #include "acnamesp.h"
 #include "accommon.h"
 
+#include <linux/signal.h>
+
 #define _COMPONENT          EVENT_HANDLING
 	 MODULE_NAME         ("evevent")
 
@@ -49,25 +51,15 @@
  *************************************************************************/
 
 ACPI_STATUS
-acpi_ev_initialize (
-	void)
+acpi_ev_initialize (void)
 {
 	ACPI_STATUS             status;
 
-
-	/* Make sure we have ACPI tables */
-
-	if (!acpi_gbl_DSDT) {
+	if (!acpi_gbl_DSDT)		 	/* Make sure we have ACPI tables */
 		return (AE_NO_ACPI_TABLES);
-	}
-
-
-	/* Make sure the BIOS supports ACPI mode */
 
-	if (SYS_MODE_LEGACY == acpi_hw_get_mode_capabilities()) {
+	if (SYS_MODE_LEGACY == acpi_hw_get_mode_capabilities())	/* Make sure the BIOS supports ACPI mode */
 		return (AE_ERROR);
-	}
-
 
 	acpi_gbl_original_mode = acpi_hw_get_mode();
 
@@ -77,38 +69,18 @@
 	 * before handers are installed.
 	 */
 
-	status = acpi_ev_fixed_event_initialize ();
-	if (ACPI_FAILURE (status)) {
+	if (ACPI_FAILURE (status = acpi_ev_fixed_event_initialize ()))
 		return (status);
-	}
-
-	status = acpi_ev_gpe_initialize ();
-	if (ACPI_FAILURE (status)) {
+	if (ACPI_FAILURE (status = acpi_ev_gpe_initialize ()))
 		return (status);
-	}
-
-	/* Install the SCI handler */
-
-	status = acpi_ev_install_sci_handler ();
-	if (ACPI_FAILURE (status)) {
+	if (ACPI_FAILURE (status = acpi_ev_install_sci_handler ()))
 		return (status);
-	}
-
-
 	/* Install handlers for control method GPE handlers (_Lxx, _Exx) */
-
-	status = acpi_ev_init_gpe_control_methods ();
-	if (ACPI_FAILURE (status)) {
+	if (ACPI_FAILURE (status = acpi_ev_init_gpe_control_methods ()))
 		return (status);
-	}
-
 	/* Install the handler for the Global Lock */
-
-	status = acpi_ev_init_global_lock_handler ();
-	if (ACPI_FAILURE (status)) {
+	if (ACPI_FAILURE (status = acpi_ev_init_global_lock_handler ()))
 		return (status);
-	}
-
 
 	return (status);
 }
@@ -131,6 +103,7 @@
 {
 	int                     i = 0;
 
+	printk("acpi: Initializing fixed events\n");
 	/* Initialize the structure that keeps track of fixed event handlers */
 
 	for (i = 0; i < NUM_FIXED_EVENTS; i++) {
@@ -181,6 +154,7 @@
 	if ((status_register & ACPI_STATUS_PMTIMER) &&
 		(enable_register & ACPI_ENABLE_PMTIMER))
 	{
+		printk ("acpi: PM timer!\n");
 		int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_PMTIMER);
 	}
 
@@ -189,22 +163,27 @@
 	if ((status_register & ACPI_STATUS_GLOBAL) &&
 		(enable_register & ACPI_ENABLE_GLOBAL))
 	{
+		printk ("acpi: BIOS wants to play!\n");
 		int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_GLOBAL);
 	}
 
 	/* power button event */
 
 	if ((status_register & ACPI_STATUS_POWER_BUTTON) &&
-		(enable_register & ACPI_ENABLE_POWER_BUTTON))
+	    (enable_register & ACPI_ENABLE_POWER_BUTTON))
 	{
+		printk ("acpi: Power button pressed!\n");
+		kill_proc (1, SIGTERM, 1);
 		int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_POWER_BUTTON);
 	}
 
+
 	/* sleep button event */
 
 	if ((status_register & ACPI_STATUS_SLEEP_BUTTON) &&
 		(enable_register & ACPI_ENABLE_SLEEP_BUTTON))
 	{
+		printk("acpi: Sleep button pressed!\n");
 		int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_SLEEP_BUTTON);
 	}
 
diff -ur -x .dep* -x .hdep* -x *.[oas] -x *~ -x #* -x *CVS* -x *.orig -x *.rej -x *.old -x .menu* -x asm -x local.h -x System.map -x autoconf.h -x compile.h -x version.h -x .version -x defkeymap.c -x uni_hash.tbl -x zImage -x vmlinu?* -x TAGS -x bootsect -x *RCS* -x conmakehash -x map -x build -x build -x configure -x *target* -x *.flags -x *.bak clean/drivers/acpi/hardware/hwsleep.c linux/drivers/acpi/hardware/hwsleep.c
--- clean/drivers/acpi/hardware/hwsleep.c	Sun Apr  1 00:22:57 2001
+++ linux/drivers/acpi/hardware/hwsleep.c	Wed Apr  4 00:11:19 2001
@@ -27,6 +27,7 @@
 #include "acpi.h"
 #include "acnamesp.h"
 #include "achware.h"
+#include <linux/delay.h>
 
 #define _COMPONENT          HARDWARE
 	 MODULE_NAME         ("hwsleep")
@@ -50,7 +51,6 @@
 	ACPI_PHYSICAL_ADDRESS physical_address)
 {
 
-
 	/* Make sure that we have an FACS */
 
 	if (!acpi_gbl_FACS) {
@@ -59,6 +59,8 @@
 
 	/* Set the vector */
 
+	printk("Setting waking_vector to %lx\n", physical_address);
+
 	if (acpi_gbl_FACS->vector_width == 32) {
 		* (u32 *) acpi_gbl_FACS->firmware_waking_vector = (u32) physical_address;
 	}
@@ -112,6 +114,12 @@
 	return (AE_OK);
 }
 
+void
+while1(void)
+{
+	while(1);
+}
+
 /******************************************************************************
  *
  * FUNCTION:    Acpi_enter_sleep_state
@@ -136,6 +144,13 @@
 	u16 PM1_acontrol;
 	u16 PM1_bcontrol;
 
+/*
+	acpi_set_firmware_waking_vector(0xffff0);
+*/
+	acpi_set_firmware_waking_vector(&while1 - 0xc0000000);
+
+	printk("Entering power state %d\n", sleep_state);
+
 	/*
 	 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
 	 */
@@ -175,14 +190,23 @@
 	PM1_acontrol |= (type_a << acpi_hw_get_bit_shift (SLP_TYPE_X_MASK));
 	PM1_bcontrol |= (type_b << acpi_hw_get_bit_shift (SLP_TYPE_X_MASK));
 
-	disable();
+	/*disable();*/
 
+	printk("hwsleep: Writing registers\n");
 	acpi_hw_register_write(ACPI_MTX_LOCK, PM1_a_CONTROL, PM1_acontrol);
 	acpi_hw_register_write(ACPI_MTX_LOCK, PM1_b_CONTROL, PM1_bcontrol);
+	printk("hwsleep: enabling sleep!\n");
 	acpi_hw_register_write(ACPI_MTX_LOCK, PM1_CONTROL,
 		(1 << acpi_hw_get_bit_shift (SLP_EN_MASK)));
+	printk("hwsleep: before enable\n");
 
-	enable();
+	/*enable();*/
+	printk("hwsleep: after enable\n");
 
+	arg_list.count = 1;
+	arg_list.pointer = &arg;
+	acpi_evaluate_object(NULL, "\\_WAK", &arg_list, NULL);
+	printk("hwsleep: Waked up?\n");
+	mdelay(1000);
 	return (AE_OK);
 }
diff -ur -x .dep* -x .hdep* -x *.[oas] -x *~ -x #* -x *CVS* -x *.orig -x *.rej -x *.old -x .menu* -x asm -x local.h -x System.map -x autoconf.h -x compile.h -x version.h -x .version -x defkeymap.c -x uni_hash.tbl -x zImage -x vmlinu?* -x TAGS -x bootsect -x *RCS* -x conmakehash -x map -x build -x build -x configure -x *target* -x *.flags -x *.bak clean/drivers/acpi/namespace/nsxfobj.c linux/drivers/acpi/namespace/nsxfobj.c
--- clean/drivers/acpi/namespace/nsxfobj.c	Sun Apr  1 00:23:00 2001
+++ linux/drivers/acpi/namespace/nsxfobj.c	Tue Apr 10 00:19:01 2001
@@ -30,6 +30,10 @@
 #include "acnamesp.h"
 #include "acdispat.h"
 
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <asm/uaccess.h>
 
 #define _COMPONENT          NAMESPACE
 	 MODULE_NAME         ("nsxfobj")
@@ -592,7 +596,7 @@
 
 	status = acpi_cm_execute_STA (node, &flags);
 	if (ACPI_FAILURE (status)) {
-		return (status);
+		return AE_OK;
 	}
 
 	if (!(flags & 0x01)) {
@@ -694,3 +698,203 @@
 
 	return (status);
 }
+
+static int
+proc_read_device_info(char *page, char **start, off_t off,
+			int count, int *eof, void *data)
+{
+	ACPI_HANDLE             obj_handle = (u32) data;
+	ACPI_NAMESPACE_NODE     *node;
+	ACPI_STATUS		status;
+	char *p = page;
+	int len;
+	u32 flags;
+	DEVICE_ID               device_id;
+
+	/* don't get info more than once for a single proc read */
+	if (off != 0)
+		goto end;
+
+	acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
+
+	node = acpi_ns_convert_handle_to_entry (obj_handle);
+
+	acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
+
+	status = acpi_cm_execute_STA (node, &flags);
+	if (ACPI_FAILURE (status))
+		p += sprintf(p, "Present:	No (%lx)\n", status);
+	else	p += sprintf(p, "Present:	Yes (flags %lx)\n", flags);
+
+	status = acpi_cm_execute_HID (node, &device_id);
+	if (!ACPI_FAILURE (status))
+		p += sprintf(p, "HID ident:	%s\n", &device_id.buffer );
+
+	status = acpi_cm_execute_UID (node, &device_id);
+	if (!ACPI_FAILURE (status))
+		p += sprintf(p, "UID ident:	%s\n", &device_id.buffer );
+
+	flags = 0xdeadbeef;
+	status = acpi_cm_execute_rint (node, &flags, "_PSC");
+	if (!ACPI_FAILURE (status))
+		p += sprintf(p, "Power status:	%d\n", flags);
+
+	p += sprintf(p, "This is some random information\n");
+end:
+	len = (p - page);
+	if (len <= off+count) *eof = 1;
+	*start = page + off;
+	len -= off;
+	if (len>count) len = count;
+	if (len<0) len = 0;
+	return len;
+}
+
+int
+proc_write_device_info(struct file *file, const char *buffer,
+		       unsigned long count, void *data)
+{
+	ACPI_HANDLE             obj_handle = (u32) data;
+	ACPI_NAMESPACE_NODE     *node;
+	ACPI_STATUS		status;
+	int len;
+	u32 flags;
+	char buf[256], buf2[256];
+	DEVICE_ID               device_id;
+
+	acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
+
+	node = acpi_ns_convert_handle_to_entry (obj_handle);
+
+	acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
+
+	if (count > 250)
+		return -EPERM;
+	if (copy_from_user(buf, buffer, count))
+		return -EFAULT;
+	buf[count] = 0;
+	printk("acpi_write_device_info: %s...", buf);
+	flags = 0xdeadbeef;
+	status = acpi_cm_execute_any (node, buf2, buf);
+	if (ACPI_FAILURE (status))
+		printk("error: %lx (%s)\n", status, buf2);
+	else 
+		printk("okay: %lx (%s)\n", status, buf2);
+
+	return -EL3RST;
+}
+
+
+static ACPI_STATUS
+acpi_ns_add_proc_callback (
+	ACPI_HANDLE             obj_handle,
+	u32                     nesting_level,
+	void                    *context,
+	void                    **return_value)
+{
+	ACPI_STATUS             status;
+	ACPI_NAMESPACE_NODE     *node;
+	u32                     flags;
+	DEVICE_ID               device_id;
+	ACPI_GET_DEVICES_INFO   *info;
+
+
+	info = context;
+
+	acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
+
+	printk("acpi_add_proc_callback: %lx\n", obj_handle);
+	node = acpi_ns_convert_handle_to_entry (obj_handle);
+
+	acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
+
+	if (!node) {
+		printk("No node?!\n");
+		return (AE_BAD_PARAMETER);
+	}
+
+	/*
+	 * Run _STA to determine if device is present
+	 */
+
+#if 0
+	status = acpi_cm_execute_STA (node, &flags);
+	if (ACPI_FAILURE (status)) {
+		return (AE_OK);
+	}
+
+	if (!(flags & 0x01)) {
+		/* don't return at the device or children of the device if not there */
+
+		return (AE_CTRL_DEPTH);
+	}
+#endif
+
+	{
+		char proc_name[120];
+		struct proc_dir_entry *proc;
+
+		status = acpi_cm_execute_HID (node, &device_id);
+
+		if ((status == AE_NOT_FOUND) || (ACPI_FAILURE (status)))
+			sprintf(proc_name, "power/device_unknown_%lx", obj_handle);
+		else	sprintf(proc_name, "power/device_%s", device_id.buffer );
+		printk("ACPI: creating %s\n", proc_name);
+		proc = create_proc_read_entry(proc_name, 0, NULL,
+			proc_read_device_info, (void *) obj_handle);
+		if (!proc) printk(KERN_ERR "ACPI: Error creating %s\n", proc_name);
+		else {
+			proc->write_proc = proc_write_device_info;
+		}
+	}
+
+	return (AE_OK);
+}
+
+
+void
+acpi_namespace_init(
+	void)
+{
+	ACPI_STATUS             status;
+	void ** return_value;
+
+	printk("ACPI: initializing namespace\n");
+
+	acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ns_walk_namespace (ACPI_TYPE_ANY,
+			   ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+			   NS_WALK_UNLOCK,
+			   acpi_ns_add_proc_callback, NULL,
+			   return_value);
+
+	acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
+
+	return (status);
+}
+
+/*
+   _PSW -> lid does something interesting (unknown status).
+   _PSC -> PNP0303  (type error)
+   _LID -> lid does get lid status.
+   _ADR -> succeeds on many things
+   _CRS -> sometimes okay
+   _DIS -> 3 times okay
+   _EJ0 -> 1 time okay
+   _HID -> mostly returns integers
+   _PCL -> 2 times okay
+   _PRS -> 2 times okay
+   _PR[W0] -> 4 times okay
+   _PR1 -> okay once
+   _PSC -> 8 times okay
+   _PS3 -> 8 times okay, and seems to work
+   _PS2 -> okay once
+   _PS0 -> 8 times okay
+   _STA -> many times okay
+   _SRS -> error 3008
+   _UID -> many times okay.
+   _BST -> PNP0C0A battery status
+   _STM -> error 3008, sometimes (IDE set transfer timings)
+
+   
+*/
diff -ur -x .dep* -x .hdep* -x *.[oas] -x *~ -x #* -x *CVS* -x *.orig -x *.rej -x *.old -x .menu* -x asm -x local.h -x System.map -x autoconf.h -x compile.h -x version.h -x .version -x defkeymap.c -x uni_hash.tbl -x zImage -x vmlinu?* -x TAGS -x bootsect -x *RCS* -x conmakehash -x map -x build -x build -x configure -x *target* -x *.flags -x *.bak clean/drivers/acpi/power.c linux/drivers/acpi/power.c
--- clean/drivers/acpi/power.c	Wed Jan 31 16:14:33 2001
+++ linux/drivers/acpi/power.c	Thu Apr  5 00:51:28 2001
@@ -118,6 +118,7 @@
 	}
 
 	acpi_cmbatt_init();
+	acpi_namespace_init();
 
 	return 0;
 }
diff -ur -x .dep* -x .hdep* -x *.[oas] -x *~ -x #* -x *CVS* -x *.orig -x *.rej -x *.old -x .menu* -x asm -x local.h -x System.map -x autoconf.h -x compile.h -x version.h -x .version -x defkeymap.c -x uni_hash.tbl -x zImage -x vmlinu?* -x TAGS -x bootsect -x *RCS* -x conmakehash -x map -x build -x build -x configure -x *target* -x *.flags -x *.bak clean/drivers/acpi/sys.c linux/drivers/acpi/sys.c
--- clean/drivers/acpi/sys.c	Wed Jan 31 16:14:33 2001
+++ linux/drivers/acpi/sys.c	Thu Apr  5 00:51:17 2001
@@ -79,11 +79,12 @@
 /*
  * Enter soft-off (S5)
  */
-static void
+void
 acpi_power_off(void)
 {
 	struct acpi_enter_sx_ctx ctx;
 	
+	printk("Entering power off\n");
 	init_waitqueue_head(&ctx.wait);
 	ctx.state = ACPI_STATE_S5;
 	acpi_enter_sx_async(&ctx);

-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
@ 2001-04-17 16:45 Grover, Andrew
  2001-04-17 19:54 ` Pavel Machek
                   ` (2 more replies)
  0 siblings, 3 replies; 69+ messages in thread
From: Grover, Andrew @ 2001-04-17 16:45 UTC (permalink / raw)
  To: 'Pavel Machek', Simon Richter, Andreas Ferber; +Cc: linux-kernel

> From: Pavel Machek [mailto:pavel@suse.cz]
> > I would think that it would make sense to keep shutdown 
> with all the other
> > power management events. Perhaps it will makes more sense 
> to handle UPS's
> > through the power management code.
> 
> Yes, that would be another acceptable solution. Situation where half
> of power managment (UPS) is done with init and half with acpid is not
> acceptable. [I doubt UPS users will want to switch. Why invent new
> daemon when init is doing perfect job?]

Hi Pavel,

I think init is doing a perfect job WRT UPSs because this is a trivial
application of power management. init wasn't really meant for this.
According to its man page:

"init...it's primary role is to create processes from a script in the file
/etc/inittab...It also controls autonomous processes required by any
particular system"

We are going to need some software that handles button events, as well as
thermal events, battery events, polling the battery, AC adapter status
changes, sleeping the system, and more.

We need WAY more flexibility than init provides. I find the argument that
init is already handling one minor power-related thing an unconvincing
reason why we should cram all power management through it.

Unix philosophy: "do one thing and do it well".

Regards -- Andy


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-17  8:39                     ` Andreas Ferber
@ 2001-04-17 14:09                       ` Simon Richter
  0 siblings, 0 replies; 69+ messages in thread
From: Simon Richter @ 2001-04-17 14:09 UTC (permalink / raw)
  To: Andreas Ferber; +Cc: Pavel Machek, linux-kernel

On Tue, 17 Apr 2001, Andreas Ferber wrote:

[Extending the current signalling mechanism]

> The problem with this is that there is no single init. Most
> distribution run the same SysV init, but there are quite a few init
> replacements around. Should we really break all of them?

We don't break anything as long as noone sets the config option. People
who want to use this feature need a current init.

   Simon

-- 
GPG public key available from http://phobos.fs.tum.de/pgp/Simon.Richter.asc
 Fingerprint: DC26 EB8D 1F35 4F44 2934  7583 DBB6 F98D 9198 3292
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-16 23:32 Grover, Andrew
  2001-04-17  6:40 ` John Fremlin
  2001-04-17  6:41 ` Simon Richter
@ 2001-04-17 11:16 ` Pavel Machek
  2 siblings, 0 replies; 69+ messages in thread
From: Pavel Machek @ 2001-04-17 11:16 UTC (permalink / raw)
  To: Grover, Andrew, Simon Richter, Andreas Ferber; +Cc: linux-kernel

Hi!

> > There are 32 signals, and signals can carry more information, if
> > required. I really think doing it way UPS-es are done is right
> > approach.
> 
> I would think that it would make sense to keep shutdown with all the other
> power management events. Perhaps it will makes more sense to handle UPS's
> through the power management code.

Yes, that would be another acceptable solution. Situation where half
of power managment (UPS) is done with init and half with acpid is not
acceptable. [I doubt UPS users will want to switch. Why invent new
daemon when init is doing perfect job?]

However, I believe that simple way of sending signal to init is best
solution. It will suffice in 99% cases, users already know how to
configure init, and it does not need another process in userspace. In
remaining 1% case, init can simply notify acpid that even came.

I believe that one-patch is still worth applying. *Maybe* signal
should be changed to SIGUSR1 (to make room for SIGUSR2 to be sleep
button).
								Pavel
-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-17  6:16                   ` Simon Richter
@ 2001-04-17  8:39                     ` Andreas Ferber
  2001-04-17 14:09                       ` Simon Richter
  0 siblings, 1 reply; 69+ messages in thread
From: Andreas Ferber @ 2001-04-17  8:39 UTC (permalink / raw)
  To: Simon Richter; +Cc: Pavel Machek, linux-kernel

On Tue, Apr 17, 2001 at 08:16:00AM +0200, Simon Richter wrote:
> 
> > Extending SIGPWR will break inits not yet supporting the extensions,
> > so this is IMO not an option. There should be used some other signal
> > which is simply ignored by an old init.
> Make it a config option then; the short description says "read help", the
> long help says "you need init version x.y". People compiling their own
> kernels should know what they're doing, and distributors usually know what
> init they are packaging.

The problem with this is that there is no single init. Most
distribution run the same SysV init, but there are quite a few init
replacements around. Should we really break all of them? We can simply
use another signal and build a generic (and extensible) signalling
mechanism around it, so I don't really see a reason why we should
break old inits.

Andreas
-- 
Insults are effective only where emotion is present.
		-- Spock, "Who Mourns for Adonais?"  stardate 3468.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
  2001-04-16 23:32 Grover, Andrew
  2001-04-17  6:40 ` John Fremlin
@ 2001-04-17  6:41 ` Simon Richter
  2001-04-17 11:16 ` Pavel Machek
  2 siblings, 0 replies; 69+ messages in thread
From: Simon Richter @ 2001-04-17  6:41 UTC (permalink / raw)
  To: Grover, Andrew; +Cc: 'Pavel Machek', Andreas Ferber, linux-kernel

On Mon, 16 Apr 2001, Grover, Andrew wrote:

> > From: Pavel Machek [mailto:pavel@suse.cz]
> > There are 32 signals, and signals can carry more information, if
> > required. I really think doing it way UPS-es are done is right
> > approach.

> I would think that it would make sense to keep shutdown with all the other
> power management events. Perhaps it will makes more sense to handle UPS's
> through the power management code.

I've already started to like the idea, since init is the tool that runs
all the time, not any ACPI or PM daemon, and it seems good to me that the
kernel always knows what to do on an event (signal init and think that it
has been dealt with).

init should provide a "direct" interface that doesn't rely on scripts
being present in certain directories (one less thing that can be broken)
for programs that want to receive these events. From the application
programmer's view this doesn't even make a difference if you have a shlib.

Maybe we should copy the init people? :-)

   Simon

-- 
GPG public key available from http://phobos.fs.tum.de/pgp/Simon.Richter.asc
 Fingerprint: DC26 EB8D 1F35 4F44 2934  7583 DBB6 F98D 9198 3292
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-16 23:32 Grover, Andrew
@ 2001-04-17  6:40 ` John Fremlin
  2001-04-17  6:41 ` Simon Richter
  2001-04-17 11:16 ` Pavel Machek
  2 siblings, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-17  6:40 UTC (permalink / raw)
  To: Grover, Andrew; +Cc: 'Pavel Machek', linux-kernel

 "Grover, Andrew" <andrew.grover@intel.com> writes:

> > From: Pavel Machek [mailto:pavel@suse.cz]
> > There are 32 signals, and signals can carry more information, if
> > required. I really think doing it way UPS-es are done is right
> > approach.

> I would think that it would make sense to keep shutdown with all the
> other power management events. Perhaps it will makes more sense to
> handle UPS's through the power management code.

I'm happy add UPS functionality to the pmpolicy patch, if someone were
willing to test it - as I have no UPS ;-)

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-16 22:38                 ` Andreas Ferber
@ 2001-04-17  6:16                   ` Simon Richter
  2001-04-17  8:39                     ` Andreas Ferber
  0 siblings, 1 reply; 69+ messages in thread
From: Simon Richter @ 2001-04-17  6:16 UTC (permalink / raw)
  To: Andreas Ferber; +Cc: Pavel Machek, linux-kernel

On Tue, 17 Apr 2001, Andreas Ferber wrote:

> > Okay, but at least take a better signal than SIGINT, probably one that the
> > init maintainers like so it gets adopted faster (or extend SIGPWR).

> Extending SIGPWR will break inits not yet supporting the extensions,
> so this is IMO not an option. There should be used some other signal
> which is simply ignored by an old init.

Make it a config option then; the short description says "read help", the
long help says "you need init version x.y". People compiling their own
kernels should know what they're doing, and distributors usually know what
init they are packaging.

> The distribution of such events to other userspace processes (if there
> are some that want to receive a subset of the events) can be perfectly
> done by init, so we should IMO keep this stuff out of the kernel (I
> don't think that the processing of such events will ever be
> performance critical).

Fine with me as long as I get a decent interface where the policy manager
can plug into. :-)

   Simon

-- 
GPG public key available from http://phobos.fs.tum.de/pgp/Simon.Richter.asc
 Fingerprint: DC26 EB8D 1F35 4F44 2934  7583 DBB6 F98D 9198 3292
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
@ 2001-04-16 23:32 Grover, Andrew
  2001-04-17  6:40 ` John Fremlin
                   ` (2 more replies)
  0 siblings, 3 replies; 69+ messages in thread
From: Grover, Andrew @ 2001-04-16 23:32 UTC (permalink / raw)
  To: 'Pavel Machek', Simon Richter, Andreas Ferber; +Cc: linux-kernel

> From: Pavel Machek [mailto:pavel@suse.cz]
> There are 32 signals, and signals can carry more information, if
> required. I really think doing it way UPS-es are done is right
> approach.

I would think that it would make sense to keep shutdown with all the other
power management events. Perhaps it will makes more sense to handle UPS's
through the power management code.

Regards -- Andy


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-16 21:44               ` Simon Richter
@ 2001-04-16 22:38                 ` Andreas Ferber
  2001-04-17  6:16                   ` Simon Richter
  0 siblings, 1 reply; 69+ messages in thread
From: Andreas Ferber @ 2001-04-16 22:38 UTC (permalink / raw)
  To: Simon Richter; +Cc: Pavel Machek, linux-kernel

Hi,

On Mon, Apr 16, 2001 at 11:44:20PM +0200, Simon Richter wrote:
> 
> Okay, but at least take a better signal than SIGINT, probably one that the
> init maintainers like so it gets adopted faster (or extend SIGPWR).

Extending SIGPWR will break inits not yet supporting the extensions,
so this is IMO not an option. There should be used some other signal
which is simply ignored by an old init.

If we are actually introducing this new signal, maybe we should in
turn also provide for a generic init signalling API which could
be used later by other subsystems also? The distribution of such
events to other userspace processes (if there are some that want to
receive a subset of the events) can be perfectly done by init, so we
should IMO keep this stuff out of the kernel (I don't think that the
processing of such events will ever be performance critical).

Andreas
-- 
Of course you can't flap your arms and fly to the moon.  After a while you'd
run out of air to push against.


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-16 21:27             ` Pavel Machek
@ 2001-04-16 21:44               ` Simon Richter
  2001-04-16 22:38                 ` Andreas Ferber
  0 siblings, 1 reply; 69+ messages in thread
From: Simon Richter @ 2001-04-16 21:44 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andreas Ferber, linux-kernel

On Mon, 16 Apr 2001, Pavel Machek wrote:

> > Because we'd be running out of signals soon, when all the other ACPI
> > events get available.

> There are 32 signals, and signals can carry more information, if
> required. I really think doing it way UPS-es are done is right
> approach.

Okay, but at least take a better signal than SIGINT, probably one that the
init maintainers like so it gets adopted faster (or extend SIGPWR).

   Simon

-- 
GPG public key available from http://phobos.fs.tum.de/pgp/Simon.Richter.asc
 Fingerprint: DC26 EB8D 1F35 4F44 2934  7583 DBB6 F98D 9198 3292
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-16 12:42       ` Simon Richter
  2001-04-16 15:49         ` Andreas Ferber
@ 2001-04-16 21:36         ` Ben Ford
  1 sibling, 0 replies; 69+ messages in thread
From: Ben Ford @ 2001-04-16 21:36 UTC (permalink / raw)
  To: Simon Richter; +Cc: Pavel Machek, linux-kernel

Simon Richter wrote:

>On Fri, 13 Apr 2001, Pavel Machek wrote:
>
>>>Then a more general user space tool could be used that would do policy
>>>appropriate stuff, ending with init 0.
>>>
>>init _is_ the tool which is right for defining policy on such issues.
>>
>>Take a look how UPS managment is handled.
>>
>
>A power failure is a different thing from a power button press. There are
>users (me for example) who want to have something different then "init 0"
>mapped to the power button, for example a sleep state (since my box
>doesn't have a dedicated sleep button). I doubt there are many people who
>want something else than a shutdown if the power is out (although I think
>there will be with suspend-to-disk working, so we might have to change UPS
>handling here).
>
>My plan for power management was to have a special daemon that would
>decide what to do based on system state (battery status, local time, ...)
>and events (power/sleep button, last user logged out, ...) [I know that
>from a programmer's POV, both are events]. This daemon could, for example,
>make sure that no services are affected, for example by priming WOL and
>entering a not-so-deep sleep state instead of doing a suspend-to-disk if
>someone is still listening on a port after the "shutdown unimportant
>services" scripts have been run.
>
>   Simon
>
(root@qwerty)-(02:32pm Mon Apr 16)-(root)
# cat /etc/inittab | grep -1 CTRL

# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now 


I believe that what is being referred to is similar.  In which case, you 
can put whatever the bleep you want here and do anything from popup a 
message saying, "Shutdown denied" to immediately poweroff.

-b

-- 
Three things are certain:
Death, taxes, and lost data
Guess which has occurred.
- - - - - - - - - - - - - - - - - - - -
Patched Micro$oft servers are secure today . . . but tomorrow is another story!




^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-16 16:25           ` Simon Richter
@ 2001-04-16 21:27             ` Pavel Machek
  2001-04-16 21:44               ` Simon Richter
  0 siblings, 1 reply; 69+ messages in thread
From: Pavel Machek @ 2001-04-16 21:27 UTC (permalink / raw)
  To: Simon Richter, Andreas Ferber; +Cc: linux-kernel

Hi!

> > > A power failure is a different thing from a power button press.
> 
> > And why not do exactly this with init? Have a look in /etc/inittab:
> 
> > You can shut down your machine there, but you can also have it play a
> > cancan on power failure. It is up to your gusto. And now tell me, why
> > not choose a similar approach, but instead reinvent the wheel and
> > create a completely new mechanism?
> 
> Because we'd be running out of signals soon, when all the other ACPI
> events get available.

There are 32 signals, and signals can carry more information, if
required. I really think doing it way UPS-es are done is right
approach.

								Pavel
-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-16 15:49         ` Andreas Ferber
@ 2001-04-16 16:25           ` Simon Richter
  2001-04-16 21:27             ` Pavel Machek
  0 siblings, 1 reply; 69+ messages in thread
From: Simon Richter @ 2001-04-16 16:25 UTC (permalink / raw)
  To: Andreas Ferber; +Cc: Pavel Machek, linux-kernel

On Mon, 16 Apr 2001, Andreas Ferber wrote:

> > A power failure is a different thing from a power button press.

> And why not do exactly this with init? Have a look in /etc/inittab:

> You can shut down your machine there, but you can also have it play a
> cancan on power failure. It is up to your gusto. And now tell me, why
> not choose a similar approach, but instead reinvent the wheel and
> create a completely new mechanism?

Because we'd be running out of signals soon, when all the other ACPI
events get available.

   Simon

-- 
GPG public key available from http://phobos.fs.tum.de/pgp/Simon.Richter.asc
 Fingerprint: DC26 EB8D 1F35 4F44 2934  7583 DBB6 F98D 9198 3292
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-16 12:42       ` Simon Richter
@ 2001-04-16 15:49         ` Andreas Ferber
  2001-04-16 16:25           ` Simon Richter
  2001-04-16 21:36         ` Ben Ford
  1 sibling, 1 reply; 69+ messages in thread
From: Andreas Ferber @ 2001-04-16 15:49 UTC (permalink / raw)
  To: Simon Richter; +Cc: Pavel Machek, linux-kernel

Hi,

On Mon, Apr 16, 2001 at 02:42:03PM +0200, Simon Richter wrote:
> 
> A power failure is a different thing from a power button press. There are
> users (me for example) who want to have something different then "init 0"
> mapped to the power button, for example a sleep state (since my box
> doesn't have a dedicated sleep button). I doubt there are many people who
> want something else than a shutdown if the power is out (although I think
> there will be with suspend-to-disk working, so we might have to change UPS
> handling here).

And why not do exactly this with init? Have a look in /etc/inittab:

% grep power /etc/inittab
# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

You can shut down your machine there, but you can also have it play a
cancan on power failure. It is up to your gusto. And now tell me, why
not choose a similar approach, but instead reinvent the wheel and
create a completely new mechanism?

Andreas
-- 
Besides, I think Slackware sounds better than 'Microsoft,' don't you?
	-- Patrick Volkerding


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-13  0:29     ` Pavel Machek
@ 2001-04-16 12:42       ` Simon Richter
  2001-04-16 15:49         ` Andreas Ferber
  2001-04-16 21:36         ` Ben Ford
  0 siblings, 2 replies; 69+ messages in thread
From: Simon Richter @ 2001-04-16 12:42 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linux-kernel

On Fri, 13 Apr 2001, Pavel Machek wrote:

> > Then a more general user space tool could be used that would do policy
> > appropriate stuff, ending with init 0.

> init _is_ the tool which is right for defining policy on such issues.

> Take a look how UPS managment is handled.

A power failure is a different thing from a power button press. There are
users (me for example) who want to have something different then "init 0"
mapped to the power button, for example a sleep state (since my box
doesn't have a dedicated sleep button). I doubt there are many people who
want something else than a shutdown if the power is out (although I think
there will be with suspend-to-disk working, so we might have to change UPS
handling here).

My plan for power management was to have a special daemon that would
decide what to do based on system state (battery status, local time, ...)
and events (power/sleep button, last user logged out, ...) [I know that
from a programmer's POV, both are events]. This daemon could, for example,
make sure that no services are affected, for example by priming WOL and
entering a not-so-deep sleep state instead of doing a suspend-to-disk if
someone is still listening on a port after the "shutdown unimportant
services" scripts have been run.

   Simon

-- 
GPG public key available from http://phobos.fs.tum.de/pgp/Simon.Richter.asc
 Fingerprint: DC26 EB8D 1F35 4F44 2934  7583 DBB6 F98D 9198 3292
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-10 23:41   ` Mike Castle
@ 2001-04-13  0:29     ` Pavel Machek
  2001-04-16 12:42       ` Simon Richter
  0 siblings, 1 reply; 69+ messages in thread
From: Pavel Machek @ 2001-04-13  0:29 UTC (permalink / raw)
  To: Mike Castle, linux-kernel

Hi!

> > >Init should get to know that user pressed power button (so it can do
> > >shutdown and poweroff). Plus, it is nice to let user know that we can
> > 
> > Not so hasty ;)
> > 
> > >+		printk ("acpi: Power button pressed!\n");
> > >+		kill_proc (1, SIGTERM, 1);
> 
> [reasons deleted]
> 
> Is using a signal the appropriate thing to do anyway?
> 
> Wouldn't there be better solutions?
> 
> Perhaps a mechanism a user space program can use to communicate to the kernel
> (ala arpd/kerneld message queues, or something like klogd).  Then a more
> general user space tool could be used that would do policy appropriate
> stuff, ending with init 0.

init _is_ the tool which is right for defining policy on such issues.

Take a look how UPS managment is handled.

-- 
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt,
details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
       [not found]   ` <9b052eod@ncc1701.cistron.net>
@ 2001-04-13  0:26     ` Pavel Machek
  0 siblings, 0 replies; 69+ messages in thread
From: Pavel Machek @ 2001-04-13  0:26 UTC (permalink / raw)
  To: Miquel van Smoorenburg; +Cc: linux-kernel


> In article <9b04food@ncc1701.cistron.net>,
> Miquel van Smoorenburg <miquels@cistron-office.nl> wrote:
> >SIGTERM is a bad choise. Right now, init ignores SIGTERM. For
> >good reason; on some (many?) systems, the shutdown scripts
> >include "kill -15 -1; sleep 2; kill -9 -1". The "-1" means
> >"all processes except me". That means init will get hit with
> >SIGTERM occasionally during shutdown, and that might cause
> >weird things to happen.
> >
> >Perhaps SIGUSR1 ?
> 
> In the immortal words of Max Headroom, t-t-talking to myself ;)
> 
> In fact, the kernel should probably use a real-time signal
> with si_code set to 1 for ctrl-alt-del, 2 for the powerbutton etc.
> 
> It should first check if process 1 (init) installed a handler
> for that real-time signal. If not, it should use the old
> signals (SIGINT for ctrl-alt-del, SIGWINCH for kbrequest).

This is ugly as night, but SIGUSR1 looks okay.

-- 
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt,
details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-11 17:06 Grover, Andrew
@ 2001-04-11 18:29 ` John Fremlin
  0 siblings, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-11 18:29 UTC (permalink / raw)
  To: Grover, Andrew
  Cc: 'John Fremlin', 'Pavel Machek',
	kernel list, Acpi-linux (E-mail)

"Grover, Andrew" <andrew.grover@intel.com> writes:

[...]

> > > > +		printk ("acpi: Power button pressed!\n");
> > 
> > [...]
> > 
> > > > +		printk("acpi: Sleep button pressed!\n");
> > 
> > Do you think you could keep the above part of the patch? It would be
> > nice to know how much of ACPI was actually working ;-)

> I'm hesitant to do this, since 1) You can put those printk's in
> yourself to find out if your particular system is working and 2) You
> can just cat /proc/sys/event, hit a button, and you should see
> output if it works.

Hmm. Pavel Machek could hardly be described as a newbie at hacking
stuff, and yet he says, "I hunted bug for few hours, thinking that
kernel does not get the event at all."

The printks are certainly clearer than cat'ing some binary garbage to
the console and will help out the casual user who doesn't want to
recompile kernel and reboot just to discover that the damn thing
doesn't work.

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
@ 2001-04-11 17:06 Grover, Andrew
  2001-04-11 18:29 ` John Fremlin
  0 siblings, 1 reply; 69+ messages in thread
From: Grover, Andrew @ 2001-04-11 17:06 UTC (permalink / raw)
  To: 'John Fremlin'
  Cc: 'Pavel Machek', kernel list, Acpi-linux (E-mail)

I'm hesitant to do this, since 1) You can put those printk's in yourself to
find out if your particular system is working and 2) You can just cat
/proc/sys/event, hit a button, and you should see output if it works.

Regards -- Andy

> From: John Fremlin [mailto:chief@bandits.org]

>  "Grover, Andrew" <andrew.grover@intel.com> writes:
> 
> > This is not correct, because we want the power button to be
> > configurable.  The user should be able to redefine the power
> > button's action, perhaps to only sleep the system. We currently
> > surface button events to acpid, which then can do the right thing,
> > including a shutdown -h now (which I assume notifies init).
> 
> That's just fine and dandy, but
> 
> [...]
> 
> > > +		printk ("acpi: Power button pressed!\n");
> 
> [...]
> 
> > > +		printk("acpi: Sleep button pressed!\n");
> 
> Do you think you could keep the above part of the patch? It would be
> nice to know how much of ACPI was actually working ;-)


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-11 12:20 ` Pavel Machek
@ 2001-04-11 15:10   ` John Fremlin
  0 siblings, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-11 15:10 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Grover, Andrew, kernel list, Acpi-linux (E-mail)

 Pavel Machek <pavel@suse.cz> writes:

> Hi!
> 
> > This is not correct, because we want the power button to be
> > configurable.  The user should be able to redefine the power
> > button's action, perhaps to only sleep the system. We currently
> > surface button events to acpid, which then can do the right thing,
> > including a shutdown -h now (which I assume notifies init).
> 
> There's no problem with configurability -- you can configure init as
> well. I saw it pretty much analogic to situation with Ctrl-Alt-Del:
> it also sends signal to init. Init then decides what to do. [I
> believe requiring acpid for such easy stuff is not neccessary...]

Using a signal to hit init with is a bit dubious because most signals
are hooked up for something else already. For example, SIGTERM sent to
my init (http://john.snoop.dk/programs/linux/jinit) would shutdown and
start sulogin, which is probably not what you want when you press the
off button. The FreeBSD init is similar FWIW (goes to single user
mode).

Some PM interfaces (e.g. APM) require a descision to be made by
software on such an event (to turn off or to "reject"). IMHO the best
way to do this is to exec a small script from kernelspace to get the
user's preferred policy; this is lighter weight than a daemon, doesn't
require some nasty magic number interface, and can be easily
programmed by any admin knowing sh or perl or whatever.

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-11  4:23 ` John R Lenton
@ 2001-04-11 14:59   ` John Fremlin
  0 siblings, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-11 14:59 UTC (permalink / raw)
  To: kernel list

 John R Lenton <john@grulic.org.ar> writes:

[...]

> Just today a friend saw my box shutdown via the powerbutton and
> wondered if he coudln't set his up to trigger a different event
> (actually two: he wanted his sister - the guilty party - zapped, and
> a webcam shot of her face to prove it)...

That is in fact possible (given that you have the zapper) on certain
hardware with my pmpolicy patch

        http://john.snoop.dk/programs/linux/offbutton

It uses APM instead of ACPI because ACPI doesn't work on my
computer. I have an updated version of the patch for 2.4.2, but I
haven't got round to uploading it.

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-10 17:05 Grover, Andrew
  2001-04-11  4:23 ` John R Lenton
  2001-04-11 12:20 ` Pavel Machek
@ 2001-04-11 14:56 ` John Fremlin
  2 siblings, 0 replies; 69+ messages in thread
From: John Fremlin @ 2001-04-11 14:56 UTC (permalink / raw)
  To: Grover, Andrew; +Cc: 'Pavel Machek', kernel list, Acpi-linux (E-mail)

 "Grover, Andrew" <andrew.grover@intel.com> writes:

> This is not correct, because we want the power button to be
> configurable.  The user should be able to redefine the power
> button's action, perhaps to only sleep the system. We currently
> surface button events to acpid, which then can do the right thing,
> including a shutdown -h now (which I assume notifies init).

That's just fine and dandy, but

[...]

> > +		printk ("acpi: Power button pressed!\n");

[...]

> > +		printk("acpi: Sleep button pressed!\n");

Do you think you could keep the above part of the patch? It would be
nice to know how much of ACPI was actually working ;-)

[...]

-- 

	http://www.penguinpowered.com/~vii

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-10 17:05 Grover, Andrew
  2001-04-11  4:23 ` John R Lenton
@ 2001-04-11 12:20 ` Pavel Machek
  2001-04-11 15:10   ` John Fremlin
  2001-04-11 14:56 ` John Fremlin
  2 siblings, 1 reply; 69+ messages in thread
From: Pavel Machek @ 2001-04-11 12:20 UTC (permalink / raw)
  To: Grover, Andrew; +Cc: kernel list, Acpi-linux (E-mail)

Hi!

> This is not correct, because we want the power button to be configurable.
> The user should be able to redefine the power button's action, perhaps to
> only sleep the system. We currently surface button events to acpid, which
> then can do the right thing, including a shutdown -h now (which I assume
> notifies init).

There's no problem with configurability -- you can configure init as
well. I saw it pretty much analogic to situation with Ctrl-Alt-Del: it
also sends signal to init. Init then decides what to do. [I believe
requiring acpid for such easy stuff is not neccessary...]
								Pavel


> Regards -- Andy
> 
> > From: Pavel Machek [mailto:pavel@suse.cz]
> > Init should get to know that user pressed power button (so it can do
> > shutdown and poweroff). Plus, it is nice to let user know that we can
> > read such event. [I hunted bug for few hours, thinking that kernel
> > does not get the event at all].
> > 
> > Here's patch to do that. Please apply,
> > 								Pavel
> > 
> > diff -urb -x .dep* -x .hdep* -x *.[oas] -x *~ -x #* -x *CVS* 
> > -x *.orig -x *.rej -x *.old -x .menu* -x asm -x local.h -x 
> > System.map -x autoconf.h -x compile.h -x version.h -x 
> > .version -x defkeymap.c -x uni_hash.tbl -x zImage -x vmlinu?* 
> > -x TAGS -x bootsect -x *RCS* -x conmakehash -x map -x build 
> > -x build -x configure -x *target* -x *.flags -x *.bak 
> > clean/drivers/acpi/events/evevent.c 
> > linux/drivers/acpi/events/evevent.c
> > --- clean/drivers/acpi/events/evevent.c	Sun Apr  1 00:22:57 2001
> > +++ linux/drivers/acpi/events/evevent.c	Wed Apr  4 01:08:11 2001
> > @@ -30,6 +30,8 @@
> >  #include "acnamesp.h"
> >  #include "accommon.h"
> >  
> > +#include <linux/signal.h>
> > +
> >  #define _COMPONENT          EVENT_HANDLING
> >  	 MODULE_NAME         ("evevent")
> >  
> > @@ -197,14 +172,18 @@
> >  	if ((status_register & ACPI_STATUS_POWER_BUTTON) &&
> >  		(enable_register & ACPI_ENABLE_POWER_BUTTON))
> >  	{
> > +		printk ("acpi: Power button pressed!\n");
> > +		kill_proc (1, SIGTERM, 1);
> >  		int_status |= acpi_ev_fixed_event_dispatch 
> > (ACPI_EVENT_POWER_BUTTON);
> >  	}
> >  
> > +
> >  	/* sleep button event */
> >  
> >  	if ((status_register & ACPI_STATUS_SLEEP_BUTTON) &&
> >  		(enable_register & ACPI_ENABLE_SLEEP_BUTTON))
> >  	{
> > +		printk("acpi: Sleep button pressed!\n");
> >  		int_status |= acpi_ev_fixed_event_dispatch 
> > (ACPI_EVENT_SLEEP_BUTTON);
> >  	}
> >  
> > 
> > -- 
> > I'm pavel@ucw.cz. "In my country we have almost anarchy and I 
> > don't care."
> > Panos Katsaloulis describing me w.r.t. patents at 
> > discuss@linmodems.org
> > 

-- 
The best software in life is free (not shareware)!		Pavel
GCM d? s-: !g p?:+ au- a--@ w+ v- C++@ UL+++ L++ N++ E++ W--- M- Y- R+

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
@ 2001-04-11  4:31 alad
  0 siblings, 0 replies; 69+ messages in thread
From: alad @ 2001-04-11  4:31 UTC (permalink / raw)
  To: Kurt Roeckx; +Cc: Miquel van Smoorenburg, linux-kernel








Kurt Roeckx <Q@ping.be> on 04/11/2001 06:16:52 AM

To:   Miquel van Smoorenburg <miquels@cistron-office.nl>
cc:   linux-kernel@vger.kernel.org (bcc: Amol Lad/HSS)

Subject:  Re: Let init know user wants to shutdown




On Wed, Apr 11, 2001 at 01:38:30AM +0200, Kurt Roeckx wrote:
> On Tue, Apr 10, 2001 at 11:20:24PM +0000, Miquel van Smoorenburg wrote:
> >
> > the shutdown scripts
> > include "kill -15 -1; sleep 2; kill -9 -1". The "-1" means
> > "all processes except me". That means init will get hit with
> > SIGTERM occasionally during shutdown, and that might cause
> > weird things to happen.
>
> -1 mean everything but init.

>>> well. don't fight.. here is something from kernel/signal.c

asmlinkage int sys_kill(int pid, int sig){
...
...
return kill_something_info(sig,&info,pid)
}


int
kill_something_info(int sig, struct siginfo *info, int pid){
...
...
...
     if (pid == -1){
          for_each_task(p){(int
               if (p->pid >1 && p != current){
                    err = send_sig_info(sig,info,p);
                    ...
                    ...
               }
          }
     }

Amol


Oh, maybe you mean killall5 -TERM?

Which would send a SIGTERM to all processes but the one in his
own session.

(Hey look, you wrote that manpage.)


Kurt

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/





^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-10 17:05 Grover, Andrew
@ 2001-04-11  4:23 ` John R Lenton
  2001-04-11 14:59   ` John Fremlin
  2001-04-11 12:20 ` Pavel Machek
  2001-04-11 14:56 ` John Fremlin
  2 siblings, 1 reply; 69+ messages in thread
From: John R Lenton @ 2001-04-11  4:23 UTC (permalink / raw)
  To: kernel list

On Tue, Apr 10, 2001 at 10:05:13AM -0700, Grover, Andrew wrote:
> This is not correct, because we want the power button to be configurable.
> The user should be able to redefine the power button's action, perhaps to
> only sleep the system. We currently surface button events to acpid, which
> then can do the right thing, including a shutdown -h now (which I assume
> notifies init).

Just today a friend saw my box shutdown via the powerbutton and
wondered if he coudln't set his up to trigger a different event
(actually two: he wanted his sister - the guilty party - zapped,
and a webcam shot of her face to prove it)...

-- 
John Lenton (john@grulic.org.ar) -- Random fortune:
¿Como meterán los cacahuetes dentro de la cáscara?

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-10 23:38   ` Kurt Roeckx
  2001-04-10 23:46     ` Kurt Roeckx
@ 2001-04-10 23:53     ` Miquel van Smoorenburg
  1 sibling, 0 replies; 69+ messages in thread
From: Miquel van Smoorenburg @ 2001-04-10 23:53 UTC (permalink / raw)
  To: Kurt Roeckx; +Cc: Miquel van Smoorenburg, linux-kernel

According to Kurt Roeckx:
> On Tue, Apr 10, 2001 at 11:20:24PM +0000, Miquel van Smoorenburg wrote:
> > The "-1" means
> > "all processes except me". That means init will get hit with
> > SIGTERM occasionally during shutdown, and that might cause
> > weird things to happen.
> 
> -1 mean everything but init.
> 
> From the manpage:

Oh. OK, so this is yet another special case for init - forget to
check those. Sorry about that (hey it's 01:53 here, I should be
in bed).  Yet I still think it'd be a better idea to use RT signals,
see my other message in this thread.

Mike.

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-10 23:38   ` Kurt Roeckx
@ 2001-04-10 23:46     ` Kurt Roeckx
  2001-04-10 23:53     ` Miquel van Smoorenburg
  1 sibling, 0 replies; 69+ messages in thread
From: Kurt Roeckx @ 2001-04-10 23:46 UTC (permalink / raw)
  To: Miquel van Smoorenburg; +Cc: linux-kernel

On Wed, Apr 11, 2001 at 01:38:30AM +0200, Kurt Roeckx wrote:
> On Tue, Apr 10, 2001 at 11:20:24PM +0000, Miquel van Smoorenburg wrote:
> > 
> > the shutdown scripts
> > include "kill -15 -1; sleep 2; kill -9 -1". The "-1" means
> > "all processes except me". That means init will get hit with
> > SIGTERM occasionally during shutdown, and that might cause
> > weird things to happen.
> 
> -1 mean everything but init.

Oh, maybe you mean killall5 -TERM?

Which would send a SIGTERM to all processes but the one in his
own session.

(Hey look, you wrote that manpage.)


Kurt


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-10 23:20 ` Miquel van Smoorenburg
  2001-04-10 23:30   ` Miquel van Smoorenburg
  2001-04-10 23:38   ` Kurt Roeckx
@ 2001-04-10 23:41   ` Mike Castle
  2001-04-13  0:29     ` Pavel Machek
  2 siblings, 1 reply; 69+ messages in thread
From: Mike Castle @ 2001-04-10 23:41 UTC (permalink / raw)
  To: linux-kernel

On Tue, Apr 10, 2001 at 11:20:24PM +0000, Miquel van Smoorenburg wrote:
> In article <20010405000215.A599@bug.ucw.cz>,
> Pavel Machek  <pavel@suse.cz> wrote:
> >Init should get to know that user pressed power button (so it can do
> >shutdown and poweroff). Plus, it is nice to let user know that we can
> 
> Not so hasty ;)
> 
> >+		printk ("acpi: Power button pressed!\n");
> >+		kill_proc (1, SIGTERM, 1);

[reasons deleted]

Is using a signal the appropriate thing to do anyway?

Wouldn't there be better solutions?

Perhaps a mechanism a user space program can use to communicate to the kernel
(ala arpd/kerneld message queues, or something like klogd).  Then a more
general user space tool could be used that would do policy appropriate
stuff, ending with init 0.

mrc
-- 
       Mike Castle       Life is like a clock:  You can work constantly
  dalgoda@ix.netcom.com  and be right all the time, or not work at all
www.netcom.com/~dalgoda/ and be right at least twice a day.  -- mrc
    We are all of us living in the shadow of Manhattan.  -- Watchmen

^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-10 23:20 ` Miquel van Smoorenburg
  2001-04-10 23:30   ` Miquel van Smoorenburg
@ 2001-04-10 23:38   ` Kurt Roeckx
  2001-04-10 23:46     ` Kurt Roeckx
  2001-04-10 23:53     ` Miquel van Smoorenburg
  2001-04-10 23:41   ` Mike Castle
  2 siblings, 2 replies; 69+ messages in thread
From: Kurt Roeckx @ 2001-04-10 23:38 UTC (permalink / raw)
  To: Miquel van Smoorenburg; +Cc: linux-kernel

On Tue, Apr 10, 2001 at 11:20:24PM +0000, Miquel van Smoorenburg wrote:
> 
> the shutdown scripts
> include "kill -15 -1; sleep 2; kill -9 -1". The "-1" means
> "all processes except me". That means init will get hit with
> SIGTERM occasionally during shutdown, and that might cause
> weird things to happen.

-1 mean everything but init.

>From the manpage:

       If pid equals -1, then sig is sent to every process except
       for the first one, from  higher  numbers  in  the  process
       table to lower.

And later:

BUGS
       It  is impossible to send a signal to task number one, the
       init process, for which it has not installed a signal han-
       dler.   This  is  done to assure the system is not brought
       down accidentally.


Kurt


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-10 23:20 ` Miquel van Smoorenburg
@ 2001-04-10 23:30   ` Miquel van Smoorenburg
  2001-04-10 23:38   ` Kurt Roeckx
  2001-04-10 23:41   ` Mike Castle
  2 siblings, 0 replies; 69+ messages in thread
From: Miquel van Smoorenburg @ 2001-04-10 23:30 UTC (permalink / raw)
  To: linux-kernel

In article <9b04fo$9od$3@ncc1701.cistron.net>,
Miquel van Smoorenburg <miquels@cistron-office.nl> wrote:
>SIGTERM is a bad choise. Right now, init ignores SIGTERM. For
>good reason; on some (many?) systems, the shutdown scripts
>include "kill -15 -1; sleep 2; kill -9 -1". The "-1" means
>"all processes except me". That means init will get hit with
>SIGTERM occasionally during shutdown, and that might cause
>weird things to happen.
>
>Perhaps SIGUSR1 ?

In the immortal words of Max Headroom, t-t-talking to myself ;)

In fact, the kernel should probably use a real-time signal
with si_code set to 1 for ctrl-alt-del, 2 for the powerbutton etc.

It should first check if process 1 (init) installed a handler
for that real-time signal. If not, it should use the old
signals (SIGINT for ctrl-alt-del, SIGWINCH for kbrequest).

Mike.


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Re: Let init know user wants to shutdown
  2001-04-04 22:02 Pavel Machek
@ 2001-04-10 23:20 ` Miquel van Smoorenburg
  2001-04-10 23:30   ` Miquel van Smoorenburg
                     ` (2 more replies)
       [not found] ` <9b04food@ncc1701.cistron.net>
  1 sibling, 3 replies; 69+ messages in thread
From: Miquel van Smoorenburg @ 2001-04-10 23:20 UTC (permalink / raw)
  To: linux-kernel

In article <20010405000215.A599@bug.ucw.cz>,
Pavel Machek  <pavel@suse.cz> wrote:
>Hi!
>
>Init should get to know that user pressed power button (so it can do
>shutdown and poweroff). Plus, it is nice to let user know that we can
>read such event. [I hunted bug for few hours, thinking that kernel
>does not get the event at all].
>
>Here's patch to do that. Please apply,

Not so hasty ;)

>+		printk ("acpi: Power button pressed!\n");
>+		kill_proc (1, SIGTERM, 1);

SIGTERM is a bad choise. Right now, init ignores SIGTERM. For
good reason; on some (many?) systems, the shutdown scripts
include "kill -15 -1; sleep 2; kill -9 -1". The "-1" means
"all processes except me". That means init will get hit with
SIGTERM occasionally during shutdown, and that might cause
weird things to happen.

Perhaps SIGUSR1 ?

Mike.


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: Let init know user wants to shutdown
@ 2001-04-10 17:05 Grover, Andrew
  2001-04-11  4:23 ` John R Lenton
                   ` (2 more replies)
  0 siblings, 3 replies; 69+ messages in thread
From: Grover, Andrew @ 2001-04-10 17:05 UTC (permalink / raw)
  To: 'Pavel Machek', kernel list; +Cc: Acpi-linux (E-mail)

This is not correct, because we want the power button to be configurable.
The user should be able to redefine the power button's action, perhaps to
only sleep the system. We currently surface button events to acpid, which
then can do the right thing, including a shutdown -h now (which I assume
notifies init).

Regards -- Andy

> From: Pavel Machek [mailto:pavel@suse.cz]
> Init should get to know that user pressed power button (so it can do
> shutdown and poweroff). Plus, it is nice to let user know that we can
> read such event. [I hunted bug for few hours, thinking that kernel
> does not get the event at all].
> 
> Here's patch to do that. Please apply,
> 								Pavel
> 
> diff -urb -x .dep* -x .hdep* -x *.[oas] -x *~ -x #* -x *CVS* 
> -x *.orig -x *.rej -x *.old -x .menu* -x asm -x local.h -x 
> System.map -x autoconf.h -x compile.h -x version.h -x 
> .version -x defkeymap.c -x uni_hash.tbl -x zImage -x vmlinu?* 
> -x TAGS -x bootsect -x *RCS* -x conmakehash -x map -x build 
> -x build -x configure -x *target* -x *.flags -x *.bak 
> clean/drivers/acpi/events/evevent.c 
> linux/drivers/acpi/events/evevent.c
> --- clean/drivers/acpi/events/evevent.c	Sun Apr  1 00:22:57 2001
> +++ linux/drivers/acpi/events/evevent.c	Wed Apr  4 01:08:11 2001
> @@ -30,6 +30,8 @@
>  #include "acnamesp.h"
>  #include "accommon.h"
>  
> +#include <linux/signal.h>
> +
>  #define _COMPONENT          EVENT_HANDLING
>  	 MODULE_NAME         ("evevent")
>  
> @@ -197,14 +172,18 @@
>  	if ((status_register & ACPI_STATUS_POWER_BUTTON) &&
>  		(enable_register & ACPI_ENABLE_POWER_BUTTON))
>  	{
> +		printk ("acpi: Power button pressed!\n");
> +		kill_proc (1, SIGTERM, 1);
>  		int_status |= acpi_ev_fixed_event_dispatch 
> (ACPI_EVENT_POWER_BUTTON);
>  	}
>  
> +
>  	/* sleep button event */
>  
>  	if ((status_register & ACPI_STATUS_SLEEP_BUTTON) &&
>  		(enable_register & ACPI_ENABLE_SLEEP_BUTTON))
>  	{
> +		printk("acpi: Sleep button pressed!\n");
>  		int_status |= acpi_ev_fixed_event_dispatch 
> (ACPI_EVENT_SLEEP_BUTTON);
>  	}
>  
> 
> -- 
> I'm pavel@ucw.cz. "In my country we have almost anarchy and I 
> don't care."
> Panos Katsaloulis describing me w.r.t. patents at 
> discuss@linmodems.org
> 


^ permalink raw reply	[flat|nested] 69+ messages in thread

* Let init know user wants to shutdown
@ 2001-04-04 22:02 Pavel Machek
  2001-04-10 23:20 ` Miquel van Smoorenburg
       [not found] ` <9b04food@ncc1701.cistron.net>
  0 siblings, 2 replies; 69+ messages in thread
From: Pavel Machek @ 2001-04-04 22:02 UTC (permalink / raw)
  To: andrew.grover, kernel list

Hi!

Init should get to know that user pressed power button (so it can do
shutdown and poweroff). Plus, it is nice to let user know that we can
read such event. [I hunted bug for few hours, thinking that kernel
does not get the event at all].

Here's patch to do that. Please apply,
								Pavel

diff -urb -x .dep* -x .hdep* -x *.[oas] -x *~ -x #* -x *CVS* -x *.orig -x *.rej -x *.old -x .menu* -x asm -x local.h -x System.map -x autoconf.h -x compile.h -x version.h -x .version -x defkeymap.c -x uni_hash.tbl -x zImage -x vmlinu?* -x TAGS -x bootsect -x *RCS* -x conmakehash -x map -x build -x build -x configure -x *target* -x *.flags -x *.bak clean/drivers/acpi/events/evevent.c linux/drivers/acpi/events/evevent.c
--- clean/drivers/acpi/events/evevent.c	Sun Apr  1 00:22:57 2001
+++ linux/drivers/acpi/events/evevent.c	Wed Apr  4 01:08:11 2001
@@ -30,6 +30,8 @@
 #include "acnamesp.h"
 #include "accommon.h"
 
+#include <linux/signal.h>
+
 #define _COMPONENT          EVENT_HANDLING
 	 MODULE_NAME         ("evevent")
 
@@ -197,14 +172,18 @@
 	if ((status_register & ACPI_STATUS_POWER_BUTTON) &&
 		(enable_register & ACPI_ENABLE_POWER_BUTTON))
 	{
+		printk ("acpi: Power button pressed!\n");
+		kill_proc (1, SIGTERM, 1);
 		int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_POWER_BUTTON);
 	}
 
+
 	/* sleep button event */
 
 	if ((status_register & ACPI_STATUS_SLEEP_BUTTON) &&
 		(enable_register & ACPI_ENABLE_SLEEP_BUTTON))
 	{
+		printk("acpi: Sleep button pressed!\n");
 		int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_SLEEP_BUTTON);
 	}
 

-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org

^ permalink raw reply	[flat|nested] 69+ messages in thread

end of thread, other threads:[~2001-05-02 16:53 UTC | newest]

Thread overview: 69+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-12 17:25 Let init know user wants to shutdown David Balazic
2001-04-16  7:03 ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2001-04-18 22:52 Grover, Andrew
2001-04-26 22:10 ` David S. Miller
2001-04-18 21:46 Grover, Andrew
2001-04-18 22:09 ` David S. Miller
2001-04-18 22:30 ` John Fremlin
2001-04-19  2:16 ` Jeff Garzik
2001-04-19 12:04 ` David Woodhouse
2001-04-18 18:28 Grover, Andrew
2001-04-18 18:45 ` Jeff Garzik
2001-04-18 19:36 ` John Fremlin
2001-04-18  0:07 Grover, Andrew
2001-04-18  0:51 ` Alan Cox
2001-04-18  1:56   ` John Fremlin
2001-04-18 11:55     ` Alan Cox
2001-04-18 19:10       ` John Fremlin
2001-04-18 20:10         ` Alan Cox
2001-04-18 20:21           ` John Fremlin
2001-04-18 21:05           ` Avery Pennarun
2001-04-18 21:34             ` John Fremlin
2001-04-20 17:02         ` Pavel Machek
2001-05-02 16:52           ` John Fremlin
2001-04-20 17:01     ` Pavel Machek
2001-04-20 23:41       ` John Fremlin
2001-04-21  7:54         ` Pavel Machek
2001-04-24  0:17         ` Jamie Lokier
2001-04-24  1:08           ` John Fremlin
2001-04-24 10:06           ` Pavel Machek
2001-04-25 14:28             ` Jamie Lokier
2001-04-25 16:11             ` Richard Gooch
2001-04-18  1:54 ` John Fremlin
2001-04-17 16:45 Grover, Andrew
2001-04-17 19:54 ` Pavel Machek
2001-04-17 22:23 ` John Fremlin
2001-04-18 15:26 ` Simon Richter
2001-04-18 19:51   ` John Fremlin
2001-04-16 23:32 Grover, Andrew
2001-04-17  6:40 ` John Fremlin
2001-04-17  6:41 ` Simon Richter
2001-04-17 11:16 ` Pavel Machek
2001-04-11 17:06 Grover, Andrew
2001-04-11 18:29 ` John Fremlin
2001-04-11  4:31 alad
2001-04-10 17:05 Grover, Andrew
2001-04-11  4:23 ` John R Lenton
2001-04-11 14:59   ` John Fremlin
2001-04-11 12:20 ` Pavel Machek
2001-04-11 15:10   ` John Fremlin
2001-04-11 14:56 ` John Fremlin
2001-04-04 22:02 Pavel Machek
2001-04-10 23:20 ` Miquel van Smoorenburg
2001-04-10 23:30   ` Miquel van Smoorenburg
2001-04-10 23:38   ` Kurt Roeckx
2001-04-10 23:46     ` Kurt Roeckx
2001-04-10 23:53     ` Miquel van Smoorenburg
2001-04-10 23:41   ` Mike Castle
2001-04-13  0:29     ` Pavel Machek
2001-04-16 12:42       ` Simon Richter
2001-04-16 15:49         ` Andreas Ferber
2001-04-16 16:25           ` Simon Richter
2001-04-16 21:27             ` Pavel Machek
2001-04-16 21:44               ` Simon Richter
2001-04-16 22:38                 ` Andreas Ferber
2001-04-17  6:16                   ` Simon Richter
2001-04-17  8:39                     ` Andreas Ferber
2001-04-17 14:09                       ` Simon Richter
2001-04-16 21:36         ` Ben Ford
     [not found] ` <9b04food@ncc1701.cistron.net>
     [not found]   ` <9b052eod@ncc1701.cistron.net>
2001-04-13  0:26     ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).