[PATCH 3/3] drm/prime: Use anon_drm_getfile() for an internal drm struct file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently the drm_prime mmap fallback uses a mock struct file to provide
the file pointer into the backend mmap routine. Now that we can create
fully fledged anonymous struct file around the drm device, put it to
use.

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
 drivers/gpu/drm/drm_prime.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 0814211b0f3f..5faa63713ec8 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -709,8 +709,7 @@ EXPORT_SYMBOL(drm_gem_dmabuf_vunmap);
  */
 int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 {
-	struct drm_file *priv;
-	struct file *fil;
+	struct file *file;
 	int ret;
 
 	if (obj->funcs && obj->funcs->mmap) {
@@ -722,30 +721,21 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 		return 0;
 	}
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	fil = kzalloc(sizeof(*fil), GFP_KERNEL);
-	if (!priv || !fil) {
-		ret = -ENOMEM;
-		goto out;
-	}
+	file = anon_drm_getfile(obj->dev->primary, O_RDWR);
+	if (IS_ERR(file))
+		return PTR_ERR(file);
 
-	/* Used by drm_gem_mmap() to lookup the GEM object */
-	priv->minor = obj->dev->primary;
-	fil->private_data = priv;
-
-	ret = drm_vma_node_allow(&obj->vma_node, priv);
+	ret = drm_vma_node_allow(&obj->vma_node, file->private_data);
 	if (ret)
 		goto out;
 
 	vma->vm_pgoff += drm_vma_node_start(&obj->vma_node);
 
-	ret = obj->dev->driver->fops->mmap(fil, vma);
+	ret = file->f_op->mmap(file, vma);
 
-	drm_vma_node_revoke(&obj->vma_node, priv);
+	drm_vma_node_revoke(&obj->vma_node, file->private_data);
 out:
-	kfree(priv);
-	kfree(fil);
-
+	fput(file);
 	return ret;
 }
 EXPORT_SYMBOL(drm_gem_prime_mmap);
-- 
2.24.0

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux