Bug 60214 - upower battery level off by power of 10
Summary: upower battery level off by power of 10
Status: RESOLVED FIXED
Alias: None
Product: upower
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Richard Hughes
QA Contact:
URL:
Whiteboard:
Keywords:
: 66661 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-02-03 06:39 UTC by Pierce Lopez
Modified: 2015-04-02 14:19 UTC (History)
5 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Screenshot of gnome-power-statistics with upower output in the background. (319.43 KB, image/png)
2014-03-13 15:51 UTC, Alex Markley
Details

Description Pierce Lopez 2013-02-03 06:39:31 UTC
upower thinks my batter is at 8%, when many other indicators say it's at 92% (and that's the level that makes sense). This is on a MacBook Air from mid-2011 (4,2 IIRC) running Arch Linux (so, always a recent kernel), and I've experienced and tolerated this odd issue since I bought it in early 2012.

Anyway, as you can see, upower thinks "energy-full" is 10 times higher than it really is, but I can't quite see in sysfs why it thinks that.

[plo@plo-air ~]$ uname -a
Linux plo-air 3.7.4-1-ARCH #1 SMP PREEMPT Mon Jan 21 23:05:29 CET 2013 x86_64 GNU/Linux
[plo@plo-air ~]$ upower -i /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0
  vendor:               SMPNz451T98DKRNA500ASAN
  model:                bq20z451T98DKRNA500ASAN
  power supply:         yes
  updated:              Sun Feb  3 01:28:26 2013 (5 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              55.93 Wh
    energy-empty:        0 Wh
    energy-full:         643.85 Wh
    energy-full-design:  67 Wh
    energy-rate:         9.156 W
    voltage:             8.103 V
    time to empty:       6.1 hours
    percentage:          8.68681%
    capacity:            89.2687%
  History (charge):
    1359872906	8.687	discharging
    1359872876	8.702	discharging
    1359872846	8.716	discharging
    1359872816	8.732	discharging
  History (rate):
    1359872906	9.156	discharging
    1359872876	8.918	discharging
    1359872846	9.163	discharging
    1359872816	9.273	discharging

[plo@plo-air ~]$ find /sys/devices/LNXSYSTM\:00/LNXSYBUS\:00/PNP0C0A\:00/power_supply/BAT0/ -type f -print -exec cat '{}' ';'
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/type
Battery
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power_now
9093000
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/alarm
0
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power/control
auto
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power/async
disabled
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power/runtime_enabled
disabled
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power/runtime_active_kids
0
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power/runtime_active_time
0
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power/autosuspend_delay_ms
cat: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power/autosuspend_delay_ms: Input/output error
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power/runtime_status
unsupported
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power/runtime_usage
0
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power/runtime_suspended_time
0
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/capacity
93
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/status
Discharging
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/voltage_now
8105000
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/uevent
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Unknown
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=7500000
POWER_SUPPLY_VOLTAGE_NOW=8105000
POWER_SUPPLY_POWER_NOW=9093000
POWER_SUPPLY_ENERGY_FULL_DESIGN=67000000
POWER_SUPPLY_ENERGY_FULL=59810000
POWER_SUPPLY_ENERGY_NOW=55960000
POWER_SUPPLY_CAPACITY=93
POWER_SUPPLY_MODEL_NAME=bq20z451T98DKRNA500ASAN
POWER_SUPPLY_MANUFACTURER=SMPNz451T98DKRNA500ASAN
POWER_SUPPLY_SERIAL_NUMBER=
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/energy_now
55960000
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/model_name
bq20z451T98DKRNA500ASAN
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/manufacturer
SMPNz451T98DKRNA500ASAN
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/technology
Unknown
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/cycle_count
0
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/energy_full_design
67000000
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/voltage_min_design
7500000
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/serial_number

/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/energy_full
59810000
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/present
1
Comment 1 Pierce Lopez 2013-02-03 06:40:22 UTC
forgot to mention:
[plo@plo-air ~]$ upower --version
UPower client version 0.9.19
UPower daemon version 0.9.19
Comment 2 main.haarp 2013-07-14 15:39:26 UTC
energy-full:         643.85 Wh
that's the problem.

I sometimes get the same on my Thinkpad SL510 - after resuming from suspend, the max capacity is read incorrectly, and the resulting charge level is completely off. Suspending and resuming again usually fixes it.
Comment 3 George Wright 2013-07-19 20:29:45 UTC
Just a quick comment to note that this also affects the mid-2012 Retina MacBook Pro (MacBookPro10,1). I'm seeing an "energy-full" value of 1025.8 Wh, when in reality it should be around 80 Wh.
Comment 4 Daniel Stone 2013-07-19 23:03:31 UTC
I've seen this on the 2008, 2011 (Sandy Bridge) and 2012 (Ivy Bridge) MacBook Airs, running GNOME under Fedora.
Comment 5 Stefano Debenedetti 2013-08-01 11:13:33 UTC
Same here with MacBook Pro 13 inch 2011 model, 8,1.

Further details:

https://bugs.kde.org/show_bug.cgi?id=318868
Comment 6 Bastien Nocera 2013-10-12 22:29:08 UTC
*** Bug 66661 has been marked as a duplicate of this bug. ***
Comment 7 Bastien Nocera 2013-10-20 12:11:05 UTC
This was fixed in:

commit 07b95b8e27e7c488828c46a28df96f1c83b185c8
Author: Martin Pitt <martinpitt@gnome.org>
Date:   Fri Aug 23 08:31:20 2013 +0200

    linux: Fix batteries which report capacity, but not energy/charge
    
    Many Android devices only export charge_full and capacity, but not charge_now
    or energy_now. In that case, directly read the percentage (from the capacity
    attribute) and calculate current energy from that.
    
    Thanks to Seth Forshee for the original patch!
    
    https://bugs.freedesktop.org/show_bug.cgi?id=68337


The code reads:
        /* get a precise percentage */
        if (sysfs_file_exists (native_path, "capacity")) {
                percentage = sysfs_get_double (native_path, "capacity");
So if capacity is set, then we use that as the percentage value, not a calculated value based on energy or energy_full which broke in your case.
Comment 8 Alex Markley 2013-11-07 01:36:47 UTC
All,

Forgive me if this is documented somewhere I can't find, but what release is this fix targeted for?

I'm running Fedora 19, which includes upower 0.9.20, and I am definitely affected by this bug. I know there are newer releases, but I want to know which is the first stable release this bugfix appeared in?

Thanks!
Comment 9 Alex Markley 2014-03-11 04:25:17 UTC
I am definitely running a recent version of upower and this bug is still plaguing me. Upower will spuriously report a sudden drop in battery percentage, which causes my system to freak out and hibernate or suspend for no reason.

I'm running upower 0.9.23 packaged with Fedora 20 on a MacBookAir 6,2.

The following were all captured while the laptop was complaining about the battery being "critically low":

$ upower -d
Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SMPNz451
  model:                bq20z451
  power supply:         yes
  updated:              Tue 11 Mar 2014 12:05:52 AM EDT (4 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              47.43 Wh
    energy-empty:        0 Wh
    energy-full:         627.96 Wh
    energy-full-design:  71.5 Wh
    energy-rate:         20.246 W
    voltage:             7.719 V
    time to empty:       2.3 hours
    percentage:          66%
    capacity:            99.3846%
  History (charge):
    1394510752	66.000	discharging
    1394510722	100.000	discharging
  History (rate):
    1394510752	20.246	discharging
    1394510722	21.158	discharging
    1394510692	21.308	discharging
    1394510662	20.451	discharging

Device: /org/freedesktop/UPower/devices/line_power_ADP1
  native-path:          ADP1
  power supply:         yes
  updated:              Mon 10 Mar 2014 11:37:17 PM EDT (1719 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    online:             no

Daemon:
  daemon-version:  0.9.23
  on-battery:      yes
  on-low-battery:  no
  lid-is-closed:   no
  lid-is-present:  yes
  is-docked:       no


$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/alarm
0

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/capacity
66

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/cycle_count
0

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/energy_full
71060000

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/energy_full_design
71500000

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/energy_now
47400000

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/manufacturer
SMPNz451

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/model_name
bq20z451

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/power_now
22114000

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/present
1

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/serial_number


$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/status
Discharging

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/technology
Unknown

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/type
Battery

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/uevent
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Unknown
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=7600000
POWER_SUPPLY_VOLTAGE_NOW=7708000
POWER_SUPPLY_POWER_NOW=22114000
POWER_SUPPLY_ENERGY_FULL_DESIGN=71500000
POWER_SUPPLY_ENERGY_FULL=71060000
POWER_SUPPLY_ENERGY_NOW=47400000
POWER_SUPPLY_CAPACITY=66
POWER_SUPPLY_MODEL_NAME=bq20z451
POWER_SUPPLY_MANUFACTURER=SMPNz451
POWER_SUPPLY_SERIAL_NUMBER=

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/voltage_min_design
7600000

$ cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0/voltage_now
7708000
Comment 10 Alex Markley 2014-03-13 15:48:51 UTC
I was able to capture the output of upower --monitor-detail during one of the incidents. It definitely shows wrong numbers about the battery being reported, but I don't understand where the fault lies. I am also attaching a screenshot. Please help? :-\

(This is the report from right before the incident.)

[11:39:35.768]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SMPNz451
  model:                bq20z451
  power supply:         yes
  updated:              Thu 13 Mar 2014 11:39:35 AM EDT (0 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              51.78 Wh
    energy-empty:        0 Wh
    energy-full:         68.78 Wh
    energy-full-design:  71.5 Wh
    energy-rate:         11.32 W
    voltage:             7.95 V
    time to empty:       4.6 hours
    percentage:          75%
    capacity:            96.1958%
  History (rate):
    1394725175  11.320  discharging
    1394725145  11.258  discharging
    1394725115  12.394  discharging
    1394725085  11.107  discharging

(Incident begins.)

[11:40:05.785]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SMPNz451
  model:                bq20z451
  power supply:         yes
  updated:              Thu 13 Mar 2014 11:40:05 AM EDT (0 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              628.44 Wh (What?? This seems wrong.)
    energy-empty:        0 Wh
    energy-full:         628.44 Wh (This is definitely wrong.)
    energy-full-design:  71.5 Wh
    energy-rate:         21.239 W
    voltage:             7.89 V
    time to empty:       29.6 hours
    percentage:          100%
    capacity:            96.1958%
  History (charge):
    1394725205  100.000 discharging
  History (rate):
    1394725205  21.239  discharging
    1394725175  11.320  discharging
    1394725145  11.258  discharging
    1394725115  12.394  discharging

[11:40:35.785]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SMPNz451
  model:                bq20z451
  power supply:         yes
  updated:              Thu 13 Mar 2014 11:40:35 AM EDT (0 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              51.42 Wh (Normal measurement again.)
    energy-empty:        0 Wh
    energy-full:         628.44 Wh (Still wrong.)
    energy-full-design:  71.5 Wh
    energy-rate:         11.701 W
    voltage:             7.933 V
    time to empty:       4.4 hours
    percentage:          74%
    capacity:            96.1958%
  History (charge):
    1394725235  74.000  discharging
    1394725205  100.000 discharging
  History (rate):
    1394725235  11.701  discharging
    1394725205  21.239  discharging
    1394725175  11.320  discharging
    1394725145  11.258  discharging

(At this point I have manually restarted upowerd to prevent my system from hibernating.)

[11:40:56.759]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SMPNz451
  model:                bq20z451
  power supply:         yes
  updated:              Thu 13 Mar 2014 11:40:56 AM EDT (0 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              51.29 Wh
    energy-empty:        0 Wh
    energy-full:         68.78 Wh
    energy-full-design:  71.5 Wh
    energy-rate:         11.157 W
    voltage:             7.93 V
    time to empty:       4.6 hours
    percentage:          74%
    capacity:            96.1958%
  History (charge):
    1394725256  74.000  discharging
    1394725255  0.000   unknown
  History (rate):
    1394725256  11.157  discharging
    1394725255  0.000   unknown
Comment 11 Alex Markley 2014-03-13 15:51:55 UTC
Created attachment 95726 [details]
Screenshot of gnome-power-statistics with upower output in the background.

This problem seems impossible to manually reproduce. Sometimes it will happen several times only a few minutes apart, and sometimes it will go a couple of days without happening. I don't know what, if anything, I am doing to trigger it.
Comment 12 ffs 2014-04-01 14:59:51 UTC
I have this problem on my mba running kubuntu. apci reports the correct level.

Problem is it causes my computer to hibernate which leads to remote sessions being dropped, inconvenience and sometimes data loss.  If I'm quick I can"fix" the problem by shuttingh the laptop lid  and reopnenning a few seconds later or just turn off power management.
Comment 13 Mike Krutov 2014-05-17 07:49:58 UTC
Ok.
I have two asus laptops which tell this after uptime of 2 days:
  native-path:          /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/PNP0C0A:00/power_supply/BAT0
  vendor:               ASUSTeK
  model:                N750-62
  power supply:         yes
  updated:              Sat May 17 11:49:05 2014 (8 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    energy:              64.491 Wh
    energy-empty:        0 Wh
    energy-full:         138.383 Wh
    energy-full-design:  69.486 Wh
    energy-rate:         0 W
    voltage:             11.1 V
    percentage:          46.6033%
    capacity:            95.3185%
    technology:          lithium-ion



Right after reboot, percentage is 95%.
Comment 14 Mike Krutov 2014-05-17 07:54:44 UTC
*** Bug 66661 has been marked as a duplicate of this bug. ***
Comment 15 Daniel Stone 2014-11-19 03:47:21 UTC
For what it's worth, Fedora 21 hasn't (touch wood) shown this problem in a very long time indeed.
Comment 16 Pierce Lopez 2014-11-20 04:03:39 UTC
don't keep it open on my account
Comment 17 Bastien Nocera 2015-04-02 14:19:17 UTC
I'll consider this fixed. If the problem happens again, please file a new bug, and do mention the version of UPower used (and make sure you use at least 0.99.2).


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.