Bug 45321 - UPower does not send line_power_ac events
Summary: UPower does not send line_power_ac events
Alias: None
Product: upower
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium major
Assignee: Richard Hughes
QA Contact:
Depends on:
Reported: 2012-01-27 10:27 UTC by jking+freedesktop
Modified: 2013-10-12 22:42 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Description jking+freedesktop 2012-01-27 10:27:06 UTC
On my new Sony VAIO laptop UPower is not sending line_power_AC events. When the AC power is disconnected, I get events (monitored using upower -m) for the battery, but not for line_power_ac. This results in the system thinking it is still plugged in.

I tested on my other Linux system, and disconnecting/reconnecting the  AC power supply results in line_power_ac events.

Interestingly, on_ac_power (from pm-utils) correctly reports the AC power status for both connected and disconnected states.
Comment 1 jking+freedesktop 2012-01-27 11:51:06 UTC
It would appear as though upowerd isn't updating the line AC power's online status, ever. Here's the (edited) output of upower -d:

Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          /sys/devices/LNXSYSTM:00/device:00/ACPI0003:00/power_supply/AC
  power supply:         yes
  updated:              Fri Jan 27 12:31:41 2012 (4590 seconds ago)
  has history:          no
  has statistics:       no
    online:             yes

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0
  vendor:               Sony Corp.
  model:                VGP-BPS26
  serial:               59
  power supply:         yes
  updated:              Fri Jan 27 13:42:36 2012 (335 seconds ago)

The "updated" value for line_power_AC is equal to my system's uptime; it hasn't been updated since it was first checked. The 335 seconds since the battery update roughly corresponds to the last time I unplugged the AC power supply.
Comment 2 jking+freedesktop 2012-01-27 12:33:01 UTC
Upon further investigation, it would appear that the kernel is not producing uevents for the AC power device, though the kernel is producing events for the battery. This is a kernel bug, it would appear.

However, I wonder if it would be possible to have upowerd explicitly check the line_power devices when a battery state change occurs, since the sysfs interface does correctly report the connected status of the AC adapter.
Comment 3 jking+freedesktop 2012-01-28 09:25:57 UTC
The end result of all this is that upowerd gets confused and never sets the "on battery" state.

However, if the system is booted from battery and AC is plugged in after upower is running, the system gets the state right. What's also interesting is that, if the system is booted from battery, the kernel sends backlight events, and it doesn't if the system is booted with AC connected. In either case (plugged or unplugged boot) the kernel doesn't appear to be sending AC supply events.
Comment 4 Alexander Mezin 2012-04-03 04:49:24 UTC
I have HP Pavilion dv6-6179er and it seems that I'm affected by this bug too.
However, I found a workaround:
I rebuilt kernel with ACPI_PROCFS_POWER=y ("Deprecated power /proc/acpi directories") and noticed that if I do "cat /proc/acpi/ac_adapter/AC/state" then state of the adapter becomes correct in kde, upower's output, etc.

I added a file to /etc/acpi/events/ with following contents:
action=cat /proc/acpi/ac_adapter/AC/state > /dev/null

After restarting acpid everything works. The only problem is that ACPI_PROCFS_POWER is deprecated. I hope this bug will be fixed before
the option will be removed.
Comment 5 bugzilla 2013-02-07 09:07:24 UTC
On my Sony Vaio VPCS11V9E, i'm affected of this bug too. As mentioned before i can get the status of the ac-adapter correctly from sysfs by reading
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/AC/online or 

The uevent-file looks good, so i don't think the kernel is missing to export this events. Although upower -d shows me the following:

Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/AC
  power supply:         yes
  updated:              Thu Feb  7 09:45:39 2013 (723 seconds ago)
  has history:          no
  has statistics:       no
    online:             yes

The status isn't updated ever so the state of the ac-adapter is always the state it had on boot.
upower -m shows events for the Battery (charging/discharging) but not for the ac-adapter.
The workaround mentioned by Alexander Mezin doesn't work for me. /proc/acpi/ac_adapter/AC/state contains the correct state, but reading the file does not affect upower in any way.

I'm on ArchLinux using upower 0.9.19 with Kernel 3.7.6. If you need more information, just tell me.
Comment 6 Stefan Nagy 2013-02-08 17:14:29 UTC
Multiple users of the HP Folio 13 ultrabook are affected by this bug on Ubuntu, I'm seeing it on Debian Wheezy. I'm adding the URLs to the downstream bug reports.
Comment 7 Stefan Nagy 2013-03-01 21:32:29 UTC
At least in my case the kernel doesn't produce any uevents for the battery or the ac adapter, so I filed a bug report against the kernel.

UPower seems to force an update of the battery status every 30 seconds, so the charging level reported by GNOME battery status applet corresponds to the one reported in /sys/class/power_supply/BAT1/uevent (POWER_SUPPLY_CAPACITY). 'upowerd --verbose' tells me: 'No updates on supply /org/freedesktop/UPower/devices/battery_BAT1 for 30 seconds; forcing update'.

However, UPower doesn't force an update of the ac adapter status (un/plugged), so that's why my notebook wouldn't go into hibernation when the time defined in /org/gnome/settings-daemon/plugins/power/time-action is reached.

Since UPower seems to expect the kernel to send uevents for the battery and the ac adapter, I filed a report against the kernel: https://bugzilla.kernel.org/show_bug.cgi?id=54621.

As I understand it all that remains here is the reqeust that UPower should force an update of the line_power device in case the kernel fails to send an uevent. If if this is correct it would make sense to change the title.
Comment 8 Bastien Nocera 2013-10-12 22:42:46 UTC
Looks like the kernel bug got fixed, so closing this report.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.