Bug 151789

Summary: Battery module is missing suspend/resume functions
Product: [openSUSE] openSUSE 10.2 Reporter: Bjoern Jacke <bjacke>
Component: KernelAssignee: Thomas Renninger <trenn>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: vincenzo_ml
Version: Alpha 1   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Bjoern Jacke 2006-02-17 13:04:43 UTC
when I remove the 2nd battery from a IBM X31 while it's suspended, this is not noticed by the acpi battery module. Instead it shows critical state:

bjacke@pell:~> cat /proc/acpi/battery/BAT2/state
present:                 yes
capacity state:          critical
charging state:          charged
present rate:            0 mW
remaining capacity:      0 mWh
present voltage:         0 mV
bjacke@pell:~> cat /proc/acpi/battery/BAT2/info
present:                 yes
design capacity:         unknown
last full capacity:      unknown
battery technology:      rechargeable
design voltage:          10800 mV
design capacity warning: 0 mWh
design capacity low:     0 mWh
capacity granularity 1:  1 mWh
capacity granularity 2:  1 mWh
model number:            IBM-02K7043
serial number:              40
battery type:            LION
OEM info:                SANYO

plugging in the second battery then again BAT0 shows correctly:

pell:~ # cat /proc/acpi/battery/BAT2/info
present:                 no

but then kpowersave does not notice that BAT2 went to state "present: no" and shows a 0% charged 2nd battery and a 50% overall charge (do you want for this kpowersave bug a second bugzilla entry?)
Comment 1 Bjoern Jacke 2006-02-17 13:06:24 UTC
sorry, I meant
...
plugging in the second battery AND REMOVING AGIN then again BAT0 shows correctly:
present:                 no
Comment 2 Thomas Renninger 2006-02-22 18:18:36 UTC
No, you do not need to open a separate bug.

It is known that ACPI modules lack suspend/resume functions, this is one of the symptoms. There has work been done recently, I ask whether there is already some outcome.
Comment 3 Thomas Renninger 2006-04-21 20:48:20 UTC
There won't be any progress for 10.1/SLED 10.
This should be one of the major enhancements of moving ACPI stuff to sysfs, but this may still take some kernel versions.
Comment 4 Thomas Renninger 2006-05-16 16:01:19 UTC
There is progress...
I found a general ACPI suspend patch and a fan suspend patch from Konstantin.
I added a resume method for battery, if it works for you, maybe we can still add this stuff to SLES/SLED10, maybe even backport to 10.1.

You find a kernel rpm to test here:
ftp.suse.com/pub/people/trenn/10.1_kernel_with_acpi_suspend_functions/kernel-default-2.6.16.16-7.i586.rpm
(may take some hours, until it is synced and pops up there).
Comment 5 Bjoern Jacke 2006-05-17 10:39:30 UTC
Okay, tested that kernel: I plugged in the second battery while system, the battery did not appear in /proc/acpi/battery/ 
...rebooted, so that both batteries are known by Linux, suspend to RAM - but this kernel makes my X31 never wake up again, no matter if batteries are being changed during suspend or not. I did not try suspend to Disk after this, if you really also want the result of a suspend to disk test I can do that some time later ...
Comment 6 Thomas Renninger 2006-05-23 10:12:11 UTC
I think I know why...
I also had the patch from:
http://bugzilla.kernel.org/show_bug.cgi?id=5534
applied.
Last message from a tester:
"I tried Alexey Starikovskiy patch it seems that suspend to ram does not work
anymore."

I built another kernel with only the ACPI suspend patches applied:
ftp.suse.com/pub/people/trenn/10.1_kernel_with_acpi_suspend_functions_new
(be aware of the "_new" at the end without, the ftp mirror has not been synced yet and you might have to wait for some hours...).
Does this fix the problem of exchanging batteries while suspended?
If you should still have problems with suspend to disk/ram, please try the kernel of the day (without the ACPI suspend patches):
ftp.suse.com/pub/projects/kernel/kotd/i386/HEAD/kernel-default.i586.rpm

Like that we should know whether these new patches are the culprit or whether there is already another bug in our current kernel...
Thanks.
Comment 7 Thomas Renninger 2006-05-23 10:41:10 UTC
Increasing severity at least to normal, as there are patches that address this and these patches seem not too intrusive, we still might want to add them...

CC'ing Pavel, he should finally decide when/whether we want to add the ACPI suspend patches.
Pavel: I don't find the bug no. right now, you should also be in CC (bugzilla.kernel.org?). It's one patch for general ACPI suspend/resume (from Konstantin? The patches have no signed-off...) methods and one patch adding suspend/resume methods for fan. I also added a little resume function for ACPI battery device. Could you point me to that bug or CC me, I really can't find it right now anymore, sorry...
This one:
http://bugzilla.kernel.org/show_bug.cgi?id=2571
should be a duplicate...
Comment 8 Pavel Machek 2006-05-23 11:02:31 UTC
As (almost) everything acpi related, it will probably fix battery detection on some system and break boot on some other systems. No, patches probably are not too intrusive, but we definitely want them tested in mainline, first. I bet there _will_ be some nasty side effects.

This is variant of "don't change your hardware while suspended", and yes we probably want to fix it, but no, I do not think we want to fix it now.
Comment 9 Thomas Renninger 2006-06-08 09:55:35 UTC
*** Bug 179417 has been marked as a duplicate of this bug. ***
Comment 10 Vincenzo Ciancia 2006-09-06 09:23:17 UTC
I have a similar problem: I made powersaved remove the "ac" module before suspend and insert it after resume; this works and in /proc/acpi I can correctly see the ac status to be offline, but kpowersave won't reset its state nor change profile (thus won't automatically suspend on battery low and this caused some unwanted poweroff of the laptop), even if killed, until I do /etc/init.d/powersaved restart.

But, the strangest, powersave -a will show the correct information, i.e. that AC is unplugged. Don't really know how this works.
Comment 11 Thomas Renninger 2006-09-11 23:53:43 UTC
Comment #10 is probably unrelated to the rest of the bug and could also be a  userspace problem (hald, powersaved), maybe Danny has already heard about.

For the main problem (battery changes done while suspended are not noticed) I think I posted a patch to acpi-devel list some weeks ago, not sure right now.
I think I will add some suspend/resume functionality to our kernel at least soon and try to repost. Please stay tuned, I still have some other stuff that is more important right now...
Comment 12 Thomas Renninger 2006-12-04 11:15:28 UTC
Pavel and Jeff added a last minute patch to 10.2. This includes battery resume function (I thought current kernels already had it...). Anyway, I let this open until I finally have the stuff for SLE10 SP1 ready and accepted. Hmm, no I better I close it to get back an overview of my bugs, it will not be forgotten for SP1.