Refresh method authorization

Marc Ferland marc.ferland at gmail.com
Thu Sep 30 06:30:41 PDT 2010


On Thu, Sep 30, 2010 at 8:45 AM, Richard Hughes <hughsient at gmail.com> wrote:
> On 30 September 2010 13:04, Marc Ferland <marc.ferland at gmail.com> wrote:
>> I'm having BIOS/firmware related problems that prevent some interrupt
>> from being sent to the OS. I have to manually refresh the status.
>> Since the problem is firmware related, it will probably won't be fixed
>> in the kernel (see this bug report for more info:
>> https://bugzilla.kernel.org/show_bug.cgi?id=19022). The only option
>> left is to refresh the status by polling.
>
> Right, is there any DMI data or device data that can be used to force
> upower to keep polling? I think that's preferable than userspace keep
> requesting Refresh().
>

Of course, I would rather not be polling from user space all the. The
battery status (percentage, remaining time, etc) is correctly updated
by upowerd and is delivered to user-space as normal but not the
battery or AC plug/unplugged events (caused by the firmware
limitation).

So what happens is that if I remove a battery or unplug the AC cable,
the devices just stop updating but they are not removed from the
/sysfs tree. They are still there with false information....

The only way I've found to update the devices tree (sysfs) is to
manually read the /proc/acpi/battery/BAT[12]/state file. Reading this
file seems to force a read of the battery presence _and_ their status
information. So this works well in theory for the batteries.

For the AC adapter, I found that the information, even when correctly
updated in the sysfs tree, is not updated in upowerd. This is why I
wanted to manually refresh it.

For example:

On a machine running on batteries:
# upower -d
Device: /org/freedesktop/UPower/devices/line_power_ADP1
 native-path:
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:02/ACPI0003:00/power_supply/ADP1
 power supply:         yes
 updated:              Thu Sep 30 12:49:48 2010 (1638 seconds ago)
 has history:          no
 has statistics:       no
 line-power
   online:             no

Device: /org/freedesktop/UPower/devices/battery_BAT1
 native-path:
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:02/PNP0C0A:00/power_supply/BAT1
 vendor:               SHEnerTech
 model:                LI202SX
 serial:               SN 00E5
 power supply:         yes
 updated:              Thu Sep 30 13:16:54 2010 (12 seconds ago)
 has history:          yes
 has statistics:       yes
 battery
   present:             yes
   rechargeable:        yes
   state:               discharging
   energy:              23.643 Wh
   energy-empty:        0 Wh
   energy-full:         79.8423 Wh
   energy-full-design:  79.92 Wh
   energy-rate:         18.6036 W
   voltage:             11.011 V
   time to empty:       1.3 hours
   percentage:          29.6121%
   capacity:            99.9028%
 History (charge):
   1285852554  29.612  discharging
 History (rate):
   1285852614  18.604  discharging
   1285852584  18.615  discharging
   1285852554  18.570  discharging
   1285852524  18.604  discharging

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

Now if I plug the AC adapter in:
# upower -d
Device: /org/freedesktop/UPower/devices/line_power_ADP1
 native-path:
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:02/ACPI0003:00/power_supply/ADP1
 power supply:         yes
 updated:              Thu Sep 30 12:49:48 2010 (1792 seconds ago)
 has history:          no
 has statistics:       no
 line-power
   online:             no

Device: /org/freedesktop/UPower/devices/battery_BAT1
 native-path:
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:02/PNP0C0A:00/power_supply/BAT1
 vendor:               SHEnerTech
 model:                LI202SX
 serial:               SN 00E5
 power supply:         yes
 updated:              Thu Sep 30 13:19:24 2010 (16 seconds ago)
 has history:          yes
 has statistics:       yes
 battery
   present:             yes
   rechargeable:        yes
   state:               charging
   energy:              22.8549 Wh
   energy-empty:        0 Wh
   energy-full:         79.8423 Wh
   energy-full-design:  79.92 Wh
   energy-rate:         0 W
   voltage:             11.248 V
   percentage:          28.6251%
   capacity:            99.9028%
 History (charge):
   1285852704  28.625  discharging
 History (rate):
   1285852764  0.000   charging
   1285852734  18.648  discharging
   1285852704  18.626  discharging
   1285852674  18.659  discharging

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

The battery status has been updated (state is now charging) but the AC
adapter is marked as offline... and by looking at the "updated" field
of the AC power line it looks like it was never updated.

Now if I ask sysfs:
# cat /sys/class/power_supply/ADP1/online
0

And procfs:
cat /proc/acpi/ac_adapter/ADP1/state
state:                   on-line

And then to sysfs again:
cat /sys/class/power_supply/ADP1/online
1

And to upowerd again:
upower -d
Device: /org/freedesktop/UPower/devices/line_power_ADP1
 native-path:
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:02/ACPI0003:00/power_supply/ADP1
 power supply:         yes
 updated:              Thu Sep 30 12:49:48 2010 (2175 seconds ago)
 has history:          no
 has statistics:       no
 line-power
   online:             no

Still offline and the updated field wasn't updated.

Hope this is not too confusing !

Regards,

Marc


More information about the devkit-devel mailing list