Re: hard hang with intel video driver

From: Kostik Belousov <kostikbel_at_gmail.com>
Date: Mon, 2 Jun 2008 21:23:02 +0300
On Mon, Jun 02, 2008 at 06:32:45PM +0200, Michiel Boland wrote:
> Hi. I'm not having much luck with the 'intel' video driver on i386 
> -CURRENT. Whereas it would panic the box earlier when starting X (see 
> http://lists.freebsd.org/pipermail/freebsd-current/2008-February/082955.html 
> ), it now just completely hangs the machine.
> 
> No DDB, nothing.
> 
> FWIW hardware is a dell optiplex 756. Kernel is GENERIC with one added 
> option (BREAK_TO_DEBUGGER). Graphics card is reported as 'Q963/Q965 
> Integrated Graphics Controller' by pciconf.
> 
> The i810 driver works fine, but from what I gather from the xorg-drivers 
> port, this driver is being phased out in favour of the intel driver. Is 
> that correct? If so, then some work is needed somewhere.
> 
> What can I do to debug this further? I can't poweroff/poweron this machine 
> remotely. :(

There is a patch produced long time ago that might be relevant to the hang,
may be not.

diff --git a/sys/dev/drm/i915_dma.c b/sys/dev/drm/i915_dma.c
index eadd9e7..7c9acab 100644
--- a/sys/dev/drm/i915_dma.c
+++ b/sys/dev/drm/i915_dma.c
_at__at_ -367,20 +367,14 _at__at_ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords)
 	for (i = 0; i < dwords;) {
 		int cmd, sz;
 
-	     if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd))) {
-
-			return DRM_ERR(EINVAL);
-	      }
+		cmd = buffer[i];
 		if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords)
 			return DRM_ERR(EINVAL);
 
 		OUT_RING(cmd);
 
 		while (++i, --sz) {
-			if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i],
-							 sizeof(cmd))) {
-				return DRM_ERR(EINVAL);
-			}
+			cmd = buffer[i];
 			OUT_RING(cmd);
 		}
 	}
_at__at_ -401,10 +395,7 _at__at_ static int i915_emit_box(drm_device_t * dev,
 	drm_clip_rect_t box;
 	RING_LOCALS;
 
-	if (DRM_COPY_FROM_USER_UNCHECKED(&box, &boxes[i], sizeof(box))) {
-		return EFAULT;
-	}
-
+	box = boxes[i];
 	if (box.y2 <= box.y1 || box.x2 <= box.x1 || box.y2 <= 0 || box.x2 <= 0) {
 		DRM_ERROR("Bad box %d,%d..%d,%d\n",
 			  box.x1, box.y1, box.x2, box.y2);
_at__at_ -604,6 +595,7 _at__at_ static int i915_batchbuffer(DRM_IOCTL_ARGS)
 	drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *)
 	    dev_priv->sarea_priv;
 	drm_i915_batchbuffer_t batch;
+	size_t cliplen;
 	int ret;
 
 	if (!dev_priv->allow_batchbuffer) {
_at__at_ -619,14 +611,25 _at__at_ static int i915_batchbuffer(DRM_IOCTL_ARGS)
 
 	LOCK_TEST_WITH_RETURN(dev, filp);
 
+	DRM_UNLOCK();
+	cliplen = batch.num_cliprects * sizeof(drm_clip_rect_t);	
 	if (batch.num_cliprects && DRM_VERIFYAREA_READ(batch.cliprects,
-						       batch.num_cliprects *
-						       sizeof(drm_clip_rect_t)))
+						       cliplen)) {
+		DRM_LOCK();
 		return DRM_ERR(EFAULT);
-
+	}
+	ret = vslock(batch.cliprects, cliplen);
+	if (ret) {
+		DRM_ERROR("Fault wiring cliprects\n");
+		DRM_LOCK();
+		return DRM_ERR(EFAULT);
+	}
+	DRM_LOCK();
 	ret = i915_dispatch_batchbuffer(dev, &batch);
-
 	sarea_priv->last_dispatch = (int)hw_status[5];
+	DRM_UNLOCK();
+	vsunlock(batch.cliprects, cliplen);
+	DRM_LOCK();
 	return ret;
 }
 
_at__at_ -638,6 +641,7 _at__at_ static int i915_cmdbuffer(DRM_IOCTL_ARGS)
 	drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *)
 	    dev_priv->sarea_priv;
 	drm_i915_cmdbuffer_t cmdbuf;
+	size_t cliplen;
 	int ret;
 
 	DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_i915_cmdbuffer_t __user *) data,
_at__at_ -648,22 +652,38 _at__at_ static int i915_cmdbuffer(DRM_IOCTL_ARGS)
 
 	LOCK_TEST_WITH_RETURN(dev, filp);
 
+	DRM_UNLOCK();
+	cliplen = cmdbuf.num_cliprects * sizeof(drm_clip_rect_t);
 	if (cmdbuf.num_cliprects &&
-	    DRM_VERIFYAREA_READ(cmdbuf.cliprects,
-				cmdbuf.num_cliprects *
-				sizeof(drm_clip_rect_t))) {
+	    DRM_VERIFYAREA_READ(cmdbuf.cliprects, cliplen)) {
 		DRM_ERROR("Fault accessing cliprects\n");
+		DRM_LOCK();
 		return DRM_ERR(EFAULT);
 	}
-
-	ret = i915_dispatch_cmdbuffer(dev, &cmdbuf);
+	ret = vslock(cmdbuf.cliprects, cliplen);
 	if (ret) {
-		DRM_ERROR("i915_dispatch_cmdbuffer failed\n");
-		return ret;
+		DRM_ERROR("Fault wiring cliprects\n");
+		DRM_LOCK();
+		return DRM_ERR(EFAULT);
 	}
-
-	sarea_priv->last_dispatch = (int)hw_status[5];
-	return 0;
+	ret = vslock(cmdbuf.buf, cmdbuf.sz);
+	if (ret) {
+		vsunlock(cmdbuf.cliprects, cliplen);
+		DRM_ERROR("Fault wiring cmds\n");
+		DRM_LOCK();
+		return DRM_ERR(EFAULT);
+	}
+	DRM_LOCK();
+	ret = i915_dispatch_cmdbuffer(dev, &cmdbuf);
+	if (ret == 0)
+		sarea_priv->last_dispatch = (int)hw_status[5];
+	else
+		DRM_ERROR("i915_dispatch_cmdbuffer failed\n");
+	DRM_UNLOCK();
+	vsunlock(cmdbuf.buf, cmdbuf.sz);
+	vsunlock(cmdbuf.cliprects, cliplen);
+	DRM_LOCK();
+	return (ret);
 }
 
 static int i915_do_cleanup_pageflip(drm_device_t * dev)

Received on Mon Jun 02 2008 - 16:23:14 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:31 UTC