Bug 21722 - AC sysfs I/F exports cached AC status
Summary: AC sysfs I/F exports cached AC status
Status: CLOSED CODE_FIX
Alias: None
Product: ACPI
Classification: Unclassified
Component: Power-Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Zhang Rui
URL:
Keywords:
: 26092 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-11-02 00:27 UTC by Zhang Rui
Modified: 2011-01-06 03:27 UTC (History)
2 users (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments
dmesg output, with ACPI errors when evaluating _PSR (42.39 KB, text/plain)
2010-11-02 00:31 UTC, Zhang Rui
Details
patch: update the AC status when querying from sysfs (1.89 KB, text/plain)
2010-11-02 00:41 UTC, Zhang Rui
Details

Description Zhang Rui 2010-11-02 00:27:37 UTC
reported by Seblu(seblu@seblu.net) in the maillist,
http://marc.info/?l=linux-acpi&m=128855015826728&w=2

When starting up my laptop my AC adapter dectection was not done
correctly in sysfs, but correclty via procfs.

At first sight this was weird because acpitool calls ask my power
adapter is online, but my kde power manager dected adapter off-line.

$acpitool
  Battery #1     : charged, 100.0%, 00:00:00
  AC adapter     : on-line
  Thermal info   : <not available>

acpitool bring informations from /proc fs

$ cat /proc/acpi/ac_adapter/AC/state
state:                   on-line

So my system see correctly AC plugging state, so why kde not?

After some tracing, it seems that : kde power manager use powerdevi,
which use solid, which use hal, which use sysfs.

$ lshal -u /org/freedesktop/Hal/devices/computer_power_supply_ac_adapter_AC
udi = '/org/freedesktop/Hal/devices/computer_power_supply_ac_adapter_AC'
  ac_adapter.present = false  (bool)
  info.capabilities = {'ac_adapter'} (string list)
  info.category = 'ac_adapter'  (string)
  info.parent = '/org/freedesktop/Hal/devices/computer'  (string)
  info.product = 'Generic AC Adapter Device'  (string)
  info.subsystem = 'power_supply'  (string)
  info.udi = '/org/freedesktop/Hal/devices/computer_power_supply_ac_adapter_AC'
 (string)
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'power_supply'  (string)
  linux.sysfs_path =
'/sys/devices/LNXSYSTM:00/device:00/ACPI0003:00/power_supply/AC'
(string)

Got it, hal says adapter is offline...

cat /sys/devices/LNXSYSTM:00/device:00/ACPI0003:00/power_supply/AC/online
255
watching dmesg show error about acpi ac adapter reading... (in pj)

The most strange for me, is, if i call acpitool or cat
/proc/acpi/ac_adapter/AC/state, value in
/sys/devices/LNXSYSTM:00/device:00/ACPI0003:00/power_supply/AC/online
the answer goes right become 1. And so everything become ok. if i
unplug and plug again the power cord, online state is reported
correctly. This issue is only when the pc start with power cord
plugged.

I believe, issue come from a race condition, because if in my init
script i access to /proc acpi file, and after hal start, status is
reported correctly.

My current workaround is to load ac module in initrd, because, distro
startup run udevadm trigger after and when it's done before, behaviour
was like i said before.

my test was done on a dell laptop e6410 under linux-next-2010-10-29
and 2.6.35.8. (2.6.36 has big drm-intel regression on my laptop and
become unusable).

$uname -a
Linux rwolf 2.6.36-next-20101029 #1 SMP PREEMPT Sun Oct 31 17:34:37
CET 2010 x86_64 Intel(R) Core(TM) i7 CPU M 620 @ 2.67GHz GenuineIntel
GNU/Linux
Comment 1 Zhang Rui 2010-11-02 00:31:20 UTC
Created attachment 35802 [details]
dmesg output, with ACPI errors when evaluating _PSR
Comment 2 Zhang Rui 2010-11-02 00:41:21 UTC
Created attachment 35812 [details]
patch: update the AC status when querying from sysfs

this patch "fix" the problem for seblu. But I don't think we get the root cause yet.
Comment 3 Zhang Rui 2010-12-16 06:23:03 UTC
Patch in comment #2 shipped in acpi test tree.
Comment 4 Len Brown 2010-12-25 02:51:23 UTC
commit 3151dbb04ad5a5bd6358371c0bfb457216d00205
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Wed Dec 8 10:40:45 2010 +0800

    ACPI ac: update AC status upon sysfs query

shipped in 2.6.37-rc6
closed
Comment 5 TAXI 2011-01-06 03:27:02 UTC
*** Bug 26092 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.