Bug 101461

Summary: [SKL] Unplugging the HDMI/DP/mDP cable from dock will not automically resize framebuffer
Product: DRI Reporter: Ethan Hsieh <ethan.hsieh>
Component: DRM/IntelAssignee: Dhinakaran Pandiyan <dhinakaran.pandiyan>
Status: CLOSED FIXED QA Contact: Intel GFX Bugs mailing list <intel-gfx-bugs>
Severity: normal    
Priority: medium CC: dhinakaran.pandiyan, ethan.hsieh, intel-gfx-bugs, ricardo.vega, tjaalton
Version: XOrg git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard: ReadyForDev
i915 platform: SKL i915 features: display/Other
Attachments:
Description Flags
Kernel log (drm.debug=0xe), Xorg.0.log, xrandr, and screenshot
none
1-kern.log
none
1-Xorg.0.log
none
2-kern.log
none
2-Xorg.0.log.0
none
2-Xorg.0.log.1
none
screenshot
none
xrandr
none
kern.log
none
kernel log
none
dmesg.log
none
kern.log none

Description Ethan Hsieh 2017-06-16 03:48:46 UTC
Created attachment 131992 [details]
Kernel log (drm.debug=0xe), Xorg.0.log, xrandr, and screenshot

Unplugging the HDMI/DP/mDP cable from dock will not automically resize framebuffer. drm/i915 receives hotplug event, but does not handle it.

I submitted a patch , but it was rejected.
https://patchwork.freedesktop.org/patch/161729/
Here is the reply from ville.syrjala@linux.intel.com
---
We're not supposed to handle it like that. The HPD is for the main encoder,
the MST hotplug handling comes via the topology manager.
---

Reproduction steps:
1. The external monitor with DP/mDP/HDMI cable connected to Dell Dock.
All two displays: Built-in LCD and external DP/mDP/HDMI monitor
2. Boot to Ubuntu Desktop
3. See two displays (extend mode)
4. Unplug the DP/mDP/HDMI cable
5. Press the "PrtScn" button to capture the screen.
We still have two screens after unplugging the cable.

Additional information:
1. Kernel: 4.12.0-994-generic x86_64
2. Linux distribution: Ubuntu 16.04.2 LTS
3. Laptop: Dell Precision 5520
4. Dell Business Thunderbolt Dock - TB16
https://goo.gl/vFDjpi
5. kernel log:
[CONNECTOR:48:eDP-1]: Built-in LCD 
[CONNECTOR:74:DP-4]: The external monitor connected to Dell Dock

How to recover:
1. Go to [All Settings] => [Displays] => Press [Detect Displays], or
2. Run xrandr to resize the screen
Comment 1 Elizabeth 2017-06-16 21:52:02 UTC
Hello Ethan, could you please attach the logs and images uncompressed. Thank you.
Comment 2 Ethan Hsieh 2017-06-19 01:59:01 UTC
Created attachment 132033 [details]
1-kern.log
Comment 3 Ethan Hsieh 2017-06-19 01:59:47 UTC
Created attachment 132034 [details]
1-Xorg.0.log
Comment 4 Ethan Hsieh 2017-06-19 02:00:03 UTC
Created attachment 132035 [details]
2-kern.log
Comment 5 Ethan Hsieh 2017-06-19 02:08:35 UTC
Created attachment 132036 [details]
2-Xorg.0.log.0

Compile xserver-xorg-video-intel with --enable-debug=full
Comment 6 Ethan Hsieh 2017-06-19 02:09:12 UTC
Created attachment 132037 [details]
2-Xorg.0.log.1

Compile xserver-xorg-video-intel with --enable-debug=full
Comment 7 Ethan Hsieh 2017-06-19 02:09:40 UTC
Created attachment 132038 [details]
screenshot
Comment 8 Ethan Hsieh 2017-06-19 02:09:56 UTC
Created attachment 132039 [details]
xrandr
Comment 9 Elizabeth 2017-06-19 19:46:12 UTC
Adding tag into "Whiteboard" field - ReadyForDev
*Status is correct
*Platform is included
*Feature is included
*Priority and Severity correctly set
*Logs included
Comment 10 Ethan Hsieh 2017-06-20 09:04:23 UTC
Created attachment 132079 [details]
kern.log

When I unplugged the cable, the status of DP-4 was still "connected".
That is why the framebuffer is not resized automatically.

Here is the log:
[313.665321] [drm:intel_get_hpd_pins [i915]] hotplug event received, stat 0x00200000, dig 0x10101012, pins 0x00000020
[313.665383] [drm:intel_hpd_irq_handler [i915]] digital hpd port B - long
[313.665436] [drm:intel_hpd_irq_handler [i915]] Received HPD interrupt on PIN 5 - cnt: 0 
[313.665539] [drm:intel_dp_hpd_pulse [i915]] got hpd irq on port B - long
[313.944743] [drm:intel_dp_destroy_mst_connector [i915]]
//[313.944745] intel_dp_destroy_mst_connector: connector->name=DP-4 status=connected
[313.944848] [drm:intel_dp_destroy_mst_connector [i915]]

---

The framebuffer is resized automatically after applying the following workaround.
drivers/gpu/drm/i915/intel_dp_mst.c
@@ -474,6 +478,20 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
        struct intel_connector *intel_connector = to_intel_connector(connector);
        struct drm_device *dev = connector->dev;
+       enum drm_connector_status old_status;
+
+       printk(KERN_ERR "%s: connector->name=%s status=%s\n", __func__, connector->name, drm_get_connector_status_name(connector->status));
+
+       old_status = connector->status;
+       connector->status = connector->funcs->detect(connector, false);
+       if (old_status != connector->status)
+               DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n",
+                             connector->base.id,
+                             connector->name,
+                             drm_get_connector_status_name(old_status),
+                             drm_get_connector_status_name(connector->status));

Here is the log:
[43.175787] intel_dp_destroy_mst_connector: connector->name=DP-4 status=connected
[43.175798] [drm:intel_dp_destroy_mst_connector [i915]] [CONNECTOR:70:DP-4] status updated from connected to disconnected
[43.175870] [drm:intel_dp_destroy_mst_connector [i915]]
[43.177675] [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:70:DP-4]
[43.177679] [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:70:DP-4] disconnected
Comment 11 Dhinakaran Pandiyan 2017-06-21 23:23:04 UTC
I *think* the real problem is we do not differentiate between the dock being unplugged and a monitor connected to the dock being unplugged.
Comment 12 Armando Antonio 2017-06-30 22:04:24 UTC
This issue still happen with the following configuration:

Monitor with DP/mDP/HDMI cable connected to MST
======================================
        Graphic stack
======================================

======================================
             Software
======================================
kernel version              : 4.12.0-rc3-drm-tip-ww22-commit-187376e+
architecture                : x86_64
os version                  : Ubuntu 17.04
os codename                 : zesty
kernel driver               : i915
bios revision               : 5.12
bios release date           : 09/12/2016

======================================
        Graphic drivers
======================================
mesa                        : 17.0.3
modesetting                 : modesetting_drv.so
xorg-xserver                : 1.19.3
libdrm                      : 2.4.81
cairo                       : 1.14.8
xserver                     : X.Org X Server 1.19.99.1
intel-gpu-tools (tag)       : intel-gpu-tools-1.18-211-g00ce341b
intel-gpu-tools (commit)    : 00ce341b

======================================
             Hardware
======================================
platform                   : KBL-Nuc
motherboard model          : MS-B142
motherboard id             : MS-B1421
form factor                : Desktop
manufacturer               : Micro-StarInternationalCo.,Ltd.
cpu family                 : Core i7
cpu family id              : 6
cpu information            : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
gpu card                   : Intel Corporation Device 5916 (rev 02) (prog-if 00 [VGA controller])
memory ram                 : 7.65 GB
max memory ram             : 64 GB
display resolution         : 1600x900
cpu thread                 : 4
cpu core                   : 2
cpu model                  : 142
cpu stepping               : 9
socket                     : Other
signature                  : Type 0, Family 6, Model 142, Stepping 9
hard drive                 : 111GiB (120GB)
current cd clock frequency : 450000 kHz
maximum cd clock frequency : 675000 kHz
displays connected         : DP-2 DP-4 DP-8

======================================
             Firmware
======================================
dmc fw loaded             : yes
dmc version               : 1.1
guc fw loaded             : NONE
guc version wanted        : 0.0
guc version found         : 0.0

======================================
             kernel parameters
======================================
quiet splash fastboot drm.debug=0xe

Regards.
Comment 13 Armando Antonio 2017-06-30 22:04:53 UTC
Created attachment 132379 [details]
kernel log
Comment 14 Dhinakaran Pandiyan 2017-07-31 17:01:07 UTC
(In reply to Ethan Hsieh from comment #10)
> Created attachment 132079 [details]
> kern.log
> 
> When I unplugged the cable, the status of DP-4 was still "connected".
> That is why the framebuffer is not resized automatically.
> 
> Here is the log:
> [313.665321] [drm:intel_get_hpd_pins [i915]] hotplug event received, stat
> 0x00200000, dig 0x10101012, pins 0x00000020
> [313.665383] [drm:intel_hpd_irq_handler [i915]] digital hpd port B - long
> [313.665436] [drm:intel_hpd_irq_handler [i915]] Received HPD interrupt on
> PIN 5 - cnt: 0 
> [313.665539] [drm:intel_dp_hpd_pulse [i915]] got hpd irq on port B - long
> [313.944743] [drm:intel_dp_destroy_mst_connector [i915]]
> //[313.944745] intel_dp_destroy_mst_connector: connector->name=DP-4
> status=connected
> [313.944848] [drm:intel_dp_destroy_mst_connector [i915]]
> 
> ---
> 
> The framebuffer is resized automatically after applying the following
> workaround.
> drivers/gpu/drm/i915/intel_dp_mst.c
> @@ -474,6 +478,20 @@ static void intel_dp_destroy_mst_connector(struct
> drm_dp_mst_topology_mgr *mgr,
>         struct intel_connector *intel_connector =
> to_intel_connector(connector);
>         struct drm_device *dev = connector->dev;
> +       enum drm_connector_status old_status;
> +
> +       printk(KERN_ERR "%s: connector->name=%s status=%s\n", __func__,
> connector->name, drm_get_connector_status_name(connector->status));
> +
> +       old_status = connector->status;
> +       connector->status = connector->funcs->detect(connector, false);
> +       if (old_status != connector->status)
> +               DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to
> %s\n",
> +                             connector->base.id,
> +                             connector->name,
> +                             drm_get_connector_status_name(old_status),
> +                            
> drm_get_connector_status_name(connector->status));
> 
> Here is the log:
> [43.175787] intel_dp_destroy_mst_connector: connector->name=DP-4
> status=connected
> [43.175798] [drm:intel_dp_destroy_mst_connector [i915]] [CONNECTOR:70:DP-4]
> status updated from connected to disconnected
> [43.175870] [drm:intel_dp_destroy_mst_connector [i915]]
> [43.177675] [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]]
> [CONNECTOR:70:DP-4]
> [43.177679] [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]]
> [CONNECTOR:70:DP-4] disconnected

Hello Ethan,

I did some debugging, this patch does solve one issue I am seeing.  I'll be happy to review your patch if you send it to intel-gfx.

-DK
Comment 15 Ethan Hsieh 2017-08-01 09:00:01 UTC
Hi DK,
I have submitted the patch to upstream. Please help to review it.
https://patchwork.freedesktop.org/patch/169752/
Ethan
Comment 16 Ethan Hsieh 2017-08-07 07:33:44 UTC
According to Daniel's comment, this issue should be caused by userspace.
I installed ubuntu 17.04 (4.10.0-30-generic) to use newer deb packages, and found that I cannot reproduce the issue.

Here is the kernel log:
[drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:70:DP-4] status updated from connected to disconnected
[drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:70:DP-4] disconnected
Comment 17 Ricardo Madrigal 2017-08-08 16:23:39 UTC
I ran this test with the latest kernel and the follow configuration, and everything works correctly:

Using Monitors connected with mDP-MST/ DP / HDMI

======================================
             Software
======================================
kernel version              : 4.13.0-rc4-drm-tip-ww32-commit-b7a69d4+
architecture                : x86_64
os version                  : Ubuntu 17.04
os codename                 : zesty
kernel driver               : i915
bios revision               : 5.6
bios release date           : 09/29/2016

======================================
        Graphic drivers
======================================
mesa                      : 17.0.3
modesetting               : modesetting_drv.so
xorg-xserver              : 1.19.3
libdrm                    : 2.4.76
libva                     : 1.7.3-2
vaapi (intel-driver)      : 1.7.3
cairo                     : 1.14.8-1
intel-gpu-tools           : 1.17-1

======================================
             Hardware
======================================
platform                   : SKL Canyon
motherboard id             : NUC6i7KYB
form factor                : Desktop
cpu family                 : Core i7
cpu family id              : 6
cpu information            : Intel(R) Core(TM) i7-6770HQ CPU @ 2.60GHz
gpu card                   : Intel Corporation Iris Pro Graphics 580 (rev 09) (prog-if 00 [VGA controller])
memory ram                 : 31.31 GB
max memory ram             : 32 GB
display resolution         : 3840x1080
cpu thread                 : 8
cpu core                   : 4
cpu model                  : 94
cpu stepping               : 3
socket                     : Other
signature                  : Type 0, Family 6, Model 94, Stepping 3
hard drive                 : 223GiB (240GB)
current cd clock frequency : 450000 kHz
maximum cd clock frequency : 675000 kHz
displays connected         : DP-5

Adding dmesg.log and kern.log
Comment 18 Ricardo Madrigal 2017-08-08 16:24:09 UTC
Created attachment 133384 [details]
dmesg.log
Comment 19 Ricardo Madrigal 2017-08-08 16:24:32 UTC
Created attachment 133385 [details]
kern.log

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.