Bug 76301

Summary: Intel G41 doesn't see any screens connected after suspend/resume
Product: DRI Reporter: Nikolay <mar.kolya>
Component: DRM/IntelAssignee: Jesse Barnes <jbarnes>
Status: CLOSED FIXED QA Contact: Intel GFX Bugs mailing list <intel-gfx-bugs>
Severity: normal    
Priority: medium CC: intel-gfx-bugs
Version: XOrg git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Boot log from 3.11.0-18 with debug enabled
none
dmesg log: boot, log in, suspend, resume, on ubuntu 3.11.0 kernel
none
dmesg log: boot, log in, suspend, resume, on ubuntu 3.14.0-rc7 kernel
none
Dmesg output while running drm-intel-nightly
none
Logs from drm-intel 53dcc2e5588aedffe73ba45cb519aa20c3ddef96
none
Log output for git://gitorious.org/vsyrjala/linux.git cdclk_7 none

Description Nikolay 2014-03-18 04:02:40 UTC
Created attachment 95977 [details]
Boot log from 3.11.0-18 with debug enabled

I've got Ubuntu Saucy on a desktop with Intel G41 chipset (Asus
P5G41M LE/CSM). It exibits weird behaviour. Kernel: Linux kolya
3.11.0-18-generic.

  When I boot system up, login into X session and run xrands I get this:
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 connected 1920x1080+0+0 (normal left inverted right x axis y
axis) 531mm x 299mm
   1920x1080      60.0*+
   1280x1024      75.0     60.0
   1152x864       75.0
   1024x768       75.1     60.0
   800x600        75.0     60.3
   640x480        75.0     60.0
   720x400        70.1
DP1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

  In this state I can switch to a text mode console and it works fine.

  Then I suspend/resume machine and run xrandr again with following result:
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected 1920x1080+0+0 (normal left inverted right x axis y
axis) 0mm x 0mm
DP1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
  1920x1080 (0x47)  148.5MHz
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock   67.5KHz
        v: height 1080 start 1084 end 1089 total 1125           clock   60.0Hz

Note, that all screens are in disconnected state. Fortunately I still
see my desktop.

  But unfortunately when I switch to a text console my monitor goes
into power saving mode and doesn't return from it even if I type on
keyboard. Also if I leave my X session (i.e. logout) my monitor goes
into sleep on all virtual terminals and I have to reboot the box.

  I've tried to 'redetect' screens in my X session but it doesn't help
to fix the issue. Disconnecting/reconnecting screen doesn't help as
well. Reboot helps.

  I'll attach dmesg output with drm.debug=0xe as suggested in the mailing list.

  I've tried booting drm-intel-nightly on same machine but it hangs during boot saying (sometimes, sometimes I get black screen) something about softlock. It is probably graphics related since it does boot with 'nomodeset', but I would guess that is not interesting for this particular bug.

  I would be happy to provide any additional information or to test things.
  Thanks!
Comment 1 Chris Wilson 2014-03-18 07:37:03 UTC
Can you please extend the debug log to include boot + suspend & resume?
Comment 2 Nikolay 2014-03-18 23:58:24 UTC
Created attachment 96020 [details]
dmesg log: boot, log in, suspend, resume, on ubuntu 3.11.0 kernel
Comment 3 Nikolay 2014-03-18 23:58:49 UTC
Created attachment 96021 [details]
dmesg log: boot, log in, suspend, resume, on ubuntu 3.14.0-rc7 kernel
Comment 4 Nikolay 2014-03-19 00:00:14 UTC
Attached dmesg that includes suspend/resume. Just in case put two different kernels. Note: both kernels built by Ubuntu.

Please let me know if there is anything else I can do.
Thanks!
Comment 5 Nikolay 2014-03-20 23:20:35 UTC
Created attachment 96128 [details]
Dmesg output while running drm-intel-nightly

The problem still persists in drm-intel-nightly. I'm attaching dmesg output. Looks like it contains several traces, not sure if they are relevant or not.

Please let me know if I can help in any way.
Thanks!
Comment 6 Chris Wilson 2014-03-25 13:49:35 UTC
Can you please try:

diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index d33b61d..58ff64f 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -34,6 +34,9 @@
 #include <drm/i915_drm.h>
 #include "i915_drv.h"
 
+#undef HAS_GMBUS_IRQ
+#define HAS_GMBUS_IRQ(X) 0
+
 enum disp_clk {
        CDCLK,
        CZCLK
Comment 7 Nikolay 2014-03-26 13:07:53 UTC
Hi.

  I've tried a quick kernel rebuild and this patch does not seem to help.

  I'll try a complete rebuild today to confirm that.

  Sorry for the delay.

Thanks!
Comment 8 Nikolay 2014-03-27 04:10:22 UTC
Hi,

  I've verified your patch with completely new build and the problem still exists. Sorry.

Thank you so much for your support!
Comment 9 Nikolay 2014-04-28 16:29:13 UTC
Hi.

  The bug still persists. If there any other information I can provide to help to resolve it?
Comment 10 Jesse Barnes 2014-12-04 21:22:17 UTC
Ugly... so things look like they work fine on boot, but then on resume:

[   86.048829] [drm:i915_redisable_vga], Something enabled VGA plane, disabling it
[   86.049139] [drm:intel_opregion_setup], graphic opregion physical addr: 0xd7d8e0f4
[   86.049152] [drm:intel_opregion_setup], Public ACPI methods supported
[   86.049153] [drm:intel_opregion_setup], SWSCI supported
[   86.072014] [drm:swsci_setup], SWSCI BIOS requested (00000021) SBCB callbacks that are not supported (00000041)
[   86.072016] [drm:swsci_setup], SWSCI GBDA callbacks 000004f3, SBCB callbacks 00000021
[   86.072017] [drm:intel_opregion_setup], ASLE supported

We've made changes to our resume code around opregion I think, so it's worth trying a drm-intel-nightly kernel...

[   86.072065] [drm:init_status_page], render ring hws offset: 0x00001000
[   86.072068] [drm:i915_gem_object_create_stolen], creating stolen object: size=20000
[   86.072071] [drm:i915_pages_create_for_stolen], offset=0x0, size=131072
[   86.072111] [drm:init_status_page], bsd ring hws offset: 0x00024000
[   86.072113] [drm:i915_gem_object_create_stolen], creating stolen object: size=20000
[   86.072115] [drm:i915_pages_create_for_stolen], offset=0x20000, size=131072
[   86.072172] [drm:intel_modeset_readout_hw_state], [CRTC:3] hw state readout: disabled
[   86.072175] [drm:intel_modeset_readout_hw_state], [CRTC:4] hw state readout: disabled
[   86.072178] [drm:intel_modeset_readout_hw_state], [ENCODER:6:DAC-6] hw state readout: disabled, pipe A
[   86.072181] [drm:intel_modeset_readout_hw_state], [ENCODER:7:TMDS-7] hw state readout: disabled, pipe A
[   86.072184] [drm:intel_modeset_readout_hw_state], [ENCODER:11:TMDS-11] hw state readout: disabled, pipe A
[   86.072187] [drm:intel_modeset_readout_hw_state], [CONNECTOR:5:VGA-1] hw state readout: disabled
[   86.072189] [drm:intel_modeset_readout_hw_state], [CONNECTOR:8:HDMI-A-1] hw state readout: disabled
[   86.072191] [drm:intel_modeset_readout_hw_state], [CONNECTOR:12:DP-1] hw state readout: disabled

So we came out of resume and saw everything disabled, that's expected.

...
[   86.072237] [drm:intel_modeset_affected_pipes], set mode pipe masks: modeset: 1, prepare: 1, disable: 0
[   86.072239] [drm:connected_sink_compute_bpp], [CONNECTOR:8:HDMI-A-1] checking for sink bpp constrains
[   86.072240] [drm:intel_hdmi_compute_config], picking bpc to 8 for HDMI output
[   86.072241] [drm:intel_hdmi_compute_config], forcing pipe bpc to 24 for HDMI
[   86.072242] [drm:intel_modeset_pipe_config], plane bpp: 24, pipe bpp: 24, dithering: 0
[   86.072243] [drm:intel_dump_pipe_config], [CRTC:3][modeset] config for pipe A
[   86.072244] [drm:intel_dump_pipe_config], cpu_transcoder: A
[   86.072245] [drm:intel_dump_pipe_config], pipe bpp: 24, dithering: 0
[   86.072246] [drm:intel_dump_pipe_config], fdi/pch: 0, lanes: 0, gmch_m: 0, gmch_n: 0, link_m: 0, link_n: 0, tu: 0
[   86.072247] [drm:intel_dump_pipe_config], dp: 0, gmch_m: 0, gmch_n: 0, link_m: 0, link_n: 0, tu: 0
[   86.072248] [drm:intel_dump_pipe_config], requested mode:
[   86.072250] [drm:drm_mode_debug_printmodeline], Modeline 0:"1920x1080" 60 148500 1920 2008 2052 2200 1080 1084 1089 1125 0x48 0x5
[   86.072250] [drm:intel_dump_pipe_config], adjusted mode:
[   86.072252] [drm:drm_mode_debug_printmodeline], Modeline 0:"1920x1080" 60 148500 1920 2008 2052 2200 1080 1084 1089 1125 0x48 0x5
[   86.072254] [drm:intel_dump_crtc_timings], crtc timings: 148500 1920 2008 2052 2200 1080 1084 1089 1125, type: 0x48 flags: 0x5
[   86.072254] [drm:intel_dump_pipe_config], port clock: 148500
[   86.072255] [drm:intel_dump_pipe_config], pipe src size: 1920x1080
[   86.072256] [drm:intel_dump_pipe_config], gmch pfit: control: 0x00000000, ratios: 0x00000000, lvds border: 0x00000000
[   86.072257] [drm:intel_dump_pipe_config], pch pfit: pos: 0x00000000, size: 0x00000000, disabled
[   86.072258] [drm:intel_dump_pipe_config], ips: 0
[   86.072259] [drm:intel_dump_pipe_config], double wide: 0
[   86.072293] [drm:i9xx_set_pipeconf], disabling CxSR downclocking
[   86.072298] [drm:i9xx_update_plane], Writing base 05045000 00000000 0 0 7680
[   86.072301] [drm:intel_crtc_mode_set], [ENCODER:7:TMDS-7] set [MODE:0:1920x1080]
[   86.072957] [drm:g4x_check_srwm], SR watermark: display plane 114, cursor 6
[   86.072958] [drm:g4x_check_srwm], display watermark is too large(114/63), disabling
[   86.072960] [drm:g4x_update_wm], Setting FIFO watermarks - A: plane=49, cursor=6, B: plane=2, cursor=2, SR: plane=0, cursor=0
[   86.128027] [drm:intel_modeset_affected_pipes], set mode pipe masks: modeset: 0, prepare: 0, disable: 0

Here we're trying to set the resume mode on the connectors, and it looks ok until...

[   86.128031] [drm:intel_connector_check_state], [CONNECTOR:8:HDMI-A-1]
[   86.128034] [drm:check_encoder_state], [ENCODER:6:DAC-6]
[   86.128036] [drm:check_encoder_state], [ENCODER:7:TMDS-7]
[   86.128038] [drm:check_encoder_state], [ENCODER:11:TMDS-11]
[   86.128040] [drm:check_crtc_state], [CRTC:3]
[   86.128050] [drm:check_crtc_state], [CRTC:4]
[   86.128053] [drm:intel_resume_hotplug], running encoder hotplug functions
[   86.128056] [drm:intel_crt_detect], [CONNECTOR:5:VGA-1] force=0
[   86.144017] [drm:intel_crt_detect], CRT not detected via hotplug
[   86.148016] [drm:gmbus_xfer], GMBUS [i915 gmbus vga] NAK for addr: 0050 r(1)
[   86.148018] [drm:drm_do_probe_ddc_edid], drm: skipping non-existent adapter i915 gmbus vga
[   86.148019] [drm:intel_crt_get_edid], CRT GMBUS EDID read failed, retry using GPIO bit-banging
[   86.148021] [drm:intel_gmbus_force_bit], enabling bit-banging on i915 gmbus vga. force bit now 1
[   86.148287] [drm:drm_do_probe_ddc_edid], drm: skipping non-existent adapter i915 gmbus vga
[   86.148288] [drm:intel_gmbus_force_bit], disabling bit-banging on i915 gmbus vga. force bit now 0
[   86.148289] [drm:intel_crt_detect_ddc], CRT not detected via DDC:0x50 [no valid EDID found]
[   86.148291] [drm:drm_helper_hpd_irq_event], [CONNECTOR:5:VGA-1] status updated from unknown to disconnected
[   86.148292] [drm:intel_hdmi_detect], [CONNECTOR:8:HDMI-A-1]
[   86.152015] [drm:gmbus_xfer], GMBUS [i915 gmbus dpb] NAK for addr: 0050 r(1)
[   86.152017] [drm:drm_do_probe_ddc_edid], drm: skipping non-existent adapter i915 gmbus dpb
[   86.152019] [drm:drm_helper_hpd_irq_event], [CONNECTOR:8:HDMI-A-1] status updated from unknown to disconnected
[   86.152021] [drm:intel_dp_detect], [CONNECTOR:12:DP-1]
[   86.152024] [drm:drm_helper_hpd_irq_event], [CONNECTOR:12:DP-1] status updated from unknown to disconnected
[   86.152057] i915: No ACPI video bus found

Here when we fail to detect anything after resume.  So our DDC probing is failing.  Chris had a good theory about our GMbus failing, but it sounds like you tested that.

So it's possible your BIOS is disabling something we don't re-enable, or changing a clock we don't re-program, which causes our probing to fail.

Can you test again with a current kernel and attach the debug output again?  Hopefully this has been fixed, but if not we'll have to grot around in some additional registers and see what's going on...
Comment 11 Nikolay 2014-12-05 05:29:48 UTC
Created attachment 110475 [details]
Logs from drm-intel 53dcc2e5588aedffe73ba45cb519aa20c3ddef96

Unfortunately problem still exists in current drm-intel (and 3.17.2 as well)
Attaching dmesg output with debugging enabled.

I'll be happy to provide any additional information required.
Thanks!
Comment 12 Ville Syrjala 2014-12-05 09:39:40 UTC
Can you check 'setpci -s 0:2.0 0xcc.w' before and after suspend?
Comment 13 Nikolay 2014-12-05 14:17:26 UTC
Before suspend:

$ sudo setpci -s 0:2.0 0xcc.w
01bc

After suspend:

$ sudo setpci -s 0:2.0 0xcc.w
0000


That's not right, isn't it?
Comment 14 Jesse Barnes 2014-12-05 18:13:53 UTC
Here's a hack to try:

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 2725243..f33102b 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -925,6 +925,7 @@ struct i915_suspend_saved_registers {
 	u32 savePIPEB_LINK_N1;
 	u32 saveMCHBAR_RENDER_STANDBY;
 	u32 savePCH_PORT_HOTPLUG;
+	u16 saveGCDGMBUS;
 };
 
 struct vlv_s0ix_state {
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index dfe6617..d877aca 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -303,6 +303,10 @@ int i915_save_state(struct drm_device *dev)
 		}
 	}
 
+	if (IS_GEN4(dev))
+		pci_read_config_word(dev->pdev, 0xcc,
+				     &dev_priv->regfile.saveGCDGMBUS);
+
 	/* Cache mode state */
 	if (INTEL_INFO(dev)->gen < 7)
 		dev_priv->regfile.saveCACHE_MODE_0 = I915_READ(CACHE_MODE_0);
@@ -331,6 +335,10 @@ int i915_restore_state(struct drm_device *dev)
 	mutex_lock(&dev->struct_mutex);
 
 	i915_gem_restore_fences(dev);
+
+	if (IS_GEN4(dev))
+		pci_write_config_word(dev->pdev, 0xcc,
+				      dev_priv->regfile.saveGCDGMBUS);
 	i915_restore_display(dev);
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
Comment 15 Ville Syrjala 2014-12-05 18:41:17 UTC
BTW can you also build a kernel from this branch:
git://gitorious.org/vsyrjala/linux.git cdclk_7

It won't fix the problem (for that try Jesse's patch), but that kernel will print the cdclk frequency we deduce from varous registers, and I'd be interested in seeing how the 0xcc register correlates with that on your machine. You need to boot the kernel with drm.debug=0xe to make it report the frequency.
Comment 16 Nikolay 2014-12-06 02:46:03 UTC
Created attachment 110498 [details]
Log output for git://gitorious.org/vsyrjala/linux.git cdclk_7

Please find requested log output attached.
Comment 17 Nikolay 2014-12-06 02:52:38 UTC
I can confirm that Jesse's patch seems to be fixing the problem when applied against drm-intel tree.

I'll see if this patch works same wonders if applied aginst 3.17.4.

Thanks!
Comment 18 Nikolay 2014-12-06 17:07:37 UTC
This patch applied to 3.17.4 works great as well.

Thanks!
Comment 19 Jesse Barnes 2014-12-08 23:20:49 UTC
ok great, we'll come up with an upstream patch for this and submit it.  Thanks a ton for testing.
Comment 21 Jani Nikula 2014-12-11 13:43:55 UTC
commit 9f49c37635d5c2a801f7670d5fbf0b25ec461f2c
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Wed Dec 10 12:16:05 2014 -0800

    drm/i915: save/restore GMBUS freq across suspend/resume on gen4

in drm-intel-next-fixes, headed for 3.19 and stable.

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.