From nobody@FreeBSD.org  Sun Apr 20 23:26:37 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 451E48D0
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 20 Apr 2014 23:26:37 +0000 (UTC)
Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client did not present a certificate)
	by mx1.freebsd.org (Postfix) with ESMTPS id 257A91FF1
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 20 Apr 2014 23:26:37 +0000 (UTC)
Received: from cgiserv.freebsd.org ([127.0.1.6])
	by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s3KNQaXL050348
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 20 Apr 2014 23:26:36 GMT
	(envelope-from nobody@cgiserv.freebsd.org)
Received: (from nobody@localhost)
	by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s3KNQa1u050317;
	Sun, 20 Apr 2014 23:26:36 GMT
	(envelope-from nobody)
Message-Id: <201404202326.s3KNQa1u050317@cgiserv.freebsd.org>
Date: Sun, 20 Apr 2014 23:26:36 GMT
From: Ivan Rokotov <ivan.rokotov.bsd@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Suspend/resume with Intel GMA HD 4000: AIGLX fails to restart
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         188833
>Category:       kern
>Synopsis:       [suspend/resume] Suspend/resume with Intel GMA HD 4000: AIGLX fails to restart
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 20 23:30:00 UTC 2014
>Closed-Date:    
>Last-Modified:  Tue Apr 22 05:36:22 UTC 2014
>Originator:     Ivan Rokotov
>Release:        FreeBSD 10.0-RELEASE
>Organization:
>Environment:
FreeBSD thorium 10.0-RELEASE FreeBSD 10.0-RELEASE #0: Tue Apr 15 19:52:30 MSK 2014     nikola@thorium:/usr/obj/usr/src/sys/KRYPTONVT  amd64

with the latest VT, drm2 and i915kms code from 10-STABLE mfc'ed and compiled.
>Description:
My Intel GMA HD 4000 on Lenovo IdeaPad S400 with the latest VT, drm2 and i915kms from 10-STABLE can't resume properly because AIGLX fails to wake up. Of course, the graphics after it non-usable or horribly corrupted, like here:
http://i327.photobucket.com/albums/k477/ivan_rokotov_bsd/2_zpsd7564e4b.png

I found this patch, which solved the problem completely:
http://lists.freebsd.org/pipermail/freebsd-x11/2013-October/013727.html

Now, I can resome, and have this in X log after it:
[  4561.749] (WW) intel(0): retrying batchbuffer submit
[  4561.803] (WW) intel(0): retrying batchbuffer submit
[  4561.857] (WW) intel(0): retrying batchbuffer submit
[  4561.908] (WW) intel(0): retrying batchbuffer submit
[  4561.959] (WW) intel(0): retrying batchbuffer submit
[  4562.012] (WW) intel(0): retrying batchbuffer submit
[  4562.063] (WW) intel(0): retrying batchbuffer submit
[  4562.117] (WW) intel(0): retrying batchbuffer submit
[  4562.171] (WW) intel(0): retrying batchbuffer submit
[  4562.225] (WW) intel(0): retrying batchbuffer submit
[  4562.279] (WW) intel(0): retrying batchbuffer submit
[  4562.333] (WW) intel(0): retrying batchbuffer submit
[  4562.386] (WW) intel(0): retrying batchbuffer submit
[  4562.439] (WW) intel(0): retrying batchbuffer submit
[  4562.493] (WW) intel(0): retrying batchbuffer submit
[  4562.547] (WW) intel(0): retrying batchbuffer submit
[  4564.779] (II) AIGLX: Suspending AIGLX clients for VT switch
[  4564.779] (WW) intel(0): drmDropMaster failed: Unknown error: -22
[  4565.994] (II) AIGLX: Resuming AIGLX clients after VT switch
[  4566.096] (II) intel(0): EDID vendor "CMN", prod id 5239
[  4566.096] (II) intel(0): Printing DDC gathered Modelines:
[  4566.096] (II) intel(0): Modeline "1366x768"x0.0   71.59  1366 1410
1439 1512  768 771 775 789 -hsync -vsync (47.3 kHz eP)

but everything is alive: compiz restarts correctly, GL applications
work as they did before resume. This is very stable, I suspended/resumed my notebook more than ten times for 4-5 days (without shutting down) - and it works.

The ret value obtained with this code
xf86DrvMsg(scrn->scrnIndex, X_WARNING, "retrying batchbuffer submit,
ret=%d\n", ret);

is:

[  8572.583] (WW) intel(0): retrying batchbuffer submit, ret=-16
>How-To-Repeat:
Install FreeBSD with the latest VT code on Lenovo IdeaPad S400 and try to do suspend/resume from X.
>Fix:
The retry hack proposed by Jan Kokemller <jan.kokemueller@gmail.com> here
http://lists.freebsd.org/pipermail/freebsd-x11/2013-October/013727.html
solves the problem.
 

>Release-Note:
>Audit-Trail:
>Unformatted:
