All of lore.kernel.org
 help / color / mirror / Atom feed
From: "José Roberto de Souza" <jose.souza@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Jani Nikula <jani.nikula@intel.com>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH 5/5] drm/i915: Extract gem_init() from modeset_load()
Date: Fri,  1 Mar 2019 16:49:35 -0800	[thread overview]
Message-ID: <20190302004935.28906-5-jose.souza@intel.com> (raw)
In-Reply-To: <20190302004935.28906-1-jose.souza@intel.com>

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@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2019-03-02  0:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-02  0:49 [PATCH 1/5] drm/i915/vlv: Move czclk to intel_pm José Roberto de Souza
2019-03-02  0:49 ` [PATCH 2/5] drm/i915: Rename i915_load_modeset_init() to i915_modeset_load() José Roberto de Souza
2019-03-04 11:00   ` Jani Nikula
2019-03-04 16:06     ` Lucas De Marchi
2019-03-02  0:49 ` [PATCH 3/5] drm/i915: Add a cleanup function for i915_modeset_load() José Roberto de Souza
2019-03-02  0:49 ` [PATCH 4/5] drm/i915: Move rawclck, power_domain and irq un/initialization from modeset functions José Roberto de Souza
2019-03-04 17:34   ` Ville Syrjälä
2019-03-05 11:42     ` Jani Nikula
2019-03-02  0:49 ` José Roberto de Souza [this message]
2019-03-02  2:37 ` ✓ Fi.CI.BAT: success for series starting with [1/5] drm/i915/vlv: Move czclk to intel_pm Patchwork
2019-03-02 11:28 ` ✗ Fi.CI.IGT: failure " Patchwork
2019-03-04 16:57 ` [PATCH 1/5] " Ville Syrjälä
2019-03-04 17:02   ` Ville Syrjälä

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190302004935.28906-5-jose.souza@intel.com \
    --to=jose.souza@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=lucas.demarchi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.