drm/i915: Split GGTT initialisation between probing and setup
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 4 Aug 2016 06:52:21 +0000 (07:52 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 4 Aug 2016 07:09:13 +0000 (08:09 +0100)
In order to handle conflicting drivers (i.e. vgacon) having a different
setup of hardware, we have to remove those other drivers before we try
to setup our own mappings. This requires us to split GGTT initialisation
between probing for the hardware location (part of the PCI BAR) and
later establishing the kernel resources for it.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1470293567-10811-2-git-send-email-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_gem_gtt.h

index 83afdd0597b576c003f3e64db65fe92ef995bc0a..8996c2a6cd073fc108a2b56816a8b1d772be270c 100644 (file)
@@ -1004,16 +1004,10 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv)
 
        intel_sanitize_options(dev_priv);
 
-       ret = i915_ggtt_init_hw(dev);
+       ret = i915_ggtt_probe_hw(dev);
        if (ret)
                return ret;
 
-       ret = i915_ggtt_enable_hw(dev);
-       if (ret) {
-               DRM_ERROR("failed to enable GGTT\n");
-               goto out_ggtt;
-       }
-
        /* WARNING: Apparently we must kick fbdev drivers before vgacon,
         * otherwise the vga fbdev driver falls over. */
        ret = i915_kick_out_firmware_fb(dev_priv);
@@ -1028,6 +1022,16 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv)
                goto out_ggtt;
        }
 
+       ret = i915_ggtt_init_hw(dev);
+       if (ret)
+               return ret;
+
+       ret = i915_ggtt_enable_hw(dev);
+       if (ret) {
+               DRM_ERROR("failed to enable GGTT\n");
+               goto out_ggtt;
+       }
+
        pci_set_master(dev->pdev);
 
        /* overlay on gen2 is broken and can't address above 1G */
index 671b1cab5e541d1626f6add73dd9735b9f30ac1f..3fc77776d89b14d0545bdd8809d4914660c6fb3b 100644 (file)
@@ -3208,10 +3208,10 @@ static void i915_gmch_remove(struct i915_address_space *vm)
 }
 
 /**
- * i915_ggtt_init_hw - Initialize GGTT hardware
+ * i915_ggtt_probe_hw - Probe GGTT hardware location
  * @dev: DRM device
  */
-int i915_ggtt_init_hw(struct drm_device *dev)
+int i915_ggtt_probe_hw(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = to_i915(dev);
        struct i915_ggtt *ggtt = &dev_priv->ggtt;
@@ -3254,14 +3254,6 @@ int i915_ggtt_init_hw(struct drm_device *dev)
                ggtt->mappable_end = min(ggtt->mappable_end, ggtt->base.total);
        }
 
-       /*
-        * Initialise stolen early so that we may reserve preallocated
-        * objects for the BIOS to KMS transition.
-        */
-       ret = i915_gem_init_stolen(dev);
-       if (ret)
-               goto out_gtt_cleanup;
-
        /* GMADR is the PCI mmio aperture into the global GTT. */
        DRM_INFO("Memory usable by graphics device = %lluM\n",
                 ggtt->base.total >> 20);
@@ -3273,10 +3265,30 @@ int i915_ggtt_init_hw(struct drm_device *dev)
 #endif
 
        return 0;
+}
+
+/**
+ * i915_ggtt_init_hw - Initialize GGTT hardware
+ * @dev: DRM device
+ */
+int i915_ggtt_init_hw(struct drm_device *dev)
+{
+       struct drm_i915_private *dev_priv = to_i915(dev);
+       struct i915_ggtt *ggtt = &dev_priv->ggtt;
+       int ret;
+
+       /*
+        * Initialise stolen early so that we may reserve preallocated
+        * objects for the BIOS to KMS transition.
+        */
+       ret = i915_gem_init_stolen(dev);
+       if (ret)
+               goto out_gtt_cleanup;
+
+       return 0;
 
 out_gtt_cleanup:
        ggtt->base.cleanup(&ggtt->base);
-
        return ret;
 }
 
index c4a657973cc6efa74544a809f7b757004f88a7b0..5b6744a5c944a64d4797b7369e3a0bdbcd237bce 100644 (file)
@@ -521,6 +521,7 @@ i915_page_dir_dma_addr(const struct i915_hw_ppgtt *ppgtt, const unsigned n)
                px_dma(ppgtt->base.scratch_pd);
 }
 
+int i915_ggtt_probe_hw(struct drm_device *dev);
 int i915_ggtt_init_hw(struct drm_device *dev);
 int i915_ggtt_enable_hw(struct drm_device *dev);
 void i915_gem_init_ggtt(struct drm_device *dev);