Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 360607

Summary: sys-power/upower - wrong battery status in after resume from suspend
Product: Gentoo Linux Reporter: optiluca <optiluca>
Component: [OLD] KDEAssignee: Freedesktop bugs <freedesktop-bugs>
Status: RESOLVED OBSOLETE    
Severity: normal CC: caster, nikoli, qdii
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: https://bugs.freedesktop.org/show_bug.cgi?id=27399
See Also: https://bugs.kde.org/show_bug.cgi?id=270627
Whiteboard:
Package list:
Runtime testing required: ---

Description optiluca@gmail.com 2011-03-26 18:11:34 UTC
Hi.  I am running Gentoo amd64 on a Thinkpad W510, with KDE 4.6.1 running under a no-hal, udev only setup.  I have started encountering a peculiar issue where after resuming from suspend, the powerdevil battery indicator claims I have 11% charge remaining, even if plugged in.  A reboot fixes everything and brings the indicator back to normal.  A very similar issue is manifesting itself on similar hardware, under GNOME in Ubuntu ( https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/606159 ), so I assume it is a udev/kernel issue of some sorts.  Possibly upstream somewhere?

emerge --info

Portage 2.2.0_alpha28 (default/linux/amd64/10.0/desktop/kde, gcc-4.5.2, glibc-2.13-r2, 2.6.38-gentoo x86_64)
=================================================================
System uname: Linux-2.6.38-gentoo-x86_64-Intel-R-_Core-TM-_i7_CPU_Q_820_@_1.73GHz-with-gentoo-2.0.2
Timestamp of tree: Sat, 26 Mar 2011 08:00:01 +0000
app-shells/bash:     4.2_p8
dev-java/java-config: 2.1.11-r3
dev-lang/python:     2.7.1-r1
dev-util/cmake:      2.8.4
sys-apps/baselayout: 2.0.2
sys-apps/openrc:     0.8.0
sys-apps/sandbox:    2.5
sys-devel/autoconf:  2.13, 2.68
sys-devel/automake:  1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:  2.21
sys-devel/gcc:       4.5.2
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.4-r1
sys-devel/make:      3.82
virtual/os-headers:  2.6.38 (sys-kernel/linux-headers)
Repositories: gentoo multimedia sunrise gamerlay-stable ikelos LOCAL
Installed sets: 
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/etc/portage/distfiles"
FEATURES="assume-digests binpkg-logs distlocks fixlafiles fixpackages news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://mirror.jamit.de/gentoo/ ftp://mirror.switch.ch/mirror/gentoo/"
LANG="en_GB.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-O1"
LINGUAS="en_GB it"
MAKEOPTS="-j8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/multimedia /var/lib/layman/sunrise /var/lib/layman/gamerlay /var/lib/layman/ikelos /usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X a52 aac acl acpi alsa amd64 amr apm avi bash-completion berkdb bluetooth branding bzip2 cairo caps cdaudio cddb cdr chm cleartype cli consolekit cracklib crypt css cups cxx dbus dhcp dri dts dv dvb dvd dvdr dvdread editor emboss emovix encode exif faac faad fam fame fbcondecor fbsplash ffmpeg firefox flac foomaticdb fortran gcj gd gdbm gdu gif git glitz glx gphoto2 gpm gps gstreamer hdaps iconv id3tag ieee1394 imagemagick inotify ipod ipv6 it jack java java6 joystick jpeg kde kickoff ladspa lastfm lcms ldap libnotify libsamplerate lm_sensors mad mbrola mikmod mmx mng modules mp2 mp3 mp4 mpeg mplayer msn mudflap multilib musicbrainz ncurses nls nptl nptlonly nsplugin nvidia ogg opengl openmp pam pango pcre pdf perl phonon pmu png policykit ppds pppd python qt qt3support qt4 quicktime readline rtc samba scanner sdl semantic-desktop session skype slp smp snmp spell sse sse2 sse3 ssl ssse3 startup-notification subtitles subversion svg sysfs tcpd theora threads tiff truetype twolame udev unicode usb v4l v4l2 vdpau vorbis wicd wifi x264 xcomposite xine xml xorg xulrunner xv xvid zeroconf zlib" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev joystick synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en_GB it" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Jorge Manuel B. S. Vicetto (RETIRED) Gentoo Infrastructure gentoo-dev 2011-03-27 15:47:56 UTC
What does "acpi -b" return?
Comment 2 optiluca@gmail.com 2011-03-27 19:07:00 UTC
I had no acpi executable.  After installing the acpi package:

acpi -b
Battery 0: Discharging, 59%, 00:54:15 remaining

This is before any suspend/resuming, and matches what powerdevil has to say

After a suspend, the powerdevil indicator goes the opposite way as what it has previously, and shows 100% charge!  I guess it's just chance, and is still incorrect.  In any case:

acpi -b
Battery 0: Discharging, 55%, 00:45:48 remaining

which is sensible enough.

After a further suspend, powerdevil says 93% charge, 46 minutes.  And:

acpi -b
Battery 0: Discharging, 52%, 00:45:00 remaining

So the time indication is correct, but the percentage clearly is not.

Hope any of this helps :)
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2011-03-29 22:51:30 UTC
Let's assume kde-base/powerdevil gets it wrong. I don't know where it gets its ACPI information, but KDE developers should.
Comment 4 Andreas K. Hüttel archtester gentoo-dev 2011-04-10 20:47:05 UTC
(Filed kde bug.)
Any better luck with kde-4.6.2?
Comment 5 optiluca@gmail.com 2011-04-11 07:05:00 UTC
No luck I am afraid.  The wrongness seems to vary according to the pattern of suspend/resumes/plugging into AC one follows.  For example, running on battery, suspending, plugging into AC and then resuming will yield an alleged 100% battery charge.  The time indicator seems sensible though, so powerdevil reports something like 99% charge, half an hour of run time...
Comment 6 Andreas K. Hüttel archtester gentoo-dev 2011-04-13 21:01:37 UTC
From upstream:

------- Comment #1 From Lamarque V. Souza 2011-04-11 02:09:53 (-) [reply] -------

Powerdevil requests battery information from upower. What does upower says
about your battery? The acpi command does not use upower as far as I know.
Comment 7 optiluca@gmail.com 2011-04-14 22:06:08 UTC
Bug also found at https://bugs.freedesktop.org/show_bug.cgi?id=27399 , and mentioned in http://forums.gentoo.org/viewtopic-t-857650-view-previous.html?sid=86864833a7737fbdc23d9bacda346632

upower -d output is consistent with powerdevil, eg is equally wrong.  The "percentage:" entry goes up to 100% after resume.

upower -d 

Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0003:00/power_supply/AC
  power supply:         yes
  updated:              Thu Apr 14 23:59:08 2011 (195 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/device:00/PNP0A08:00/device:02/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
  vendor:               SONY
  model:                42T4795
  serial:               2763
  power supply:         yes
  updated:              Fri Apr 15 00:02:14 2011 (9 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              53.676 Wh
    energy-empty:        0 Wh
    energy-full:         56.1168 Wh
    energy-full-design:  54.5832 Wh
    energy-rate:         32.454 W
    voltage:             11.479 V
    time to empty:       1.7 hours
    percentage:          95.6505%
    capacity:            100%
    technology:          lithium-ion
  History (charge):
    1302818534  95.651  discharging
    1302818504  96.286  discharging
    1302818474  96.978  discharging
    1302818444  97.729  discharging
  History (rate):
    1302818534  32.454  discharging
    1302818504  36.914  discharging
    1302818474  35.629  discharging
    1302818444  36.742  discharging

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


SUSPEND/RESUME


luca@optipad ~ $ upower -d
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0003:00/power_supply/AC
  power supply:         yes
  updated:              Thu Apr 14 23:59:08 2011 (297 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/device:00/PNP0A08:00/device:02/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
  vendor:               SONY
  model:                42T4795
  serial:               2763
  power supply:         yes
  updated:              Fri Apr 15 00:03:59 2011 (6 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              523.26 Wh
    energy-empty:        0 Wh
    energy-full:         523.26 Wh
    energy-full-design:  54.5832 Wh
    energy-rate:         395.68 W
    voltage:             11.194 V
    time to empty:       1.3 hours
    percentage:          100%
    capacity:            100%
    technology:          lithium-ion
  History (charge):
    1302818639  100.000 discharging
    1302818594  94.130  discharging
    1302818564  94.881  discharging
    1302818534  95.651  discharging
  History (rate):
    1302818639  395.680 discharging
    1302818594  38.772  discharging
    1302818564  40.176  discharging
    1302818534  32.454  discharging

Daemon:
  daemon-version:  0.9.9
  can-suspend:     yes
  can-hibernate    no
  on-battery:      yes
  on-low-battery:  no
  lid-is-closed:   no
  lid-is-present:  yes
  is-docked:       no
Comment 8 Lu Ran 2011-04-23 19:42:50 UTC
I have a W510 with amd64 Gentoo, exactly the same anonying bug, I did some research and I think it is a bug in the kernel, though upower handle data differently from hal thus exposed the bug. Here is the problem I find:

When I boot up normally, "cat /sys/.../BAT0/charge_now" gives me something like this:

7517000

"cat /sys/../BAT0/charge_full" shows

9396000

Use the battery for a while, (I am not sure exactly how to trigger this reliably though), the number beomes

69350000

and

93960000

Notice the extra "0"! However upower only check charge_full once when it starts, now it find "energy" calculated from "charge_now" is larger than "energy_full" calculated from "charge_full", it assume "energe_full" is wrong and replace the value using "energy" calculated from "charge_now".The battery capacity become 100% for a while.

Now suspend/resume, the number from "charge_now" and "charge_full" becomes normal again, but now upower have a cached "energy_full" calculated when "charge_now" is 10 times larger. The capacity upower calculated will hardly be larger than 10%.
Comment 9 Andreas K. Hüttel archtester gentoo-dev 2011-04-25 17:21:51 UTC
(In reply to comment #8)
> I have a W510 with amd64 Gentoo, exactly the same anonying bug, I did some
> research and I think it is a bug in the kernel, though upower handle data
> differently from hal thus exposed the bug. Here is the problem I find:
> [...]

That looks VERY interesting, you may have found the cause of the problem. :) I copied your comments into the upstream bug report; lets see if the upower developers can work out the details.
Comment 10 qdii 2011-12-31 20:26:55 UTC
Any update on this bug?
Comment 11 Samuli Suominen (RETIRED) gentoo-dev 2013-08-23 18:51:48 UTC
(In reply to qdii from comment #10)
> Any update on this bug?

indeed, it's middle of 2013 and last comment is from users using UPower in 2011, a lot of bug fixes has happened since re: bugs in battery status showing as per git log

please reopen the bug if you still see the need with =sys-power/upower-0.9.21 and up-to-date kernel