Skip to contentSkip to conversation

drm: call drm_device_set_unplugged in drm_put_dev

PATCH New Maarten Lankhorst 1 participant 1 message Mar 7, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: call drm_device_set_unplugged in drm_put_dev

This prevents the device from being reopened after drm_put_dev is called.

---
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

drivers/gpu/drm/drm_stub.c +5 -4
index 7d30802..e575c81 100644
@@ -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);