sleep on powerbook crashes

Bug #144305 reported by Benjamin Herrenschmidt
52
This bug affects 4 people
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Fix Released
Undecided
Colin Ian King

Bug Description

On gutsy, trying to put the powerbook to sleep (by closing the lid for example) causes the machine to crash with a PMU shutdown, which also has the side effect of losing the content of the real time clock. Very annoying. It works with Edgy.

I've verified that the kernel sleep stuff is working properly by sending the appropriate ioctl to /dev/pmu. So it's something being done by userland. One possibility that I have to investigate is that maybe userspace is using the /sys/power/state file which doesn't work properly on powerbooks, instead of the custom ioctl.

Revision history for this message
Benjamin Herrenschmidt (benh-kernel) wrote :

Looks like I wasn't completely right above. I don't know yet whether userspace is using the ioctl or not, but it seems that calling the ioctl directly also fails when X is frontmost.

Among other things I've noticed:

 - the APM emulation module isn't loaded by default.
 - the kernel isn't switching to text console before suspend

The 2 above together means that X has no chance to quiesce the graphics engine and properly re-initialize it on wakeup, which probably explains some of the problems. I've manually loaded apm-emu and restart X, but that didn't fully fix the problem, so there is still something else going on. I'll try to investigate and let you know. In the meantime, apm-emu should definitely be added to the loaded-by-default list of modules at least on powerbooks.

Revision history for this message
Benjamin Herrenschmidt (benh-kernel) wrote :

With a bit more digging, it seems that for some reason, the APM emulation isn't doing the job it used to do of
having X cleanup properly for suspend. It could be a bug with the recent X servers or ATI drivers, that's unclear.

However, rather than trying to fix that, the best solution is to do like x86 does with ACPI and basically use
scripts to trigger a VT switch. That will be more solid anyway.

The ACPI scripts are not useable as-is with /etc/power as they assume that env. variables can be set in
suspend and re-used in resume. So I've hacked a pair of scripts that can be put in /etc/power/suspend.d and
/etc/power/resume.d for powerpc (though they wouldn't hurt old style APM based x86 either I believe). Those
are a bit on the hackish side of things but they do the job fine for me, please do something similar to fix the
problem in gutsy !

- console-switch-out (in suspend.d):

#!/bin/sh

# And remember which console we're on
fgconsole >/tmp/saved-fg-console

# Change away from X, otherwise it'll blow up when we POST the video interface
chvt 12

- console-switch-in (in resume.d):

#!/bin/sh

CONSOLE=`cat /tmp/saved-fg-console`
rm /tmp/saved-fg-console
chvt $CONSOLE

Revision history for this message
John Steele Scott (toojays) wrote :

Sleep doesn't work on my iBook G4 either. It used to work in Feisty.

One strange thing I've noted is that when the machine goes to sleep, after the LED starts "breathing" (fading in and out to show the machine is asleep), the LCD backlight turns on.

Ben, I haven't been able to get your workaround to work for me yet, but I'll keep fiddling with it a bit more. Problem is there's never really a convenient time to do the kind of stuff which requires constantly crashing/rebooting the computer. :(

I think the gnome-power-manager is handling the sleep via hal, which should mean that /usr/lib/hal/hal-system-power-pmu is invoked to use the PMU ioctl to cause sleep. If that's the case, should the APM emulation module still be required? It is loaded on my iBook, but my install is pretty crufty because I've been through many dist-upgrades over the last few years.

Revision history for this message
Benjamin Herrenschmidt (benh-kernel) wrote :

APM emu should still be useful to notify apps that directly listen to /dev/apm_bios such as X, though I haven't seen that working properly lately.

A few things you can try:

 - First, check if radeonfb is loaded & working
 - Try sleeping from console mode without having ever launched X from boot
 - Try sleeping from console mode after switching to console from X
 - Try sleeping with network manager not running
 - Try all of the above while booting with the feisty kernel

Revision history for this message
John Steele Scott (toojays) wrote :

Okay, I'm sure your workaround is the way to go, it's just the implementation which doesn't seem to be the same between my computer and yours.

Notes:

If I manually switch to vt1 and sleep using "/usr/lib/hal/hal-system-power-pmu sleep", it sleeps and resumes fine.

Also, if I sleep from X by running "pbbcmd sleep", it runs /etc/power/suspend.d/console-switch-out and sleeps and resumes okay, but for some reason /etc/power/resume.d/console-switch-in is not being run and so after wakeup I have to switch back to vt7 by hand.

But if I try and sleep just by closing the lid, I get the backlight switching on after it goes to sleep, and the machine dies on resume.

Am I correct in thinking that the /etc/power scripts are called from userspace by pbbuttonsd or pmud? So if the PMU ioctl is being called by some other process, those scripts will not necessarily be run?

I think it's gnome-power-manager which is handling the lid-close event, and not running the scripts. So I just need to find out where to hook into there to do the vt switch. I suspect it's happening in /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux; if that's the case it should be a piece of cake to fix.

Revision history for this message
John Steele Scott (toojays) wrote :

This patch mostly fixes it for me . . . I can now confidently close the lid to suspend, and open it without a crash.

The only issue is that the call to chvt after resume does not always work, so sometimes I need to switch vts manually. But it sure beats having the machine lock-up.

Revision history for this message
Benjamin Herrenschmidt (benh-kernel) wrote :

Are env. variables preserved between invocations of the script ? they are on ACPI scripts but not on /etc/power scripts afaik, which is why my proposed pair of scripts does this hack with a temp file. You might simply be missing your CONSOLE variable on the way back...

I find it a bit disturbing that we end up having at least now 3 or 4 different sleep mechanisms using different sets of scripts.

I especially wonder what kind of conflict do we end up with having both pbbuttonsd and that gnome thing trying to do it.

Revision history for this message
Steven Walter (stevenrwalter) wrote :

The patch posted by John Steele Scott fixes the resume issue I had.

Revision history for this message
b (ben-ekran) wrote :

I'm having this same problem on my powerbook 5,2 gutsy.

Some extra observations:

/usr/lib/hal/hal-system-power-pmu sleep

Does seem to work in all cases, except when the GDM screen is formost (tested by using sleep to have the command issued after I've switched to VT7.)

Running "suspend" from the GDM actions menu does nothing, and I see this in the syslog:

Nov 20 17:08:12 localhost gdm[9409]: WARNING: Request for configuration key daemon/SuspendCommand=, but not type STRING

Any ETA and when the patch above will be in the repos so I can update? I'd also much rather have been bumped to another VT than have the machine hang after suspend.

Thanks,

Revision history for this message
Benjamin Herrenschmidt (benh-kernel) wrote :

Some notes:

 - APM emu is broken in recent kernels, so that's why that part doesn't work, but it isn't a big issue here
 - "Fixing" HAL is not really useful as we want something more like x86 where it's done by the suspend
   & resume scripts and works always, not only when HAL is there. I would suggest using the example
   script I posted, it works fine
 - This has been open for some time and the fix is still not in...

Revision history for this message
fuoco (fuoco2-deactivatedaccount) wrote :

This doesn't seem to be fixed in hardy. Moreover in hardy I cannot suspend at all - it's no longer an option in gnome-power-manager. also according to pm-is-suspend suspend is unavailable. if i manually suspend it does work - but of course doesn't resume because of this problem.

Revision history for this message
ScottMiller (stmiller) wrote :

This is a rather critical bug still present in hardy alpha. Should this be assigned to the kernel team? Anyone know?

Revision history for this message
John Steele Scott (toojays) wrote :

I just assumed it wasn't assigned to anyone because powerpc is no longer a supported architecture.

Revision history for this message
ScottMiller (stmiller) wrote :

PowerPC no longer has commercial paid support from Canonical. That is the only thing that was dropped.
It is still a supported architecture as far as making Ubuntu releases for the public.

Revision history for this message
Jonathan Hudson (jh+lpd) wrote :

Similar issues of a G4 powerbook. In my experience, gnome-power-manager is a disaster on ppc. Deleting /usr/bin/gnome-power-manager and letting pbbuttonsd handle power management makes for stable suspend / resume, albeit with a VT switcher in /etc/power/{suspend.d,resume.d}.

A consensus on how to arbitrate between pbbuttonsd / g-p-m is solicited; I really don't like that two things fighting over power management.

Revision history for this message
Nolan (kijiki0) wrote :

Just a note for people who find this by search:
In Hardy, I've found that you must now kill/delete hald-addon-pmu instead of gnome-power-manager.

Combined with BenH's /etc/power scripts, suspend/resume by closing the lib now appears to work reliably.

Revision history for this message
Andreas Moog (ampelbein) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. The issue that you reported is one that should be reproducible with the live environment of the Desktop CD of the development release - Jaunty Jackalope. It would help us greatly if you could test with it so we can work on getting it fixed in the next release of Ubuntu. You can find out more about the development release at http://www.ubuntu.com/testing/. Thanks again and we appreciate your help.

summary: - [gutsy] sleep on powerbook crashes
+ sleep on powerbook crashes
affects: ubuntu → linux (Ubuntu)
Changed in linux (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Colin Ian King (colin-king) wrote :

Unfortunately it seems this bug is still probably an issue. Can you confirm this issue exists with the most recent Jaunty Jackalope 9.04 release - http://www.ubuntu.com/news/ubuntu-9.04-desktop . Please let us know your results. Thanks.

Changed in linux (Ubuntu):
assignee: nobody → colin-king
Revision history for this message
Jonathan Hudson (jh+lpd) wrote :

Sadly, if works fine in 9.04 for me!

-jh

Revision history for this message
Colin Ian King (colin-king) wrote :

Anyone else like to comment if this problem now is fixed with Jaunty 9.04? If so, I suspect we can mark this as now fixed.

Revision history for this message
Philip Hale (phil989) wrote :

Still doesn't work for me in Jaunty. Running 2.6.28-6-powerpc on a mid 2005 12" iBook G4.

Revision history for this message
clewis (cl-functionx) wrote :

This is still a problem for me in Jaunty.

Additional things I've noted are that gnome does not display a suspend option, and 'lshal' reports that 'power_management.can_suspend' is false (which, I think, explains gnome not offering a suspend option). What seems interesting about this is that other threads have reported that these machines do not support hibernating, an option that gnome does offer, but that they do support sleep/suspend to ram. Manually setting 'power_management.can_suspend' to true and then using gnome's suspend functionality just "flashes" the screen and then presents a logon screen. If I switch to a virtual terminal and run either '/usr/lib/hal/hal-system-power-pmu sleep' or 'pbbcmd sleep' the same thing happens: the screen blanks, but the machine does not go to sleep.

/proc/version:
Linux version 2.6.28-6-powerpc (buildd@adare) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #20-Ubuntu Fri Apr 17 08:30:40 UTC 2009

/proc/cpuinfo:
processor : 0
cpu : 7447A, altivec supported
clock : 1333.333000MHz
revision : 1.1 (pvr 8003 0101)
bogomips : 73.47
timebase : 18432000
platform : PowerMac
model : PowerBook6,4
machine : PowerBook6,4
motherboard : PowerBook6,4 MacRISC3 Power Macintosh
detected as : 287 (PowerBook G4 12")
pmac flags : 0000001a
L2 cache : 512K unified
pmac-generation : NewWorld
Memory : 512 MB

Changed in linux (Ubuntu):
status: Incomplete → In Progress
Revision history for this message
Colin Ian King (colin-king) wrote :

@Philip Hale, @clewis,

Can you confirm this issue exists with the most recent Karmic Koala 9.10 Alpha release. ISO CD images are available at http://cdimage.ubuntu.com/releases/karmic/ . If the issue remains with Karmic it would be great to then also test the latest upstream mainline kernel available. This will allow additional upstream developers to examine this issue. Refer to https://wiki.ubuntu.com/KernelMainlineBuilds. Thanks!

Revision history for this message
Colin Ian King (colin-king) wrote :

Correction: Make that Karmic Koala 9.10 Beta release.

Changed in linux (Ubuntu):
status: In Progress → Incomplete
Revision history for this message
Albertas Agejevas (alga) wrote :

Suspend hangs on a clean install of Karmic release on a Powerbook G4 (with ATI Radeon Mobility 9600). I get a pattern of white vertical lines every 8(?) pixels on black, machine stops responding to pings.

Revision history for this message
Colin Ian King (colin-king) wrote :

@Albertas, which ATI driver are you using? The open source one or the binary driver?

Revision history for this message
Albertas Agejevas (alga) wrote :

Colin, I downgraded the kernel to the one from Jaunty and now suspend works perfectly. On the older kernel the driver is definitely the open source one. I did not install any closed source drivers beside the Broadcom Wifi firmware extractor.

Revision history for this message
Vikram Dhillon (dhillon-v10) wrote :

It looks like the patch noted in patch for hal-system-power-suspend-linux: switch to text-mode VT before invoking PMU sleep to resolve this issue has already been included and released in Ubuntu Karmic. As a result I'm marking this bug Fix Released. Thanks.

Changed in linux (Ubuntu):
status: Incomplete → Fix Released
Revision history for this message
VirtualWolf (w-launchpad-virtualwolf-sneakemail-com) wrote :

I'm still seeing this on my original 800MHz iBook G4, running 9.10. The Live CD I ran and installed from was Xubuntu, I don't know how much of a difference that makes. Close the lid, the sleep light comes on after a while, but upon opening the lid again the machine turns off totally.

Revision history for this message
Benjamin Herrenschmidt (benh-kernel) wrote : Re: [Bug 144305] Re: sleep on powerbook crashes

On Wed, 2010-04-07 at 01:47 +0000, VirtualWolf wrote:
> I'm still seeing this on my original 800MHz iBook G4, running 9.10. The
> Live CD I ran and installed from was Xubuntu, I don't know how much of a
> difference that makes. Close the lid, the sleep light comes on after a
> while, but upon opening the lid again the machine turns off totally.

Sadly, I don't have one of those machines at hand, so it's very hard for
me to test or try to figure out what's wrong :-(

Cheers,
Ben.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.