[PATCH 5/5] drm/i915: Extract gem_init() from modeset_load()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



modeset_load() is definally not the right place to initialize gem but
it is there because it should only be called after intel_mode_init()
as one of the tasks of this function is check if BIOS have already
allocated a framebuffer and if so reuse it to accomplish a smooth
boot transition.

So here it is spliting the loading into two functions and
initializing gem between those functions.

Also renaming i915_modeset_unload() to i915_modeset_begin_unload()
as so far it is only doing this job and this way it can be used in
the errors paths of i915_driver_load().

Cc: Lucas De Marchi <lucas.demarchi@xxxxxxxxx>
Cc: Jani Nikula <jani.nikula@xxxxxxxxx>
Signed-off-by: José Roberto de Souza <jose.souza@xxxxxxxxx>
---
 drivers/gpu/drm/i915/i915_drv.c | 58 ++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 2b5ce764e694..f4163a8bb244 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -639,7 +639,7 @@ static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {
 	.can_switch = i915_switcheroo_can_switch,
 };
 
-static void i915_modeset_unload(struct drm_device *dev)
+static void i915_modeset_begin_unload(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct pci_dev *pdev = dev_priv->drm.pdev;
@@ -656,7 +656,7 @@ static void i915_modeset_unload(struct drm_device *dev)
 	intel_csr_ucode_fini(dev_priv);
 }
 
-static int i915_modeset_load(struct drm_device *dev)
+static int i915_modeset_begin_load(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct pci_dev *pdev = dev_priv->drm.pdev;
@@ -701,9 +701,22 @@ static int i915_modeset_load(struct drm_device *dev)
 	if (ret)
 		goto cleanup_gmbus;
 
-	ret = i915_gem_init(dev_priv);
-	if (ret)
-		goto cleanup_modeset;
+	return 0;
+
+cleanup_gmbus:
+	intel_teardown_gmbus(dev_priv);
+	intel_csr_ucode_fini(dev_priv);
+	vga_switcheroo_unregister_client(pdev);
+cleanup_vga_client:
+	vga_client_register(pdev, NULL, NULL, NULL);
+out:
+	return ret;
+}
+
+static int i915_modeset_finish_load(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = to_i915(dev);
+	int ret;
 
 	intel_overlay_setup(dev_priv);
 
@@ -712,7 +725,7 @@ static int i915_modeset_load(struct drm_device *dev)
 
 	ret = intel_fbdev_init(dev);
 	if (ret)
-		goto cleanup_gem;
+		return ret;
 
 	/* Only enable hotplug handling once the fbdev is fully set up. */
 	intel_hpd_init(dev_priv);
@@ -720,21 +733,6 @@ static int i915_modeset_load(struct drm_device *dev)
 	intel_init_ipc(dev_priv);
 
 	return 0;
-
-cleanup_gem:
-	if (i915_gem_suspend(dev_priv))
-		DRM_ERROR("failed to idle hardware; continuing to unload!\n");
-	i915_gem_fini(dev_priv);
-cleanup_modeset:
-	intel_modeset_cleanup(dev);
-cleanup_gmbus:
-	intel_teardown_gmbus(dev_priv);
-	intel_csr_ucode_fini(dev_priv);
-	vga_switcheroo_unregister_client(pdev);
-cleanup_vga_client:
-	vga_client_register(pdev, NULL, NULL, NULL);
-out:
-	return ret;
 }
 
 static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
@@ -1762,10 +1760,18 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (ret)
 		goto out_cleanup_power;
 
-	ret = i915_modeset_load(&dev_priv->drm);
+	ret = i915_modeset_begin_load(&dev_priv->drm);
 	if (ret < 0)
 		goto out_cleanup_irq;
 
+	ret = i915_gem_init(dev_priv);
+	if (ret)
+		goto out_cleanup_modeset_begin_load;
+
+	ret = i915_modeset_finish_load(&dev_priv->drm);
+	if (ret < 0)
+		goto out_cleanup_gem;
+
 	i915_driver_register(dev_priv);
 
 	enable_rpm_wakeref_asserts(dev_priv);
@@ -1774,6 +1780,12 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	return 0;
 
+out_cleanup_gem:
+	if (i915_gem_suspend(dev_priv))
+		DRM_ERROR("failed to idle hardware; continuing to unload!\n");
+	i915_gem_fini(dev_priv);
+out_cleanup_modeset_begin_load:
+	i915_modeset_begin_unload(&dev_priv->drm);
 out_cleanup_irq:
 	drm_irq_uninstall(&dev_priv->drm);
 out_cleanup_power:
@@ -1817,7 +1829,7 @@ void i915_driver_unload(struct drm_device *dev)
 	 */
 	intel_irq_uninstall(dev_priv);
 
-	i915_modeset_unload(dev);
+	i915_modeset_begin_unload(dev);
 
 	/* Free error state after interrupts are fully disabled. */
 	cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work);
-- 
2.21.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux