From nobody@FreeBSD.org  Fri May 25 10:07:07 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 10E9316A421
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 May 2007 10:07:07 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id 0284813C4B8
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 May 2007 10:07:07 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l4PA76St092329
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 May 2007 10:07:06 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l4PA763j092328;
	Fri, 25 May 2007 10:07:06 GMT
	(envelope-from nobody)
Message-Id: <200705251007.l4PA763j092328@www.freebsd.org>
Date: Fri, 25 May 2007 10:07:06 GMT
From: Adam K Kirchhoff<adamk@voicenet.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Xorg 7.2 locks up with AIGLX enabled on the r300 driver.
X-Send-Pr-Version: www-3.0

>Number:         112984
>Category:       kern
>Synopsis:       [drm] [patch] Xorg 7.2 locks up with AIGLX enabled on the r300 driver.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    rnoland
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 25 10:10:06 GMT 2007
>Closed-Date:    Wed Oct 22 16:03:01 UTC 2008
>Last-Modified:  Wed Oct 22 16:03:01 UTC 2008
>Originator:     Adam K Kirchhoff
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
none
>Environment:
FreeBSD memory.visualtech.com 7.0-CURRENT FreeBSD 7.0-CURRENT #0: Tue May 22 18:54:12 EDT 2007     root@memory.visualtech.com:/usr/obj/usr/src/sys/GENERIC  i386

>Description:

With Xorg 7.2, if I enabled AIGLX, the X server locks up.  I am able to
login via a serial console and reboot.  This happens with the DRM in
-CURRENT (1.25) and with the DRM supplied by Jung-uk Kim (1.27).


The serial console displays:

drm0: <ATI Radeon RV410 X700 Pro> on vgapci0
info: [drm] AGP at 0xc0000000 256MB
info: [drm] Initialized radeon 1.27.0 20060524
info: [drm] Setting GART location based on new memory map
info: [drm] Loading R300 Microcode
info: [drm] writeback test succeeded in 1 usecs
drm0: [ITHREAD]
error: [drm:pid1106:radeon_cp_buffers] *ERROR* radeon_cp_buffers called without lock held
error: [drm:pid1106:radeon_cp_reset] *ERROR* radeon_cp_reset called without lock held
error: [drm:pid1106:radeon_cp_start] *ERROR* radeon_cp_start called without lock held
error: [drm:pid1106:radeon_cp_buffers] *ERROR* radeon_cp_buffers called without lock held
error: [drm:pid1106:radeon_cp_reset] *ERROR* radeon_cp_reset called without lock held
error: [drm:pid1106:radeon_cp_start] *ERROR* radeon_cp_start called without lock held

The last six lines are repated indefinitely.
>How-To-Repeat:

Install Xorg 7.2, enable AIGLX in your xorg.conf file, and run Xorg on
an r300 or newer card (though I understand this is true for all radeon cards).


>Fix:


>Release-Note:
>Audit-Trail:

From: Henry Hu <hugangmail@163.com>
To: bug-followup@FreeBSD.org,  adamk@voicenet.com
Cc:  
Subject: Re: kern/112984: [drm] Xorg 7.2 locks up with AIGLX enabled on the
 r300 driver.
Date: Thu, 05 Jul 2007 16:12:23 +0800

 I'm using FreeBSD 6.2-STABLE, with Xorg 7.2 and Mesa 6.5.3.
 I have a radeon 7500 card, using radeon driver.
 If I turn on AIGLX and startx, the screen goes blank, and there's no
 response from the keyboard or the shutdown button. I can only use the
 RESET button to restart. And there are many messages in
 /var/log/messages, just the same as Kirchhoff's.
 If I run X -configure and X -config ~/xorg.conf.new, the screen will go
 blank and return, just because my fonts are still in /usr/X11R6. But I
 can get some different messages from /var/log/messages:
 ...
 (WW) AIGLX: 3D driver claims to not support visual 0x23
 (WW) AIGLX: 3D driver claims to not support visual 0x24
 (WW) AIGLX: 3D driver claims to not support visual 0x25
 (WW) AIGLX: 3D driver claims to not support visual 0x26
 (WW) AIGLX: 3D driver claims to not support visual 0x27
 (WW) AIGLX: 3D driver claims to not support visual 0x28
 (WW) AIGLX: 3D driver claims to not support visual 0x29
 (WW) AIGLX: 3D driver claims to not support visual 0x2a
 (WW) AIGLX: 3D driver claims to not support visual 0x2b
 (WW) AIGLX: 3D driver claims to not support visual 0x2c
 (WW) AIGLX: 3D driver claims to not support visual 0x2d
 (WW) AIGLX: 3D driver claims to not support visual 0x2e
 (WW) AIGLX: 3D driver claims to not support visual 0x2f
 (WW) AIGLX: 3D driver claims to not support visual 0x30
 (WW) AIGLX: 3D driver claims to not support visual 0x31
 (WW) AIGLX: 3D driver claims to not support visual 0x32
 (II) AIGLX: Loaded and initialized /usr/local/lib/dri/radeon_dri.so
 (II) GLX: Initialized DRI GL provider for screen 0
 ...
 
 Fatal server error:
 could not open default font 'fixed'
 (II) AIGLX: Suspending AIGLX clients for VT switch
 (**) RADEON(0): RADEONLeaveVT
 (EE) RADEON(0): RADEONLeaveVT: CP stop -22
 (**) RADEON(0): EngineRestore (32/32)
 (**) RADEON(0): RADEONRestore
 (**) RADEON(0): RADEONRestoreMode()
 (**) RADEON(0): RADEONRestoreMode(0x81cd130)
 (**) RADEON(0): RADEONRestoreMemMapRegisters() :
 (**) RADEON(0): MC_FB_LOCATION : 0x1fff0000
 (**) RADEON(0): MC_AGP_LOCATION : 0x27ff2000
 (**) RADEON(0): Map Changed ! Applying ...
 (**) RADEON(0): Map applied, resetting engine ...
 (**) RADEON(0): Updating display base addresses...
 (**) RADEON(0): Memory map updated.
 (**) RADEON(0): Programming CRTC2, offset: 0x00000000
 (**) RADEON(0): Wrote: 0x00000000 0x00000000 0x00000000 (0x0000a400)
 (**) RADEON(0): Wrote: rd=0, fd=0, pd=0
 (**) RADEON(0): Programming CRTC1, offset: 0x00000000
 (**) RADEON(0): Wrote: 0x00000007 0x00030057 0x00000000 (0x0000a400)
 (**) RADEON(0): Wrote: rd=7, fd=87, pd=3
 (==) RADEON(0): Write-combining range (0xa0000,0x10000) was already clear
 (**) RADEON(0): Ok, leaving now...
 
 
 
 

From: Stefan Sperling <stsp@stsp.name>
To: bug-followup@freebsd.org, Adam K Kirchhoff <adamk@voicenet.com>
Cc:  
Subject: Re: kern/112984: [drm] Xorg 7.2 locks up with AIGLX enabled on the
	r300 driver.
Date: Sun, 15 Jul 2007 14:02:33 +0200

 --gatW/ieO32f1wygP
 Content-Type: multipart/mixed; boundary="LZvS9be/3tNcYl/X"
 Content-Disposition: inline
 
 
 --LZvS9be/3tNcYl/X
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 The hard lockup went away for me after applying the patches from
 http://docs.freebsd.org/cgi/getmsg.cgi?fetch=3D86381+0+archive/2006/freebsd=
 -x11/20061112.freebsd-x11
 linked from
 http://lists.freebsd.org/pipermail/freebsd-x11/2007-June/004571.html
 
 They did not apply at all on 6.2 but it was trivial to port them,
 see attachments.
 
 One patch is for the kernel (sys/dev/drm/).
 
 The other is for xorg-server, I put it into
 /usr/ports/x11-servers/xorg-server/files/patch-aiglxfix.diff
 and did "cd /usr/ports/x11-servers/xorg-server && make && make deinstall re=
 install"
 
 The only issues that still remain are:
 
 	* Minor graphic glitches (fuzzy grey lines across the screen)
 	in gdm which disappear once I log into gnome
 
 	* The fact that I'm apparently too stupid to start compiz
 	properly as my windows still have no decorations after:
 	env LIBGL_ALWAYS_INDIRECT=3D1 LIBGL_DEBUG=3Dverbose compiz --replace & # r=
 uns fine apparently
 	env LIBGL_ALWAYS_INDIRECT=3D1 LIBGL_DEBUG=3Dverbose gtk-window-decorator &=
  # does nothing???
 
 	* And the following lines occuring repeatedly in dmesg:
 
 error: [drm:pid1117:radeon_cp_indirect] *ERROR* radeon_cp_indirect called w=
 ithout lock held
 error: [drm:pid1117:radeon_cp_stop] *ERROR* radeon_cp_stop called without l=
 ock held
 error: [drm:pid1117:radeon_cp_init] *ERROR* radeon_cp_init called without l=
 ock held
 
 Again, this hasn't caused any lockups so far...
 
 The card I'm using is:
 
 drm0: <ATI Radeon AS 9550> port 0xb800-0xb8ff mem 0xc0000000-0xcfffffff,0xd=
 fef0000-0xdfefffff irq 16 at device 0.0 on pci1
 info: [drm] AGP at 0xe0000000 64MB
 info: [drm] Initialized radeon 1.24.0 20060225
 info: [drm] Setting GART location based on new memory map
 info: [drm] Loading R300 Microcode
 info: [drm] writeback test succeeded in 1 usecs
 
 --=20
 stefan
 http://stsp.name                                         PGP Key: 0xF59D25F0
 
 --LZvS9be/3tNcYl/X
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="radeon-drm-aiglx-fix-6.2.diff"
 Content-Transfer-Encoding: quoted-printable
 
 Index: sys/dev/drm/radeon_cp.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /usr/ncvs/src/sys/dev/drm/radeon_cp.c,v
 retrieving revision 1.15.2.3
 diff -u -r1.15.2.3 radeon_cp.c
 --- sys/dev/drm/radeon_cp.c	17 May 2006 07:40:11 -0000	1.15.2.3
 +++ sys/dev/drm/radeon_cp.c	15 Jul 2007 09:00:08 -0000
 @@ -1928,8 +1928,6 @@
  	drm_radeon_private_t *dev_priv =3D dev->dev_private;
  	DRM_DEBUG("\n");
 =20
 -	LOCK_TEST_WITH_RETURN(dev, filp);
 -
  	return radeon_do_cp_idle(dev_priv);
  }
 =20
 @@ -1947,8 +1945,6 @@
  	DRM_DEVICE;
  	DRM_DEBUG("\n");
 =20
 -	LOCK_TEST_WITH_RETURN(dev, filp);
 -
  	return radeon_do_engine_reset(dev);
  }
 =20
 @@ -2141,8 +2137,6 @@
  	drm_dma_t __user *argp =3D (void __user *)data;
  	drm_dma_t d;
 =20
 -	LOCK_TEST_WITH_RETURN(dev, filp);
 -
  	DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d));
 =20
  	/* Please don't send us buffers.
 Index: sys/dev/drm/radeon_state.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /usr/ncvs/src/sys/dev/drm/radeon_state.c,v
 retrieving revision 1.15.2.3
 diff -u -r1.15.2.3 radeon_state.c
 --- sys/dev/drm/radeon_state.c	17 May 2006 07:40:11 -0000	1.15.2.3
 +++ sys/dev/drm/radeon_state.c	15 Jul 2007 09:06:32 -0000
 @@ -2452,8 +2452,6 @@
  	int i;
  	unsigned char laststate;
 =20
 -	LOCK_TEST_WITH_RETURN(dev, filp);
 -
  	if (!dev_priv) {
  		DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
  		return DRM_ERR(EINVAL);
 @@ -2774,6 +2772,7 @@
  	drm_radeon_cmd_header_t header;
  	int orig_nbox, orig_bufsz;
  	char *kbuf =3D NULL;
 +	RING_LOCALS;
 =20
  	LOCK_TEST_WITH_RETURN(dev, filp);
 =20
 @@ -2813,7 +2812,15 @@
  	}
 =20
  	orig_nbox =3D cmdbuf.nbox;
 -
 +=20
 +        /* Wait for the engine to idle before the indirect buffer
 +         * is processed.
 +         */
 +=20
 +        BEGIN_RING(2);
 +        RADEON_WAIT_UNTIL_IDLE();
 +        ADVANCE_RING();
 +=20
  	if (dev_priv->microcode_version =3D=3D UCODE_R300) {
  		int temp;
  		temp =3D r300_do_cp_cmdbuf(dev, filp, filp_priv, &cmdbuf);
 
 --LZvS9be/3tNcYl/X
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="patch-aiglxfix.diff"
 Content-Transfer-Encoding: quoted-printable
 
 --- hw/xfree86/dri/dri.c.orig	Sun Jul 15 11:11:55 2007
 +++ hw/xfree86/dri/dri.c	Sun Jul 15 11:10:49 2007
 @@ -1603,8 +1603,12 @@
  	/* unwrap */
  	pScreen->WindowExposures =3D pDRIPriv->wrap.WindowExposures;
 =20
 +       DRILock(pScreen, 0);
 +
  	/* call lower layers */
  	(*pScreen->WindowExposures)(pWin, prgn, bsreg);
 +
 +       DRIUnlock(pScreen);
 =20
  	/* rewrap */
  	pDRIPriv->wrap.WindowExposures =3D pScreen->WindowExposures;
 
 --LZvS9be/3tNcYl/X--
 
 --gatW/ieO32f1wygP
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.7 (FreeBSD)
 
 iD8DBQFGmgzZ5dMCc/WdJfARAgDTAJ9qHqkGb6f2O3GDkEFDWhwMypPIfwCg5zrf
 JT/TrPejaHitkahoJiOrkBc=
 =d/74
 -----END PGP SIGNATURE-----
 
 --gatW/ieO32f1wygP--

From: Stefan Sperling <stsp@stsp.name>
To: bug-followup@freebsd.org, Adam K Kirchhoff <adamk@voicenet.com>
Cc:  
Subject: Re: kern/112984: [drm] Xorg 7.2 locks up with AIGLX enabled on the
	r300 driver.
Date: Sun, 15 Jul 2007 14:46:48 +0200

 --SUOF0GtieIMvvwua
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Sun, Jul 15, 2007 at 02:02:33PM +0200, Stefan Sperling wrote:
 > The hard lockup went away for me after applying the patches from
 
 Well, it turns out it's not too stable after all even
 with those patches :-/
 
 I just had to two lockups, one occured after I ran "pkill -9 compiz"
 =66rom remote through ssh. I did this cause I could not focus any window
 after starting compiz nor could could I switch to text mode,
 and without -9 nothing happened. That lockup could only be resolved by
 resetting the box.
 
 The other one was not as bad, it occured after restaring gdm - the
 screen just went grey with a few white lines across here and there.
 The box was still pinging, ssh made it to the password prompt after
 about a minute (very strange) but I still got no shell after waiting
 another while. I could shutdown the box cleanly by pressing the power
 button. From /var/log/messages:
 
 Jul 15 14:05:41 ted kernel: error: [drm:pid1230:radeon_cp_stop] *ERROR* rad=
 eon_c
 p_stop called without lock held
 Jul 15 14:05:41 ted kernel: error: [drm:pid1230:radeon_cp_init] *ERROR* rad=
 eon_c
 p_init called without lock held
 Jul 15 14:05:41 ted gdm[1229]: Error reinitilizing server
 
 
 Also once there were major graphics glitches: every horizontal
 line the mouse moved over went black, new windows were drawn
 on top of the black area but that didn't help much as they
 got covered up again as soon as the mouse moved over them...
 I was able to half-blindly use the gnome menu to log out though...
 
 All this went away again when I disabled AIGLX in xorg.conf.
 
 --=20
 stefan
 http://stsp.name                                         PGP Key: 0xF59D25F0
 
 --SUOF0GtieIMvvwua
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.7 (FreeBSD)
 
 iD8DBQFGmhc45dMCc/WdJfARAg+EAJ94CHJ3yxE6rmeJjP7jpWdfuWWl0QCglxC0
 7K7LDU4V6RQNrDqcU6dZ/fY=
 =eNqq
 -----END PGP SIGNATURE-----
 
 --SUOF0GtieIMvvwua--

From: "Henry Hu" <henry.hu.sh@gmail.com>
To: bug-followup@freebsd.org, adamk@voicenet.com
Cc:  
Subject: Re: kern/112984: [drm] Xorg 7.2 locks up with AIGLX enabled on the r300 driver.
Date: Mon, 16 Jul 2007 16:23:11 +0800

 Thanks a lot!
 I've applied the patch, rebuilt the kernel and xorg-server. Now AIGLX is ok,
 and glxgears with LIBGL_ALWAYS_INDIRECT is as fast as direct rendering.
 glxinfo -i gives me:
 
 OpenGL vendor string: Tungsten Graphics, Inc.
 OpenGL renderer string: Mesa DRI Radeon 20061018 AGP 1x x86/MMX/SSE2 TCL
 OpenGL version string: 1.3 Mesa 7.0
 
 Till now nothing strange happened.
 I've heard about this patch, but I cound not find it. Thanks!
 
Responsible-Changed-From-To: freebsd-bugs->rnoland 
Responsible-Changed-By: joel 
Responsible-Changed-When: Mon Sep 15 16:24:33 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=112984 
State-Changed-From-To: open->closed 
State-Changed-By: rnoland 
State-Changed-When: Wed Oct 22 16:03:00 UTC 2008 
State-Changed-Why:  
adamk reports issues are resolved with current drm code. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=112984 
>Unformatted:
