[Intel-gfx] [PATCH] i915: Restore fence registers on resume

Kristian Høgsberg krh at bitplanet.net
Mon May 4 21:59:43 CEST 2009


From: Kristian Høgsberg <krh at redhat.com>

Buffers that stay pinned during suspend/resume need to have their
fence registers rewritten when we come back from resume.

Signed-off-by: Kristian Høgsberg <krh at redhat.com>
---
 drivers/gpu/drm/i915/i915_drv.c |    2 ++
 drivers/gpu/drm/i915/i915_drv.h |    1 +
 drivers/gpu/drm/i915/i915_gem.c |   26 ++++++++++++++++++++++++++
 3 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index b293ef0..a77d7f1 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -111,6 +111,8 @@ static int i915_resume(struct drm_device *dev)
 			ret = -1;
 		mutex_unlock(&dev->struct_mutex);
 
+		i915_gem_restore_fences(dev);
+			
 		drm_irq_install(dev);
 	}
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index d6cc986..2c9faa7 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -632,6 +632,7 @@ int i915_gem_attach_phys_object(struct drm_device *dev,
 void i915_gem_detach_phys_object(struct drm_device *dev,
 				 struct drm_gem_object *obj);
 void i915_gem_free_all_phys_object(struct drm_device *dev);
+int i915_gem_restore_fences(struct drm_device *dev);
 
 /* i915_gem_tiling.c */
 void i915_gem_detect_bit_6_swizzle(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index fb6390a..2b36a32 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1708,6 +1708,32 @@ i915_gem_clear_fence_reg(struct drm_gem_object *obj)
 	obj_priv->fence_reg = I915_FENCE_REG_NONE;
 }
 
+int
+i915_gem_restore_fences(struct drm_device *dev)
+{
+	drm_i915_private_t *dev_priv = dev->dev_private;
+	struct drm_i915_fence_reg *reg;
+	int i, count, ret = 0;
+
+	for (i = dev_priv->fence_reg_start;
+	     i < dev_priv->num_fence_regs; i++) {
+		reg = &dev_priv->fence_regs[i];
+		if (!reg->obj)
+			continue;
+
+		count++;
+		if (IS_I965G(dev))
+			i965_write_fence_reg(reg);
+		else if (IS_I9XX(dev))
+			i915_write_fence_reg(reg);
+		else
+			i830_write_fence_reg(reg);
+	}
+
+	if (count > 0)
+		DRM_DEBUG("restored %d fence regs\n", count);
+}
+
 /**
  * Finds free space in the GTT aperture and binds the object there.
  */
-- 
1.6.2.2




More information about the Intel-gfx mailing list