Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_agp.c
===================================================================
RCS file: /cvs/XF4/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_agp.c,v
retrieving revision 1.3
diff -u -d -p -r1.3 bsd_agp.c
--- xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_agp.c	23 Feb 2006 14:07:28 -0000	1.3
+++ xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_agp.c	19 Apr 2006 20:33:22 -0000
@@ -29,17 +29,20 @@
 #endif
 
 static int gartFd = -1;
+static Bool gartNew = FALSE;
 static int acquiredScreen = -1;
 static Bool initDone = FALSE;
 
 /*
- * Close /dev/agpgart.  This frees all associated memory allocated during
+ * Close the AGP device.  This frees all associated memory allocated during
  * this server generation.
  */
 Bool
 xf86GARTCloseScreen(int screenNum)
 {
 	if(gartFd != -1) {
+		if (gartNew)
+			close(gartFd);
 		acquiredScreen = -1;
 		gartFd = -1;
 		initDone = FALSE;
@@ -48,7 +51,7 @@ xf86GARTCloseScreen(int screenNum)
 }
 
 /*
- * Open /dev/agpgart.  Keep it open until xf86GARTCloseScreen is called.
+ * Open the AGP device.  Keep it open until xf86GARTCloseScreen is called.
  */
 static Bool
 GARTInit(int screenNum)
@@ -60,16 +63,29 @@ GARTInit(int screenNum)
 
 	initDone = TRUE;
 
-	if (gartFd == -1)
+	if (gartFd != -1)
+		return FALSE;
+
+	gartFd = open(AGP_DEVICE, O_RDWR, 0);
+	if (gartFd != -1) {
+		gartNew = TRUE;
+	} else if (errno == ENOENT) {
 		gartFd = xf86Info.consoleFd;
-	else
+		gartNew = FALSE;
+	} else {
+		xf86DrvMsg(screenNum, X_ERROR,
+		    "GARTInit: Unable to open " AGP_DEVICE " (%s)\n",
+		    strerror(errno));
 		return FALSE;
+	}
 
 	xf86AcquireGART(-1);
 	/* Check the kernel driver version. */
 	if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
 		xf86DrvMsg(screenNum, X_WARNING,
 			"GARTInit: AGPIOC_INFO failed (%s)\n", strerror(errno));
+		if (gartNew)
+			close(gartFd);
 		gartFd = -1;
 		return FALSE;
 	}
