Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v3 16/19] drm/i915: Split out load time HW initialization
Date: Wed, 16 Mar 2016 13:39:05 +0200	[thread overview]
Message-ID: <1458128348-15730-17-git-send-email-imre.deak@intel.com> (raw)
In-Reply-To: <1458128348-15730-1-git-send-email-imre.deak@intel.com>

According to the new init phases scheme we should have a definite step
in the init sequence where we setup things requiring accessing the
device, so move the corresponding code to separate function. The steps
in this init phase should avoid exposing the driver via some interface,
which is done in the last registration init phase. This changae also
has the benefit of making the error path cleaner both in the new
function and i915_driver_load()/unload().

No functional change.

Suggested by Chris.

CC: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/i915_dma.c | 122 ++++++++++++++++++++++++----------------
 1 file changed, 75 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index ab97404..aaf1b17 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1095,45 +1095,23 @@ static void i915_driver_cleanup_mmio(struct drm_i915_private *dev_priv)
 }
 
 /**
- * i915_driver_load - setup chip and create an initial config
- * @dev: DRM device
- * @flags: startup flags
+ * i915_driver_init_hw - setup state requiring device access
+ * @dev_priv: device private
  *
- * The driver load routine has to do several things:
- *   - drive output discovery via intel_modeset_init()
- *   - initialize the memory manager
- *   - allocate initial config memory
- *   - setup the DRM framebuffer with the allocated memory
+ * Setup state that requires accessing the device, but doesn't require
+ * exposing the driver via kernel internal or userspace interfaces.
  */
-int i915_driver_load(struct drm_device *dev, unsigned long flags)
+static int i915_driver_init_hw(struct drm_i915_private *dev_priv)
 {
-	struct drm_i915_private *dev_priv;
-	int ret = 0;
+	struct drm_device *dev = dev_priv->dev;
 	uint32_t aperture_size;
-
-	dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
-	if (dev_priv == NULL)
-		return -ENOMEM;
-
-	dev->dev_private = dev_priv;
-
-	ret = i915_driver_init_early(dev_priv, dev,
-				     (struct intel_device_info *)flags);
-
-	if (ret < 0)
-		goto out_free_priv;
-
-	intel_runtime_pm_get(dev_priv);
-
-	ret = i915_driver_init_mmio(dev_priv);
-	if (ret < 0)
-		goto out_runtime_pm_put;
+	int ret;
 
 	intel_device_info_runtime_init(dev);
 
 	ret = i915_gem_gtt_init(dev);
 	if (ret)
-		goto out_cleanup_mmio;
+		return ret;
 
 	/* WARNING: Apparently we must kick fbdev drivers before vgacon,
 	 * otherwise the vga fbdev driver falls over. */
@@ -1205,10 +1183,73 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 			DRM_DEBUG_DRIVER("can't enable MSI");
 	}
 
