Using an HP EliteBook 8540w with built in battery plus extended life batter, ACPI events return for both BAT0 and BAT1. laptop-mode hibernated the laptop when BAT0 was at 0% and BAT1 was at 57% Reproducible: Always Steps to Reproduce: 1. Run laptop with both batteries installed but no AC power 2. Watch BAT0 go to zero, including xmessage alerts that the battery is at 2% 3. Machine hibernates, unexpededly when BAT1 is only half discharged Actual Results: Unexpected hibernation Expected Results: hibernate not occur until BAT1 is almost completely flat Include emerge --info plus 'eix laptop-mode' showing version. root@pearcely2 actions # emerge --info Portage 2.1.9.42 (default/linux/amd64/10.0/desktop, gcc-4.4.5, glibc-2.11.3-r0, 2.6.36-gentoo-r8 x86_64) ================================================================= System uname: Linux-2.6.36-gentoo-r8-x86_64-Intel-R-_Core-TM-_i7_CPU_M_620_@_2.67GHz-with-gentoo-1.12.14 Timestamp of tree: Mon, 11 Apr 2011 00:45:01 +0000 app-shells/bash: 4.1_p9 dev-java/java-config: 2.1.11-r3 dev-lang/python: 2.6.6-r2, 2.7.1-r1, 3.1.3-r1 dev-util/cmake: 2.8.4 sys-apps/baselayout: 1.12.14-r1 sys-apps/sandbox: 2.4 sys-devel/autoconf: 2.13, 2.65-r1 sys-devel/automake: 1.9.6-r3, 1.10.3, 1.11.1 sys-devel/binutils: 2.20.1-r1 sys-devel/gcc: 4.4.5 sys-devel/gcc-config: 1.4.1 sys-devel/libtool: 2.2.10 sys-devel/make: 3.81-r2 virtual/os-headers: 2.6.36.1 (sys-kernel/linux-headers) ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="* -@EULA" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-O2 -pipe -mtune=core2 -march=core2 -ggdb" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /lib/udev/rules.d /usr/share/config /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5.3/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cli-php5.3/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo" CXXFLAGS="-O2 -pipe -mtune=core2 -march=core2 -ggdb" DISTDIR="/portage/gentoo/distfiles" FEATURES="assume-digests binpkg-logs collision-protect distlocks fixlafiles fixpackages news parallel-fetch protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox" FFLAGS="" GENTOO_MIRRORS="http://mirror.internode.on.net/pub/gentoo" LANG="en_AU.UTF-8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" MAKEOPTS="-j8" PKGDIR="/portage/gentoo/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="/tmp" PORTDIR="/portage/gentoo" PORTDIR_OVERLAY="/portage/local" SYNC="rsync://mirror.internode.on.net/gentoo-portage" USE="X a52 aac acl acpi alsa amd64 amr apache2 berkdb bindist bluetooth branding bzip2 cairo cdb cddb cdparanoia cdr cleartype cli consolekit corefonts cracklib crypt css cups cxx daap dbus dri dts dvb dvd dvdr emacs emboss encode exif fam ffmpeg firefox flac fortran gd gdbm gdu gif gpm gtk iconv ipod ipv6 java javascript joystick jpeg jpeg2k kde laptop latin1 lcms ldap libnotify lm_sensors mad mikmod mmx mmxext mng modules mp3 mp4 mpeg mplayer mudflap multilib mysql ncurses nls nptl nptlonly nsplugin nvidia ogg opengl openmp pam pango pcre pdf perl pmu png policykit posix ppds pppd python qt3support qt4 readline rss samba sdl server session smp spell sqlite sse sse2 sse3 ssl startup-notification svg sysfs tcpd threads tiff transcode truetype type1 udev unicode usb v4l v4l2 vcd vorbis wifi wma x264 xcb xcomposite xine xinerama xml xorg xulrunner xv xvid xvmc zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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="keyboard mouse evdev synaptics joystick" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" 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, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS root@pearcely2 actions # eix laptop-mode [I] app-laptop/laptop-mode-tools Available versions: 1.55-r1 {acpi apm bluetooth scsi} Installed versions: 1.55-r1(13:44:09 28/12/10)(acpi bluetooth -apm -scsi) Homepage: http://www.samwel.tk/laptop_mode/ Description: Linux kernel laptop_mode user-space utilities root@pearcely2 actions #
Created attachment 269621 [details] acpid and laptop-mode /etc/ config directories Configuration options for both ACPI and laptop-mode, to assist in determining problem.
/sys/class/power_supply: total used in directory 0 available 0 drwxr-xr-x 2 root root 0 Apr 12 21:09 . drwxr-xr-x 44 root root 0 Apr 12 21:09 .. lrwxrwxrwx 1 root root 0 Apr 12 21:09 AC -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/AC lrwxrwxrwx 1 root root 0 Apr 12 21:09 BAT0 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0 lrwxrwxrwx 1 root root 0 Apr 12 21:09 BAT1 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:01/power_supply/BAT1
Created attachment 269623 [details] tar archive of /sys/class/power_supply To provide info on the battery configuration
It appears my battery reports 0 on /sys/class/power_supply/BAT*/alarm Which, I am speculating, breaks the block of code in /usr/sbin/laptop_mode starting at line 771 (shown below) where ENOUGH_CHARGE_TO_PREVENT_HIBERNATION from the second battery will override the state of the first. In my case, it's the second battery which is discharged first, thus, laptop-mode will auto-hibernate when the second battery reports flat, not when they both report flat. At least, that's my initial interpretation. I would hope that the attached tar archive of /sys/class/power_supply would provide enough details to confirm this. ALARM_LEVEL=$(cat $BATT/alarm) if [ "$ALARM_LEVEL" -ne 0 ] ; then if [ "$REMAINING" -le "$ALARM_LEVEL" ] ; then # Restore the state we had before checking this battery, so that # this battery does not count as having enough charge. ENOUGH_CHARGE=$PREV_ENOUGH_CHARGE elif [ "$FOUND_AN_ENABLED_CHECK" -eq 0 ] ; then # This is the only check that is enabled. In that case a non-critical # battery level counts as "enough". (If we would count non-critical # battery levels as enough *always*, then the other settings would # have no effect; this is only a final fallback.) ENOUGH_CHARGE=1 fi fi if [ "$AUTO_HIBERNATION_ON_CRITICAL_BATTERY_LEVEL" -ne 0 ] ; then if [ "$REMAINING" -le "$ALARM_LEVEL" ] ; then ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=$PREV_ENOUGH_CHARGE_TO_PREVENT_HIBERNATION elif [ "$FOUND_AN_ENABLED_HIBERNATION_CHECK" -eq 0 ] ; then ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1 fi fi
Created attachment 270607 [details, diff] Patch to fix multiple batteries on HP EliteBook 8540w For Kernel 2.6.36-gentoo-r8 The HP EliteBook 8540w appears to populate /sys/class/power_supply/BAT*/alarm with zero. I have yet to check whether alarm is actually populated with a '1' if an alarm state. If this is the case, then the alarm value is being used incorrectly as laptop_mode. In addition, the HP EliteBook 8540w discharges BAT1 prior to BAT0. So, laptop_mode would see that BAT0 had sufficient charge, but when it found BAT1, in combination with ALARM=0, the charge state of BAT0 was lost, and the laptop would hibernate before fully discharging BAT0. Patch is simply moving a 'fi' down 6 lines and re-indenting the newly enclosed code as ALARM_LEVEL was used even though it was invalid (zero).
Would it be possible to send this patch upstream? If they accept it, then we can commit that to portage
Hello Lyall, The patch is someone strange as it shadow this block for other devices, please discuss it with upstream[1]. I will be happy to apply once upstream approves this. Thanks, Alon [1] http://samwel.tk/laptop_mode/
Hello Ritesh, Any progress with this issue? Thanks! Alon
Hello Ramos, On Thursday 03 January 2013 01:09 PM, Ritesh Raj Sarraf wrote: > I will look into it. Thank you for bringing this up. > > On Thu, Jan 3, 2013 at 2:54 AM, Pacho Ramos <pachoramos@gmail.com> wrote: >>> As reported downstream at: >>> https://bugs.gentoo.org/show_bug.cgi?id=363265 >>> >>> "Using an HP EliteBook 8540w with built in battery plus extended life >>> batter, ACPI events return for both BAT0 and BAT1. >>> laptop-mode hibernated the laptop when BAT0 was at 0% and BAT1 was at >>> 57%" >>> >>> Explanation about the issue is at: >>> https://bugs.gentoo.org/show_bug.cgi?id=363265#c4 >>> >>> And a patch that looks to fix this is at: >>> https://bugs.gentoo.org/show_bug.cgi?id=363265#c5 >>> >>> Could you please review it and include for a future release if possible? >>> >>> Thanks I finally had some time to look into this bug report. From what has been reported in the bug report, and looking at the code, I am not able to determine the problem. In the checks, we do account for all batteries present in the machine. We retain the states for all batteries. There could be 2 reasons for the unexpected hibernation. 1) LMT has a bug somewhere. Unfortunately, I cannot find the bug and do not have access to such hardware. The reporter may want to run LMT in debug mode so we have more information on what is happening. 2) It could be another (buggy) application that could have triggered the hibernation.