Bug 587112

Summary: thinks the battery is fuller than it is
Product: [Fedora] Fedora Reporter: Bill Nottingham <notting>
Component: upowerAssignee: Richard Hughes <richard>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 13CC: kmcmartin, rhughes, richard, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: upower-0.9.4-1.fc13 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-05-19 19:07:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bill Nottingham 2010-04-28 23:17:43 UTC
Description of problem:

[notting@nostromo: ~]$ upower -d
...
Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:09/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
  vendor:               SANYO
  model:                42T4694
  serial:               536
  power supply:         yes
  updated:              Wed Apr 28 19:13:04 2010 (29 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              589.743 Wh
    energy-empty:        0 Wh
    energy-full:         605.616 Wh
    energy-full-design:  103.496 Wh
    energy-rate:         207.892 W
    voltage:             11.655 V
    time to empty:       2.8 hours
    percentage:          97.379%
    capacity:            99.453%
    technology:          lithium-ion
  History (charge):
    1272496384	97.379	discharging
    1272496354	97.672	discharging
    1272496324	97.947	discharging
  History (rate):
    1272496384	207.892	discharging
    1272496354	199.689	discharging
    1272496324	193.817	discharging

...
[notting@nostromo: ~]$ cat /proc/acpi/battery/BAT0/*
alarm:                   463 mWh
present:                 yes
design capacity:         93240 mWh
last full capacity:      92730 mWh
battery technology:      rechargeable
design voltage:          11100 mV
design capacity warning: 4636 mWh
design capacity low:     200 mWh
capacity granularity 1:  1 mWh
capacity granularity 2:  1 mWh
model number:            42T4694
serial number:             536
battery type:            LION
OEM info:                SANYO
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            18073 mW
remaining capacity:      52650 mWh
present voltage:         11623 mV

Those don't appear to match.

Version-Release number of selected component (if applicable):

upower-0.9.2-1.fc13.x86_64

How reproducible:

100%

Comment 1 Richard Hughes 2010-04-29 08:27:04 UTC
Can you please get the output of "cat /sys/class/power_supply/BAT0/*" and "upower -d" again please. UPower doesn't look in /proc, although it _should_ be the same data. Also, what hardware is this on? Thanks.

Comment 2 Bill Nottingham 2010-04-29 14:20:08 UTC
Oddly, it's better now:

[notting@nostromo: ~]$ upower -d
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:09/PNP0C09:00/ACPI0003:00/power_supply/AC
  power supply:         yes
  updated:              Thu Apr 29 09:22:21 2010 (3249 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    online:             no

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:09/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
  vendor:               SANYO
  model:                42T4694
  serial:               536
  power supply:         yes
  updated:              Thu Apr 29 10:16:27 2010 (3 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              848.928 Wh
    energy-empty:        0 Wh
    energy-full:         1027.53 Wh
    energy-full-design:  103.496 Wh
    energy-rate:         165.246 W
    voltage:             12.213 V
    time to empty:       5.1 hours
    percentage:          82.6186%
    capacity:            99.453%
    technology:          lithium-ion
  History (charge):
    1272550587	82.619	discharging
    1272550557	82.759	discharging
    1272550527	82.889	discharging
    1272550497	83.061	discharging
  History (rate):
    1272550587	165.246	discharging
    1272550557	158.552	discharging
    1272550527	210.656	discharging
    1272550497	163.714	discharging

Daemon:
  daemon-version:  0.9.2
  can-suspend:     yes
  can-hibernate    no
  on-battery:      yes
  on-low-battery:  no
  lid-is-closed:   no
  lid-is-present:   yes

$ cat /sys/class/power_supply/BAT0/*
463000
92730000
93240000
76400000
14427000
cat: /sys/class/power_supply/BAT0/device: Is a directory
SANYO
42T4694
cat: /sys/class/power_supply/BAT0/power: Is a directory
1
  536
Discharging
cat: /sys/class/power_supply/BAT0/subsystem: Is a directory
Li-ion
Battery
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
POWER_SUPPLY_VOLTAGE_NOW=12216000
POWER_SUPPLY_CURRENT_NOW=14427000
POWER_SUPPLY_CHARGE_FULL_DESIGN=93240000
POWER_SUPPLY_CHARGE_FULL=92730000
POWER_SUPPLY_CHARGE_NOW=76400000
POWER_SUPPLY_MODEL_NAME=42T4694
POWER_SUPPLY_MANUFACTURER=SANYO
POWER_SUPPLY_SERIAL_NUMBER=  536
11100000
12216000

Note that the 'energy full' changed (fairly drastically), which I'm guessing would throw off the calculations.

Lenovo X201s is the hardware.

Comment 3 Bill Nottingham 2010-04-29 17:51:01 UTC
And now, I've got another (apparent) disagreement:

[notting@nostromo: ~]$ cat /proc/acpi/battery/BAT0/*
alarm:                   463 mAh
present:                 yes
design capacity:         9324 mAh
last full capacity:      9257 mAh
battery technology:      rechargeable
design voltage:          11100 mV
design capacity warning: 462 mAh
design capacity low:     18 mAh
capacity granularity 1:  1 mAh
capacity granularity 2:  1 mAh
model number:            42T4694
serial number:             536
battery type:            LION
OEM info:                SANYO
present:                 yes
capacity state:          ok
charging state:          charging
present rate:            2847 mA
remaining capacity:      7588 mAh
present voltage:         12650 mV
[notting@nostromo: ~]$ cat /sys/class/power_supply/BAT0/*
463000
9257000
9324000
7623000
3053000
cat: /sys/class/power_supply/BAT0/device: Is a directory
SANYO
42T4694
cat: /sys/class/power_supply/BAT0/power: Is a directory
1
  536
Charging
cat: /sys/class/power_supply/BAT0/subsystem: Is a directory
Li-ion
Battery
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
POWER_SUPPLY_VOLTAGE_NOW=12673000
POWER_SUPPLY_CURRENT_NOW=3053000
POWER_SUPPLY_CHARGE_FULL_DESIGN=9324000
POWER_SUPPLY_CHARGE_FULL=9257000
POWER_SUPPLY_CHARGE_NOW=7623000
POWER_SUPPLY_MODEL_NAME=42T4694
POWER_SUPPLY_MANUFACTURER=SANYO
POWER_SUPPLY_SERIAL_NUMBER=  536
11100000
12673000
[notting@nostromo: ~]$ upower -d
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:09/PNP0C09:00/ACPI0003:00/power_supply/AC
  power supply:         yes
  updated:              Thu Apr 29 10:48:12 2010 (10825 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    online:             yes

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:09/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
  vendor:               SANYO
  model:                42T4694
  serial:               536
  power supply:         yes
  updated:              Thu Apr 29 13:48:33 2010 (4 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    energy:              84.6597 Wh
    energy-empty:        0 Wh
    energy-full:         1027.53 Wh
    energy-full-design:  103.496 Wh
    energy-rate:         34.0437 W
    voltage:             12.69 V
    percentage:          8.23917%
    capacity:            99.453%
    technology:          lithium-ion
  History (charge):
    1272563313	8.239	charging
    1272563283	8.204	charging
    1272563253	8.173	charging
    1272563223	8.138	charging
  History (rate):
    1272563313	34.044	charging
    1272563283	32.678	charging
    1272563253	33.766	charging
    1272563223	32.689	charging

Daemon:
  daemon-version:  0.9.2
  can-suspend:     yes
  can-hibernate    no
  on-battery:      no
  on-low-battery:  no
  lid-is-closed:   no
  lid-is-present:   yes

g-p-m says the battery is 8% full. I suspect it's way more full than that.

Comment 4 Bill Nottingham 2010-04-29 18:02:23 UTC
(And no, I have no idea why the /proc interface switched from mWh to mAh.)

Comment 5 Kyle McMartin 2010-05-10 15:46:39 UTC
It's not just that, charge_* moved to energy_* in sysfs as well. Looks like an EC bug... :/

Comment 6 Kyle McMartin 2010-05-11 05:03:16 UTC
http://kyle.fedorapeople.org/upower-cache-units.diff

This patch attempts to cache whether we based our cached full values on energy or charge and invalidates them if the path changed to kludge around Lenovo stupidity.

Comment 7 Richard Hughes 2010-05-11 08:09:16 UTC
Kyle -- does this patch fix things for you? Bill, could you give this a go too please. Thanks.

Comment 8 Kyle McMartin 2010-05-11 13:42:54 UTC
Yeah, the units stay sensible after a resume (I left the battery to go down to ~60% and confirmed that the rate/charge were the same) and then after a reboot that the calculated values stayed the same.

Comment 9 Richard Hughes 2010-05-11 14:53:46 UTC
commit 5881e7435f140b857ddb979525aa74a5dbf78d20
Author: Kyle McMartin <kmcmartin>
Date:   Tue May 11 15:53:36 2010 +0100

    Detect when the kernel changes the reported charge units. Fixes rh#587112
    
    Signed-off-by: Richard Hughes <richard>

I'll do a new upstream release tomorrow and push to updates. Thanks!

Comment 10 Kyle McMartin 2010-05-11 15:58:30 UTC
Ugh, I spoke too soon, looks like there's still an issue with it. I'm off by a factor of ten now somehow (9.9% instead of 99%) but the capacity remaining seems correct. I'll debug this further this afternoon.

Comment 11 Kyle McMartin 2010-05-11 16:00:44 UTC
Wait, and after another resume, the units are fine again (still the opposite to first boot though.) Really confusing.

Comment 12 Fedora Update System 2010-05-12 14:26:33 UTC
upower-0.9.4-1.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/upower-0.9.4-1.fc13

Comment 13 Fedora Update System 2010-05-13 19:26:59 UTC
upower-0.9.4-1.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update upower'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/upower-0.9.4-1.fc13

Comment 14 Fedora Update System 2010-05-19 19:07:36 UTC
upower-0.9.4-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.