+	return 0;
+
+out_gtt:
+	i915_global_gtt_cleanup(dev);
+
+	return ret;
+}
+
+/**
+ * i915_driver_cleanup_hw - cleanup the setup done in i915_driver_init_hw()
+ * @dev_priv: device private
+ */
+static void i915_driver_cleanup_hw(struct drm_i915_private *dev_priv)
+{
+	struct drm_device *dev = dev_priv->dev;
+
+	if (dev->pdev->msi_enabled)
+		pci_disable_msi(dev->pdev);
+
+	pm_qos_remove_request(&dev_priv->pm_qos);
+	arch_phys_wc_del(dev_priv->gtt.mtrr);
+	io_mapping_free(dev_priv->gtt.mappable);
+	i915_global_gtt_cleanup(dev);
+}
+
+/**
+ * i915_driver_load - setup chip and create an initial config
+ * @dev: DRM device
+ * @flags: startup flags
+ *
+ * The driver load routine has to do several things:
+ *   - drive output discovery via intel_modeset_init()
+ *   - initialize the memory manager
+ *   - allocate initial config memory
+ *   - setup the DRM framebuffer with the allocated memory
+ */
+int i915_driver_load(struct drm_device *dev, unsigned long flags)
+{
+	struct drm_i915_private *dev_priv;
+	int ret = 0;
+
+	dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
+	if (dev_priv == NULL)
+		return -ENOMEM;
+
+	dev->dev_private = dev_priv;
+
+	ret = i915_driver_init_early(dev_priv, dev,
+				     (struct intel_device_info *)flags);
+
+	if (ret < 0)
+		goto out_free_priv;
+
+	intel_runtime_pm_get(dev_priv);
+
+	ret = i915_driver_init_mmio(dev_priv);
+	if (ret < 0)
+		goto out_runtime_pm_put;
+
+	ret = i915_driver_init_hw(dev_priv);
+	if (ret < 0)
+		goto out_cleanup_mmio;
+
 	if (INTEL_INFO(dev)->num_pipes) {
 		ret = drm_vblank_init(dev, INTEL_INFO(dev)->num_pipes);
 		if (ret)
-			goto out_disable_msi;
+			goto out_cleanup_hw;
 	}
 
 	ret = i915_load_modeset_init(dev);
@@ -1247,15 +1288,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 out_power_well:
 	intel_power_domains_fini(dev_priv);
 	drm_vblank_cleanup(dev);
-out_disable_msi:
-	if (dev->pdev->msi_enabled)
-		pci_disable_msi(dev->pdev);
-
-	pm_qos_remove_request(&dev_priv->pm_qos);
-	arch_phys_wc_del(dev_priv->gtt.mtrr);
-	io_mapping_free(dev_priv->gtt.mappable);
-out_gtt:
-	i915_global_gtt_cleanup(dev);
+out_cleanup_hw:
+	i915_driver_cleanup_hw(dev_priv);
 out_cleanup_mmio:
 	i915_driver_cleanup_mmio(dev_priv);
 out_runtime_pm_put:
@@ -1331,13 +1365,7 @@ int i915_driver_unload(struct drm_device *dev)
 
 	intel_power_domains_fini(dev_priv);
 
-	if (dev->pdev->msi_enabled)
-		pci_disable_msi(dev->pdev);
-	pm_qos_remove_request(&dev_priv->pm_qos);
-	arch_phys_wc_del(dev_priv->gtt.mtrr);
-	io_mapping_free(dev_priv->gtt.mappable);
-	i915_global_gtt_cleanup(dev);
-
+	i915_driver_cleanup_hw(dev_priv);
 	i915_driver_cleanup_mmio(dev_priv);
 
 	intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
-- 
2.5.0

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

  parent reply	other threads:[~2016-03-16 11:39 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 11:38 [PATCH v3 00/19] Split driver init step to phases Imre Deak
2016-03-16 11:38 ` [PATCH v3 01/19] Fix MCHBAR cleanup on the driver init error path Imre Deak
2016-03-16 11:38 ` [PATCH v3 02/19] drm/i915: Move load time PCH detect, DPIO, power domain SW init earlier Imre Deak
2016-03-16 11:38 ` [PATCH v3 03/19] drm/i915: Move load time IRQ " Imre Deak
2016-03-16 11:38 ` [PATCH v3 04/19] drm/i915: Move load time init of display/audio hooks earlier Imre Deak
2016-03-16 11:38 ` [PATCH v3 05/19] drm/i915: Move load time init of clock gating " Imre Deak
2016-03-16 11:38 ` [PATCH v3 06/19] drm/i915: Move load time runtime device info init earlier Imre Deak
2016-03-16 11:38 ` [PATCH v3 07/19] drm/i915: Move load time gem_load_init earlier Imre Deak
2016-03-16 11:57   ` Chris Wilson
2016-03-16 12:18     ` Imre Deak
2016-03-16 12:54   ` [PATCH v4 " Imre Deak
2016-03-16 11:38 ` [PATCH v3 08/19] drm/i915: Move load time runtime PM get later Imre Deak
2016-03-16 11:38 ` [PATCH v3 09/19] drm/i915: Move load time shrinker registration later Imre Deak
2016-03-16 11:38 ` [PATCH v3 10/19] drm/i915: Move load time audio component registration earlier Imre Deak
2016-03-16 11:39 ` [PATCH v3 11/19] drm/i915: Move unload time display power domain uninit later Imre Deak
2016-03-16 11:39 ` [PATCH v3 12/19] drm/i915: Move unload time GTT, MSI IRQ cleanup later Imre Deak
2016-03-16 11:39 ` [PATCH v3 13/19] drm/i915: Move unload time opregion unregistration earlier Imre Deak
2016-03-16 11:39 ` [PATCH v3 14/19] drm/i915: Split out load time early initialization Imre Deak
2016-03-16 11:39 ` [PATCH v3 15/19] drm/i915: Split out load time MMIO initialization Imre Deak
2016-03-16 11:39 ` Imre Deak [this message]
2016-03-16 11:39 ` [PATCH v3 17/19] drm/i915: Split out load time interface registration Imre Deak
2016-03-16 11:39 ` [PATCH v3 18/19] drm/i915: Fix power domain HW state cleanup on error path Imre Deak
2016-03-16 11:39 ` [PATCH v3 19/19] drm/i915: Add fault injection support Imre Deak
2016-03-16 12:00   ` Chris Wilson
2016-03-16 12:12     ` Imre Deak
2016-03-16 12:44       ` Chris Wilson
2016-03-16 12:47         ` Imre Deak
2016-03-16 17:31   ` [PATCH v4 " Imre Deak
2016-03-16 12:01 ` [PATCH v3 00/19] Split driver init step to phases Chris Wilson
2016-03-16 16:44 ` ✗ Fi.CI.BAT: failure for Split driver init step to phases (rev2) Patchwork
2016-03-17 11:32 ` ✗ Fi.CI.BAT: warning for Split driver init step to phases (rev3) Patchwork
2016-03-17 12:23   ` Imre Deak
2016-03-17 13:27     ` Imre Deak

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=1458128348-15730-17-git-send-email-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox