Bug 13410 - Switching batteries during suspend gives bogus values for BATx/info
Summary: Switching batteries during suspend gives bogus values for BATx/info
Status: REJECTED INVALID
Alias: None
Product: ACPI
Classification: Unclassified
Component: Power-Battery (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: ykzhao
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-31 08:57 UTC by wilderjds
Modified: 2009-06-18 16:16 UTC (History)
4 users (show)

See Also:
Kernel Version: 2.6.29
Subsystem:
Regression: No
Bisected commit-id:


Attachments
output of acpidump (146.21 KB, text/plain)
2009-05-31 09:56 UTC, wilderjds
Details
acpidump in a normal situation with 12-cell battery (146.21 KB, text/plain)
2009-05-31 13:23 UTC, wilderjds
Details
acpidump output in a normal situation with 6-cell battery (146.21 KB, text/plain)
2009-05-31 20:00 UTC, wilderjds
Details
customized DSDT with more debug info (252.87 KB, application/octet-stream)
2009-06-01 07:55 UTC, Zhang Rui
Details
dsdt for my laptop (29.19 KB, application/octet-stream)
2009-06-17 08:17 UTC, wilderjds
Details

Description wilderjds 2009-05-31 08:57:36 UTC
I have two batteries, a 6-cells and a 12-cells; I suspended to ram (tuxonice) with the 6-cells, plugged in the AC-adaptor, switched to the 12-cells (which was nearly empty), when it was fully charged I resumed and this is what I obtain:

# cat /proc/acpi/battery/BAT0/state
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            0 mA
remaining capacity:      7223 mAh
present voltage:         11705 mV

# cat /proc/acpi/battery/BAT0/info
present:                 yes
design capacity:         5100 mAh
last full capacity:      2507 mAh
battery technology:      rechargeable
design voltage:          10800 mV
design capacity warning: 125 mAh
design capacity low:     87 mAh
capacity granularity 1:  38 mAh
capacity granularity 2:  2382 mAh

Notice that the design capacity should be 8800 mAh
Comment 1 ykzhao 2009-05-31 09:45:10 UTC
Will you please attach the output of acpidump?

It will be great if you can attach the output of "cat /proc/acpi/battery/BAT0/*" while booting with the different battery.
Thanks.
Comment 2 wilderjds 2009-05-31 09:56:35 UTC
Created attachment 21655 [details]
output of acpidump

I'll attach cat BAT0/* with different batteries as soon as I will switch them again in ~2-3 hours. If the bogus values will persist, I'll do a fresh reboot and attach the output again
Comment 3 wilderjds 2009-05-31 13:23:37 UTC
Created attachment 21657 [details]
acpidump in a normal situation with 12-cell battery

After one more suspend to RAM/resume cycle everything is back to normal;  

# cat /proc/acpi/battery/BAT0/*
alarm:                   unsupported
present:                 yes
design capacity:         8800 mAh
last full capacity:      8765 mAh
battery technology:      rechargeable
design voltage:          10800 mV
design capacity warning: 435 mAh
design capacity low:     304 mAh
capacity granularity 1:  131 mAh
capacity granularity 2:  8330 mAh
model number:            Primary
serial number:
battery type:            LION
OEM info:                Hewlett-Packard
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            0 mA
remaining capacity:      2615 mAh
present voltage:         10618 mV

The attached file is the output of acpidump in this (normal) situation
Comment 4 wilderjds 2009-05-31 13:28:12 UTC
ykzhao: do you need more infos?
Comment 5 wilderjds 2009-05-31 20:00:36 UTC
Created attachment 21669 [details]
acpidump output in a normal situation with 6-cell battery

# cat /proc/acpi/battery/BAT0/*

alarm:                   unsupported
present:                 yes
design capacity:         5100 mAh
last full capacity:      2507 mAh
battery technology:      rechargeable
design voltage:          10800 mV
design capacity warning: 125 mAh
design capacity low:     87 mAh
capacity granularity 1:  38 mAh
capacity granularity 2:  2382 mAh
model number:            Primary
serial number:
battery type:            LION
OEM info:                Hewlett-Packard
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            0 mA
remaining capacity:      1481 mAh
present voltage:         11366 mV

It appears that when the battery is switched during a suspend/resume cycle, the acpi module does not (obviously) get the proper event and it does not query the battery on resume, so that the old values are still reported and used.
Comment 6 ykzhao 2009-06-01 01:43:10 UTC
Is the battery info correct if you switch the battery while the system is in working state?
   Thanks.
Comment 7 wilderjds 2009-06-01 07:46:56 UTC
Yes, I did not reboot to obtain the previous outputs.
I plugged in the ac adaptor and switched batteries.
Thanks
  Jacopo
Comment 8 Zhang Rui 2009-06-01 07:51:49 UTC
this is part of the _BST AML code
                        ...
                            If (LEqual (Local0, 0x00))
                            {
                                Return (Arg3) /* this is the right value */
                            }
                        ...
                        Store (Local0, Index (Arg3, 0x00))
                        Store (0x00, Index (Arg3, 0x01)) /* the "present rate" is cleared */
                        Store (Local2, Index (Arg3, 0x02))
                        Store (Local3, Index (Arg3, 0x03))
                        Return (Arg3)

so I suspect that the _BST runs different code path when battery is changed during suspend.
Comment 9 Zhang Rui 2009-06-01 07:55:13 UTC
Created attachment 21680 [details]
customized DSDT with more debug info

please apply this custom DSDT, set CONFIG_ACPI_DEBUG,
rebuild your kernel and boot with acpi.debug_layer=0xffffffff, acpi.debug_level=0x07
please attach the dmesg output after
1. resume without battery change
2. the first resume with battery change
3. the second resume with battery change
Comment 10 wilderjds 2009-06-04 11:51:29 UTC
I've been traveling for the past few days, I'll test as requested as soon as I am able to. thx
Comment 11 Zhang Rui 2009-06-17 03:12:29 UTC
ping wilderjds, any updates?
Comment 12 wilderjds 2009-06-17 08:17:06 UTC
Sorry for the delay, I've been quite busy in the last weeks.
I am confused about the customized dsdt; In particular why should the provided dsdt work on my machine? I thought they were OEM specific;
In case you want to have a look at it, I attach here my dsdt.dat obtained with 

# acpidump --table DSDT -b -o dsdt.dat

Zhang Rui, could you please provide your original AND patched dsdt.dsl so that I can try and patch my DSDT accordingly?

Thanks
Comment 13 wilderjds 2009-06-17 08:17:50 UTC
Created attachment 21961 [details]
dsdt for my laptop
Comment 14 Zhang Rui 2009-06-18 02:00:56 UTC
you have already attached your acpidump in this bug report, and that's why I can get your DSDT table.
the custom DSDT attached in comment #9 is made based on your dsdt table, so please feel free to apply it. :)
Comment 15 wilderjds 2009-06-18 10:10:57 UTC
ok thanks, and sorry for the dumb comment :P
Comment 16 Len Brown 2009-06-18 16:16:09 UTC
This bug appears to be filed against tux-on-ice hibernate.

But bugzilla.kernel.org is for the upstream kernel,
which does not contain tux-on-ice.

So there are two paths forward:
1. report this to the tux-on-ice developers at http://www.tuxonice.net/
2. reproduce this issue using the upstream kernel
   and re-open this bug report.

Note You need to log in before you can comment on or make changes to this bug.