All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Use drm_dev_unplug()
@ 2019-04-05  7:26 ` Janusz Krzysztofik
  0 siblings, 0 replies; 22+ messages in thread
From: Janusz Krzysztofik @ 2019-04-05  7:26 UTC (permalink / raw)
  To: Joonas Lahtinen, Jani Nikula, Rodrigo Vivi
  Cc: David Airlie, Daniel Vetter, Chris Wilson, michal.wajdeczko,
	intel-gfx, dri-devel, linux-kernel, Janusz Krzysztofik

From: Janusz Krzysztofik <janusz.krzysztofik@intel.com>

The driver does not currently support unbinding from a device which is
in use.  Since open file descriptors may still be pointing into kernel
memory where the device structures used to be, entirely correct kernel
panics protect the driver from being unbound as we should not be
unbinding it before those dangling pointers have been made safe.

According to the documentation found inside drivers/gpu/drm/drm_drv.c,
drm_dev_unplug() should be used instead of drm_dev_unregister() in
order to make a device inaccessible to users as soon as it is unpluged.
Follow that advice to make those possibly dangling pointers safe,
protected by DRM layer from a user who is otherwise left pointing into
possibly reused kernel memory after the driver has been unbound from
the device.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 9df65d386d11..66163378c481 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1596,7 +1596,7 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv)
 	i915_pmu_unregister(dev_priv);
 
 	i915_teardown_sysfs(dev_priv);
-	drm_dev_unregister(&dev_priv->drm);
+	drm_dev_unplug(&dev_priv->drm);
 
 	i915_gem_shrinker_unregister(dev_priv);
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread
* [PATCH 0/2] Stop users from using the device on driver unbind
@ 2019-04-05 13:02 Janusz Krzysztofik
  2019-04-05 13:02   ` Janusz Krzysztofik
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Janusz Krzysztofik @ 2019-04-05 13:02 UTC (permalink / raw)
  To: Joonas Lahtinen, Jani Nikula, Rodrigo Vivi
  Cc: David Airlie, Daniel Vetter, Chris Wilson, michal.wajdeczko,
	intel-gfx, dri-devel, linux-kernel, Janusz Krzysztofik

Use drm_dev_unplug() to have device resources protected from user access
by DRM layer as soon as the driver is going to be unbound.  Also, cancel
all pending work so associated resources can be quickly released.

Janusz Krzysztofik (2):
  drm/i915: Use drm_dev_unplug()
  drm/i915: Mark GEM wedged right after marking device unplugged

 drivers/gpu/drm/i915/i915_drv.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

I'm resending these two patches together in series to make the robot
happy about the second one.  Also, I've added the Suggested-by: clause
to credit actual Chris' contribution.

Thanks,
Janusz
-- 
2.20.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-04-18 14:51 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-05  7:26 [PATCH] drm/i915: Use drm_dev_unplug() Janusz Krzysztofik
2019-04-05  7:26 ` Janusz Krzysztofik
2019-04-05  7:41 ` Chris Wilson
2019-04-05  8:11   ` Janusz Krzysztofik
2019-04-05  8:24     ` Chris Wilson
2019-04-05  8:24       ` Chris Wilson
2019-04-05 11:38       ` Janusz Krzysztofik
2019-04-15  9:29   ` Daniel Vetter
2019-04-15  9:29     ` Daniel Vetter
2019-04-05  8:23 ` ✗ Fi.CI.BAT: failure for " Patchwork
2019-04-05 13:02 [PATCH 0/2] Stop users from using the device on driver unbind Janusz Krzysztofik
2019-04-05 13:02 ` [PATCH 1/2] drm/i915: Use drm_dev_unplug() Janusz Krzysztofik
2019-04-05 13:02   ` Janusz Krzysztofik
2019-04-15  9:32   ` Daniel Vetter
2019-04-18 14:51     ` [PATCH v2 0/1] Stop users from using the device on driver unbind Janusz Krzysztofik
2019-04-18 14:51       ` [PATCH v2 1/1] drm/i915: Use drm_dev_unplug() Janusz Krzysztofik
2019-04-05 13:02 ` [PATCH 2/2] drm/i915: Mark GEM wedged right after marking device unplugged Janusz Krzysztofik
2019-04-05 13:02   ` Janusz Krzysztofik
2019-04-05 16:20 ` ✗ Fi.CI.BAT: failure for Stop users from using the device on driver unbind Patchwork
2019-04-05 16:26   ` Chris Wilson
2019-04-05 17:37     ` Chris Wilson
2019-04-08  8:19       ` Janusz Krzysztofik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.