drm/i915: fix module unload after context merge
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 19 Jun 2012 19:55:32 +0000 (21:55 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 20 Jun 2012 08:06:29 +0000 (10:06 +0200)
commit 8e96d9c4d9843f00ebeb4a9b33596d96602ea101
Author: Ben Widawsky <ben@bwidawsk.net>
Date:   Mon Jun 4 14:42:56 2012 -0700

    drm/i915: reset the GPU on context fini

broke module unload because it reset the gpu before we've stopped
touching it. Later on in the unload sequence the ringbuffer code
complained that the gpu would idle properly (because intel_gpu_reset
only resets the hw and not our sw state).

v2: Reorder things so that we reset the gpu _before_ we release the
backing storage of the default context.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51183
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_gem_context.c

index ba75af12f1fdd9f3ea17ee1706f2e5dfe2ba4f81..9913a77478a314adc5005f83c3fc00407eb5abf0 100644 (file)
@@ -1669,7 +1669,6 @@ int i915_driver_unload(struct drm_device *dev)
        if (ret)
                DRM_ERROR("failed to idle hardware: %d\n", ret);
        i915_gem_retire_requests(dev);
-       i915_gem_context_fini(dev);
        mutex_unlock(&dev->struct_mutex);
 
        /* Cancel the retire work handler, which should be idle now. */
@@ -1720,6 +1719,7 @@ int i915_driver_unload(struct drm_device *dev)
                mutex_lock(&dev->struct_mutex);
                i915_gem_free_all_phys_object(dev);
                i915_gem_cleanup_ringbuffer(dev);
+               i915_gem_context_fini(dev);
                mutex_unlock(&dev->struct_mutex);
                i915_gem_cleanup_aliasing_ppgtt(dev);
                i915_gem_cleanup_stolen(dev);
index 8fb8cd8f632084cc670041bdaa8770c82defa8c2..48e41df075b902451a196c76b14fd31e0ccad879 100644 (file)
@@ -277,11 +277,14 @@ void i915_gem_context_fini(struct drm_device *dev)
        if (dev_priv->hw_contexts_disabled)
                return;
 
+       /* The only known way to stop the gpu from accessing the hw context is
+        * to reset it. Do this as the very last operation to avoid confusing
+        * other code, leading to spurious errors. */
+       intel_gpu_reset(dev);
+
        i915_gem_object_unpin(dev_priv->ring[RCS].default_context->obj);
 
        do_destroy(dev_priv->ring[RCS].default_context);
-
-       intel_gpu_reset(dev);
 }
 
 void i915_gem_context_open(struct drm_device *dev, struct drm_file *file)