drm/i915: Extract commmon global gtt cleanup code
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 6 Aug 2014 13:04:56 +0000 (15:04 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 13 Aug 2014 12:23:35 +0000 (14:23 +0200)
We want to move the aliasing ppgtt cleanup back into the global
gtt cleanup code for symmetry, but first we need to create such
a place.

Reviewed-by: Michel Thierry <michel.thierry@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_gem_gtt.h

index 895f9f2f35eae757f187a52a16a67428df177120..c9af48503f76dae47d60ca99f497344d46ce60b3 100644 (file)
@@ -1821,7 +1821,7 @@ out_mtrrfree:
        arch_phys_wc_del(dev_priv->gtt.mtrr);
        io_mapping_free(dev_priv->gtt.mappable);
 out_gtt:
-       dev_priv->gtt.base.cleanup(&dev_priv->gtt.base);
+       i915_global_gtt_cleanup(dev);
 out_regs:
        intel_uncore_fini(dev);
        pci_iounmap(dev->pdev, dev_priv->regs);
@@ -1920,7 +1920,7 @@ int i915_driver_unload(struct drm_device *dev)
        destroy_workqueue(dev_priv->wq);
        pm_qos_remove_request(&dev_priv->pm_qos);
 
-       dev_priv->gtt.base.cleanup(&dev_priv->gtt.base);
+       i915_global_gtt_cleanup(dev);
 
        intel_uncore_fini(dev);
        if (dev_priv->regs != NULL)
index c1e2d9a9f9e213777679a2dd259b2691e3ff2c1a..8d94e35820453559ded5cd70af9a482a86f30096 100644 (file)
@@ -1767,6 +1767,18 @@ void i915_gem_init_global_gtt(struct drm_device *dev)
        i915_gem_setup_global_gtt(dev, 0, mappable_size, gtt_size);
 }
 
+void i915_global_gtt_cleanup(struct drm_device *dev)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct i915_address_space *vm = &dev_priv->gtt.base;
+
+       if (drm_mm_initialized(&vm->mm)) {
+               drm_mm_takedown(&vm->mm);
+               list_del(&vm->global_link);
+       }
+
+       vm->cleanup(vm);
+}
 static int setup_scratch_page(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
@@ -2035,10 +2047,6 @@ static void gen6_gmch_remove(struct i915_address_space *vm)
 
        struct i915_gtt *gtt = container_of(vm, struct i915_gtt, base);
 
-       if (drm_mm_initialized(&vm->mm)) {
-               drm_mm_takedown(&vm->mm);
-               list_del(&vm->global_link);
-       }
        iounmap(gtt->gsm);
        teardown_scratch_page(vm->dev);
 }
@@ -2071,10 +2079,6 @@ static int i915_gmch_probe(struct drm_device *dev,
 
 static void i915_gmch_remove(struct i915_address_space *vm)
 {
-       if (drm_mm_initialized(&vm->mm)) {
-               drm_mm_takedown(&vm->mm);
-               list_del(&vm->global_link);
-       }
        intel_gmch_remove();
 }
 
index 98fbb7309ea5c12232890e4f1aa99b346b15dcca..6280648d4805bd5216f45dfcc9e4be238967c75a 100644 (file)
@@ -273,6 +273,7 @@ int i915_gem_gtt_init(struct drm_device *dev);
 void i915_gem_init_global_gtt(struct drm_device *dev);
 int i915_gem_setup_global_gtt(struct drm_device *dev, unsigned long start,
                              unsigned long mappable_end, unsigned long end);
+void i915_global_gtt_cleanup(struct drm_device *dev);
 
 
 int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt);