Bug 15867 - Battery state not reported correctly
Summary: Battery state not reported correctly
Status: REJECTED DOCUMENTED
Alias: None
Product: ACPI
Classification: Unclassified
Component: Power-Battery (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Zhang Rui
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-28 07:28 UTC by arond
Modified: 2010-05-31 09:32 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.34-rc5-19-pae
Subsystem:
Regression: No
Bisected commit-id:


Attachments
acpidump output (94.88 KB, text/plain)
2010-04-28 21:12 UTC, arond
Details
dmesg output right after booting without the battery (53.51 KB, text/plain)
2010-04-28 21:15 UTC, arond
Details
contents of /proc/acpi/battery (1.30 KB, text/plain)
2010-04-28 21:21 UTC, arond
Details
custom DSDT (169.59 KB, application/octet-stream)
2010-05-11 08:24 UTC, Zhang Rui
Details
custom DSDT source code (172.34 KB, application/octet-stream)
2010-05-11 09:10 UTC, Zhang Rui
Details

Description arond 2010-04-28 07:28:38 UTC
At boot: 

When I boot up without the battery in my laptop the kernel reports that the battery is still there and that it is empty (charged at 0%). Coming back from suspend to ram or suspend to disk will cause the detection that the battery is not present.

Also:

When it is AC adaptor-no battery state is correctly detected, if i go to suspend, insert the battery, disconnect the adaptor, and come back from suspend, kernel doesn't detect the new battery-only state. Pluging and unplugging the AC adaptor fixes it.


This problem has been happening for as long as i can remember (2.6.27...?). The main implication concerns that the power-saving mechanisms are not turned on when the battery presence is misdetected.

Let me know if i can be any help attaching other infos...
Comment 1 Alexey Starikovskiy 2010-04-28 09:13:43 UTC
Could you please check more recent kernel, say 2.6.34-rcX?
Comment 2 arond 2010-04-28 10:42:48 UTC
sorry, spelling mistake on kernel version. im actually on 2.6.34-rc5 and not 2.6.24
Comment 3 Alexey Starikovskiy 2010-04-28 13:12:18 UTC
Please provide acpidump and dmesg outputs.
Please append the output of "grep . /proc/battery/*/*"
Comment 4 arond 2010-04-28 21:12:35 UTC
Created attachment 26175 [details]
acpidump output
Comment 5 arond 2010-04-28 21:15:06 UTC
Created attachment 26176 [details]
dmesg output right after booting without the battery
Comment 6 arond 2010-04-28 21:21:51 UTC
Created attachment 26177 [details]
contents of /proc/acpi/battery

Note that this correspond to a moment when the battery is present and therefore correctly detected.

if i try to run "grep . /proc/acpi/battery/*/*" when the battery is misdetected (battery is not present but acpi has initially considered it is -like shown in the dmesg output ive attached), that automaticly causes the lack of battery to be detected, giving the following correct output:

/proc/acpi/battery/BAT0/alarm:present:                 no
/proc/acpi/battery/BAT0/info:present:                 no
/proc/acpi/battery/BAT0/state:present:                 no

My battery monitor changes its icon to "AC adaptor only" right at that moment.
Comment 7 Zhang Rui 2010-05-11 08:22:04 UTC
BATS is set unconditionally in _REG method, even if the battery is not present at the moment.
This is wrong, IMO, AML code should reset the BATS value based on PCI0.LPC.EC0.ESTS, once the EC operegion can be accessed,

we can re-write the BAT0._STA method like:
            Name (BATT, Zero)
            Method (_STA, 0, NotSerialized)
            {
                If (LEqual(BATT, Zero))
                {
                    Store (\_SB.PCI0.LPC.EC0.ESTS, Local0)
                    If (LEqual (And (Local0, 0x08), 0x08))
                    {
                       Store (One, BATS)
                    }
                    Else
                    {
                       Store (Zero, BATS)
                    }
                    Store (One, BATT)
                }

                If (ECON)
                {
                    If (BATS)
                    {
                        Return (0x1F)
                    }
                    Else
                    {
                        Return (0x0F)
                    }
                }
                Else
                {
                    Return (0x0F)
                }

                Return (0x0F)
            }
Comment 8 Zhang Rui 2010-05-11 08:24:09 UTC
Created attachment 26332 [details]
custom DSDT

please try this custom DSDT and see if the problem still exists.
To override a DSDT, you can follow step 5, 6, and 7 at http://www.lesswatts.org/projects/acpi/overridingDSDT.php
Comment 9 arond 2010-05-11 09:06:21 UTC
Please, could you provide a DSTD built with "iasl -ta" so I can try it with the initrd method? or just the DSTD.dsl. Thanks
Comment 10 Zhang Rui 2010-05-11 09:10:49 UTC
Created attachment 26333 [details]
custom DSDT source code

dsdt.dsl attached. :)
Comment 11 Zhang Rui 2010-05-11 09:14:46 UTC
(In reply to comment #9)
> Please, could you provide a DSTD built with "iasl -ta" so I can try it with
> the
> initrd method? or just the DSTD.dsl. Thanks

BTW, I'm wondering how you can use the initrd method as it's not supported in Linux kernel any more... :)
Comment 12 arond 2010-05-11 09:25:59 UTC
(In reply to comment #11)
> (In reply to comment #9)
> > Please, could you provide a DSTD built with "iasl -ta" so I can try it with
> the
> > initrd method? or just the DSTD.dsl. Thanks
> 
> BTW, I'm wondering how you can use the initrd method as it's not supported in
> Linux kernel any more... :)

Is it not? It looked like a too easy, time-saving way... Did it work back in 2.6.27? I can try on that one...

In any case, iasl complains:

Intel ACPI Component Architecture
ASL Optimizing Compiler version 20100428 [May 11 2010]
Copyright (c) 2000 - 2010 Intel Corporation
Supports ACPI Specification Revision 4.0a

DSDT.dsl  1234:                             And (CAPB, 0xFFFFFFFC)
Warning  1106 -                                     ^ Result is not used, operator has no effect

DSDT.dsl  1419:                     0x00000000,         // Length
Error    4122 -                              ^ Invalid combination of Length and Min/Max fixed flags

ASL Input:  DSDT.dsl - 5119 lines, 176479 bytes, 2194 keywords
Compilation complete. 1 Errors, 1 Warnings, 0 Remarks, 33 Optimizations
Comment 13 Zhang Rui 2010-05-12 02:09:35 UTC
please try "iasl -ta -cr DSDT.dsl"
Comment 14 Zhang Rui 2010-05-19 06:45:37 UTC
ping ...
Comment 15 arond 2010-05-19 08:45:01 UTC
eh, i have been away last week, but will take care of this in the next few days. I haven't forgotten dont worry (the battery monitor reminds me everyday :) )
Comment 16 arond 2010-05-29 18:55:45 UTC
Hi, your custom DSDT seems to fix the problem. :) can the patch be included in the mainline? thank you!
Comment 17 Zhang Rui 2010-05-31 03:15:16 UTC
No, :(
If the custom DSDt works for you, this means that this is an AML code logic error, rather than a Linux/kernel/ACPI problem.
So I'm afraid there is nothing we can do in Linux kernel.

As this bug should also affect Windows, would you please check if there is any new BIOS released for your laptop? as this is the only way to fix the problem. :(
Comment 18 arond 2010-05-31 09:32:19 UTC
Ok thanks for everything anyway. Just in case someone's googling for this:

vendor: MALATA
model: PC-81005

Though it has been sold under different brands like BluSens...
and its not the first BIOS-related problem showing up (https://bugs.freedesktop.org/show_bug.cgi?id=25523)

hoping its the last :)

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