Commit 47bc28d7 authored by Janusz Krzysztofik's avatar Janusz Krzysztofik Committed by Chris Wilson

drm/i915: Split off pci_driver.remove() tail to drm_driver.release()

In order to support driver hot unbind, some cleanup operations, now
performed on PCI driver remove, must be called later, after all device
file descriptors are closed.

Split out those operations from the tail of pci_driver.remove()
callback and put them into drm_driver.release() which is called as soon
as all references to the driver are put.  As a result, those cleanups
will be now run on last drm_dev_put(), either still called from
pci_driver.remove() if all device file descriptors are already closed,
or on last drm_release() file operation.
Signed-off-by: default avatarJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190530133105.30467-1-janusz.krzysztofik@linux.intel.com
parent 6501aa4e
...@@ -742,6 +742,7 @@ static int i915_load_modeset_init(struct drm_device *dev) ...@@ -742,6 +742,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
cleanup_gem: cleanup_gem:
i915_gem_suspend(dev_priv); i915_gem_suspend(dev_priv);
i915_gem_fini_hw(dev_priv);
i915_gem_fini(dev_priv); i915_gem_fini(dev_priv);
cleanup_modeset: cleanup_modeset:
intel_modeset_cleanup(dev); intel_modeset_cleanup(dev);
...@@ -1690,7 +1691,6 @@ static void i915_driver_cleanup_hw(struct drm_i915_private *dev_priv) ...@@ -1690,7 +1691,6 @@ static void i915_driver_cleanup_hw(struct drm_i915_private *dev_priv)
pci_disable_msi(pdev); pci_disable_msi(pdev);
pm_qos_remove_request(&dev_priv->pm_qos); pm_qos_remove_request(&dev_priv->pm_qos);
i915_ggtt_cleanup_hw(dev_priv);
} }
/** /**
...@@ -1914,6 +1914,7 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1914,6 +1914,7 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)
out_cleanup_hw: out_cleanup_hw:
i915_driver_cleanup_hw(dev_priv); i915_driver_cleanup_hw(dev_priv);
i915_ggtt_cleanup_hw(dev_priv);
out_cleanup_mmio: out_cleanup_mmio:
i915_driver_cleanup_mmio(dev_priv); i915_driver_cleanup_mmio(dev_priv);
out_runtime_pm_put: out_runtime_pm_put:
...@@ -1965,21 +1966,29 @@ void i915_driver_unload(struct drm_device *dev) ...@@ -1965,21 +1966,29 @@ void i915_driver_unload(struct drm_device *dev)
cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work); cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work);
i915_reset_error_state(dev_priv); i915_reset_error_state(dev_priv);
i915_gem_fini(dev_priv); i915_gem_fini_hw(dev_priv);
intel_power_domains_fini_hw(dev_priv); intel_power_domains_fini_hw(dev_priv);
i915_driver_cleanup_hw(dev_priv); i915_driver_cleanup_hw(dev_priv);
i915_driver_cleanup_mmio(dev_priv);
enable_rpm_wakeref_asserts(dev_priv); enable_rpm_wakeref_asserts(dev_priv);
intel_runtime_pm_cleanup(dev_priv);
} }
static void i915_driver_release(struct drm_device *dev) static void i915_driver_release(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = to_i915(dev); struct drm_i915_private *dev_priv = to_i915(dev);
disable_rpm_wakeref_asserts(dev_priv);
i915_gem_fini(dev_priv);
i915_ggtt_cleanup_hw(dev_priv);
i915_driver_cleanup_mmio(dev_priv);
enable_rpm_wakeref_asserts(dev_priv);
intel_runtime_pm_cleanup(dev_priv);
i915_driver_cleanup_early(dev_priv); i915_driver_cleanup_early(dev_priv);
i915_driver_destroy(dev_priv); i915_driver_destroy(dev_priv);
} }
......
...@@ -2745,6 +2745,7 @@ void i915_gem_init_mmio(struct drm_i915_private *i915); ...@@ -2745,6 +2745,7 @@ void i915_gem_init_mmio(struct drm_i915_private *i915);
int __must_check i915_gem_init(struct drm_i915_private *dev_priv); int __must_check i915_gem_init(struct drm_i915_private *dev_priv);
int __must_check i915_gem_init_hw(struct drm_i915_private *dev_priv); int __must_check i915_gem_init_hw(struct drm_i915_private *dev_priv);
void i915_gem_init_swizzling(struct drm_i915_private *dev_priv); void i915_gem_init_swizzling(struct drm_i915_private *dev_priv);
void i915_gem_fini_hw(struct drm_i915_private *dev_priv);
void i915_gem_fini(struct drm_i915_private *dev_priv); void i915_gem_fini(struct drm_i915_private *dev_priv);
int i915_gem_wait_for_idle(struct drm_i915_private *dev_priv, int i915_gem_wait_for_idle(struct drm_i915_private *dev_priv,
unsigned int flags, long timeout); unsigned int flags, long timeout);
......
...@@ -1664,7 +1664,7 @@ int i915_gem_init(struct drm_i915_private *dev_priv) ...@@ -1664,7 +1664,7 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
return ret; return ret;
} }
void i915_gem_fini(struct drm_i915_private *dev_priv) void i915_gem_fini_hw(struct drm_i915_private *dev_priv)
{ {
GEM_BUG_ON(dev_priv->gt.awake); GEM_BUG_ON(dev_priv->gt.awake);
...@@ -1679,6 +1679,14 @@ void i915_gem_fini(struct drm_i915_private *dev_priv) ...@@ -1679,6 +1679,14 @@ void i915_gem_fini(struct drm_i915_private *dev_priv)
mutex_lock(&dev_priv->drm.struct_mutex); mutex_lock(&dev_priv->drm.struct_mutex);
intel_uc_fini_hw(dev_priv); intel_uc_fini_hw(dev_priv);
intel_uc_fini(dev_priv); intel_uc_fini(dev_priv);
mutex_unlock(&dev_priv->drm.struct_mutex);
i915_gem_drain_freed_objects(dev_priv);
}
void i915_gem_fini(struct drm_i915_private *dev_priv)
{
mutex_lock(&dev_priv->drm.struct_mutex);
intel_engines_cleanup(dev_priv); intel_engines_cleanup(dev_priv);
i915_gem_contexts_fini(dev_priv); i915_gem_contexts_fini(dev_priv);
i915_gem_fini_scratch(dev_priv); i915_gem_fini_scratch(dev_priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment