diff options
author | Imre Deak <imre.deak@intel.com> | 2016-03-16 13:39:04 +0200 |
---|---|---|
committer | Imre Deak <imre.deak@intel.com> | 2016-03-17 15:22:07 +0200 |
commit | f28cea45e5a9e1680753ce1b91f033dc3ceda7d0 (patch) | |
tree | 9c83d88c74a6c9c5797af953b5963f4df0819833 /drivers/gpu/drm/i915/i915_dma.c | |
parent | 5d7a6eefc3b025725dd1b5a643e90ce068e9dbd4 (diff) |
drm/i915: Split out load time MMIO initialization
According to the new init phases scheme we should have a definite step
in the init sequence where MMIO access is setup, so move the
corresponding code to a separate function. This also has the benefit of
making the error path cleaner both in the new function and in
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>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1458128348-15730-16-git-send-email-imre.deak@intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/i915_dma.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_dma.c | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 182770dee746..142d59acb632 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1051,6 +1051,50 @@ static void i915_mmio_cleanup(struct drm_device *dev) } /** + * i915_driver_init_mmio - setup device MMIO + * @dev_priv: device private + * + * Setup minimal device state necessary for MMIO accesses later in the + * initialization sequence. The setup here should avoid any other device-wide + * side effects or exposing the driver via kernel internal or user space + * interfaces. + */ +static int i915_driver_init_mmio(struct drm_i915_private *dev_priv) +{ + struct drm_device *dev = dev_priv->dev; + int ret; + + if (i915_get_bridge_dev(dev)) + return -EIO; + + ret = i915_mmio_setup(dev); + if (ret < 0) + goto put_bridge; + + intel_uncore_init(dev); + + return 0; + +put_bridge: + pci_dev_put(dev_priv->bridge_dev); + + return ret; +} + +/** + * i915_driver_cleanup_mmio - cleanup the setup done in i915_driver_init_mmio() + * @dev_priv: device private + */ +static void i915_driver_cleanup_mmio(struct drm_i915_private *dev_priv) +{ + struct drm_device *dev = dev_priv->dev; + + intel_uncore_fini(dev); + i915_mmio_cleanup(dev); + pci_dev_put(dev_priv->bridge_dev); +} + +/** * i915_driver_load - setup chip and create an initial config * @dev: DRM device * @flags: startup flags @@ -1081,22 +1125,15 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) intel_runtime_pm_get(dev_priv); - if (i915_get_bridge_dev(dev)) { - ret = -EIO; - goto out_runtime_pm_put; - } - - ret = i915_mmio_setup(dev); + ret = i915_driver_init_mmio(dev_priv); if (ret < 0) - goto put_bridge; - - intel_uncore_init(dev); + goto out_runtime_pm_put; intel_device_info_runtime_init(dev); ret = i915_gem_gtt_init(dev); if (ret) - goto out_uncore_fini; + goto out_cleanup_mmio; /* WARNING: Apparently we must kick fbdev drivers before vgacon, * otherwise the vga fbdev driver falls over. */ @@ -1218,11 +1255,8 @@ out_disable_msi: io_mapping_free(dev_priv->gtt.mappable); out_gtt: i915_global_gtt_cleanup(dev); -out_uncore_fini: - intel_uncore_fini(dev); - i915_mmio_cleanup(dev); -put_bridge: - pci_dev_put(dev_priv->bridge_dev); +out_cleanup_mmio: + i915_driver_cleanup_mmio(dev_priv); out_runtime_pm_put: intel_runtime_pm_put(dev_priv); i915_driver_cleanup_early(dev_priv); @@ -1303,10 +1337,7 @@ int i915_driver_unload(struct drm_device *dev) io_mapping_free(dev_priv->gtt.mappable); i915_global_gtt_cleanup(dev); - intel_uncore_fini(dev); - i915_mmio_cleanup(dev); - - pci_dev_put(dev_priv->bridge_dev); + i915_driver_cleanup_mmio(dev_priv); intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |