Bug 11126 - ac_adapter: boot state off-line, e2fsck never checks partitions
Summary: ac_adapter: boot state off-line, e2fsck never checks partitions
Status: CLOSED CODE_FIX
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: 2008-07-19 14:53 UTC by Sebastian Kemper
Modified: 2008-07-27 22:17 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.26
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
acpidump.txt (83.54 KB, text/plain)
2008-07-19 14:54 UTC, Sebastian Kemper
Details
dmesg-s64000.txt (13.85 KB, text/plain)
2008-07-19 14:55 UTC, Sebastian Kemper
Details
Try the customed DSDT (1.45 KB, patch)
2008-07-25 02:03 UTC, ykzhao
Details | Diff
dmesg-default-dsdt.txt.bz2 (8.42 KB, application/octet-stream)
2008-07-25 10:02 UTC, Sebastian Kemper
Details
try the custom DSDT (169.73 KB, patch)
2008-07-27 05:29 UTC, ykzhao
Details | Diff
dmesg-ykzhao.txt.bz2 (8.92 KB, application/octet-stream)
2008-07-27 09:09 UTC, Sebastian Kemper
Details

Description Sebastian Kemper 2008-07-19 14:53:32 UTC
Latest working kernel version: unknown, maybe not a regression
Earliest failing kernel version:
Distribution: Gentoo
Hardware Environment: Acer Aspire 2000 Laptop
Software Environment:
Problem Description:

Hi all,

when booting my laptop the state of the ac_adapter appears to be off. I think it's off because when e2fsck is called (and when the time for a file system check has come) it defers the check thinking the laptop's running on battery.

I put

[options]
defer_check_on_battery = false

in /etc/e2fsck.conf but that means that the check will happen anyway, but I like the idea of the defer_check_on_battery feature and would like to use it.

Is there something that can be done to set the state of ac_adapter earlier?

