public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: apm suspend broken ?
@ 2001-10-30 15:58 Thomas Hood
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Hood @ 2001-10-30 15:58 UTC (permalink / raw)
  To: linux-kernel

> I, by the way, had my Latitude suspend perfectly with 2.4.12-ac5.
> Now, with 2.4.13-ac[34] pressing Fn+Suspend just blanks the screen (it
> doesn't shut it off, _just_ blanks it) and hangs the machine.
> 
> Any ideas on how to proceed in order to find out where the problem
> lies?

The apm driver was changed so that clients who open
the apm device without the write flag won't be expected
to return standby or suspend events; and clients who
open the apm device without the read flag won't be
notified of apm events.

For consistency, clients without the write flag should
not be able to request standbys or suspends.  Thus
this patch seems required:
--- linux-2.4.13-ac2/arch/i386/kernel/apm.c	Mon Oct 22 09:22:38 2001
+++ linux-2.4.13-ac2-fix/arch/i386/kernel/apm.c	Tue Oct 30 10:29:41 2001
@@ -1473,6 +1473,8 @@
 		return -EIO;
 	if (!as->suser)
 		return -EPERM;
+	if (!as->writer)
+		return -EPERM;
 	switch (cmd) {
 	case APM_IOC_STANDBY:
 		if (as->standbys_read > 0) {

Applying this patch may solve your problem.

Scenario: You have a client that is opening the apm
device O_RDONLY, yet has been acking standby events
back to the apm driver.  Formerly the driver would
ignore the lack of write permission, but now, since
the client does not have write permission, the driver
does not count the standby event that it sends to the
client as "pending".  So when the client acks the
event, it looks to the driver like a new request.
Without the above patch, the driver will process this
request, dutifully  queueing it to the other clients.
If there is more than one client of this kind, then
an infinite series of standby requests will result.

The patch should prevent that from happening.

However, if there are apm clients that expect the
driver to inform them of standby and suspend events
and to wait for an ack before going ahead with the
standby or suspend, then such clients should be
modified to open the apm device O_RDWR.  So long
as such a client opens the apm device O_RDONLY,
the driver will not wait for it to reply and
(patched with the above) will reject its reply
when it comes.

The changelog at the top of apm.c cites me as the
originator of the idea behind the change.  The
motivation was to eliminate queue overflows for
clients that aren't interested in the events and
don't read them.  The idea of not waiting for 
feedback from clients without write perm seems
like a good one too, since some clients might
just want to hear about events, not generate or
ack them.  However this does constitute an API
change, so either (1) we should disable the
change until 2.5, or (2) we should check that
clients such as apmd are opening the apm device
with O_RDWR.

--
Thomas Hood



^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: apm suspend broken ?
@ 2001-11-29 19:59 Thomas Hood
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Hood @ 2001-11-29 19:59 UTC (permalink / raw)
  To: linux-kernel

It's a long shot, but you might try upgrading to
the latest release of apmd, 3.0.2.  You might also
try killing  apmd altogether before suspending;
see what happens.

Does it make any difference if X is not running
when you try to suspend?

Is your BIOS up to date?

Is the only problem the fact that you sometimes have
to press Fn+D to get the suspend to complete?  If so,
that doesn't seem like too big a deal (even if it would
be nice if it were fixed).  Or is the problem more
serious than that?

Thomas


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: apm suspend broken ?
@ 2001-11-02 12:38 Thomas Hood
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Hood @ 2001-11-02 12:38 UTC (permalink / raw)
  To: linux-kernel

> Fn+Suspend (or launching "apm -s") does not ALWAYS suspend
> the laptop. Sometimes, it blanks the screen but leaves the
> lcd light on, the cpu fan is on also. Pressing Fn+D to turn
> off the lcd light completes the job and the laptop finaly
> suspends completely.

My guess is that what is happening is: apm receives the event
and notifies apmd an X.  X blanks the display and returns.
apmd processes the event and returns.  apm does suspend().
But then you hit some BIOS bug.  Or the BIOS expects the 
OS to turn off the LCD light before returning.

Does it make any difference if apmd and X are NOT running?

Stephen: Do you think it would be worth sticking a call to
apm_console_blank inside suspend() for this person to see
if it helps?

--
Thomas

P.S.  Stephen:  Should the line "ignore_normal_resume = 1;"
inside suspend() be put prior to the sti()?


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: apm suspend broken ?
@ 2001-10-31  4:05 Thomas Hood
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Hood @ 2001-10-31  4:05 UTC (permalink / raw)
  To: linux-kernel

Following  up on my earlier message.

On my machine, lsof reveals that apmd and X both open
/dev/apm_bios with O_RDWR flags; also, reading the source
of libapm reveals that it too opens with O_RDWR;
so none of these should see any change in the behavior
of the apm driver.

Nevertheless, the two-line patch given below needs to be
applied in order to prevent the problem I described before.
I'm running a kernel with the patch applied now and it
works fine.

--
Thomas


--- original message ---

The apm driver was changed so that clients who open
the apm device without the write flag won't be expected
to return standby or suspend events; and clients who
open the apm device without the read flag won't be
notified of apm events.

For consistency, clients without the write flag should
not be able to request standbys or suspends.  Thus
this patch seems required:
--- linux-2.4.13-ac2/arch/i386/kernel/apm.c	Mon Oct 22 09:22:38 2001
+++ linux-2.4.13-ac2-fix/arch/i386/kernel/apm.c	Tue Oct 30 10:29:41 2001
@@ -1473,6 +1473,8 @@
 		return -EIO;
 	if (!as->suser)
 		return -EPERM;
+	if (!as->writer)
+		return -EPERM;
 	switch (cmd) {
 	case APM_IOC_STANDBY:
 		if (as->standbys_read > 0) {

Applying this patch may solve your problem.

Scenario: You have a client that is opening the apm
device O_RDONLY, yet has been acking standby events
back to the apm driver.  Formerly the driver would
ignore the lack of write permission, but now, since
the client does not have write permission, the driver
does not count the standby event that it sends to the
client as "pending".  So when the client acks the
event, it looks to the driver like a new request.
Without the above patch, the driver will process this
request, dutifully  queueing it to the other clients.
If there is more than one client of this kind, then
an infinite series of standby requests will result.

The patch should prevent that from happening.

However, if there are apm clients that expect the
driver to inform them of standby and suspend events
and to wait for an ack before going ahead with the
standby or suspend, then such clients should be
modified to open the apm device O_RDWR.  So long
as such a client opens the apm device O_RDONLY,
the driver will not wait for it to reply and
(patched with the above) will reject its reply
when it comes.

The changelog at the top of apm.c cites me as the
originator of the idea behind the change.  The
motivation was to eliminate queue overflows for
clients that aren't interested in the events and
don't read them.  The idea of not waiting for 
feedback from clients without write perm seems
like a good one too, since some clients might
just want to hear about events, not generate or
ack them.  However this does constitute an API
change, so either (1) we should disable the
change until 2.5, or (2) we should check that
clients such as apmd are opening the apm device
with O_RDWR.

--
Thomas Hood




^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: apm suspend broken ?
@ 2001-10-30 16:18 Thomas Hood
  2001-10-31 14:28 ` Stephen Rothwell
  0 siblings, 1 reply; 17+ messages in thread
From: Thomas Hood @ 2001-10-30 16:18 UTC (permalink / raw)
  To: linux-kernel

I have a question related to this.

If a driver ioctl handler requires
    (filp->f_mode) & FMODE_WRITE
to be set before processing a request, and if only
root has write permission to the device file, does this
make it unnecessary to check for
     capable(CAP_SYS_ADMIN)
?

If we were to use the write permission bit to control
access, then it would not be necessary for the apm
command to be setuid root to give the non-root user
the ability to suspend the machine.  Instead we could
    chgrp apm /dev/apm_bios
    chmod g+w /dev/apm_bios
and add the trusted user to the 'apm' group.

Am I missing something here?

--
Thomas


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: apm suspend broken ?
@ 2001-10-30 16:04 Thomas Hood
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Hood @ 2001-10-30 16:04 UTC (permalink / raw)
  To: linux-kernel

Hmm.  I just noticed that your problem was with 
suspend, not standby.  The same scenario could occur
with suspend, of course.  However, the scenario does
not match the problem you describe.  I don't see how
a change to the apm driver could cause a suspend to
turn into something that looks like a standby-plus-crash.

Are you sure that the machine is hanged: SysRq-s,
SysRq-u, SysRq-b doesn't work?

--
Thomas


^ permalink raw reply	[flat|nested] 17+ messages in thread
* apm suspend broken ?
@ 2001-10-30 10:55 Pascal Lengard
  2001-10-30 11:43 ` Samuli Suonpaa
  0 siblings, 1 reply; 17+ messages in thread
From: Pascal Lengard @ 2001-10-30 10:55 UTC (permalink / raw)
  To: linux-kernel

Hello,

I read a thread on the mailing list archive about the exact same
problem I am facing now (thread started on Tue Sep 25 2001:
"apm suspend broken in 2.4.10).

I use a Dell latitude C600 and it used to work fine with kernel up
to 2.4.9 (regular kernel from kernel.org).
I upgraded to redhat 7.2 and to kernel 2.4.13+ext3 patches (again
from regular sources), and apm refuses to suspend the beast.

Did someone find a solution for this problem since last thread ?
If no light shined from last thread, I would be happy to help out
on this. I am not a kernel hacker so I guess my help will be limited,
but I do have the hardware ready for testing purposes

Pascal

(please cc me in replies since I am not subscribed to the list)


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

end of thread, other threads:[~2001-11-29 19:58 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-30 15:58 apm suspend broken ? Thomas Hood
  -- strict thread matches above, loose matches on Subject: below --
2001-11-29 19:59 Thomas Hood
2001-11-02 12:38 Thomas Hood
2001-10-31  4:05 Thomas Hood
2001-10-30 16:18 Thomas Hood
2001-10-31 14:28 ` Stephen Rothwell
2001-10-30 16:04 Thomas Hood
2001-10-30 10:55 Pascal Lengard
2001-10-30 11:43 ` Samuli Suonpaa
2001-10-30 12:10   ` Alan Cox
2001-10-31  1:27     ` Pascal Lengard
2001-10-31 11:08       ` Alan Cox
2001-10-31 14:51       ` Stephen Rothwell
2001-11-02  8:31         ` Pascal Lengard
2001-11-29 18:50           ` Pascal Lengard
2001-11-15 17:43     ` Samuli Suonpaa
2001-11-15 17:58       ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox