<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [SNB] [4.4 regression] vblank wait timed out on crtc"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=93509">93509</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[SNB] [4.4 regression] vblank wait timed out on crtc
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>DRI
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DRM/Intel
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>intel-gfx-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tomi@nomi.cz
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>intel-gfx-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>intel-gfx-bugs@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm sometimes getting "vblank wait timed out on crtc 0" when switching between
X and console on my ThinkPad T420.

Steps to reproduce:
1. get a machine with sandybridge and optimus
2. boot it with some 4.4-rc kernel
3. power off nvidia using bbswitch (couldn't reproduce without this)
4. switch between X and console a few times
   (while :; do chvt 10; sleep 2; chvt 1; sleep 2; done)
5. this happens:

------------[ cut here ]------------
WARNING: CPU: 0 PID: 1382 at drivers/gpu/drm/drm_irq.c:1216
drm_wait_one_vblank+0x1b0/0x1c0()
vblank wait timed out on crtc 0
Modules linked in: ccm br_netfilter bridge stp llc dm_thin_pool
dm_persistent_data dm_bio_prison libcrc32c dm_bufio binfmt_misc tun bnep
nf_conntrack_ipv6 nf_defrag_ipv6 ip6table_raw ip6table_filter ip6_tables
xt_multiport xt_conntrack iptable_raw uvcvideo xt_TCPMSS xt_tcpudp
iptable_mangle btusb ipt_MASQUERADE nf_nat_masquerade_ipv4 videobuf2_vmalloc
btrtl xt_addrtype videobuf2_memops videobuf2_v4l2 btbcm iptable_nat arc4
nf_conntrack_ipv4 btintel videobuf2_core iwldvm bluetooth nf_defrag_ipv4
nf_nat_ipv4 v4l2_common nf_nat videodev mac80211 iptable_filter ip_tables
x_tables x86_pkg_temp_thermal kvm_intel kvm iwlwifi snd_hda_codec_conexant
snd_hda_codec_generic snd_hda_intel snd_hda_codec cfg80211 irqbypass
crc32_pclmul snd_hwdep crc32c_intel sdhci_pci snd_hda_core sdhci snd_pcm_oss
aesni_intel mmc_core aes_x86_64 lrw hdaps(O) thinkpad_ec(O) glue_helper psmouse
ablk_helper snd_mixer_oss cryptd snd_pcm serio_raw e1000e thinkpad_acpi
ehci_pci snd_timer nvram ehci_hcd wmi usbcore ptp snd pps_core tpm_rng tpm_tis
tpm battery bbswitch(O) nf_conntrack_netlink soundcore ac i2c_i801 usb_common
nfnetlink evdev nf_conntrack_sip nf_conntrack_proto_sctp nf_conntrack_pptp
nf_conntrack_proto_gre nf_conntrack_netbios_ns nf_conntrack_broadcast
nf_conntrack_h323 nf_conntrack_irc nf_conntrack_ftp nf_conntrack coretemp hwmon
ecryptfs loop dm_crypt
CPU: 0 PID: 1382 Comm: Xorg Tainted: G           O    4.4.0-rc2-lis64-bisect+
#13
Hardware name: LENOVO 4178A3G/4178A3G, BIOS 83ET76WW (1.46 ) 07/05/2013
 0000000000000000 0000000061618deb ffff88041fc0b790 ffffffff8f301fcc
 ffff88041fc0b7d8 ffff88041fc0b7c8 ffffffff8f05a062 ffff88042ad01000
 0000000000000000 0000000000000000 0000000000000f58 ffff88042b485a08
Call Trace:
 [<ffffffff8f301fcc>] dump_stack+0x4e/0x82
 [<ffffffff8f05a062>] warn_slowpath_common+0x82/0xc0
 [<ffffffff8f05a0fc>] warn_slowpath_fmt+0x5c/0x80
 [<ffffffff8f703d0e>] ? _raw_spin_unlock_irqrestore+0xe/0x10
 [<ffffffff8f095765>] ? finish_wait+0x55/0x70
 [<ffffffff8f427730>] drm_wait_one_vblank+0x1b0/0x1c0
 [<ffffffff8f095bf0>] ? wake_atomic_t_function+0x60/0x60
 [<ffffffff8f4bd302>] intel_atomic_commit+0x732/0x1890
 [<ffffffff8f44017e>] ? drm_atomic_check_only+0x18e/0x590
 [<ffffffff8f43ff27>] ? drm_atomic_add_affected_connectors+0x27/0xf0
 [<ffffffff8f4405b7>] drm_atomic_commit+0x37/0x60
 [<ffffffff8f41d76f>] restore_fbdev_mode+0x22f/0x260
 [<ffffffff8f41fac3>] drm_fb_helper_restore_fbdev_mode_unlocked+0x33/0x80
 [<ffffffff8f41fb3d>] drm_fb_helper_set_par+0x2d/0x50
 [<ffffffff8f4d45ca>] intel_fbdev_set_par+0x1a/0x60
 [<ffffffff8f365ae1>] ? fb_set_var+0x301/0x450
 [<ffffffff8f365a28>] fb_set_var+0x248/0x450
 [<ffffffff8f08822c>] ? update_curr+0x5c/0x120
 [<ffffffff8f0888bd>] ? check_preempt_wakeup+0xdd/0x1c0
 [<ffffffff8f360343>] fbcon_blank+0x363/0x3b0
 [<ffffffff8f3e69e3>] do_unblank_screen+0xc3/0x190
 [<ffffffff8f3dc9d9>] complete_change_console+0x59/0xe0
 [<ffffffff8f3dd170>] vt_ioctl+0x710/0x12e0
 [<ffffffff8f425719>] ? drm_ioctl+0x189/0x540
 [<ffffffff8f429a50>] ? drm_setmaster_ioctl+0xa0/0xa0
 [<ffffffff8f3ddf08>] vt_compat_ioctl+0x188/0x3b0
 [<ffffffff8f0ae650>] ? __call_rcu.constprop.56+0x250/0x250
 [<ffffffff8f3cfc14>] tty_compat_ioctl+0x54/0xc0
 [<ffffffff8f1f56bb>] compat_SyS_ioctl+0xeb/0x11f0
 [<ffffffff8f09a3c7>] ? percpu_up_read+0x17/0x40
 [<ffffffff8f1a4291>] ? __sb_end_write+0x21/0x30
 [<ffffffff8f1a1f35>] ? vfs_write+0x165/0x1a0
 [<ffffffff8f002c9a>] do_fast_syscall_32+0x9a/0x150
 [<ffffffff8f7064d2>] sysenter_flags_fixed+0x8/0x12
---[ end trace 5d6ad91f242dc76e ]---

I couldn't reproduce this on 4.3 so I bisected it and got:

43d59eda1f69631c267e06ab6b94ed3c14f1f6d1 is the first bad commit
commit 43d59eda1f69631c267e06ab6b94ed3c14f1f6d1
Author: Matt Roper <<a href="mailto:matthew.d.roper@intel.com">matthew.d.roper@intel.com</a>>
Date:   Thu Sep 24 15:53:07 2015 -0700

    drm/i915: Eliminate usage of plane_wm_parameters from ILK-style WM code
(v2)

    Just pull the info out of the plane state structure rather than staging
    it in an additional structure.

    v2: Add 'visible' condition to sprites_scaled so that we don't limit the
        WM level when the sprite isn't enabled.  (Ville)

    Signed-off-by: Matt Roper <<a href="mailto:matthew.d.roper@intel.com">matthew.d.roper@intel.com</a>>
    Reviewed-by(v1): Ander Conselvan de Oliveira <<a href="mailto:conselvan2@gmail.com">conselvan2@gmail.com</a>>
    Reviewed-by: Maarten Lankhorst <<a href="mailto:maarten.lankhorst@linux.intel.com">maarten.lankhorst@linux.intel.com</a>>
    Signed-off-by: Daniel Vetter <<a href="mailto:daniel.vetter@ffwll.ch">daniel.vetter@ffwll.ch</a>>

:040000 040000 b11db95f066a752dcccb0082490eabf21f62e8db
88bc02171246d693a868cd9ddb3144ee5d9b0ea8 M      drivers

I also tried merging yesterday's drm-intel-next
(7447a2b221cd4df3960e82478a4ee29312589611) to yesterday's master
(a88164345b81292b55a8d4829fdd35c8d611cd7d) and couldn't reproduce it either.
Bisecting gave me:

92826fcdfc147a7d16766e987c12a9dfe1860c3f is the first fix commit
commit 92826fcdfc147a7d16766e987c12a9dfe1860c3f
Author: Maarten Lankhorst <<a href="mailto:maarten.lankhorst@linux.intel.com">maarten.lankhorst@linux.intel.com</a>>
Date:   Thu Dec 3 13:49:13 2015 +0100

    drm/i915: Calculate watermark related members in the crtc_state, v4.

    This removes pre/post_wm_update from intel_crtc->atomic, and
    creates atomic state for it in intel_crtc.

    Changes since v1:
    - Rebase on top of wm changes.
    Changes since v2:
    - Split disable_cxsr into a separate patch.
    Changes since v3:
    - Move some of the changes to intel_wm_need_update.

    Signed-off-by: Maarten Lankhorst <<a href="mailto:maarten.lankhorst@linux.intel.com">maarten.lankhorst@linux.intel.com</a>>
    Link:
<a href="http://patchwork.freedesktop.org/patch/msgid/56603A49.5000507@linux.intel.com">http://patchwork.freedesktop.org/patch/msgid/56603A49.5000507@linux.intel.com</a>
    Reviewed-by: Daniel Vetter <<a href="mailto:daniel.vetter@ffwll.ch">daniel.vetter@ffwll.ch</a>>

:040000 040000 b97b4b2338e1da2ee9e93791154b4deb2ecaf8b6
ae91735a668b6785e55122c646dbca93b54eb8c9 M      drivers

I can confirm that cherry-picking just this 92826fcdf on top of master is
enough to fix the issue for me and I intend to be running that for a while.

It is worth noting that I've had problems with this "vblank wait timed out on
crtc 0" in the past and it's just this
switching-between-X-and-console-repeatedly that I can't reproduce in 4.3. I
need to keep this in xorg.conf:

        Option      "TearFree" "true"
        Option      "SwapbuffersWait" "false"
        Option      "VSync" "false"

Otherwise tearing and/or stuttering appears within a few days of X running
(although I'm not sure if all that is needed with current kernels, I added this
4.1-ish). I do get tolerable visual artifacts regularly when playing youtube
videos in chrome (playing them using mpv with hwdec off is fine), but that's a
lot better than 5 fps and random X crashes.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are on the CC list for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>