You are not logged in.

#1 2016-09-16 20:44:10

flargen
Member
Registered: 2012-10-27
Posts: 13

Lid events are always handled as if laptop is docked

I've read all the recent posts about logind.conf settings not working correctly, but I think I'm having a different issue.

The behaviour I'd like to see is what I believe the default settings should provide: laptop suspending when the lid is closed and no external displays are connected; laptop NOT suspending at all when any external displays are connected ("docked"). However, with the default logind.conf settings (the defaults are commented out), i.e.

...
#HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
...

the laptop will never suspend, external display connected or not. If I add

HandleLidSwitchDocked=suspend

myself, it proceeds to suspend regardless of external displays. Finally, if I add

HandleLidSwitch=ignore

along with the Docked setting in the previous sentence, it again suspends always. This is what leads me to believe it thinks it is always docked.

Output of

xrandr -q

with no external displays:

~> xrandr -q
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
eDP-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 293mm x 165mm
   1920x1080     60.00*+  40.00  
   1400x1050     59.98  
   1280x1024     60.02  
   1280x960      60.00  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   800x600       60.00    60.32    56.25  
   700x525       59.98  
   640x512       60.02  
   640x480       60.00    59.94  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)

and with a DisplayPort monitor attached

~> xrandr -q
Screen 0: minimum 320 x 200, current 1920 x 2160, maximum 8192 x 8192
eDP-1 connected primary 1920x1080+0+1080 (normal left inverted right x axis y axis) 293mm x 165mm
   1920x1080     60.00*+  40.00  
   1400x1050     59.98  
   1280x1024     60.02  
   1280x960      60.00  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   800x600       60.00    60.32    56.25  
   700x525       59.98  
   640x512       60.02  
   640x480       60.00    59.94  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
DP-1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 509mm x 286mm
   1920x1080     60.00*+
   1680x1050     59.95  
   1600x900      60.00  
   1280x1024     60.02  
   1440x900      59.89  
   1280x720      60.00  
   1024x768      60.00  
   800x600       60.32  
   640x480       59.94  
   720x400       70.08  
HDMI-1 disconnected (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)

The laptop screen (eDP-1) is clearly the only detected display in the first output.

My laptop is an HP Spectre 13 with Intel® HD Graphics 4400 running Gnome (but same behaviour from text console). Fully updated Arch (linux-4.7.3-2, systemd-231-1). Please let me know if I've omitted anything relevant.

Thanks in advance

Offline

#2 2016-09-17 16:57:23

flargen
Member
Registered: 2012-10-27
Posts: 13

Re: Lid events are always handled as if laptop is docked

The same behaviour occurs with kernel 4.7.4-1-ARCH

Last edited by flargen (2016-09-17 16:57:49)

Offline

#3 2016-09-17 22:47:02

laloch
Member
Registered: 2010-02-04
Posts: 186

Re: Lid events are always handled as if laptop is docked

Sounds familiar.
What does journalctl -ru systemd-logind say?

Offline

#4 2016-09-18 00:19:02

flargen
Member
Registered: 2012-10-27
Posts: 13

Re: Lid events are always handled as if laptop is docked

Thanks for the link - looks very relevant.

The following is with only my laptop display connected. After adding debug to the kernel parameters the journal contains a number of

Sep 18 00:53:29 matthew-laptop systemd-logind[308]: System is docked.

messages. I'm also seeing

Sep 18 00:53:38 matthew-laptop systemd-logind[308]: Inhibitor matthew (Multiple displays attached) pid=622 uid=1000 mode=block stopped.

among a number of other Inhibitor... messages (e.g. network, keypress related etc.). I'm guessing these are inhibitors being registered with logind, rather than it detecting multiple monitors erroneously. Full logind journal: http://pastebin.com/hQqxwS76

Following your link, I played with evtest (with all 16 "inputs"!) and it looks like "HP WMI hotkeys" might be the culprit. It is reporting the suspicious-looking states:

    Event code 1 (SW_TABLET_MODE) state 1
    Event code 5 (SW_DOCK) state 1

This laptop has a touchscreen, so I don't know if that's why "SW_TABLET_MODE" is in state 1, but "SW_DOCK" definitely looks wrong. I'll look into the hp-wmi kernel module.

Edit: systemd pull request https://github.com/systemd/systemd/pull/1100 which enabled detecting SW_DOCK (from laptop drivers, e.g. hp-wmi) to determine docking status (in addition to detecting displays)

Last edited by flargen (2016-09-18 00:25:07)

Offline

#5 2016-09-18 00:51:07

flargen
Member
Registered: 2012-10-27
Posts: 13

Re: Lid events are always handled as if laptop is docked

OK, the hp-wmi module is the cause of the problem. Blacklisting it in the kernel boot parameters causes the SW_DOCK journal entries to disappear and the laptop sleeps like normal when the lid is closed. I cannot check the behaviour with the external monitor until Monday, but I suspect it will work. Not 100% sure what hp-wmi does - seems to be related to hotkeys, but all hotkeys seem to still work including wireless toggle. The only exception is the display switching key, which I again cannot check now - maybe it's this?

Offline

#6 2016-09-18 02:08:41

laloch
Member
Registered: 2010-02-04
Posts: 186

Re: Lid events are always handled as if laptop is docked

The driver should expose /sys/devices/platform/hp-wmi/dock pseudo-file. Reading from it invokes the corresponding ACPI-WMI method. If it returns "1" with the display/dock disconnected, your BIOS is most probably incompatible or buggy.

Offline

#7 2016-09-18 12:29:53

flargen
Member
Registered: 2012-10-27
Posts: 13

Re: Lid events are always handled as if laptop is docked

I get the follow as a regular user and as root (sudo):

~> cat /sys/devices/platform/hp-wmi/dock
cat: /sys/devices/platform/hp-wmi/dock: Invalid argument

A few of the other entries return the same, including "display". However, "tablet" gives "4"...

Offline

#8 2016-09-18 13:12:31

laloch
Member
Registered: 2010-02-04
Posts: 186

Re: Lid events are always handled as if laptop is docked

The EINVAL (invalid argument) error is OK. It signals that the driver is indeed not (yet?) compatible with your BIOS. There's however definitely a bug in the way the rest of the driver code interprets the BIOS call result. The same applies to SW_TABLET_MODE - the same buggy evaluation there. You should IMO report the bug upstream.

Offline

Board footer

Powered by FluxBB