Bug 100522 - Lenovo T470s fails to detect on-battery
Summary: Lenovo T470s fails to detect on-battery
Status: RESOLVED NOTOURBUG
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:
Depends on:
Blocks:
 
Reported: 2017-04-01 07:54 UTC by Julien Goodwin
Modified: 2017-06-13 05:20 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Julien Goodwin 2017-04-01 07:54:59 UTC
Hardware is a brand new Lenovo T470s which has two internal batteries.

Regardless whether a charger is connected, or the system is powered from
internal batteries, "on-battery" is always shown as "no".

Here's the result of upower -d while running from battery:

Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          AC
  power supply:         yes
  updated:              Thu 30 Mar 2017 22:10:35 AEDT (36 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              yes
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SANYO
  model:                00HW022
  serial:               472
  power supply:         yes
  updated:              Thu 30 Mar 2017 22:11:02 AEDT (9 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    energy:              24.11 Wh
    energy-empty:        0 Wh
    energy-full:         24.67 Wh
    energy-full-design:  23.51 Wh
    energy-rate:         0 W
    voltage:             12.861 V
    percentage:          97%
    capacity:            100%
    technology:          lithium-polymer
    icon-name:          'battery-full-symbolic'
  History (charge):
    1490872236  97.000  fully-charged
    1490872235  0.000   unknown
  History (rate):
    1490872235  0.000   unknown

Device: /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               SMP
  model:                01AV406
  serial:               2230
  power supply:         yes
  updated:              Thu 30 Mar 2017 22:10:35 AEDT (36 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    warning-level:       none
    energy:              26.32 Wh
    energy-empty:        0 Wh
    energy-full:         26.32 Wh
    energy-full-design:  26.06 Wh
    energy-rate:         0 W
    voltage:             12.839 V
    percentage:          100%
    capacity:            100%
    technology:          lithium-polymer
    icon-name:          'battery-full-charged-symbolic'
  History (charge):
    1490872235  0.000   unknown
  History (rate):
    1490872235  0.000   unknown

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         yes
  updated:              Thu 30 Mar 2017 22:11:02 AEDT (9 seconds ago)
  has history:          no
  has statistics:       no
  battery
    present:             yes
    state:               discharging
    warning-level:       none
    energy:              50.43 Wh
    energy-full:         50.99 Wh
    energy-rate:         0 W
    percentage:          98.9017%
    icon-name:          'battery-full-symbolic'

Daemon:
  daemon-version:  0.99.4
  on-battery:      no
  lid-is-closed:   no
  lid-is-present:  yes
  critical-action: PowerOff


Potentially relevant is that acpi -a follows power state:
$ acpi -a
Adapter 0: on-line
$ acpi -a
Adapter 0: off-line
Comment 1 Julien Goodwin 2017-04-01 07:56:41 UTC
Running Debian testing, upower package is version 0.99.4-4+b1.

From the Debian bug report (which I now can't find, despite submitting it)

-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_AU.utf8, LC_CTYPE=en_AU.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Init: systemd (via /run/systemd/system)

Versions of packages upower depends on:
ii  dbus               1.10.16-1
ii  libc6              2.24-9
ii  libglib2.0-0       2.50.3-1
ii  libgudev-1.0-0     230-3
ii  libimobiledevice6  1.2.0+dfsg-3.1
ii  libplist3          1.12+git+1+e37ca00-0.1
ii  libupower-glib3    0.99.4-4+b1
ii  libusb-1.0-0       2:1.0.21-1
ii  udev               232-19

Versions of packages upower recommends:
ii  policykit-1  0.105-17

upower suggests no packages.

-- no debconf information
Comment 2 Julien Goodwin 2017-04-01 08:03:08 UTC
Reading the source and looking at what I get from upower -d I think in ./src/up-daemon.c, up_daemon_get_on_battery_local would return true, but up_daemon_get_on_ac_local would *also* return true, which is enough to never set the exported on-battery to true.
Comment 3 Julien Goodwin 2017-04-01 08:06:40 UTC
Debian bug is:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=859105
Comment 4 Julien Goodwin 2017-04-05 06:42:02 UTC
This seems to be never refreshing the AC supply status.

Battery status seems to update fairly frequently, but AC does not.

(All while on battery)

$ upower -d
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          AC
  power supply:         yes
  updated:              Mon 03 Apr 2017 14:34:59 AEST (179920 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              yes
    icon-name:          'ac-adapter-symbolic'

...

Daemon:
  daemon-version:  0.99.4
  on-battery:      no
  lid-is-closed:   no
  lid-is-present:  yes
  critical-action: PowerOff

$ sudo systemctl restart upower
$ upower -d
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          AC
  power supply:         yes
  updated:              Wed 05 Apr 2017 16:37:48 AEST (3 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              no
    icon-name:          'ac-adapter-symbolic'

...
Daemon:
  daemon-version:  0.99.4
  on-battery:      yes
  lid-is-closed:   no
  lid-is-present:  yes
  critical-action: PowerOff
Comment 5 Christian Kellner 2017-05-11 15:15:44 UTC
Can confirm on a T470s (tested with fedora 25, kernel 4.8.6-300.fc25.x86_64). It seems the root cause is that we don't get any udev events for the AC adapter. The following log is me unplugging and re-plugging the adapter (NB no events for AC):

# udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[611.708340] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
UDEV  [611.711087] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
KERNEL[611.785185] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
UDEV  [611.786809] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
KERNEL[617.946159] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
UDEV  [617.948944] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
KERNEL[617.983067] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
UDEV  [617.984088] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
Comment 6 Christian Kellner 2017-05-16 13:38:44 UTC
After updating the firmware of the T470s to the version 1.10 this problem is gone and I am getting the proper udev events (NB the AC lines):

KERNEL[419.475855] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
UDEV  [419.481963] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
KERNEL[419.508922] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
UDEV  [419.511957] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/PNP0C0A:01/power_supply/BAT1 (power_supply)
KERNEL[419.981587] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)
UDEV  [419.985512] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)
KERNEL[420.009402] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)
UDEV  [420.015641] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)

These are properly picked up by UPower.
Comment 7 Julien Goodwin 2017-06-13 05:20:07 UTC
Confirm that an update to 1.10 worked on my T470s as well.

Thanks.


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.