/* Zeroes out the fence register itself and clears out the associated data structures in dev_priv and obj_priv.  */
int i915_gem_object_put_fence_reg(struct drm_gem_object *obj)
/* Zeroes out the fence register itself and clears out the associated data structures in dev_priv and obj_priv.  */
int i915_gem_object_put_fence_reg(struct drm_gem_object *obj)
{
	struct drm_device *dev = obj->dev;
	struct drm_i915_gem_object *obj_priv = obj->driver_private;
	if (obj_priv->fence_reg == I915_FENCE_REG_NONE)
		return 0;
	if (!IS_I965G(dev)) {
		int ret;
		i915_gem_object_flush_gpu_write_domain(obj);
		i915_gem_object_flush_gtt_write_domain(obj);
		ret = i915_gem_object_wait_rendering(obj);
		if (ret != 0)
			return ret;
	}
	i915_gem_clear_fence_reg (obj);
	return 0;
}