Bug 12035 - Lack of event when AC adapter is plug out
Summary: Lack of event when AC adapter is plug out
Status: REJECTED INVALID
Alias: None
Product: ACPI
Classification: Unclassified
Component: Power-Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Zhang Rui
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-15 05:08 UTC by Łukasz Wojdyła
Modified: 2009-03-22 07:15 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.27.5-37.fc9.x86_64
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
patch: update AC status in sysfs I/F (885 bytes, patch)
2008-11-16 19:42 UTC, Zhang Rui
Details | Diff
refreshed patch (1.12 KB, patch)
2008-11-17 17:12 UTC, Zhang Rui
Details | Diff
customized DSDT: debug info for EC (328.45 KB, application/octet-stream)
2008-11-24 21:58 UTC, Zhang Rui
Details
customized DSDT: always send AC notifications (328.45 KB, application/octet-stream)
2008-11-30 19:22 UTC, Zhang Rui
Details
acpidump (180.79 KB, text/plain)
2009-03-18 22:34 UTC, Anish Bhatt
Details

Description Łukasz Wojdyła 2008-11-15 05:08:59 UTC
Latest working kernel version: NONE
Earliest failing kernel version: 2.6.25
Distribution: Fedora 9 (All updates installed)
Hardware Environment:
lspci output: http://wklej.org/id/18142/
Software Environment:
lsmod output: http://wklej.org/id/18141/
dmesg output: http://wklej.org/id/18144/
acpidump output: http://wklej.org/id/18154/
Problem Description:
Event "ac_adapter ACAD 00000080 00000000" doesn't appear in output of acpi_listen when I unplug AC adapter. After several plug in and plug out event appears. For example:
battery BAT0 00000080 00000001
battery BAT0 00000081 00000001
ac_adapter ACAD 00000080 00000001
battery BAT0 00000080 00000001
battery BAT0 00000080 00000001
battery BAT0 00000081 00000001
battery BAT0 00000080 00000001
ac_adapter ACAD 00000080 00000001
battery BAT0 00000080 00000001
battery BAT0 00000081 00000001
battery BAT0 00000080 00000001
battery BAT0 00000080 00000001
battery BAT0 00000081 00000001
ac_adapter ACAD 00000080 00000001
battery BAT0 00000080 00000001
ac_adapter ACAD 00000080 00000000
battery BAT0 00000080 00000001

Exept it value of /sys/class/power_supply/ACAD/online is still "1", but value of /proc/acpi/ac_adapter/ACAD/state is "off-line".
My notebook is HP Pavilion dv6700t us.
I have latest BIOS from HP website.
This problem appeared also in Gentoo (gentoo-sources) and ARCH.
Steps to reproduce:
Start up acpi_listen command and plug out AC adapter.
Comment 1 ykzhao 2008-11-16 17:03:41 UTC
From the problemd description it seems that there exists the ACPI event when AC adapter is pluged. The problem is that there is no ACPI event when AC adapter is unplugged.
   Will you please enable the CONFIG_ACPI_DEBUG in kernel configuration and do the following test?
   a. echo 0x030004 >  /sys/module/acpi/parameters/debug_layer ; echo 0x1F > /sys/module/acpi/parameters/debug_level
   b. kill the process which is using the /proc/acpi/event(use the command of "lsof /proc/acpi/event" to get the process ID).
   c. cat /proc/acpi/event >event_log and don't press CTRL+C until the step d is finished
   d. plug/unplug the AC adapter three times
   
   After the test, please attach the output of dmesg, event_log
   Thanks.
    
Comment 2 Zhang Rui 2008-11-16 19:42:15 UTC
Created attachment 18883 [details]
patch: update AC status in sysfs I/F

