Kernel doesn't generate a "Discharging" battery event after unplugging AC power on Full battery

From: James Gallagher
Date: Thu Oct 08 2009 - 16:39:02 EST


(This applies to kernel 2.6.31.2 and older)

If I unplug AC power on an Acer Aspire One with fully charged battery, the kernel/udev events generated indicate the only change as POWER_SUPPLY_ONLINE=0 (from 1), the battery POWER_SUPPLY_STATUS is still indicating FULL, and no change in the battery environment, even though the event is labelled ACTION=change on both the mains (ACAD) and battery (BAT1) (see attached log of the 4 kernel/udev events generated after unplugging)

This causes DeviceKit-power to suspend polling, so the power manager never records the subsequent discharge of the battery (the battery state in /sys updates to "Discharging" about 10 seconds later). The redhat guys on bugzilla are insisting it's a kernel/udev bug, not a DeviceKit-power bug.

This also occurs on a Dell Inspiron 1520, but less predictably - ie sometimes the battery STATE=Discharging and sometimes =FULL.

So Questions?

1. Why does the kernel generate a change event for the battery when there is no change?
2. Why does the battery STATE indicate Full rather than Discharging?
3. Why does it take ~10 seconds for the battery state to change to "Discharging" in /sys, and why is there no accompanying udev event to indicate the status change?

See https://bugzilla.redhat.com/show_bug.cgi?id=521874 (bug has been re-assigned from DeviceKit-power to Kernel)

James Gallagher

(can replies be cc'ed to me, cheers)


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

KERNEL[1254931537.850913] change /devices/LNXSYSTM:00/device:00/ACPI0003:00/power_supply/ACAD (power_supply)
UDEV_LOG=3
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/device:00/ACPI0003:00/power_supply/ACAD
SUBSYSTEM=power_supply
POWER_SUPPLY_NAME=ACAD
POWER_SUPPLY_TYPE=Mains
POWER_SUPPLY_ONLINE=0
SEQNUM=1247

UDEV [1254931537.896863] change /devices/LNXSYSTM:00/device:00/ACPI0003:00/power_supply/ACAD (power_supply)
UDEV_LOG=3
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/device:00/ACPI0003:00/power_supply/ACAD
SUBSYSTEM=power_supply
POWER_SUPPLY_NAME=ACAD
POWER_SUPPLY_TYPE=Mains
POWER_SUPPLY_ONLINE=0
SEQNUM=1247

KERNEL[1254931538.555417] change /devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT1 (power_supply)
UDEV_LOG=3
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT1
SUBSYSTEM=power_supply
POWER_SUPPLY_NAME=BAT1
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Full
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
POWER_SUPPLY_VOLTAGE_NOW=12584000
POWER_SUPPLY_CURRENT_NOW=65163000
POWER_SUPPLY_CHARGE_FULL_DESIGN=2400000
POWER_SUPPLY_CHARGE_FULL=1111000
POWER_SUPPLY_CHARGE_NOW=1111000
POWER_SUPPLY_MODEL_NAME=UM08A72
POWER_SUPPLY_MANUFACTURER=SIMPLO
POWER_SUPPLY_SERIAL_NUMBER=1C8C
SEQNUM=1248

UDEV [1254931538.563046] change /devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT1 (power_supply)
UDEV_LOG=3
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT1
SUBSYSTEM=power_supply
POWER_SUPPLY_NAME=BAT1
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Full
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
POWER_SUPPLY_VOLTAGE_NOW=12584000
POWER_SUPPLY_CURRENT_NOW=65163000
POWER_SUPPLY_CHARGE_FULL_DESIGN=2400000
POWER_SUPPLY_CHARGE_FULL=1111000
POWER_SUPPLY_CHARGE_NOW=1111000
POWER_SUPPLY_MODEL_NAME=UM08A72
POWER_SUPPLY_MANUFACTURER=SIMPLO
POWER_SUPPLY_SERIAL_NUMBER=1C8C
SEQNUM=1248