Bug 25041

Summary: lid-is-present doesn't report correct status
Product: upower Reporter: Yves-Alexis <corsac>
Component: generalAssignee: Richard Hughes <richard>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: f, sam
Version: unspecified   
Hardware: Other   
OS: All   
URL: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=555740
Whiteboard:
i915 platform: i915 features:
Attachments: devkit-power-daemon --verbose - Version 13
test patch

Description Yves-Alexis 2009-11-11 09:23:43 UTC
Hi,

I tried to play a little with devicekit-power. Besides the can-hibernate stuff, I have a problem with lid-is-present:

corsac@hidalgo: devkit-power -d | grep lid
  lid-is-closed:   no
  lid-is-present:   no

This is on a ThinkPad T61 laptop (which indeed has a lid).

It's reported in lsinput:

/dev/input/event4
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x5
   version : 0
   name    : "Lid Switch"
   phys    : "PNP0C0D/button/input0"
   bits ev : EV_SYN EV_SW

And has the capability:

cat /sys/class/input/input4/capabilities/sw
1

I first reported on the Debian BTS, but as it seems not to be a Debian-specific issue, I was asked to port that here. If you need more info, please ask.

Cheers,
--
Yves-Alexis
Comment 1 Sam Morris 2009-11-16 13:33:37 UTC
I'm seeing this too on a Samsung Q45.
Comment 2 Yves-Alexis 2009-11-16 13:47:25 UTC
(In reply to comment #1)
> I'm seeing this too on a Samsung Q45.

Did you try to reboot (Yeah, I know...). It fixed the problem for me, not exactly sure why
Comment 3 Richard Hughes 2009-11-17 01:24:17 UTC
Can you get the devkit-power-daemon --verbose output please. Thanks.
Comment 4 Florian Lohoff 2010-01-08 07:20:21 UTC
I am seeing the same on Fujitsu Lifebook E8110

flo@lifebook:~$ grep . /sys/devices/LNXSYSTM:00/device:00/*/input/input*/name
/sys/devices/LNXSYSTM:00/device:00/FUJ02E3:00/input/input8/name:Fujitsu FUJ02E3
/sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/name:Power Button
/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/name:Lid Switch
/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/name:Sleep Button

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


devkit-power-daemon --verbose attached in a minute.
Comment 5 Florian Lohoff 2010-01-08 07:21:15 UTC
Created attachment 32523 [details]
devkit-power-daemon --verbose - Version 13
Comment 6 Richard Hughes 2010-01-08 08:08:20 UTC
The interesting bit is here:

TI:16:17:41	FI:dkp-input.c	FN:dkp_input_coldplug,185
 - not a switch [/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/../capabilities/sw]
*** WARNING ***
TI:16:17:41	FI:dkp-input.c	FN:dkp_input_coldplug,215
 - no device file

This points to a kernel driver error as there is no device file to open, and thus read!
Comment 7 Florian Lohoff 2010-01-08 13:40:31 UTC
The point is that the switch of gnome-power-manager from hal to devicekit brings the regression on my notebook that i am not any longer able to suspend on lid close. So in the end i dont care who is at fault - its a very clear and simple regression moving from hal to devicekit-power

Comment 8 Florian Lohoff 2010-01-08 13:49:10 UTC
Ah - while investigating the sys dirs:

I dont have a 

/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/../capabilities/sw

But i DO have a 

/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/sw


lifebook:~# cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/sw
1
lifebook:~# cat /sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/../capabilities/sw
cat: /sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/../capabilities/sw: No such file or directory
Comment 9 Florian Lohoff 2010-01-08 13:55:04 UTC
Complete output of the input an capabilities subdirs ...

lifebook:~# grep . /sys/devices/LNXSYSTM:00/device:00/*/input/input*/{name,capabilities/*} | sort -r
/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/name:Sleep Button
/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/capabilities/sw:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/capabilities/snd:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/capabilities/rel:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/capabilities/msc:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/capabilities/led:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/capabilities/key:4000 0 0 0 0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/capabilities/ff:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/capabilities/ev:3
/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/capabilities/abs:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/name:Lid Switch
/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/sw:1
/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/snd:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/rel:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/msc:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/led:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/key:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/ff:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/ev:21
/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/abs:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/name:Power Button
/sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/capabilities/sw:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/capabilities/snd:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/capabilities/rel:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/capabilities/msc:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/capabilities/led:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/capabilities/key:100000 0 0 0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/capabilities/ff:0
/sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/capabilities/ev:3
/sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/capabilities/abs:0
/sys/devices/LNXSYSTM:00/device:00/FUJ02E3:00/input/input8/name:Fujitsu FUJ02E3
/sys/devices/LNXSYSTM:00/device:00/FUJ02E3:00/input/input8/capabilities/sw:0
/sys/devices/LNXSYSTM:00/device:00/FUJ02E3:00/input/input8/capabilities/snd:0
/sys/devices/LNXSYSTM:00/device:00/FUJ02E3:00/input/input8/capabilities/rel:0
/sys/devices/LNXSYSTM:00/device:00/FUJ02E3:00/input/input8/capabilities/msc:0
/sys/devices/LNXSYSTM:00/device:00/FUJ02E3:00/input/input8/capabilities/led:0
/sys/devices/LNXSYSTM:00/device:00/FUJ02E3:00/input/input8/capabilities/key:10000 c00 0 300000 0 0 0 0
/sys/devices/LNXSYSTM:00/device:00/FUJ02E3:00/input/input8/capabilities/ff:0
/sys/devices/LNXSYSTM:00/device:00/FUJ02E3:00/input/input8/capabilities/ev:3
/sys/devices/LNXSYSTM:00/device:00/FUJ02E3:00/input/input8/capabilities/abs:0
Comment 10 Florian Lohoff 2010-01-08 14:14:15 UTC
Investigating further - devkit tries to open this:

23700 lstat64("/dev/.udev/db/\\x2fdevices\\x2fLNXSYSTM:00\\x2fdevice:00\\x2fPNP0C0D:00\\x2finput\\x2finput4\\x2fevent4", 0xbfbceec8) = -1 ENOENT (No such file or directory)

which does not exist - But i do have all sorts of input devices:

lifebook:~# ls -la /dev/.udev/db/input\:*
-rw-r--r-- 1 root root 212 2010-01-07 11:19 /dev/.udev/db/input:event0
-rw-r--r-- 1 root root  87 2010-01-07 11:19 /dev/.udev/db/input:event1
-rw-r--r-- 1 root root 198 2010-01-07 11:19 /dev/.udev/db/input:event10
-rw-r--r-- 1 root root  71 2010-01-07 11:19 /dev/.udev/db/input:event11
-rw-r--r-- 1 root root 195 2010-01-07 11:20 /dev/.udev/db/input:event12
-rw-r--r-- 1 root root 131 2010-01-07 11:20 /dev/.udev/db/input:event13
-rw-r--r-- 1 root root  87 2010-01-07 11:19 /dev/.udev/db/input:event3
-rw-r--r-- 1 root root  70 2010-01-07 11:19 /dev/.udev/db/input:event4
-rw-r--r-- 1 root root  87 2010-01-07 11:19 /dev/.udev/db/input:event5
-rw-r--r-- 1 root root  87 2010-01-07 11:19 /dev/.udev/db/input:event6
-rw-r--r-- 1 root root  87 2010-01-07 11:19 /dev/.udev/db/input:event7
-rw-r--r-- 1 root root  87 2010-01-07 11:19 /dev/.udev/db/input:event8
-rw-r--r-- 1 root root 160 2010-01-07 11:19 /dev/.udev/db/input:event9
lrwxrwxrwx 1 root root  21 2010-01-07 11:19 /dev/.udev/db/input:mice -> input/mice char/13:63
-rw-r--r-- 1 root root 162 2010-01-07 11:19 /dev/.udev/db/input:mouse1
-rw-r--r-- 1 root root 159 2010-01-07 11:20 /dev/.udev/db/input:mouse2
lifebook:~# 

Might this be a udev / devicekit mismatch?

My udev version is 149 - I dont have any nodes with a \\x2f in the /dev/.udev/db directory and i had a look at 4 other systems:

sys1 squeeze udev 149 - No \x2f in db - links dir with \x2f dirs
sys2 sid     udev 149 - No \x2f in db - links dir with \x2f dirs
sys3 lenny   udev 125 - Lots of \x2f links in /dev/.udev/db
sys4 lenny   udev 125 - Lots of \x2f links in /dev/.udev/db

Flo
Comment 11 Richard Hughes 2010-01-09 00:45:56 UTC
Created attachment 32541 [details] [review]
test patch

Can you try the attached patch against git master please. Thanks.
Comment 12 Florian Lohoff 2010-01-09 05:22:40 UTC
Nope - doesnt work (completely) - it seems to find the sw file and
the capabilities - but

I:14:20:29     FI:dkp-input.c  FN:dkp_input_coldplug,205
 - not one bitmask entry for /sys/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input5/event5
TI:14:20:29     FI:dkp-input.c  FN:dkp_input_coldplug,185
 - not a switch [/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/../capabilities/sw]
*** WARNING ***
TI:14:20:29     FI:dkp-input.c  FN:dkp_input_coldplug,220
 - no device file
*** WARNING ***
TI:14:20:29     FI:dkp-input.c  FN:dkp_input_coldplug,220
 - no device file
TI:14:20:29     FI:dkp-input.c  FN:dkp_input_coldplug,185
 - not a switch [/sys/devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input6/../capabilities/sw]
TI:14:20:29     FI:dkp-input.c  FN:dkp_input_coldplug,205

And no success:

Daemon:
  daemon-version:  015
  can-suspend:     yes
  can-hibernate    yes
  on-battery:      yes
  on-low-battery:  no
  lid-is-closed:   no
  lid-is-present:   no
Comment 13 Florian Lohoff 2010-01-09 05:41:37 UTC
Just to give you more input - the patch itself i think is correct

This is an strace output - you can see that opening capabilities/sw instead of ../capabilities/sw works - But opening the device doesnt - it seems from
reading the code that g_udev_device_get_device_file returns a non existing
file. Something seems to be wrong with udev i guess:

flo@lifebook:~/projects/devicekit/DeviceKit-power$ find /dev/.udev/ | grep 2f | grep input
/dev/.udev/links/input\x2fby-path\x2fplatform-i8042-serio-5-event-mouse
/dev/.udev/links/input\x2fby-path\x2fplatform-i8042-serio-5-event-mouse/c13:76
/dev/.udev/links/input\x2fby-path\x2fplatform-i8042-serio-5-mouse
/dev/.udev/links/input\x2fby-path\x2fplatform-i8042-serio-5-mouse/c13:34
/dev/.udev/links/input\x2fby-path\x2fplatform-i8042-serio-4-event-mouse
/dev/.udev/links/input\x2fby-path\x2fplatform-i8042-serio-4-event-mouse/c13:74
/dev/.udev/links/input\x2fby-path\x2fplatform-i8042-serio-4-mouse
/dev/.udev/links/input\x2fby-path\x2fplatform-i8042-serio-4-mouse/c13:33
/dev/.udev/links/input\x2fby-path\x2fplatform-pcspkr-event-spkr
/dev/.udev/links/input\x2fby-path\x2fplatform-pcspkr-event-spkr/c13:73
/dev/.udev/links/input\x2fby-path\x2fplatform-i8042-serio-0-event-kbd
/dev/.udev/links/input\x2fby-path\x2fplatform-i8042-serio-0-event-kbd/c13:64


No input devices for the lid - and not in the /dev/.udev/db/ dir as
gudev suggest - it seems from udev 125 to 149 the long dirs went into
a links subdir - but not all get generated or something ...


3719  readlink("/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/subsystem", "../../../../../../class/input"..., 1024) = 29
3719  access("/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/../capabilities/sw", F_OK) = -1 ENOENT (No such file or directory)
3719  write(1, "\33[32mTI:14:29:48\tFI:dkp-input.c\t"..., 58) = 58
3719  access("/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/sw", F_OK) = 0
3719  open("/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/capabilities/sw", O_RDONLY|O_LARGEFILE) = 8
3719  open("/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/uevent", O_RDONLY|O_LARGEFILE) = 8
3719  lstat64("/dev/.udev/db/\\x2fdevices\\x2fLNXSYSTM:00\\x2fdevice:00\\x2fPNP0C0D:00\\x2finput\\x2finput4", 0xbf8dd218) = -1 ENOENT (No such file or directory)
3719  write(1, "\33[32mTI:14:29:48\tFI:dkp-input.c\t"..., 58) = 58
3719  readlink("/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/event4/subsystem", "../../../../../../../class/input"..., 1024) = 32
3719  access("/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/event4/../capabilities/sw", F_OK) = 0
3719  open("/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/event4/../capabilities/sw", O_RDONLY|O_LARGEFILE) = 8
3719  open("/sys/devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4/event4/uevent", O_RDONLY|O_LARGEFILE) = 8
3719  lstat64("/dev/.udev/db/\\x2fdevices\\x2fLNXSYSTM:00\\x2fdevice:00\\x2fPNP0C0D:00\\x2finput\\x2finput4\\x2fevent4", 0xbf8dd218) = -1 ENOENT (No such file or directory)
3719  write(1, "\33[32mTI:14:29:48\tFI:dkp-input.c\t"..., 58) = 58


Comment 14 Yves-Alexis 2010-01-09 06:26:01 UTC
I don't think it's the same problem since mine is fixed since a long time
Comment 15 Florian Lohoff 2010-01-11 07:38:47 UTC

Okay - debugged further - one of the bugs is fixed with your patch. The other necessary issue is a newer udev or better - libudev - I had still libudev 146 install which seems broken in this respect. Upgrading to libudev 149 together with your patch gets it going.

I'll feedback to the debian maintainers to put a libudev >= 149 dependency on the next devkit package. Or better - appropriate libgudev dependencys ...
Comment 16 Richard Hughes 2010-01-11 07:57:51 UTC
Okay, thanks for confirming. I've pushed the following:

commit e93895a257b1215fa0ab0e3667e900df7709fa60
Author: Richard Hughes <richard@hughsie.com>
Date:   Mon Jan 11 15:56:53 2010 +0000

    Use a fallback for the capability bit when checking the lid status. Fixes #25041

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.