Bug 21230 - [KMS i915] closing laptop lid kills LVDS until reboot
Summary: [KMS i915] closing laptop lid kills LVDS until reboot
Status: CLOSED FIXED
Alias: None
Product: DRI
Classification: Unclassified
Component: DRM/Intel (show other bugs)
Version: unspecified
Hardware: Other All
: medium major
Assignee: Jesse Barnes
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords: patch
: 22887 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-04-16 09:55 UTC by Saikat Guha
Modified: 2017-07-24 23:10 UTC (History)
10 users (show)

See Also:
i915 platform:
i915 features:


Attachments
dmesg after lid close/reopen (35.76 KB, text/plain)
2009-04-16 09:56 UTC, Saikat Guha
no flags Details
intel reg_dumper before lid close (8.62 KB, text/plain)
2009-04-16 09:56 UTC, Saikat Guha
no flags Details
intel reg_dumper while lid is closed (8.67 KB, text/plain)
2009-04-16 09:57 UTC, Saikat Guha
no flags Details
intel reg_dumper after lid is re-opened (8.63 KB, text/plain)
2009-04-16 09:57 UTC, Saikat Guha
no flags Details
xorg log (86.52 KB, text/plain)
2009-04-16 09:57 UTC, Saikat Guha
no flags Details
add lid event handler (2.43 KB, patch)
2009-05-04 13:19 UTC, Jesse Barnes
no flags Details | Splinter Review
add lid detection (6.53 KB, patch)
2009-05-13 11:52 UTC, Jesse Barnes
no flags Details | Splinter Review
acpidump output (274.46 KB, text/plain)
2009-06-09 03:21 UTC, Saikat Guha
no flags Details
add lid detection & mode reset (6.64 KB, patch)
2009-07-07 15:49 UTC, Jesse Barnes
no flags Details | Splinter Review

Description Saikat Guha 2009-04-16 09:55:53 UTC
I am using KMS with a Intel 915GM card (on a Thinkpad X41 Tablet).
Closing and reopening the lid blanks the display permanently until a reboot.
Same for docking/undocking. 

This happens even before X starts. This is not related to suspend/hibernate
etc. The problem occurs only with modeset enabled.

I can still fly blind (or log in over the network); and vbetool dpms
does manage to turn the backlight on or off, but the display remains
black. 

I posted a video of the bug at:
http://www.youtube.com/watch?v=-q1N4iosOCI
Comment 1 Saikat Guha 2009-04-16 09:56:20 UTC
Created attachment 24871 [details]
dmesg after lid close/reopen
Comment 2 Saikat Guha 2009-04-16 09:56:53 UTC
Created attachment 24872 [details]
intel reg_dumper before lid close
Comment 3 Saikat Guha 2009-04-16 09:57:14 UTC
Created attachment 24873 [details]
intel reg_dumper while lid is closed
Comment 4 Saikat Guha 2009-04-16 09:57:34 UTC
Created attachment 24874 [details]
intel reg_dumper after lid is re-opened
Comment 5 Saikat Guha 2009-04-16 09:57:57 UTC
Created attachment 24875 [details]
xorg log
Comment 6 Saikat Guha 2009-04-16 10:04:27 UTC
Hardware:
  http://www.smolts.org/client/show/pub_8723ef2a-0781-4aa9-a49c-f20b18645cfc

Package versions:
  xorg-x11-drv-intel-2.6.99.902-3.fc11.i586
  kernel-2.6.29.1-70.fc11.i586
  hwdata-0.225-1.fc11.noarch
  xorg-x11-server-Xorg-1.6.1-1.fc11.i586
  kernel-firmware-2.6.29.1-70.fc11.noarch.rpm

Config:
  No Xorg.conf (all auto-detected)
  Kernel: 
    CONFIG_DRM_I915=m 
    CONFIG_DRM_I915_KMS=y
Comment 7 Jesse Barnes 2009-04-16 10:10:45 UTC
Can you see if your platform is generating LID open/close events?  There's a an
intel_lid tool in src/reg_dumper you can use to see whether the status is
correct, but we'll also want to see if there's an ACPI event generated.  Looks
like your machine is disabling the display at lid time, and messing with the
mode:

-(II):             DSPBCNTR: 0xd9000000 (enabled, pipe B)
+(II):             DSPBCNTR: 0x59000000 (disabled, pipe B)

