summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/drm_stub.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-01-03 14:24:19 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2014-03-16 12:23:33 +0100
commit6796cb16c088905bf3af40548fda68c09e6f6ee5 (patch)
treed40162f17dad7b54ac63feaf62b7c84493556f5a /drivers/gpu/drm/drm_stub.c
parent31bbe16f6d88622d6731fa2cb4ab38d57d844ac1 (diff)
downloadlwn-6796cb16c088905bf3af40548fda68c09e6f6ee5.tar.gz
lwn-6796cb16c088905bf3af40548fda68c09e6f6ee5.zip
drm: use anon-inode instead of relying on cdevs
DRM drivers share a common address_space across all character-devices of a single DRM device. This allows simple buffer eviction and mapping-control. However, DRM core currently waits for the first ->open() on any char-dev to mark the underlying inode as backing inode of the device. This delayed initialization causes ugly conditions all over the place: if (dev->dev_mapping) do_sth(); To avoid delayed initialization and to stop reusing the inode of the char-dev, we allocate an anonymous inode for each DRM device and reset filp->f_mapping to it on ->open(). Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/drm_stub.c')
-rw-r--r--drivers/gpu/drm/drm_stub.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index f2903d7e3d8e..04c25cedd4c1 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -526,8 +526,15 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
mutex_init(&dev->struct_mutex);
mutex_init(&dev->ctxlist_mutex);
- if (drm_ht_create(&dev->map_hash, 12))
+ dev->anon_inode = drm_fs_inode_new();
+ if (IS_ERR(dev->anon_inode)) {
+ ret = PTR_ERR(dev->anon_inode);
+ DRM_ERROR("Cannot allocate anonymous inode: %d\n", ret);
goto err_free;
+ }
+
+ if (drm_ht_create(&dev->map_hash, 12))
+ goto err_inode;
ret = drm_ctxbitmap_init(dev);
if (ret) {
@@ -549,6 +556,8 @@ err_ctxbitmap:
drm_ctxbitmap_cleanup(dev);
err_ht:
drm_ht_remove(&dev->map_hash);
+err_inode:
+ drm_fs_inode_free(dev->anon_inode);
err_free:
kfree(dev);
return NULL;
@@ -576,6 +585,7 @@ void drm_dev_free(struct drm_device *dev)
drm_ctxbitmap_cleanup(dev);
drm_ht_remove(&dev->map_hash);
+ drm_fs_inode_free(dev->anon_inode);
kfree(dev->devname);
kfree(dev);