From: Imre Deak Date: Wed, 16 Mar 2016 11:39:04 +0000 (+0200) Subject: drm/i915: Split out load time MMIO initialization X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=f28cea45e5a9e1680753ce1b91f033dc3ceda7d0;p=openwrt%2Fstaging%2Fblogic.git 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 Signed-off-by: Imre Deak Reviewed-by: Chris Wilson Link: http://patchwork.freedesktop.org/patch/msgid/1458128348-15730-16-git-send-email-imre.deak@intel.com --- 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 @@ -1050,6 +1050,50 @@ static void i915_mmio_cleanup(struct drm_device *dev) pci_iounmap(dev->pdev, dev_priv->regs); } +/** + * 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 @@ -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);