so we'll need to reset the mode at lid open, but we need a way of detecting it
first.
Comment 8 Saikat Guha 2009-04-16 10:14:23 UTC
(In reply to comment #7)
> Can you see if your platform is generating LID open/close events?  There's a an
> intel_lid tool in src/reg_dumper you can use to see whether the status is
> correct, but we'll also want to see if there's an ACPI event generated.  Looks
> like your machine is disabling the display at lid time, and messing with the
> mode:
> 
> -(II):             DSPBCNTR: 0xd9000000 (enabled, pipe B)
> +(II):             DSPBCNTR: 0x59000000 (disabled, pipe B)
> 
> so we'll need to reset the mode at lid open, but we need a way of detecting it
> first.
> 

I ran the intel_lid tool (while logged in over the network) and closed and
opened the lid twice. As expected the screen blanked out after the
first close-open cycle. The output is below.

[saikat@seshat reg_dumper]$ sudo ./intel_lid
----------------------------- SG: LID was open ----------------------------
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
----------------------------- SG: LID was closed ----------------------------
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : close
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : close
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : close
----------------------------- SG: LID was opened ----------------------------
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
----------------------------- SG: LID was closed ----------------------------
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : close
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : close
----------------------------- SG: LID was opened ----------------------------
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
Intel LVDS Lid status:
       SWF14(0xc0000000) : open
       ACPI Lid state : open
^C
Comment 9 Saikat Guha 2009-04-22 08:33:03 UTC
This issue is still present with:
 xorg-x11-drv-intel-2.7.0-1.fc11.i586
 kernel-2.6.29.1-102.fc11.i586

My laptop is completely unusable as a laptop with this bug. I'd be happy to test out a kernel or xorg patch to get this resolved quickly. 
Comment 10 Jesse Barnes 2009-05-04 11:30:20 UTC
Ok let me see what I can come up with... if there's not a way to disable your machine from poking at display registers at lid event time (sometimes the _DOS setting or another ACPI setting will affect this) we'll have to catch an event in the kernel driver and reset the mode.
Comment 11 Jesse Barnes 2009-05-04 13:19:05 UTC
Created attachment 25426 [details] [review]
add lid event handler

Can you confirm that you get debug output about your lid with this patch applied?  Assuming you do I can add some infrastructure for handling disable/enable of your display at lid time.
Comment 12 Saikat Guha 2009-05-05 00:35:26 UTC
(In reply to comment #11)
> Can you confirm that you get debug output about your lid with this patch
> applied?  Assuming you do I can add some infrastructure for handling
> disable/enable of your display at lid time.

Yes, I am getting the debug out. Although, each action generates two lines. See below:

-------- Closing lid ...
May  5 03:31:29 seshat kernel: [drm:lid_event] *ERROR* received lid close event
May  5 03:31:29 seshat kernel: [drm:lid_event] *ERROR* received lid open event

-------- Opening lid ...
May  5 03:31:33 seshat kernel: [drm:lid_event] *ERROR* received lid open event
May  5 03:31:33 seshat kernel: [drm:lid_event] *ERROR* received lid open event

-------- Closing lid ...
May  5 03:31:38 seshat kernel: [drm:lid_event] *ERROR* received lid close event
May  5 03:31:38 seshat kernel: [drm:lid_event] *ERROR* received lid open event

-------- Opening lid ...
May  5 03:31:42 seshat kernel: [drm:lid_event] *ERROR* received lid open event
May  5 03:31:42 seshat kernel: [drm:lid_event] *ERROR* received lid open event
Comment 13 Jesse Barnes 2009-05-05 09:34:05 UTC
Ok that matches what I'm seeing (I was hoping it was just a problem on my platform).  Maybe I'm processing the input events wrong...

Anyway looks like we're a lot closer to being able to handle these.  Updated patch will follow soon.
Comment 14 Jim Radford 2009-05-11 10:48:54 UTC
Things are getting better (on my x61).  Now after closing/opening the lid
*twice* the screen will come back.  The first time it's blank.

  2.6.30-rc5-00096-ga4d7749
  xorg-x11-drv-intel-2.7.0-4.fc11.x86_64

I get one of the these messages every lid close/open cycle.

  ...
  [drm] LVDS-8: set mode  1a
  [drm] LVDS-8: set mode  1b
  [drm] LVDS-8: set mode  1c
  [drm] LVDS-8: set mode  1d

Of course I can't seen the first one until I perform the cycle again.  At least
I don't have to reboot now!

FWIW, I also get these on startup.  I'm not sure if they are related.

  [drm:i915_gem_object_bind_to_gtt] *ERROR* GTT full, but LRU list empty
  [drm:i915_gem_object_pin] *ERROR* Failure to bind: -12
  [drm:i915_gem_evict_something] *ERROR* inactive empty 1 request empty 1 flushing empty 1
Comment 15 Will Woods 2009-05-12 14:58:39 UTC
For the record, I can reproduce the behavior described in comment #12. My system's a 915GM in a ThinkPad T43.

xorg-x11-drv-intel-2.7.0-5.fc11.i586
kernel-PAE-2.6.29.3-141.fc11.i686 (compiled with the patch from comment #11)

See also the downstream Fedora bug:
https://bugzilla.redhat.com/show_bug.cgi?id=489907

It's currently being considered as a blocker for F11 release (due in ~2 weeks) because there's a lot of Fedora devs with intel-based ThinkPads. What are the chances of this having a fix in the next 7 days or so?
Comment 16 Jesse Barnes 2009-05-13 11:52:16 UTC
Created attachment 25832 [details] [review]
add lid detection

This one is slightly better:
  - sends DRM hotplug events on lid open/close
  - uses lid switch for LVDS connector detection

I'm somewhat reluctant to add automatic mode setting to the lid handler though, since after the hotplug event userspace may reconfigure the outputs, so we might end up restoring the wrong configuration.  However in the kms console case we might want to do something, if only to get the display back...
Comment 17 Saikat Guha 2009-05-13 15:55:48 UTC
(In reply to comment #16)
> This one is slightly better:
>   - sends DRM hotplug events on lid open/close
>   - uses lid switch for LVDS connector detection

I am getting the hotplug events; no duplicates. Log output below.

----------------- Closing lid -------------
/root/testplug: drm
declare -x ACTION="change"
declare -x DEVPATH="/devices/pci0000:00/0000:00:02.0/drm/card0"
declare -x HOME="/"
declare -x HOTPLUG="1"
declare -x MAJOR="226"
declare -x MINOR="0"
declare -x OLDPWD
declare -x PATH="/sbin:/bin:/usr/sbin:/usr/bin"
declare -x PWD="/"
declare -x SEQNUM="1241"
declare -x SHLVL="1"
declare -x SUBSYSTEM="drm"

----------------- Opening lid -------------
/root/testplug: drm
declare -x ACTION="change"
declare -x DEVPATH="/devices/pci0000:00/0000:00:02.0/drm/card0"
declare -x HOME="/"
declare -x HOTPLUG="1"
declare -x MAJOR="226"
declare -x MINOR="0"
declare -x OLDPWD
declare -x PATH="/sbin:/bin:/usr/sbin:/usr/bin"
declare -x PWD="/"
declare -x SEQNUM="1242"
declare -x SHLVL="1"
declare -x SUBSYSTEM="drm"

----------------- Closing lid -------------
/root/testplug: drm
declare -x ACTION="change"
declare -x DEVPATH="/devices/pci0000:00/0000:00:02.0/drm/card0"
declare -x HOME="/"
declare -x HOTPLUG="1"
declare -x MAJOR="226"
declare -x MINOR="0"
declare -x OLDPWD
declare -x PATH="/sbin:/bin:/usr/sbin:/usr/bin"
declare -x PWD="/"
declare -x SEQNUM="1243"
declare -x SHLVL="1"
declare -x SUBSYSTEM="drm"

----------------- Opening lid -------------
/root/testplug: drm
declare -x ACTION="change"
declare -x DEVPATH="/devices/pci0000:00/0000:00:02.0/drm/card0"
declare -x HOME="/"
declare -x HOTPLUG="1"
declare -x MAJOR="226"
declare -x MINOR="0"
declare -x OLDPWD
declare -x PATH="/sbin:/bin:/usr/sbin:/usr/bin"
declare -x PWD="/"
declare -x SEQNUM="1244"
declare -x SHLVL="1"
declare -x SUBSYSTEM="drm"
Comment 18 Jesse Barnes 2009-05-14 13:59:07 UTC
Will, have you tested this patch?  I think ajax might be working on the X side of KMS hotplug events; if he's got that working this patch may be sufficient.
Comment 19 Saikat Guha 2009-05-14 14:31:41 UTC
(In reply to comment #18)
> Will, have you tested this patch?  I think ajax might be working on the X side
> of KMS hotplug events; if he's got that working this patch may be sufficient.


The LVDS turns off even without X. e.g. during plymouth, or in init level 3. Turning the LVDS back on in X may be an interim solution, but not sufficient imo.
Comment 20 Jesse Barnes 2009-05-14 14:35:26 UTC
Yeah I'm just worried about clobbering a config by blindly re-enabling plane B or something.  It would be really easy to freeze the machine at lid open if we just did something simple; thus my desire to push it off to userspace, which will be responding to these events and making changes.

But in the plain console mode, yeah we need a solution here for sure...
Comment 21 Will Woods 2009-05-15 13:23:17 UTC
(In reply to comment #18)
> Will, have you tested this patch?  I think ajax might be working on the X side
> of KMS hotplug events; if he's got that working this patch may be sufficient.

kylem did a scratch build of the Fedora kernel with that patch merged. (It had to be modified a bit since the trees have diverged a little.) 
Build: http://koji.fedoraproject.org/koji/taskinfo?taskID=1356787
Patch: http://shortfin.cabal.ca/~kyle/drm-intel-fix-lid_close.patch

No change at all on my laptop. I checked /proc/kallsyms to make sure the new 'acpi_lid_close' symbol was present, just to be double-sure that the patch was actually applied.

Comment 22 ykzhao 2009-06-08 22:08:56 UTC
Hi, Saikat
    Will you please attach the output of acpidump?
    Thanks.
Comment 23 ykzhao 2009-06-08 22:10:35 UTC
Will you please do the following test with KMS enabled?
   a. kill the process using the /proc/acpi/event (use the command of "lsof /proc/acpi/event" to get the process id)
   b. close/reopen the lid and see whether the issue still exists?
   Thanks.
Comment 24 Saikat Guha 2009-06-09 03:21:20 UTC
Created attachment 26581 [details]
acpidump output

> with KMS enabled?
>  a. kill the process using the /proc/acpi/event
>  b. close/reopen the lid and see whether the issue still exists?

Yes, the issue still exists without any acpi listeners.

acpidump is attached.

Currently installed:
 xorg-x11-drv-intel-2.7.0-7.fc11.i586
 kernel-2.6.30-0.97.rc8.fc12.i586
Comment 25 Saikat Guha 2009-06-28 09:32:29 UTC
Still exists with xorg-x11-drv-intel-2.8.0-0.1.fc12.i586

A workaround that previously used to work (xrandr --output LVDS1 --off; xrandr --output LVDS1 --auto) stopped working with 2.8.0 with error "xrandr: Configure crtc 1 invalid time" 

Can someone look into this? If you need any additional info, I am happy to provide it. It is perfectly reproducible by many people who are eager to have this resolved. This is an embarrassing regression.
Comment 26 Jesse Barnes 2009-07-01 15:02:41 UTC
Yeah, I'm still looking at this one... forward porting my patch now.
Comment 27 Jesse Barnes 2009-07-07 15:49:28 UTC
Created attachment 27484 [details] [review]
add lid detection & mode reset

How about this patch?  It resets the mode at open time before we send the event.  That should be safe, since userland is free to change the mode once it receives the event; in the meantime we'll have the last config.
Comment 28 Jim Radford 2009-07-14 20:00:01 UTC
Your patch worked for me on 2.6.31-rc3.  I can now open and close my lid with abandon!

BTW, you forgot to include your new acpi.h header in your patch.
Comment 29 Jesse Barnes 2009-07-15 09:52:30 UTC
Great, thanks for testing, I'll fix the acpi header issue and see if the patch can get included in the next kernel.
Comment 30 Gordon Jin 2009-07-22 19:42:07 UTC
*** Bug 22887 has been marked as a duplicate of this bug. ***
Comment 31 Gordon Jin 2009-08-23 19:09:17 UTC
Jesse, how's the patch going?
Comment 32 Jesse Barnes 2009-08-24 10:02:13 UTC
Patch is done and posted to intel-gfx, just needs to be integrated into 2.6.32.
Comment 33 Gordon Jin 2009-09-06 19:48:57 UTC
Jesse, is the patch in drm-intel-next?
Comment 34 Jesse Barnes 2009-09-08 09:35:44 UTC
Not yet.  Will ping Eric again.
Comment 35 Jesse Barnes 2009-10-05 10:22:10 UTC
Fix is upstream now:

commit c1c7af60892070e4b82ad63bbfb95ae745056de0
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Thu Sep 10 15:28:03 2009 -0700

    drm/i915: force mode set at lid open time


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.