Bug 50772

Summary: [GM965/GL960] VT switching on VGA connector unplug
Product: DRI Reporter: max <manikulin>
Component: DRM/IntelAssignee: Daniel Vetter <daniel>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: medium CC: ben, chris, daniel, florian, jbarnes
Version: XOrg git   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
dmesg
none
Xorg.0.log
none
intel_reg_dumper
none
add printk to fb helper function
none
dmesg with the patch applied and drm.debug=0x0e
none
properly delay fbcon hotplug handling none

Description max 2012-06-06 02:43:36 UTC
Created attachment 62651 [details]
dmesg

If I start X server
startx /usr/bin/xterm
connect external monitor
switch to external monitor and back
xrandr --output LVDS1 --off --output VGA1 --auto
xrandr --output VGA1 --off --output LVDS1 --auto
(usually I have to switch to a console and back with
[Ctrl+Alt+F1] [Alt+F7] in the meanwhile,
otherwise a screen can be black)
At this point I have xterm window on the internal screen.
If I unplug VGA connector, the console (e.g. vt1) appears
at the screen (the first idea was X server crash, but it is alive
at vt7)

I would expect that connector unplugging should not lead to
switching of vt.

System info:
lspci
00:02.0 VGA compatible controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller (primary) (rev 03)
00:02.1 Display controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller (secondary) (rev 03)

uname -m
i686

xserver-xorg-video-intel
Version: 2:2.19.0+git20120521.afdaf184-0ubuntu0sarvatt2~sna~precise
xserver-xorg-core
Version: 2:1.12.2+git20120605+server-1.12-branch.aaf48906-0ubuntu0ricotz~precise
libgl1-mesa-dri
Version: 8.1~git20120529.f92b2e5e-0ubuntu0sarvatt~precise
libdrm-intel1
Version: 2.4.34+git20120520.481234f2-0ubuntu0ricotz~precise

kernel:
3.4.0-994-generic #201206050409 SMP Tue Jun 5 08:17:32 UTC 2012 i686 i686 i386 GNU/Linux

Ubuntu-12.04 + ppa:xorg-edgers + ppa:intel-sna + drm-intel-experimental kernel

Asus F80L laptop

i915_error_state 
no error state collected
Comment 1 max 2012-06-06 02:44:01 UTC
Created attachment 62652 [details]
Xorg.0.log
Comment 2 max 2012-06-06 02:44:41 UTC
Created attachment 62653 [details]
intel_reg_dumper
Comment 3 Daniel Vetter 2012-06-06 02:49:34 UTC
Created attachment 62654 [details] [review]
add printk to fb helper function

Please apply this debug patch, boot again with drm.debug=0xe, reproduce the issue and then attach the complete dmesg. Thanks.
Comment 4 max 2012-06-12 06:01:15 UTC
Created attachment 62931 [details]
dmesg with the patch applied and drm.debug=0x0e

Sorry for the delay
Comment 5 Daniel Vetter 2012-06-14 05:10:56 UTC
Created attachment 63020 [details] [review]
properly delay fbcon hotplug handling

Patch for you to try. My theory is that the vt-switching you're doing is the important part necessary to confuse the kms fbcon. So when testing please try all the various combinations of vt-switches that are usually required to make your system work.
Comment 6 Chris Wilson 2012-06-14 11:51:34 UTC
This will help with the inconsistency from the userspace side of things:

commit 4e50467b4f50b522a07bedae7ff68b9c37362af8
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Jun 14 17:40:09 2012 +0100

    uxa: Force the outputs to off for consistency with xf86DisableUnusedFunction
    
    Upon a VT switch, we set the desired modes and turn off the DPMS on any
    unused output. Make this explicit so that we always maintain consistency
    between the kernel and X's list of enabled CRTCs.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=50772
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Comment 7 max 2012-06-14 23:34:43 UTC
(In reply to comment #5)
> Created attachment 63020 [details] [review] [review]
> properly delay fbcon hotplug handling

It seems, the patch works. I plan to test the patch written
by Chris a bit later.

> Patch for you to try. My theory is that the vt-switching you're doing is the
> important part necessary to confuse the kms fbcon. So when testing please try
> all the various combinations of vt-switches that are usually required to make
> your system work.

Daniel, sorry, it is not clear for me what you mean by various
combinations of vt switches. Usually I use [Ctrl+Alt+F[1-6]].
I can remember `chvt'.

I realized that no vt change happens. X remains active, but
the image on the screen appears from vt1,

I have applied your patch on the top of your backlight-confusion
branch (just to save an hour for kernel compiling).

Since you suspect fbcon, the detailed description
of my steps:

grub menu
boot the patched kernel
ubuntu splash screen
vt1 with login prompt on LVDS1, 1280x800 native resolution
startx /usr/bin/ck-launch-session xterm
X server on vt7 with xterm
LVDS1, 1280x800

connect VGA cable and turn on the monitor
LVDS1 1280x800, VGA1 power saving mode

xrandr --output LVDS1 --off --output VGA1 --auto
LVDS1 black (likely no backlight)
VGA1 black 1600x1200 native resolution

[Ctrl+Alt+F2] vt2
LVDS1 very dim backlight 1280x800
VGA1 1280x768@85Hz
(Probably the issue for another bug: not 1280x800)

[Alt+F7] xserver
LVDS1 black, no backlight
VGA1 normal image 1600x1200

xrandr --output VGA1 --off --output LVDS1 --auto
LVDS1 black, no backlight
VGA1 power saving mode

[Ctrl+Alt+F2] vt2
LVDS1 black (likely no backlight)
VGA1 1280x768@85Hz

[Alt+F7] xserver
LVDS1 normal image 1280x800
VGA1 power saving mode

turn off monitor, unplug VGA cable

No problem with the patched kernel.
If drm-intel-experimental of 2012-06-13 kernel is
booted, text console appears on LVDS1.
[Alt+F7] does not lead to switch to x server,
[Ctrl+Alt+F1] [Alt+F7] does. Some new characters
in xterm due to firs hit of [Alt+F7]
Comment 8 max 2012-06-15 00:39:37 UTC
(In reply to comment #6)
> This will help with the inconsistency from the userspace side of things:
> 
> commit 4e50467b4f50b522a07bedae7ff68b9c37362af8

Chris, in general, your patch works too. I just have tested
it with linux-image-3.4.0-994-generic_3.4.0-994.201206130406_i386.deb
kernel (drm-intel-experimental) and
xserver-xorg-video-intel_2.19.0+git20120613.0db789e1.orig.tar.gz
sources from xorg-edgers.

I have to say that the patch has two side effects.

Firstly, the good one. In relation to Bug 49688 the patch
increases probability that image will appear on the screen
without switching to a console and back. Usually switching
to LVDS1 works good, but after switching to VGA1 an addition
kick is required. If I connect/disconnect external monitor
more times, VGA1 becomes more successful in displaying image
just after xrandr command.

Secondly, bad news. Two times X server failed in a strange
state.After xrandr text console appeared on both screens,
no reaction on the keyboard. I tried [Alt+SysRq+R] [Ctrl+Alt+F1]
and xterm appeared on the screen.
That was when I connected the external monitor second time.
Unfortunately, it happens not every boot.
Comment 9 Daniel Vetter 2012-06-15 01:41:24 UTC
Can I have your tested-by for the kernel patch please so that I can submit it? I.e.

Tested-by: full name <mail@address>
Comment 10 max 2012-07-08 06:57:54 UTC
I do not see the bug neither in Ubuntu xorg-edgers kernel linux-image-3.5.0-2-generic  3.5.0-2.2 nor in drm-intel-experimental linux-image-3.5.0-994-generic 3.5.0-994.201207060407.

Thank you for fixing it.

However just after switching to console (by exiting from xterm or by pressing [Ctrl+Alt+F1]) a blink can be noticed.
Comment 11 Florian Mickler 2012-08-05 11:21:13 UTC
A patch referencing this bug report has been merged in Linux v3.6-rc1:

commit 343065a605646b4c1fee8b1ca07b715283813b11
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Fri Jun 15 11:01:22 2012 +0200

    drm/fb-helper: delay hotplug handling when partially bound

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.