From owner-freebsd-stable@FreeBSD.ORG  Tue Jun 18 14:47:44 2013
Return-Path: <owner-freebsd-stable@FreeBSD.ORG>
Delivered-To: freebsd-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 01235A39
 for <freebsd-stable@freebsd.org>; Tue, 18 Jun 2013 14:47:44 +0000 (UTC)
 (envelope-from jdc@koitsu.org)
Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net
 [217.70.183.195])
 by mx1.freebsd.org (Postfix) with ESMTP id 9B0F11E5A
 for <freebsd-stable@freebsd.org>; Tue, 18 Jun 2013 14:47:43 +0000 (UTC)
Received: from mfilter25-d.gandi.net (mfilter25-d.gandi.net [217.70.178.153])
 by relay3-d.mail.gandi.net (Postfix) with ESMTP id 994AFA80D2;
 Tue, 18 Jun 2013 16:47:26 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mfilter25-d.gandi.net
Received: from relay3-d.mail.gandi.net ([217.70.183.195])
 by mfilter25-d.gandi.net (mfilter25-d.gandi.net [10.0.15.180]) (amavisd-new,
 port 10024)
 with ESMTP id uFyerY01kgCI; Tue, 18 Jun 2013 16:47:24 +0200 (CEST)
X-Originating-IP: 76.102.14.35
Received: from jdc.koitsu.org (c-76-102-14-35.hsd1.ca.comcast.net
 [76.102.14.35]) (Authenticated sender: jdc@koitsu.org)
 by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 56898A8102;
 Tue, 18 Jun 2013 16:47:24 +0200 (CEST)
Received: by icarus.home.lan (Postfix, from userid 1000)
 id 6DE2473A31; Tue, 18 Jun 2013 07:47:22 -0700 (PDT)
Date: Tue, 18 Jun 2013 07:47:22 -0700
From: Jeremy Chadwick <jdc@koitsu.org>
To: Javad Kouhi <javad.kouhi@gmail.com>
Subject: Re: system sporadically hangs on shutdown after switching to
 WITH_NEW_XORG
Message-ID: <20130618144722.GA3446@icarus.home.lan>
References: <51BDD593.5000102@xs4all.nl> <51BF60A8.6000503@xs4all.nl>
 <20130617193726.GR91021@kib.kiev.ua>
 <CA+g814fgxmkCjVNrqoTiE0AEQwGr5gystCUiMzDLCtZ3aTtk+Q@mail.gmail.com>
 <51C06AD2.5030404@xs4all.nl>
 <CA+g814dFmC1j4Czitn-VN9z3S29qBaMW47dOBOvbsaAxPvnWpg@mail.gmail.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="uAKRQypu60I7Lcqm"
Content-Disposition: inline
In-Reply-To: <CA+g814dFmC1j4Czitn-VN9z3S29qBaMW47dOBOvbsaAxPvnWpg@mail.gmail.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Cc: Michiel Boland <boland37@xs4all.nl>, freebsd-stable@freebsd.org
X-BeenThere: freebsd-stable@freebsd.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Production branch of FreeBSD source code <freebsd-stable.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-stable>,
 <mailto:freebsd-stable-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-stable>
List-Post: <mailto:freebsd-stable@freebsd.org>
List-Help: <mailto:freebsd-stable-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-stable>,
 <mailto:freebsd-stable-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Tue, 18 Jun 2013 14:47:44 -0000


--uAKRQypu60I7Lcqm
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Jun 18, 2013 at 07:00:30PM +0430, Javad Kouhi wrote:
> Thanks for the reply, seems that our source trees are not same, I got this:
> 
> % patch -p1 < /path/to/patch
> Hmm...  Looks like a unified diff to me...
> The text leading up to this was:
> --------------------------
> |diff --git a/sys/dev/drm2/i915/intel_fb.c b/sys/dev/drm2/i915/intel_fb.c
> |index 3cb3b78..e41a49f 100644
> |--- a/sys/dev/drm2/i915/intel_fb.c
> |+++ b/sys/dev/drm2/i915/intel_fb.c
> --------------------------
> Patching file sys/dev/drm2/i915/intel_fb.c using Plan A...
> Hunk #1 succeeded at 207 with fuzz 1.
> Hunk #2 failed at 231.
> 1 out of 2 hunks failed--saving rejects to sys/dev/drm2/i915/intel_fb.c.rej
> Hmm...  The next patch looks like a unified diff to me...
> The text leading up to this was:
> --------------------------
> |diff --git a/sys/dev/syscons/scvgarndr.c b/sys/dev/syscons/scvgarndr.c
> |index 6e6663c..fc7f02f 100644
> |--- a/sys/dev/syscons/scvgarndr.c
> |+++ b/sys/dev/syscons/scvgarndr.c
> --------------------------
> Patching file sys/dev/syscons/scvgarndr.c using Plan A...
> Hunk #1 succeeded at 395.
> Hunk #2 failed at 447.
> 1 out of 2 hunks failed--saving rejects to sys/dev/syscons/scvgarndr.c.rej
> done
> 
> 
> And the git way:
> 
> % git apply /path/to/patch
> error: patch failed: sys/dev/drm2/i915/intel_fb.c:207
> error: sys/dev/drm2/i915/intel_fb.c: patch does not apply
> error: patch failed: sys/dev/syscons/scvgarndr.c:445
> error: sys/dev/syscons/scvgarndr.c: patch does not apply
> 
> 
> I have revision 251934 of -STABLE branch. (I updated my source tree
> about 3 hours ago using svn)

