Bug 682173

Summary: HAL does not update the AC adapter state
Product: [openSUSE] openSUSE 11.4 Reporter: Michael Lashkevich <lashkevi>
Component: BasesystemAssignee: E-mail List <bnc-team-screening>
Status: VERIFIED NORESPONSE QA Contact: E-mail List <qa-bugs>
Severity: Critical    
Priority: P5 - None CC: jlee, mchang
Version: Final   
Target Milestone: ---   
Hardware: x86   
OS: openSUSE 11.4   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: A workaround of the bug
dmesg dump
acpi dump
dmesg dump

Description Michael Lashkevich 2011-03-24 06:29:12 UTC
Created attachment 421061 [details]
A workaround of the bug

User-Agent:       Mozilla/5.0 (X11; Linux i686; rv:2.0b12) Gecko/20110222 Firefox/4.0b12

The HAL does not update the AC adapter state leading to no reaction to plugging/unplugging the AC adapter, though the contents of the files "/proc/acpi/ac_adapter/ADP0/state" and "/sys/class/power_supply/ADP0" changes properly.

As a workaround I start the attached script, which check the adapter state every 3 seconds and update the HAL variables, in the "boot.local" file.

My computer: Toshiba Satellite L300-11E.
The bug started from OpenSUSE 10.3 and still persistent in 11.4.
By the way, I use KDE 3.5, though it has nothing to do with PowerDevil etc. It indeed the HAL problem, which is checked by means of "lshal".

Reproducible: Always

Steps to Reproduce:
1. Turn on the computer with battery inserted.
2. Plug/Unplug the AC connector and see that neither the active scheme nor the adapter state information changes.
3. Check the contents of the files "/proc/acpi/ac_adapter/ADP0/state" and "/sys/class/power_supply/ADP0" and make sure that they are updated properly.
4. Check the "udi = '/org/freedesktop/Hal/devices/computer_power_supply_ac_adapter_ADP0'" by means of "lshal" and make sure that the value of the variable " ac_adapter.present" does not change.
Comment 1 Michael Chang 2011-03-28 09:48:19 UTC
Hi Michael,

I used to bumped to this issue before.

Do you see any output from "acpi_listen" while plug/unplug AC adapter? If no it was due to problematic BIOS implementation indeed. If yes, check with the "lshal -m" again, it should log messages to reflect the change of AC adapter status as well.

Thanks.
Comment 2 Michael Chang 2011-03-28 10:14:25 UTC
Also have a try for :

 $ watch -n 1 cat /sys/firmware/acpi/interrupts/gpe??

At lease a counter should increase for AC plug/unplug. This indicates that BIOS delivered SCI event to notice OSPM about certain status changed.

