summaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-01-29 10:21:36 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2014-03-16 12:25:17 +0100
commit099d1c290e2ebc3b798961a6c177c3aef5f0b789 (patch)
tree4b0d0a693d5c08081e72cd24294d9d312b14a107 /include/drm
parentcb8a239b03608079cbfb784e9ac2f522fe846c29 (diff)
downloadblackbird-op-linux-099d1c290e2ebc3b798961a6c177c3aef5f0b789.tar.gz
blackbird-op-linux-099d1c290e2ebc3b798961a6c177c3aef5f0b789.zip
drm: provide device-refcount
Lets not trick ourselves into thinking "drm_device" objects are not ref-counted. That's just utterly stupid. We manage "drm_minor" objects on each drm-device and each minor can have an unlimited number of open handles. Each of these handles has the drm_minor (and thus the drm_device) as private-data in the file-handle. Therefore, we may not destroy "drm_device" until all these handles are closed. It is *not* possible to reset all these pointers atomically and restrict access to them, and this is *not* how this is done! Instead, we use ref-counts to make sure the object is valid and not freed. Note that we currently use "dev->open_count" for that, which is *exactly* the same as a reference-count, just open coded. So this patch doesn't change any semantics on DRM devices (well, this patch just introduces the ref-count, anyway. Follow-up patches will replace open_count by it). Also note that generic VFS revoke support could allow us to drop this ref-count again. We could then just synchronously disable any fops->xy() calls. However, this is not the case, yet, and no such patches are in sight (and I seriously question the idea of dropping the ref-cnt again). Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/drmP.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 2c322564ca7d..4e53f1607355 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -43,6 +43,7 @@
#include <asm/current.h>
#endif /* __alpha__ */
#include <linux/kernel.h>
+#include <linux/kref.h>
#include <linux/miscdevice.h>
#include <linux/fs.h>
#include <linux/init.h>
@@ -1102,6 +1103,7 @@ struct drm_device {
/** \name Lifetime Management */
/*@{ */
+ struct kref ref; /**< Object ref-count */
struct device *dev; /**< Device structure of bus-device */
struct drm_driver *driver; /**< DRM driver managing the device */
void *dev_private; /**< DRM driver private data */
@@ -1666,7 +1668,8 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map)
struct drm_device *drm_dev_alloc(struct drm_driver *driver,
struct device *parent);
-void drm_dev_free(struct drm_device *dev);
+void drm_dev_ref(struct drm_device *dev);
+void drm_dev_unref(struct drm_device *dev);
int drm_dev_register(struct drm_device *dev, unsigned long flags);
void drm_dev_unregister(struct drm_device *dev);
/*@}*/
OpenPOWER on IntegriCloud