(In reply to comment #0)
> Exept it value of /sys/class/power_supply/ACAD/online is still "1", but value
> of /proc/acpi/ac_adapter/ACAD/state is "off-line".
AC status in sysfs I/F is not updates in time.
please try this patch to see if this problem is fixed
Comment 3 Łukasz Wojdyła 2008-11-17 15:08:07 UTC
(In reply to comment #1)
> From the problemd description it seems that there exists the ACPI event when
> AC
> adapter is pluged. The problem is that there is no ACPI event when AC adapter
> is unplugged.
>    Will you please enable the CONFIG_ACPI_DEBUG in kernel configuration and
>    do
> the following test?
>    a. echo 0x030004 >  /sys/module/acpi/parameters/debug_layer ; echo 0x1F >
> /sys/module/acpi/parameters/debug_level
>    b. kill the process which is using the /proc/acpi/event(use the command of
> "lsof /proc/acpi/event" to get the process ID).
>    c. cat /proc/acpi/event >event_log and don't press CTRL+C until the step d
> is finished
>    d. plug/unplug the AC adapter three times
> 
>    After the test, please attach the output of dmesg, event_log
>    Thanks.
> 
> 
event_log output: http://wklej.org/id/19147/
dmesg output: http://wklej.org/id/19148/
debug_level: http://wklej.org/id/19149/ (should ACPI_LV_EVENTS be enable?)

I have started up test on 2.6.28-rc5.

(In reply to comment #2)
> Created an attachment (id=18883) [details]
> patch: update AC status in sysfs I/F
> 
> (In reply to comment #0)
> > Exept it value of /sys/class/power_supply/ACAD/online is still "1", but
> value
> > of /proc/acpi/ac_adapter/ACAD/state is "off-line".
> AC status in sysfs I/F is not updates in time.
> please try this patch to see if this problem is fixed
> 
Compilation with this patch on kernels 2.6.28-rc5 and 2.6.27-r5 have failed.
I forgot add, that this error appears only, when the event doesn't appear (I'am sorry).

  CC      drivers/acpi/thermal.o
  CC      drivers/acpi/power.o
  CC      drivers/acpi/system.o
  CC      drivers/acpi/event.o
  CC      drivers/acpi/debug.o
  CC      drivers/acpi/numa.o
  CC      drivers/acpi/cm_sbs.o
  LD      drivers/acpi/built-in.o
  CC [M]  drivers/acpi/ac.o
drivers/acpi/ac.c: In function ‘get_ac_property’:
drivers/acpi/ac.c:107: warning: ISO C90 forbids mixed declarations and code
drivers/acpi/ac.c:111: error: implicit declaration of function ‘acpi_ac_get_state’
drivers/acpi/ac.c: At top level:
drivers/acpi/ac.c:128: error: static declaration of ‘acpi_ac_get_state’ follows non-static declaration
drivers/acpi/ac.c:111: error: previous implicit declaration of ‘acpi_ac_get_state’ was here
make[2]: *** [drivers/acpi/ac.o] Błąd 1
make[1]: *** [drivers/acpi] Błąd 2
make: *** [drivers] Błąd 2
 
Comment 4 Łukasz Wojdyła 2008-11-17 15:26:50 UTC
(In reply to comment #1)
> From the problemd description it seems that there exists the ACPI event when
> AC
> adapter is pluged. The problem is that there is no ACPI event when AC adapter
> is unplugged.
>    Will you please enable the CONFIG_ACPI_DEBUG in kernel configuration and
>    do
> the following test?
>    a. echo 0x030004 >  /sys/module/acpi/parameters/debug_layer ; echo 0x1F >
> /sys/module/acpi/parameters/debug_level
>    b. kill the process which is using the /proc/acpi/event(use the command of
> "lsof /proc/acpi/event" to get the process ID).
>    c. cat /proc/acpi/event >event_log and don't press CTRL+C until the step d
> is finished
>    d. plug/unplug the AC adapter three times
> 
>    After the test, please attach the output of dmesg, event_log
>    Thanks.
> 
> 
event_log output: http://wklej.org/id/19147/
dmesg output: http://wklej.org/id/19148/
debug_level: http://wklej.org/id/19149/ (should ACPI_LV_EVENTS be enable?)

I have started up test on 2.6.28-rc5.

(In reply to comment #2)
> Created an attachment (id=18883) [details]
> patch: update AC status in sysfs I/F
> 
> (In reply to comment #0)
> > Exept it value of /sys/class/power_supply/ACAD/online is still "1", but
> value
> > of /proc/acpi/ac_adapter/ACAD/state is "off-line".
> AC status in sysfs I/F is not updates in time.
> please try this patch to see if this problem is fixed
> 
Compilation with this patch on kernels 2.6.28-rc5 and 2.6.27-r5 have failed.
I forgot add, that this error appears only, when the event doesn't appear (I'am sorry).

  CC      drivers/acpi/thermal.o
  CC      drivers/acpi/power.o
  CC      drivers/acpi/system.o
  CC      drivers/acpi/event.o
  CC      drivers/acpi/debug.o
  CC      drivers/acpi/numa.o
  CC      drivers/acpi/cm_sbs.o
  LD      drivers/acpi/built-in.o
  CC [M]  drivers/acpi/ac.o
drivers/acpi/ac.c: In function ‘get_ac_property’:
drivers/acpi/ac.c:107: warning: ISO C90 forbids mixed declarations and code
drivers/acpi/ac.c:111: error: implicit declaration of function ‘acpi_ac_get_state’
drivers/acpi/ac.c: At top level:
drivers/acpi/ac.c:128: error: static declaration of ‘acpi_ac_get_state’ follows non-static declaration
drivers/acpi/ac.c:111: error: previous implicit declaration of ‘acpi_ac_get_state’ was here
make[2]: *** [drivers/acpi/ac.o] Błąd 1
make[1]: *** [drivers/acpi] Błąd 2
make: *** [drivers] Błąd 2
 
Comment 5 Zhang Rui 2008-11-17 17:12:44 UTC
Created attachment 18900 [details]
refreshed patch

please try this one. :)
Comment 6 ykzhao 2008-11-17 17:39:19 UTC
Hi, Lukasz
    Thanks for the test. From the event_log in comment #3 it seems that the AC event is reported correctly after the AC adapter is plugged out.
    What is the problem about your laptop? Is no AC event reported after unplugging the AC adapter? 
    Or the problem is that the AC status can't be reflected by the sys I/F interface? In fact this issue will exist only when sometimes no AC event is reported. Of course the issue can be fixed by the patch in comment #5.
    Will you please confirm the problem again?
    Thanks.
    
    
Comment 7 Łukasz Wojdyła 2008-11-18 03:14:37 UTC
(In reply to comment #5)
> Created an attachment (id=18900) [details]
> refreshed patch
> 
> please try this one. :)
> 

It seems to work every time, even when it doesn't have event "ac_adapter ACAD 00000080 00000000" when ac_adapter is pluged out. Thanks you very much :)

(In reply to comment #6)
> Hi, Lukasz
>     Thanks for the test. From the event_log in comment #3 it seems that the
>     AC
> event is reported correctly after the AC adapter is plugged out.
>     What is the problem about your laptop? Is no AC event reported after
> unplugging the AC adapter? 
>     Or the problem is that the AC status can't be reflected by the sys I/F
> interface? In fact this issue will exist only when sometimes no AC event is
> reported. Of course the issue can be fixed by the patch in comment #5.
>     Will you please confirm the problem again?
>     Thanks.
> 
Yes, AC event is not reported by acpi_listen (acpid package) after unplugging AC adapter, but values of  /sys/class/power_supply/ACAD/online and /proc/acpi/ac_adapter/ACAD/state are changed (from 1 to 0 and from on-line to off-line).
I thnik it isn't problem with my laptop. It could be bug in acpid?
Comment 8 Łukasz Wojdyła 2008-11-18 03:20:18 UTC
I forget to add.
Patch works with 2.6.28-rc5, I will try it with 2.6.27.5.

Will the patch be add to mainline of kernel?
Comment 9 Łukasz Wojdyła 2008-11-18 03:35:45 UTC
and

Issue most often appears after system start up and not always.
Sometimes everything works perfectly, but sometimes event appears seldom.
Comment 10 Łukasz Wojdyła 2008-11-18 08:13:46 UTC
Patch works with kernel 2.6.27.5.
Comment 11 Zhang Rui 2008-11-18 17:46:42 UTC
patch in comment #5 is sent to ACPI mail list and I think it can be upstream soon.

so let's focus on the "lack of AC event" problem.

please
0. attach the acpidump output.
1. echo 0x44 > /sys/module/acpi/parameters/debug_layer
2. echo 0x88000007 > /sys/module/acpi/parameters/debug_level
3. run acpi_listen
4. dmesg -c
5. plug/unplug the AC adapter
6. attach the dmesg output in these two cases,
   a) no AC event reported by acpi_listen
   b) AC event reported by acpi_listen

BTW: remember to run dmesg -c before each time you plug/unplug the AC adapter.
BTW: in order to get the acpidump output, you can use the latest pmtools at
http://www.lesswatts.org/downloads/#acpi
Comment 12 Łukasz Wojdyła 2008-11-19 17:00:37 UTC
acpidump output: http://wklej.org/id/19799/ (20071116 version, from fedora repo)
dmesg output before unplug: http://wklej.org/id/19810/
dmesg output after unplug (no event): http://wklej.org/id/19801/
dmesg output afrer plug: http://wklej.org/id/19803/
I add extra (It may be helpful):
dmesg output after unplug (event): http://wklej.org/id/19804/ (After several unplug/plug)
acpi_listen output: http://wklej.org/id/19806/
Comment 13 Łukasz Wojdyła 2008-11-19 17:15:06 UTC
Plain text:
acpidump output: http://wklej.org/id/19799/txt
dmesg output after unplug (no event): http://wklej.org/id/19810/txt
dmesg output after plug: http://wklej.org/id/19803/txt
dmesg output after unplug (event): http://wklej.org/id/19804/txt
acpi_listen output: http://wklej.org/id/19806/txt
Comment 14 Zhang Rui 2008-11-24 21:58:40 UTC
Created attachment 19010 [details]
customized DSDT: debug info for EC

please rebuild the kernel with this customized DSDT and with CONFIG_ACPI_DEBUG set.
please re-do the tests and attach the dmesg output.

how to override a DSDT can be found at:
http://www.lesswatts.org/projects/acpi/overridingDSDT.php
Comment 15 Łukasz Wojdyła 2008-11-27 07:04:03 UTC
outputs:

acpidump: http://wklej.org/id/22222/txt
dmesg before unplug: http://wklej.org/id/22224/txt
dmesg after unplug (no event): http://wklej.org/id/22226/txt
dmesg after unplug (event): http://wklej.org/id/22228/txt
dmesg after plug: http://wklej.org/id/22229/txt
acpi_listen: http://wklej.org/id/22230/txt
Comment 16 Zhang Rui 2008-11-27 17:42:11 UTC
weird, it seems that the customized DSDT is not applied,
could you please attach the dmesg output after boot please?
there should be something like "DSDT replaced by host OS" in the dmesg.
Comment 17 Łukasz Wojdyła 2008-11-27 17:53:33 UTC
short output:
(dmesg | grep DSDT)
ACPI: DSDT BFED703C, 8BBC (r1 HP     30D2      6040000 INTL 20061109)
ACPI: Override [DSDT-30D2    ], this is unsafe: tainting kernel
ACPI: Table DSDT replaced by host OS
ACPI: DSDT 00000000, 8C02 (r1 HP     30D2      6040000 INTL 20080729)
ACPI: DSDT override uses original SSDTs unless "acpi_no_auto_ssdt"
ACPI: EC: Look up EC in DSDT

full output:
http://wklej.org/id/22410/txt
Comment 18 Zhang Rui 2008-11-27 18:26:13 UTC
okay, please
"echo 0x03 > /sys/module/acpi/parameters/debug_level"
"echo 0xffffffff > /sys/module/acpi/parameters/debug_layer"
and then attach the
1.dmesg after unplug (no event)
2.dmesg after unplug (event)
Comment 19 Łukasz Wojdyła 2008-11-28 03:39:00 UTC
no event: http://wklej.org/id/22456/txt
event: http://wklej.org/id/22458/txt
Comment 20 Zhang Rui 2008-11-30 19:12:31 UTC
from the dmesg attach above,
whether the AC event is sent or not is determined by the switch "SW2S" in EC address space.
And in some cases, when AC is unplugged, SW2S is still off and thus no AC event is sent out, and this is apparently wrong.
Unfortunately, I don't know what SW2S stands for and when it should be set/cleared. IMO, this is rather a firmware issue than an Linux/ACPI bug.

will you please upgrade your BIOS and see if it's fixed?
BTW, we can workaround this problem easily by using a customized DSDT, if there is no BIOS upgrade.
Comment 21 Zhang Rui 2008-11-30 19:22:02 UTC
Created attachment 19084 [details]
customized DSDT: always send AC notifications

this can workaround the problem for you
Comment 22 Anish Bhatt 2009-03-18 03:28:43 UTC
I am facing the same problem with my HP dv6500t, adapter disconnect is detected intermittently. Could you possibly post a diff of the two .dsl files so that I can patch my own file ?
Comment 23 Zhang Rui 2009-03-18 18:07:04 UTC
In the _Q20 method,

@@ -7100,8 +7101,8 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
                         If (And (0x02, BATF))
                         {
                             Notify (\_PR.CPU0, 0x80)
-                            Notify (ACAD, 0x80)
                         }
+                        Notify (ACAD, 0x80)
 
                         Notify (BAT0, 0x80)
                         BPOL (0x05)

I don't know if this works for you or not.
please attach the acpidump output of your laptop.
Comment 24 Anish Bhatt 2009-03-18 22:34:17 UTC
Created attachment 20590 [details]
acpidump

acidump output
Comment 25 Anish Bhatt 2009-03-18 22:35:54 UTC
patch seems to work for me. original failure was intermittent for me, sometimes the adapter disconnect was detected, sometimes not so can't comment for sure without observing for a more extended period of time.
Comment 26 Anish Bhatt 2009-03-22 07:15:57 UTC
fixed for me

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