Thanks.
Comment 3 Michael Lashkevich 2011-03-28 15:28:00 UTC
(In reply to comment #1 and #2)
Neither "acpi_listen" nor "watch -n 1 cat /sys/firmware/acpi/interrupts/gpe??" shows any reaction to plugging/unplugging AC adapter or to changes of the battery charge level.

The commands "watch -n 1 /sys/class/power_supply/ADP0/online" or "watch -n 1 cat /proc/acpi/ac_adapter/ADP0/state" can only be used to catch plugging/unplugging.
Comment 4 Michael Chang 2011-03-29 04:39:48 UTC
(In reply to comment #3)
> (In reply to comment #1 and #2)
> Neither "acpi_listen" nor "watch -n 1 cat /sys/firmware/acpi/interrupts/gpe??"
> shows any reaction to plugging/unplugging AC adapter or to changes of the
> battery charge level.

I would conclude this as BIOS problem for now. HAL monitors on ACPI event, which never be triggered in this case, to refresh the state . In general, BIOS/EC accounts for generating such events. 

Some buggy BIOS implementation will emit scan code rather than ACPI event to notify OS. You can try to observe this in console by .

   $ showkey -s 

And see is there any scancode emitted when plug/unplug AC adapter. In this case You can try binding your script to this keycode to process the event . It may be helpful to avoid polling ...

IMHO HAL has nothing to do with this problem but a victim for it. The BIOS has to be fixed first to solve this problem.

> 
> The commands "watch -n 1 /sys/class/power_supply/ADP0/online" or "watch -n 1
> cat /proc/acpi/ac_adapter/ADP0/state" can only be used to catch
> plugging/unplugging.

I think your script is ideal to get around this problem by way of this fact. :)
Comment 5 Michael Lashkevich 2011-03-30 17:57:59 UTC
Maybe something is wrong with acpid or with the kernel acpi support? Is it possible to check this?
Comment 6 Joey Lee 2011-04-22 07:32:55 UTC
(In reply to comment #5)
> Maybe something is wrong with acpid or with the kernel acpi support? Is it
> possible to check this?

If you didn't see acpi gpe, that means BIOS didn't trigger any interrupt to acpi when your unplug ac adapter.

Could you please attached dmesg:
   dmseg > dmesg.log

and DSDT?
  acpidump > acpidump.dat

Please attached dmesg.log and acpidump.dat on this bug.
Comment 7 Michael Lashkevich 2011-04-22 10:36:10 UTC
Created attachment 426235 [details]
dmesg dump
Comment 8 Michael Lashkevich 2011-04-22 10:36:58 UTC
Created attachment 426236 [details]
acpi dump
Comment 9 Joey Lee 2011-06-17 09:50:21 UTC
Hi Michael, 

Your dmesg have too many information by S4 resume, I need a dmesg after you:
 + reboot system

 + please run the following statement by root:
echo 0xFFFFFFFF >/sys/module/acpi/parameters/debug_layer; echo 0xF >/sys/module/acpi/parameters/debug_level 

 + manually plug, unplug ac-adapter

Please attached dmesg again.

On the other hand:
After traced your DSDT, EC must emit _Q13 or _Q19 event to OSPM when you unplug ac adapter, and those _Q method must notify ADP0 device.

Please help to follow the above 3 steps, then attached dmesg.

Thank's
Comment 10 Michael Lashkevich 2011-06-17 22:00:59 UTC
Created attachment 435204 [details]
dmesg dump

Here is the dmesg dump after the steps you asked to perform.
Comment 11 Joey Lee 2011-06-20 09:53:58 UTC
Per your dmesg, EC didn't emit Q event on your machine, so OSPM didn't execute _Q13 or _Q19 for notify ADP0 device (AC adapter):

    Method (_Q13, 0, NotSerialized)     /* AC unplug? */
    {  
        Notify (ADP0, Zero)             /* ACPI_NOTIFY_BUS_CHECK 0x00 */
        Notify (BAT0, 0x80)
        Notify (BAT0, 0x81)             /* ACPI_BATTERY_NOTIFY_INFO 0x81 */
    }

    Method (_Q14, 0, NotSerialized)
    {  
        Notify (LID, 0x80)
    }

    Method (_Q19, 0, NotSerialized)     /* AC unplug? */
    {
        Notify (ADP0, Zero)             /* ACPI_NOTIFY_BUS_CHECK 0x00 */
        Notify (BAT0, 0x80)
        Notify (BAT0, 0x81)             /* ACPI_BATTERY_NOTIFY_INFO 0x81 */
    }

I have no idea why EC firmware didn't emit Q event.
Did you remember the ac-adapter unplug/plug event on your machine works on Windows or any other Linux platform?
Comment 12 Zhi Juan Jia 2011-07-15 03:09:05 UTC
Long time no response,so closed.Feel free to reopen it.Thanks.
Comment 13 Michael Lashkevich 2011-07-15 08:05:25 UTC
(In reply to comment #11)
> Per your dmesg, EC didn't emit Q event on your machine, so OSPM didn't execute
> Did you remember the ac-adapter unplug/plug event on your machine works on
> Windows or any other Linux platform?
It seems to me that it worked on OpenSUSE 10.2 before some update of HAL.
Comment 14 Joey Lee 2011-07-15 09:48:08 UTC
(In reply to comment #13)
> (In reply to comment #11)
> > Per your dmesg, EC didn't emit Q event on your machine, so OSPM didn't execute
> > Did you remember the ac-adapter unplug/plug event on your machine works on
> > Windows or any other Linux platform?
> It seems to me that it worked on OpenSUSE 10.2 before some update of HAL.

That's strange, per your dmesg message, BIOS didn't emit notify event to OSPM, there will not have any event to drive userland update AC adapter status.

It must be have some polling mechanism to query the AC status like your script.

I know maybe it's not easy...
Does it possible you help to use openSUSE 10.2 to confirm? Follow the Comment #9, dump the dmesg log on openSUSE 10.2?

I will also try to check the HAL changed in RPM log.
Comment 15 Joey Lee 2011-07-18 02:54:45 UTC
Did not see openSUSE 10.2 and 10.3 HAL packages on OBS, where can I find them?
Comment 16 Zhi Juan Jia 2011-08-16 06:06:00 UTC
Long time no response,so closed.Feel free to reopen it.Thanks.