[PATCH 3/3] hmmm

Matthew Auld matthew.auld at intel.com
Fri May 26 15:35:55 UTC 2017


---
 drivers/gpu/drm/i915/i915_drv.h   |  2 ++
 drivers/gpu/drm/i915/i915_gem.c   |  5 +++++
 drivers/gpu/drm/i915/i915_gemfs.c | 32 ++++++++++++++++++++++----------
 3 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 90b41f1c20f2..573a0797c8b6 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -4167,4 +4167,6 @@ void i915_gemfs_destroy(struct drm_i915_private *i915);
 struct file *i915_gemfs_file_setup(struct drm_i915_private *i915,
 				   const char *name, size_t size);
 
+int i915_gemfs_unlink(struct drm_i915_gem_object *obj);
+
 #endif
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 25f670e7c3f1..f474268bf047 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4401,7 +4401,12 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 			drm_prime_gem_destroy(&obj->base, NULL);
 
 		reservation_object_fini(&obj->__builtin_resv);
+
+		if (obj->base.filp)
+			i915_gemfs_unlink(obj);
+
 		drm_gem_object_release(&obj->base);
+
 		i915_gem_info_remove_obj(i915, obj->base.size);
 
 		kfree(obj->bit_17);
diff --git a/drivers/gpu/drm/i915/i915_gemfs.c b/drivers/gpu/drm/i915/i915_gemfs.c
index f1d6d5d14f91..a77ef5a1fe99 100644
--- a/drivers/gpu/drm/i915/i915_gemfs.c
+++ b/drivers/gpu/drm/i915/i915_gemfs.c
@@ -49,17 +49,15 @@ int i915_gemfs_create(struct drm_i915_private *i915)
 	struct super_block *sb;
 	int flags = 0;
 	int ret;
-	char options[] = "huge=within_size";
+	char options[] = "huge=never";
 
 	type = get_fs_type("tmpfs");
-	if (!type) {
+	if (!type)
 		return -EINVAL;
-	}
 
 	gemfs_mnt = kern_mount(type);
-	if (IS_ERR(gemfs_mnt)) {
+	if (IS_ERR(gemfs_mnt))
 		return PTR_ERR(gemfs_mnt);
-	}
 
 	sb = gemfs_mnt->mnt_sb;
 
@@ -77,9 +75,13 @@ int i915_gemfs_create(struct drm_i915_private *i915)
 		return PTR_ERR(gemfs_mnt);
 	}
 
-	WARN_ON(SHMEM_SB(sb)->huge == 0);
+	WARN_ON(SHMEM_SB(sb)->huge > 0);
 #endif
 
+	WARN_ON(!(sb->s_flags & (MS_KERNMOUNT | MS_NOUSER)));
+	WARN_ON(SHMEM_SB(sb)->max_blocks > 0);
+	WARN_ON(SHMEM_SB(sb)->max_inodes > 0);
+
 	i915->gemfs_mnt = gemfs_mnt;
 
 	return 0;
@@ -109,14 +111,13 @@ struct file *i915_gemfs_file_setup(struct drm_i915_private *i915,
 	this.hash = 0;
 
 	path.mnt = mntget(i915->gemfs_mnt);
-	path.dentry = d_alloc_pseudo(sb, &this);
+	path.dentry = d_alloc(sb->s_root, &this);
 	if (!path.dentry) {
 		res = ERR_PTR(-ENOMEM);
 		goto put_path;
 	}
-	d_set_d_op(path.dentry, &anon_ops);
 
-	ret = vfs_create(d_inode(sb->s_root), path.dentry, S_IFREG, false);
+	ret = vfs_create(d_inode(sb->s_root), path.dentry, S_IFREG | S_IRWXUGO, false);
 	if (ret) {
 		res = ERR_PTR(ret);
 		goto put_path;
@@ -124,7 +125,6 @@ struct file *i915_gemfs_file_setup(struct drm_i915_private *i915,
 
 	inode = d_inode(path.dentry);
 	i_size_write(inode, size);
-	clear_nlink(inode);
 
 	ret = ramfs_nommu_expand_for_mapping(inode, size);
 	if (ret) {
@@ -138,7 +138,19 @@ struct file *i915_gemfs_file_setup(struct drm_i915_private *i915,
 
 	return res;
 
+	WARN_ON(!(SHMEM_I(inode)->flags & VM_NORESERVE));
+
 put_path:
 	path_put(&path);
 	return res;
 }
+
+int i915_gemfs_unlink(struct drm_i915_gem_object *obj)
+{
+	struct drm_i915_private *i915 = to_i915(obj->base.dev);
+	struct dentry *dentry = obj->base.filp->f_path.dentry;
+	struct super_block *sb = i915->gemfs_mnt->mnt_sb;
+	struct inode *dir = d_inode(sb->s_root);
+
+	return dir->i_op->unlink(dir, dentry);
+}
-- 
2.9.4



More information about the Intel-gfx-trybot mailing list