diff mbox

drm: call drm_device_set_unplugged in drm_put_dev

Message ID 5138C436.8000006@canonical.com (mailing list archive)
State New, archived
Headers show

Commit Message

Maarten Lankhorst March 7, 2013, 4:45 p.m. UTC
This prevents the device from being reopened after drm_put_dev is called.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com

---
XXX:

The lifetime of various objects and files still look hairy. Wouldn't it make more sense to split up teardown?

- set unplugged state
- remove all drm device nodes from the system
- make sure all outstanding userspace open/close/ioctl calls to the device nodes are finished, does vfs have something for this?
- normal cleanup, call lastclose/unload, free all stuff
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 7d30802..e575c81 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -449,6 +449,8 @@  void drm_put_dev(struct drm_device *dev)
 	}
 	driver = dev->driver;
 
+	drm_device_set_unplugged(dev);
+
 	drm_lastclose(dev);
 
 	if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) &&
@@ -499,11 +501,10 @@  void drm_unplug_dev(struct drm_device *dev)
 
 	mutex_lock(&drm_global_mutex);
 
-	drm_device_set_unplugged(dev);
-
-	if (dev->open_count == 0) {
+	if (dev->open_count)
+		drm_device_set_unplugged(dev);
+	else
 		drm_put_dev(dev);
-	}
 	mutex_unlock(&drm_global_mutex);
 }
 EXPORT_SYMBOL(drm_unplug_dev);