I do not use git, I use svn, So I cannot help you with git "crap".

Please revert your sys/dev/drm2/i915/intel_fb.c and
sys/dev/syscons/scvgarndr.c back to r251934 (or newer) before following
what I tell you below.

The problem is either that:

- The patch you were given is probably for a different FreeBSD release,
  thus the code/line numbers/info in the code break the fuzzy logic
  matching,
- You copy-pasted the diff and because of tabs vs. spaces botched it,
- git apply/patch/whatever is weird,
- Multitudes of other possibilities I do not care to go into.

The hack kib@ gave you is not hard to manually add yourself.  It's very
few lines of code.  I'm very surprised you didn't try to manually add it
yourself.  So I have done that for you.  First, the proof -- this is
against r251939, by the way, but that shouldn't matter as nobody has
touched this between r251934 and r251939:

$ svn info
Path: .
Working Copy Root Path: /home/jdc/work/src
URL: svn://svn.freebsd.org/base/stable/9
Repository Root: svn://svn.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 251939
Node Kind: directory
Schedule: normal
Last Changed Author: marius
Last Changed Rev: 251939
Last Changed Date: 2013-06-18 07:20:14 -0700 (Tue, 18 Jun 2013)

$ svn status
M       sys/dev/drm2/i915/intel_fb.c
M       sys/dev/syscons/scvgarndr.c

The diff itself is available here:

http://jdc.koitsu.org/freebsd/sysmouse_vsync.diff

I've also attached it here in Email (assuming the mailing list doesn't
delete it).

You should apply the patch using:

  cd /usr/src  (or wherever your source is)
  patch -p0 < sysmouse_vsync.diff

Assuming use of svn, you can revert this patch by doing:

  cd /usr/src  (or wherever your source is)
  svn revert sys/dev/drm2/i915/intel_fb.c
  svn revert sys/dev/syscons/scvgarndr.c
  rm sys/dev/drm2/i915/intel_fb.c.orig
  rm sys/dev/syscons/scvgarndr.c.orig

There is probably some other "magical" way to do all of this, but as
anyone here knows, I do things manually because in general I do not
trust VCSes or the "magic" they do under the hood; I prefer to do things
that I know work.

Good luck -- I cannot help with any other aspect to the issue.

-- 
| Jeremy Chadwick                                   jdc@koitsu.org |
| UNIX Systems Administrator                http://jdc.koitsu.org/ |
| Making life hard for others since 1977.             PGP 4BD6C0CB |


--uAKRQypu60I7Lcqm
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="sysmouse_vsync.diff"

Index: sys/dev/drm2/i915/intel_fb.c
===================================================================
--- sys/dev/drm2/i915/intel_fb.c	(revision 251939)
+++ sys/dev/drm2/i915/intel_fb.c	(working copy)
@@ -207,6 +207,8 @@ static void intel_fbdev_destroy(struct drm_device
 	}
 }
 
+extern int sc_txtmouse_no_retrace_wait;
+
 int intel_fbdev_init(struct drm_device *dev)
 {
 	struct intel_fbdev *ifbdev;
@@ -229,6 +231,7 @@ int intel_fbdev_init(struct drm_device *dev)
 
 	drm_fb_helper_single_add_all_connectors(&ifbdev->helper);
 	drm_fb_helper_initial_config(&ifbdev->helper, 32);
+	sc_txtmouse_no_retrace_wait = 1;
 	return 0;
 }
 
Index: sys/dev/syscons/scvgarndr.c
===================================================================
--- sys/dev/syscons/scvgarndr.c	(revision 251939)
+++ sys/dev/syscons/scvgarndr.c	(working copy)
@@ -395,6 +395,8 @@ vga_txtblink(scr_stat *scp, int at, int flip)
 {
 }
 
+int sc_txtmouse_no_retrace_wait;
+
 #ifndef SC_NO_CUTPASTE
 
 static void
@@ -445,7 +447,9 @@ draw_txtmouse(scr_stat *scp, int x, int y)
 #if 1
 	/* wait for vertical retrace to avoid jitter on some videocards */
 	crtc_addr = scp->sc->adp->va_crtc_addr;
-	while (!(inb(crtc_addr + 6) & 0x08)) /* idle */ ;
+	while (!sc_txtmouse_no_retrace_wait &&
+	    !(inb(crtc_addr + 6) & 0x08))
+		/* idle */ ;
 #endif
 	c = scp->sc->mouse_char;
 	vidd_load_font(scp->sc->adp, 0, 32, 8, font_buf, c, 4); 

--uAKRQypu60I7Lcqm--