Kind regards
Sebastian
Comment 1 Sebastian Kemper 2008-07-19 14:54:56 UTC
Created attachment 16892 [details]
acpidump.txt
Comment 2 Sebastian Kemper 2008-07-19 14:55:54 UTC
Created attachment 16893 [details]
dmesg-s64000.txt
Comment 3 ykzhao 2008-07-25 01:59:53 UTC
Hi, Sebastian
    Do you mean that the AC adapter appears to be off although it is present?
    From the attached acpidump it seems that it is related with the bios.
    The status of AC adapter is gotten by evaluating the following object(_PSR)
   > Method (_PSR, 0, NotSerialized)
                  {
                        If (LAnd (\_SB.PCI0.LPC0.EC0.ECOK, LEqual (ECDY, 0x00)))
                        {
                            If (\_SB.PCI0.LPC0.EC0.BTCH)
                            {
                                Return (0x01)
                            }

                            If (\_SB.PCI0.LPC0.EC0.BDCH)
                            {
                                Return (0x00)
                            }

                            Return (0x01)
                        }
                        Else
                        {
                            Return (0x00)
                        }
                    }
      In the boot phase the initial value of ECDY is 0x03. In such case the _PSR object will return 0, which means that ac adapter is absent.
     If ECDY is decreased to zero in the _BST object of battery device, the _PSR ojbect can return the correct status of AC adapter. 
     >Method (_BST, 0, NotSerialized)
                    {
                        Store ("==Main Battery Status _BST==", Debug)
                        If (LGreater (ECDY, 0x00))
                        {
                            Decrement (ECDY)
                            Notify (\_SB.PCI0.LPC0.BAT1, 0x81)
                        }
     
     Will you please check whether the AC adapter is still off after catting /proc/acpi/battery/BAT1/states several times? (At lease three times).
     
     Thanks.
Comment 4 ykzhao 2008-07-25 02:03:40 UTC
Created attachment 16983 [details]
Try the customed DSDT

Will you please try the custom DSDT to see whether the status of AC adapter is correct?
How to use the custom DSDT can be found in 
http://www.lesswatts.org/projects/acpi/faq.php

Will you please attach the output of dmesg?

Thanks.
Comment 5 Sebastian Kemper 2008-07-25 09:07:33 UTC
Hello ykzhao,

whenever I cat the state file _after_ booting the ac_adapter is indicated as present:

sk@jigsaw:/proc/acpi/battery/BAT1$ cat /proc/acpi/battery/BAT1/state 
present:                 yes
capacity state:          ok
charging state:          charged
present rate:            0 mA
remaining capacity:      2218 mAh
present voltage:         16574 mV
sk@jigsaw:/proc/acpi/battery/BAT1$ cat /proc/acpi/ac_adapter/ACAD/state 
state:                   on-line

With regards to the DSDT please give me a while. I switched to Ubuntu a few days ago and I have to figure out how to foist a modified DSDT on the Ubuntu kernel.

Anyway, thanks for taking the time!

Kind regards
Sebastian
Comment 6 Sebastian Kemper 2008-07-25 09:49:35 UTC
Is that a complete DSDT? The ones I looked at earlier were "bigger" ...
Comment 7 Sebastian Kemper 2008-07-25 10:02:53 UTC
Created attachment 16988 [details]
dmesg-default-dsdt.txt.bz2

Here's my dmesg output with the default DSDT. When the ac adapter ACPI driver is loaded the initial state is off-line although the adapter is plugged in and powered:

bzcat dmesg-default-dsdt.txt.bz2 |grep -i adap
[   24.433369] ACPI: AC Adapter [ACAD] (off-line)
Comment 8 Sebastian Kemper 2008-07-27 04:53:53 UTC
With Gentoo I only had had to change the file /etc/e2fsck.conf. With Ubuntu I had to work around two init script hooks in /etc/init.d/checkroot.sh and /etc/init.d/checkfs.sh that call the script "on_ac_power" (which of course says that my laptop isn't running on AC although it is). :p
Comment 9 ykzhao 2008-07-27 05:29:47 UTC
Created attachment 16999 [details]
try the custom DSDT

Sorry that I attached the incorrect file. It should be DSDT.dsl but I attached DBGP.dsl.
Will you please try again?
Thanks.
Comment 10 Sebastian Kemper 2008-07-27 09:09:29 UTC
Created attachment 17001 [details]
dmesg-ykzhao.txt.bz2

Hello Yakui,

thanks! Tried your DSDT and now it works, status for the ac adapter is correct while plugged _and_ unplugged.

Is this something that could go into the mainline kernel as a quirk so anybody who wants the fix doesn't have to setup a fixed DSDT?

Kind regards
Comment 11 Zhang Rui 2008-07-27 18:38:54 UTC
Method (_BST, 0, NotSerialized)
                    {
                        Store ("==Main Battery Status _BST==", Debug)
                        If (LGreater (ECDY, 0x00))
                        {
                            Decrement (ECDY)
                            Notify (\_SB.PCI0.LPC0.BAT1, 0x81)
                        }

IMO, the value of ECDY is really meaningless in this BIOS, and we can reset it to 0 freely.
But I'm afraid it's hard to get it fixed in the upstream kernel as
1. it's a BIOS issue.
2. a possible workaround is to evaluate _BST method for 3 times when Linux tries to get the AC state for the first time. but unfortunately mixing up two drivers won't be accepted by upstream kernel. :(

so please make sure if you're using the latest BIOS release.
If yes, either you can use the customized DSDT or Yakui can generate a patch for you to workaround this issue, which will not be upstream.
Comment 12 ykzhao 2008-07-27 19:21:30 UTC
Hi, Sebastian
    Thanks for the test.
    Now it is very clear that it is a BIOS issue . And what Rui said in comment #11 is  right. Mixing up two drivers won't be accepted by upstream kernel.
    
    This bug had better be fixed by upgrading BIOS. Of course you can use the custom DSDT or read the status of the battery three times in init script(the time interval between two reading is at least 1 second). IMO it is not reasonable to fix it by workaround patch.
    Thanks.
Comment 13 Sebastian Kemper 2008-07-27 22:17:07 UTC
Hello Zhang and Yakui!

You're right. It's an old laptop anyway so I guess not many people use it. It is the latest BIOS, but using the fixed DSDT is fine with me. Thanks again for fixing it and taking the time!

Kind regards
Sebastian

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