From: Janusz Krzysztofik <[email protected]>

As soon as a device is considered unplugged, not only prevent pending
users from accessing the device structures but also cancel all their
pending requests so all consumed resources can be cleaned up as soon
as possible.

Suggested-by: Chris Wilson <[email protected]>
Signed-off-by: Janusz Krzysztofik <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c | 7 +++++++
 drivers/gpu/drm/i915/i915_drv.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 0bbf3f5db5fc..c695b3a4deae 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1907,6 +1907,13 @@ void i915_driver_unload(struct drm_device *dev)
 
        i915_driver_unregister(dev_priv);
 
+       /*
+        * After unregistering the device to prevent any new users, cancel
+        * all in-flight requests so that we can quickly unbind the active
+        * resources.
+        */
+       i915_gem_set_wedged(dev_priv);
+
        /* Flush any external code that still may be under the RCU lock */
        synchronize_rcu();
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 4af815c3c02d..b9bedfa9652d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2917,6 +2917,7 @@ static inline void i915_gem_drain_workqueue(struct 
drm_i915_private *i915)
        int pass = 2;
        do {
                rcu_barrier();
+               i915_gem_drain_freed_objects(i915);
                drain_workqueue(i915->wq);
        } while (--pass);
 }
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to