* [RFC v2 1/3] drm: add pseudo filesystem for shared inodes
2014-01-03 14:41 [RFC v2 0/3] DRM Anonymous Inodes David Herrmann
@ 2014-01-03 14:41 ` David Herrmann
2014-01-03 14:41 ` [RFC v2 2/3] drm: use anon-inode instead of relying on cdevs David Herrmann
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: David Herrmann @ 2014-01-03 14:41 UTC (permalink / raw)
To: dri-devel; +Cc: Daniel Vetter
Our current DRM design uses a single address_space for all users of the
same DRM device. However, there is no way to create an anonymous
address_space without an underlying inode. Therefore, we wait for the
first ->open() callback on a registered char-dev and take-over the inode
of the char-dev. This worked well so far, but has several drawbacks:
- We screw with FS internals and rely on some non-obvious invariants like
inode->i_mapping being the same as inode->i_data for char-devs.
- We don't have any address_space prior to the first ->open() from
user-space. This leads to ugly fallback code and we cannot allocate
global objects early.
As pointed out by Al-Viro, fs/anon_inode.c is *not* supposed to be used by
drivers for anonymous inode-allocation. Therefore, this patch follows the
proposed alternative solution and adds a pseudo filesystem mount-point to
DRM. We can then allocate private inodes including a private address_space
for each DRM device at initialization time.
Note that we could use:
sysfs_get_inode(sysfs_mnt->mnt_sb, drm_device->dev->kobj.sd);
to get access to the underlying sysfs-inode of a "struct device" object.
However, most of this information is currently hidden and it's not clear
whether this address_space is suitable for driver access. Thus, unless
linux allows anonymous address_space objects or driver-core provides a
public inode per device, we're left with our own private internal mount
point.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
drivers/gpu/drm/drm_drv.c | 37 +++++++++++++++++++++++++++++++++++++
include/drm/drmP.h | 1 +
2 files changed, 38 insertions(+)
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 345be03..48ee03f 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -49,6 +49,8 @@
#include <linux/debugfs.h>
#include <linux/slab.h>
#include <linux/export.h>
+#include <linux/fs.h>
+#include <linux/mount.h>
#include <drm/drmP.h>
#include <drm/drm_core.h>
@@ -171,6 +173,30 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
+static struct vfsmount *drm_mnt;
+
+struct inode *drm_alloc_inode(void)
+{
+ return alloc_anon_inode(drm_mnt->mnt_sb);
+}
+
+static const struct dentry_operations drm_dops = {
+ .d_dname = simple_dname,
+};
+
+static struct dentry *drm_mount(struct file_system_type *fs_type, int flags,
+ const char *dev_name, void *data)
+{
+ return mount_pseudo(fs_type, "drm:", NULL, &drm_dops, 0x010203ff);
+}
+
+static struct file_system_type drm_fs = {
+ .name = "drm",
+ .owner = THIS_MODULE,
+ .mount = drm_mount,
+ .kill_sb = kill_anon_super,
+};
+
/** File operations structure */
static const struct file_operations drm_stub_fops = {
.owner = THIS_MODULE,
@@ -203,9 +229,19 @@ static int __init drm_core_init(void)
goto err_p3;
}
+ drm_mnt = kern_mount(&drm_fs);
+ if (IS_ERR(drm_mnt)) {
+ ret = PTR_ERR(drm_mnt);
+ DRM_ERROR("Cannot mount pseudo fs: %d\n", ret);
+ goto err_p4;
+ }
+
DRM_INFO("Initialized %s %d.%d.%d %s\n",
CORE_NAME, CORE_MAJOR, CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE);
return 0;
+
+err_p4:
+ debugfs_remove(drm_debugfs_root);
err_p3:
drm_sysfs_destroy();
err_p2:
@@ -218,6 +254,7 @@ err_p1:
static void __exit drm_core_exit(void)
{
+ kern_unmount(drm_mnt);
debugfs_remove(drm_debugfs_root);
drm_sysfs_destroy();
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 2fe9b5d..02637a5 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1258,6 +1258,7 @@ extern long drm_ioctl(struct file *filp,
extern long drm_compat_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg);
extern int drm_lastclose(struct drm_device *dev);
+extern struct inode *drm_alloc_inode(void);
/* Device support (drm_fops.h) */
extern struct mutex drm_global_mutex;
--
1.8.5.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC v2 2/3] drm: use anon-inode instead of relying on cdevs
2014-01-03 14:41 [RFC v2 0/3] DRM Anonymous Inodes David Herrmann
2014-01-03 14:41 ` [RFC v2 1/3] drm: add pseudo filesystem for shared inodes David Herrmann
@ 2014-01-03 14:41 ` David Herrmann
2014-01-03 14:41 ` [RFC v2 3/3] drm: init TTM dev_mapping in ttm_bo_device_init() David Herrmann
2014-01-16 11:29 ` [RFC v2 0/3] DRM Anonymous Inodes David Herrmann
3 siblings, 0 replies; 8+ messages in thread
From: David Herrmann @ 2014-01-03 14:41 UTC (permalink / raw)
To: dri-devel; +Cc: Daniel Vetter
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>
---
drivers/gpu/drm/ast/ast_ttm.c | 2 +-
drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 +-
drivers/gpu/drm/drm_fops.c | 25 +++----------------------
drivers/gpu/drm/drm_stub.c | 12 +++++++++++-
drivers/gpu/drm/i915/i915_gem.c | 3 ++-
drivers/gpu/drm/mgag200/mgag200_ttm.c | 2 +-
drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +-
drivers/gpu/drm/omapdrm/omap_gem.c | 34 +++++++++++++++++-----------------
drivers/gpu/drm/qxl/qxl_object.c | 3 +--
drivers/gpu/drm/qxl/qxl_ttm.c | 3 +--
drivers/gpu/drm/radeon/radeon_object.c | 2 +-
drivers/gpu/drm/radeon/radeon_ttm.c | 2 +-
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +-
include/drm/drmP.h | 2 +-
14 files changed, 43 insertions(+), 53 deletions(-)
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index 32aecb3..74eed74 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -324,7 +324,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
}
astbo->bo.bdev = &ast->ttm.bdev;
- astbo->bo.bdev->dev_mapping = dev->dev_mapping;
+ astbo->bo.bdev->dev_mapping = dev->anon_inode->i_mapping;
ast_ttm_placement(astbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index 75becde..abd401d 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -329,7 +329,7 @@ int cirrus_bo_create(struct drm_device *dev, int size, int align,
}
cirrusbo->bo.bdev = &cirrus->ttm.bdev;
- cirrusbo->bo.bdev->dev_mapping = dev->dev_mapping;
+ cirrusbo->bo.bdev->dev_mapping = dev->anon_inode->i_mapping;
cirrus_ttm_placement(cirrusbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 7f2af9a..147a84d 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -84,8 +84,6 @@ int drm_open(struct inode *inode, struct file *filp)
struct drm_minor *minor;
int retcode = 0;
int need_setup = 0;
- struct address_space *old_mapping;
- struct address_space *old_imapping;
minor = idr_find(&drm_minors_idr, minor_id);
if (!minor)
@@ -99,16 +97,9 @@ int drm_open(struct inode *inode, struct file *filp)
if (!dev->open_count++)
need_setup = 1;
- mutex_lock(&dev->struct_mutex);
- old_imapping = inode->i_mapping;
- old_mapping = dev->dev_mapping;
- if (old_mapping == NULL)
- dev->dev_mapping = &inode->i_data;
- /* ihold ensures nobody can remove inode with our i_data */
- ihold(container_of(dev->dev_mapping, struct inode, i_data));
- inode->i_mapping = dev->dev_mapping;
- filp->f_mapping = dev->dev_mapping;
- mutex_unlock(&dev->struct_mutex);
+
+ /* share address_space across all char-devs of a single device */
+ filp->f_mapping = dev->anon_inode->i_mapping;
retcode = drm_open_helper(inode, filp, dev);
if (retcode)
@@ -121,12 +112,6 @@ int drm_open(struct inode *inode, struct file *filp)
return 0;
err_undo:
- mutex_lock(&dev->struct_mutex);
- filp->f_mapping = old_imapping;
- inode->i_mapping = old_imapping;
- iput(container_of(dev->dev_mapping, struct inode, i_data));
- dev->dev_mapping = old_mapping;
- mutex_unlock(&dev->struct_mutex);
dev->open_count--;
return retcode;
}
@@ -434,7 +419,6 @@ int drm_lastclose(struct drm_device * dev)
drm_legacy_dma_takedown(dev);
- dev->dev_mapping = NULL;
mutex_unlock(&dev->struct_mutex);
drm_legacy_dev_reinit(dev);
@@ -549,9 +533,6 @@ int drm_release(struct inode *inode, struct file *filp)
}
}
- BUG_ON(dev->dev_mapping == NULL);
- iput(container_of(dev->dev_mapping, struct inode, i_data));
-
/* drop the reference held my the file priv */
if (file_priv->master)
drm_master_put(&file_priv->master);
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index a4a5c6a..0caf35f 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -452,8 +452,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_alloc_inode();
+ 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) {
@@ -475,6 +482,8 @@ err_ctxbitmap:
drm_ctxbitmap_cleanup(dev);
err_ht:
drm_ht_remove(&dev->map_hash);
+err_inode:
+ iput(dev->anon_inode);
err_free:
kfree(dev);
return NULL;
@@ -502,6 +511,7 @@ void drm_dev_free(struct drm_device *dev)
drm_ctxbitmap_cleanup(dev);
drm_ht_remove(&dev->map_hash);
+ iput(dev->anon_inode);
kfree(dev->devname);
kfree(dev);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 182c521..8cc47da 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1474,7 +1474,8 @@ i915_gem_release_mmap(struct drm_i915_gem_object *obj)
if (!obj->fault_mappable)
return;
- drm_vma_node_unmap(&obj->base.vma_node, obj->base.dev->dev_mapping);
+ drm_vma_node_unmap(&obj->base.vma_node,
+ obj->base.dev->anon_inode->i_mapping);
obj->fault_mappable = false;
}
diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index 07b192f..bb2a1cb 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -324,7 +324,7 @@ int mgag200_bo_create(struct drm_device *dev, int size, int align,
}
mgabo->bo.bdev = &mdev->ttm.bdev;
- mgabo->bo.bdev->dev_mapping = dev->dev_mapping;
+ mgabo->bo.bdev->dev_mapping = dev->anon_inode->i_mapping;
mgag200_ttm_placement(mgabo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 0447163..aafb8d6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -228,7 +228,7 @@ nouveau_gem_ioctl_new(struct drm_device *dev, void *data,
struct nouveau_bo *nvbo = NULL;
int ret = 0;
- drm->ttm.bdev.dev_mapping = drm->dev->dev_mapping;
+ drm->ttm.bdev.dev_mapping = drm->dev->anon_inode->i_mapping;
if (!pfb->memtype_valid(pfb, req->info.tile_flags)) {
NV_ERROR(cli, "bad page flags: 0x%08x\n", req->info.tile_flags);
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 5aec3e8..c8d9727 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -153,24 +153,24 @@ static struct {
static void evict_entry(struct drm_gem_object *obj,
enum tiler_fmt fmt, struct usergart_entry *entry)
{
- if (obj->dev->dev_mapping) {
- struct omap_gem_object *omap_obj = to_omap_bo(obj);
- int n = usergart[fmt].height;
- size_t size = PAGE_SIZE * n;
- loff_t off = mmap_offset(obj) +
- (entry->obj_pgoff << PAGE_SHIFT);
- const int m = 1 + ((omap_obj->width << fmt) / PAGE_SIZE);
- if (m > 1) {
- int i;
- /* if stride > than PAGE_SIZE then sparse mapping: */
- for (i = n; i > 0; i--) {
- unmap_mapping_range(obj->dev->dev_mapping,
- off, PAGE_SIZE, 1);
- off += PAGE_SIZE * m;
- }
- } else {
- unmap_mapping_range(obj->dev->dev_mapping, off, size, 1);
+ struct omap_gem_object *omap_obj = to_omap_bo(obj);
+ int n = usergart[fmt].height;
+ size_t size = PAGE_SIZE * n;
+ loff_t off = mmap_offset(obj) +
+ (entry->obj_pgoff << PAGE_SHIFT);
+ const int m = 1 + ((omap_obj->width << fmt) / PAGE_SIZE);
+
+ if (m > 1) {
+ int i;
+ /* if stride > than PAGE_SIZE then sparse mapping: */
+ for (i = n; i > 0; i--) {
+ unmap_mapping_range(obj->dev->anon_inode->i_mapping,
+ off, PAGE_SIZE, 1);
+ off += PAGE_SIZE * m;
}
+ } else {
+ unmap_mapping_range(obj->dev->anon_inode->i_mapping,
+ off, size, 1);
}
entry->obj = NULL;
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index 8691c76..7e20c21 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -82,8 +82,7 @@ int qxl_bo_create(struct qxl_device *qdev,
enum ttm_bo_type type;
int r;
- if (unlikely(qdev->mman.bdev.dev_mapping == NULL))
- qdev->mman.bdev.dev_mapping = qdev->ddev->dev_mapping;
+ qdev->mman.bdev.dev_mapping = qdev->ddev->anon_inode->i_mapping;
if (kernel)
type = ttm_bo_type_kernel;
else
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index c7e7e65..78cbc40 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -518,8 +518,7 @@ int qxl_ttm_init(struct qxl_device *qdev)
((unsigned)num_io_pages * PAGE_SIZE) / (1024 * 1024));
DRM_INFO("qxl: %uM of Surface memory size\n",
(unsigned)qdev->surfaceram_size / (1024 * 1024));
- if (unlikely(qdev->mman.bdev.dev_mapping == NULL))
- qdev->mman.bdev.dev_mapping = qdev->ddev->dev_mapping;
+ qdev->mman.bdev.dev_mapping = qdev->ddev->anon_inode->i_mapping;
r = qxl_ttm_debugfs_init(qdev);
if (r) {
DRM_ERROR("Failed to init debugfs\n");
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index c0fa4aa..0900b36 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -120,7 +120,7 @@ int radeon_bo_create(struct radeon_device *rdev,
size = ALIGN(size, PAGE_SIZE);
- rdev->mman.bdev.dev_mapping = rdev->ddev->dev_mapping;
+ rdev->mman.bdev.dev_mapping = rdev->ddev->anon_inode->i_mapping;
if (kernel) {
type = ttm_bo_type_kernel;
} else if (sg) {
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 051fa87..669c448 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -737,7 +737,7 @@ int radeon_ttm_init(struct radeon_device *rdev)
}
DRM_INFO("radeon: %uM of GTT memory ready.\n",
(unsigned)(rdev->mc.gtt_size / (1024 * 1024)));
- rdev->mman.bdev.dev_mapping = rdev->ddev->dev_mapping;
+ rdev->mman.bdev.dev_mapping = rdev->ddev->anon_inode->i_mapping;
r = radeon_ttm_debugfs_init(rdev);
if (r) {
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index c7a5496..218b711 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -860,7 +860,7 @@ static int vmw_driver_open(struct drm_device *dev, struct drm_file *file_priv)
goto out_no_tfile;
file_priv->driver_priv = vmw_fp;
- dev_priv->bdev.dev_mapping = dev->dev_mapping;
+ dev_priv->bdev.dev_mapping = dev->anon_inode->i_mapping;
return 0;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 02637a5..48d3720 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1186,7 +1186,7 @@ struct drm_device {
unsigned int num_crtcs; /**< Number of CRTCs on this device */
void *dev_private; /**< device private data */
void *mm_private;
- struct address_space *dev_mapping;
+ struct inode *anon_inode;
struct drm_sigdata sigdata; /**< For block_all_signals */
sigset_t sigmask;
--
1.8.5.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC v2 3/3] drm: init TTM dev_mapping in ttm_bo_device_init()
2014-01-03 14:41 [RFC v2 0/3] DRM Anonymous Inodes David Herrmann
2014-01-03 14:41 ` [RFC v2 1/3] drm: add pseudo filesystem for shared inodes David Herrmann
2014-01-03 14:41 ` [RFC v2 2/3] drm: use anon-inode instead of relying on cdevs David Herrmann
@ 2014-01-03 14:41 ` David Herrmann
2014-01-16 11:29 ` [RFC v2 0/3] DRM Anonymous Inodes David Herrmann
3 siblings, 0 replies; 8+ messages in thread
From: David Herrmann @ 2014-01-03 14:41 UTC (permalink / raw)
To: dri-devel; +Cc: Thomas Hellstrom, Daniel Vetter, Ben Skeggs, Dave Airlie
With dev->anon_inode we have a global address_space ready for operation
right from the beginning. Therefore, there is no need to do a delayed
setup with TTM. Instead, set dev_mapping during initialization in
ttm_bo_device_init() and remove any "if (dev_mapping)" conditions.
Cc: Dave Airlie <airlied@redhat.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
drivers/gpu/drm/ast/ast_ttm.c | 5 +++--
drivers/gpu/drm/cirrus/cirrus_ttm.c | 5 +++--
drivers/gpu/drm/mgag200/mgag200_ttm.c | 5 +++--
drivers/gpu/drm/nouveau/nouveau_gem.c | 2 --
drivers/gpu/drm/nouveau/nouveau_ttm.c | 4 +++-
drivers/gpu/drm/qxl/qxl_object.c | 1 -
drivers/gpu/drm/qxl/qxl_ttm.c | 5 +++--
drivers/gpu/drm/radeon/radeon_object.c | 1 -
drivers/gpu/drm/radeon/radeon_ttm.c | 5 +++--
drivers/gpu/drm/ttm/ttm_bo.c | 3 ++-
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 5 +++--
include/drm/drm_vma_manager.h | 6 +++---
include/drm/ttm/ttm_bo_driver.h | 2 ++
13 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index 74eed74..5465013 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -259,7 +259,9 @@ int ast_mm_init(struct ast_private *ast)
ret = ttm_bo_device_init(&ast->ttm.bdev,
ast->ttm.bo_global_ref.ref.object,
- &ast_bo_driver, DRM_FILE_PAGE_OFFSET,
+ &ast_bo_driver,
+ dev->anon_inode->i_mapping,
+ DRM_FILE_PAGE_OFFSET,
true);
if (ret) {
DRM_ERROR("Error initialising bo driver; %d\n", ret);
@@ -324,7 +326,6 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
}
astbo->bo.bdev = &ast->ttm.bdev;
- astbo->bo.bdev->dev_mapping = dev->anon_inode->i_mapping;
ast_ttm_placement(astbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index abd401d..ee7703e 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -259,7 +259,9 @@ int cirrus_mm_init(struct cirrus_device *cirrus)
ret = ttm_bo_device_init(&cirrus->ttm.bdev,
cirrus->ttm.bo_global_ref.ref.object,
- &cirrus_bo_driver, DRM_FILE_PAGE_OFFSET,
+ &cirrus_bo_driver,
+ dev->anon_inode->i_mapping,
+ DRM_FILE_PAGE_OFFSET,
true);
if (ret) {
DRM_ERROR("Error initialising bo driver; %d\n", ret);
@@ -329,7 +331,6 @@ int cirrus_bo_create(struct drm_device *dev, int size, int align,
}
cirrusbo->bo.bdev = &cirrus->ttm.bdev;
- cirrusbo->bo.bdev->dev_mapping = dev->anon_inode->i_mapping;
cirrus_ttm_placement(cirrusbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index bb2a1cb..0893f7c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -259,7 +259,9 @@ int mgag200_mm_init(struct mga_device *mdev)
ret = ttm_bo_device_init(&mdev->ttm.bdev,
mdev->ttm.bo_global_ref.ref.object,
- &mgag200_bo_driver, DRM_FILE_PAGE_OFFSET,
+ &mgag200_bo_driver,
+ dev->anon_inode->i_mapping,
+ DRM_FILE_PAGE_OFFSET,
true);
if (ret) {
DRM_ERROR("Error initialising bo driver; %d\n", ret);
@@ -324,7 +326,6 @@ int mgag200_bo_create(struct drm_device *dev, int size, int align,
}
mgabo->bo.bdev = &mdev->ttm.bdev;
- mgabo->bo.bdev->dev_mapping = dev->anon_inode->i_mapping;
mgag200_ttm_placement(mgabo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index aafb8d6..1eeb393 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -228,8 +228,6 @@ nouveau_gem_ioctl_new(struct drm_device *dev, void *data,
struct nouveau_bo *nvbo = NULL;
int ret = 0;
- drm->ttm.bdev.dev_mapping = drm->dev->anon_inode->i_mapping;
-
if (!pfb->memtype_valid(pfb, req->info.tile_flags)) {
NV_ERROR(cli, "bad page flags: 0x%08x\n", req->info.tile_flags);
return -EINVAL;
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 19e3757..d486f25 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -375,7 +375,9 @@ nouveau_ttm_init(struct nouveau_drm *drm)
ret = ttm_bo_device_init(&drm->ttm.bdev,
drm->ttm.bo_global_ref.ref.object,
- &nouveau_bo_driver, DRM_FILE_PAGE_OFFSET,
+ &nouveau_bo_driver,
+ dev->anon_inode->i_mapping,
+ DRM_FILE_PAGE_OFFSET,
bits <= 32 ? true : false);
if (ret) {
NV_ERROR(drm, "error initialising bo driver, %d\n", ret);
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index 7e20c21..b95f144 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -82,7 +82,6 @@ int qxl_bo_create(struct qxl_device *qdev,
enum ttm_bo_type type;
int r;
- qdev->mman.bdev.dev_mapping = qdev->ddev->anon_inode->i_mapping;
if (kernel)
type = ttm_bo_type_kernel;
else
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 78cbc40..29c02e0 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -493,7 +493,9 @@ int qxl_ttm_init(struct qxl_device *qdev)
/* No others user of address space so set it to 0 */
r = ttm_bo_device_init(&qdev->mman.bdev,
qdev->mman.bo_global_ref.ref.object,
- &qxl_bo_driver, DRM_FILE_PAGE_OFFSET, 0);
+ &qxl_bo_driver,
+ qdev->ddev->anon_inode->i_mapping,
+ DRM_FILE_PAGE_OFFSET, 0);
if (r) {
DRM_ERROR("failed initializing buffer object driver(%d).\n", r);
return r;
@@ -518,7 +520,6 @@ int qxl_ttm_init(struct qxl_device *qdev)
((unsigned)num_io_pages * PAGE_SIZE) / (1024 * 1024));
DRM_INFO("qxl: %uM of Surface memory size\n",
(unsigned)qdev->surfaceram_size / (1024 * 1024));
- qdev->mman.bdev.dev_mapping = qdev->ddev->anon_inode->i_mapping;
r = qxl_ttm_debugfs_init(qdev);
if (r) {
DRM_ERROR("Failed to init debugfs\n");
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 0900b36..c2f728c 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -120,7 +120,6 @@ int radeon_bo_create(struct radeon_device *rdev,
size = ALIGN(size, PAGE_SIZE);
- rdev->mman.bdev.dev_mapping = rdev->ddev->anon_inode->i_mapping;
if (kernel) {
type = ttm_bo_type_kernel;
} else if (sg) {
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 669c448..12188de 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -699,7 +699,9 @@ int radeon_ttm_init(struct radeon_device *rdev)
/* No others user of address space so set it to 0 */
r = ttm_bo_device_init(&rdev->mman.bdev,
rdev->mman.bo_global_ref.ref.object,
- &radeon_bo_driver, DRM_FILE_PAGE_OFFSET,
+ &radeon_bo_driver,
+ rdev->ddev->anon_inode->i_mapping,
+ DRM_FILE_PAGE_OFFSET,
rdev->need_dma32);
if (r) {
DRM_ERROR("failed initializing buffer object driver(%d).\n", r);
@@ -737,7 +739,6 @@ int radeon_ttm_init(struct radeon_device *rdev)
}
DRM_INFO("radeon: %uM of GTT memory ready.\n",
(unsigned)(rdev->mc.gtt_size / (1024 * 1024)));
- rdev->mman.bdev.dev_mapping = rdev->ddev->anon_inode->i_mapping;
r = radeon_ttm_debugfs_init(rdev);
if (r) {
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 07e02c4..23cf47d 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1449,6 +1449,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);
int ttm_bo_device_init(struct ttm_bo_device *bdev,
struct ttm_bo_global *glob,
struct ttm_bo_driver *driver,
+ struct address_space *mapping,
uint64_t file_page_offset,
bool need_dma32)
{
@@ -1470,7 +1471,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
0x10000000);
INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue);
INIT_LIST_HEAD(&bdev->ddestroy);
- bdev->dev_mapping = NULL;
+ bdev->dev_mapping = mapping;
bdev->glob = glob;
bdev->need_dma32 = need_dma32;
bdev->val_seq = 0;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 218b711..7c32303 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -632,7 +632,9 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
ret = ttm_bo_device_init(&dev_priv->bdev,
dev_priv->bo_global_ref.ref.object,
- &vmw_bo_driver, VMWGFX_FILE_PAGE_OFFSET,
+ &vmw_bo_driver,
+ dev->anon_inode->i_mapping,
+ VMWGFX_FILE_PAGE_OFFSET,
false);
if (unlikely(ret != 0)) {
DRM_ERROR("Failed initializing TTM buffer object driver.\n");
@@ -860,7 +862,6 @@ static int vmw_driver_open(struct drm_device *dev, struct drm_file *file_priv)
goto out_no_tfile;
file_priv->driver_priv = vmw_fp;
- dev_priv->bdev.dev_mapping = dev->anon_inode->i_mapping;
return 0;
diff --git a/include/drm/drm_vma_manager.h b/include/drm/drm_vma_manager.h
index c18a593..8cd402c7 100644
--- a/include/drm/drm_vma_manager.h
+++ b/include/drm/drm_vma_manager.h
@@ -221,8 +221,8 @@ static inline __u64 drm_vma_node_offset_addr(struct drm_vma_offset_node *node)
* @file_mapping: Address space to unmap @node from
*
* Unmap all userspace mappings for a given offset node. The mappings must be
- * associated with the @file_mapping address-space. If no offset exists or
- * the address-space is invalid, nothing is done.
+ * associated with the @file_mapping address-space. If no offset exists
+ * nothing is done.
*
* This call is unlocked. The caller must guarantee that drm_vma_offset_remove()
* is not called on this node concurrently.
@@ -230,7 +230,7 @@ static inline __u64 drm_vma_node_offset_addr(struct drm_vma_offset_node *node)
static inline void drm_vma_node_unmap(struct drm_vma_offset_node *node,
struct address_space *file_mapping)
{
- if (file_mapping && drm_vma_node_has_offset(node))
+ if (drm_vma_node_has_offset(node))
unmap_mapping_range(file_mapping,
drm_vma_node_offset_addr(node),
drm_vma_node_size(node) << PAGE_SHIFT, 1);
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 8639c85..9261e42 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -738,6 +738,7 @@ extern int ttm_bo_device_release(struct ttm_bo_device *bdev);
* @bdev: A pointer to a struct ttm_bo_device to initialize.
* @glob: A pointer to an initialized struct ttm_bo_global.
* @driver: A pointer to a struct ttm_bo_driver set up by the caller.
+ * @mapping: The address space to use for this bo.
* @file_page_offset: Offset into the device address space that is available
* for buffer data. This ensures compatibility with other users of the
* address space.
@@ -749,6 +750,7 @@ extern int ttm_bo_device_release(struct ttm_bo_device *bdev);
extern int ttm_bo_device_init(struct ttm_bo_device *bdev,
struct ttm_bo_global *glob,
struct ttm_bo_driver *driver,
+ struct address_space *mapping,
uint64_t file_page_offset, bool need_dma32);
/**
--
1.8.5.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [RFC v2 0/3] DRM Anonymous Inodes
2014-01-03 14:41 [RFC v2 0/3] DRM Anonymous Inodes David Herrmann
` (2 preceding siblings ...)
2014-01-03 14:41 ` [RFC v2 3/3] drm: init TTM dev_mapping in ttm_bo_device_init() David Herrmann
@ 2014-01-16 11:29 ` David Herrmann
2014-01-16 11:51 ` Thomas Hellstrom
3 siblings, 1 reply; 8+ messages in thread
From: David Herrmann @ 2014-01-16 11:29 UTC (permalink / raw)
To: dri-devel@lists.freedesktop.org; +Cc: Daniel Vetter
Hi
On Fri, Jan 3, 2014 at 3:41 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
> Hi
>
> With 3.13-rc1 the required VFS core changes for anonymous backing inodes in DRM
> got merged. This series reworks the previous patches (I think from early
> August '13) and finally replaces the ugly drm_device->dev_mapping hack.
>
> The patches should be fairly obvious. As I currently only have nouveau here, I'd
> be happy to get some more testers with other drivers.
>
> Patch #1 adds an internal private mount point to DRM core.
> Patch #2 replaces ->dev_mapping with a private anonymous inode for each device.
> Patch #3 removes the delayed dev_mapping initialization in TTM.
>
> The internal mnt-point is based on fs/aio.c and fs/anon_inode.c which do the
> same. It's not clear to me why we cannot share the mnt-point between all these,
> but Al Viro made clear that he will reject any patches on anon_inode.c which do
> that. So lets follow his recommendation and use our own internal mnt-point.
Also tested on i915 ivb now (before: nouveau+TTM). I think this is
ready for 3.14 if nobody finds any issues.
Thanks
David
> Thanks
> David
>
> David Herrmann (3):
> drm: add pseudo filesystem for shared inodes
> drm: use anon-inode instead of relying on cdevs
> drm: init TTM dev_mapping in ttm_bo_device_init()
>
> drivers/gpu/drm/ast/ast_ttm.c | 5 +++--
> drivers/gpu/drm/cirrus/cirrus_ttm.c | 5 +++--
> drivers/gpu/drm/drm_drv.c | 37 ++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/drm_fops.c | 25 +++--------------------
> drivers/gpu/drm/drm_stub.c | 12 ++++++++++-
> drivers/gpu/drm/i915/i915_gem.c | 3 ++-
> drivers/gpu/drm/mgag200/mgag200_ttm.c | 5 +++--
> drivers/gpu/drm/nouveau/nouveau_gem.c | 2 --
> drivers/gpu/drm/nouveau/nouveau_ttm.c | 4 +++-
> drivers/gpu/drm/omapdrm/omap_gem.c | 34 +++++++++++++++----------------
> drivers/gpu/drm/qxl/qxl_object.c | 2 --
> drivers/gpu/drm/qxl/qxl_ttm.c | 6 +++---
> drivers/gpu/drm/radeon/radeon_object.c | 1 -
> drivers/gpu/drm/radeon/radeon_ttm.c | 5 +++--
> drivers/gpu/drm/ttm/ttm_bo.c | 3 ++-
> drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 5 +++--
> include/drm/drmP.h | 3 ++-
> include/drm/drm_vma_manager.h | 6 +++---
> include/drm/ttm/ttm_bo_driver.h | 2 ++
> 19 files changed, 100 insertions(+), 65 deletions(-)
>
> --
> 1.8.5.2
>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC v2 0/3] DRM Anonymous Inodes
2014-01-16 11:29 ` [RFC v2 0/3] DRM Anonymous Inodes David Herrmann
@ 2014-01-16 11:51 ` Thomas Hellstrom
2014-01-20 2:00 ` Dave Airlie
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Hellstrom @ 2014-01-16 11:51 UTC (permalink / raw)
To: David Herrmann; +Cc: Daniel Vetter, dri-devel@lists.freedesktop.org
David,
I haven't had time to test on vmwgfx yet, but looking through the code
it looks good to me.
Acked-by: Thomas Hellstrom <thellstrom@vmware.com>
/Thomas
On 01/16/2014 12:29 PM, David Herrmann wrote:
> Hi
>
> On Fri, Jan 3, 2014 at 3:41 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
>> Hi
>>
>> With 3.13-rc1 the required VFS core changes for anonymous backing inodes in DRM
>> got merged. This series reworks the previous patches (I think from early
>> August '13) and finally replaces the ugly drm_device->dev_mapping hack.
>>
>> The patches should be fairly obvious. As I currently only have nouveau here, I'd
>> be happy to get some more testers with other drivers.
>>
>> Patch #1 adds an internal private mount point to DRM core.
>> Patch #2 replaces ->dev_mapping with a private anonymous inode for each device.
>> Patch #3 removes the delayed dev_mapping initialization in TTM.
>>
>> The internal mnt-point is based on fs/aio.c and fs/anon_inode.c which do the
>> same. It's not clear to me why we cannot share the mnt-point between all these,
>> but Al Viro made clear that he will reject any patches on anon_inode.c which do
>> that. So lets follow his recommendation and use our own internal mnt-point.
> Also tested on i915 ivb now (before: nouveau+TTM). I think this is
> ready for 3.14 if nobody finds any issues.
>
> Thanks
> David
>
>> Thanks
>> David
>>
>> David Herrmann (3):
>> drm: add pseudo filesystem for shared inodes
>> drm: use anon-inode instead of relying on cdevs
>> drm: init TTM dev_mapping in ttm_bo_device_init()
>>
>> drivers/gpu/drm/ast/ast_ttm.c | 5 +++--
>> drivers/gpu/drm/cirrus/cirrus_ttm.c | 5 +++--
>> drivers/gpu/drm/drm_drv.c | 37 ++++++++++++++++++++++++++++++++++
>> drivers/gpu/drm/drm_fops.c | 25 +++--------------------
>> drivers/gpu/drm/drm_stub.c | 12 ++++++++++-
>> drivers/gpu/drm/i915/i915_gem.c | 3 ++-
>> drivers/gpu/drm/mgag200/mgag200_ttm.c | 5 +++--
>> drivers/gpu/drm/nouveau/nouveau_gem.c | 2 --
>> drivers/gpu/drm/nouveau/nouveau_ttm.c | 4 +++-
>> drivers/gpu/drm/omapdrm/omap_gem.c | 34 +++++++++++++++----------------
>> drivers/gpu/drm/qxl/qxl_object.c | 2 --
>> drivers/gpu/drm/qxl/qxl_ttm.c | 6 +++---
>> drivers/gpu/drm/radeon/radeon_object.c | 1 -
>> drivers/gpu/drm/radeon/radeon_ttm.c | 5 +++--
>> drivers/gpu/drm/ttm/ttm_bo.c | 3 ++-
>> drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 5 +++--
>> include/drm/drmP.h | 3 ++-
>> include/drm/drm_vma_manager.h | 6 +++---
>> include/drm/ttm/ttm_bo_driver.h | 2 ++
>> 19 files changed, 100 insertions(+), 65 deletions(-)
>>
>> --
>> 1.8.5.2
>>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC v2 0/3] DRM Anonymous Inodes
2014-01-16 11:51 ` Thomas Hellstrom
@ 2014-01-20 2:00 ` Dave Airlie
2014-01-20 13:55 ` David Herrmann
0 siblings, 1 reply; 8+ messages in thread
From: Dave Airlie @ 2014-01-20 2:00 UTC (permalink / raw)
To: Thomas Hellstrom; +Cc: Daniel Vetter, dri-devel@lists.freedesktop.org
>> Hi
>>
>> On Fri, Jan 3, 2014 at 3:41 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
>>> Hi
>>>
>>> With 3.13-rc1 the required VFS core changes for anonymous backing inodes in DRM
>>> got merged. This series reworks the previous patches (I think from early
>>> August '13) and finally replaces the ugly drm_device->dev_mapping hack.
>>>
>>> The patches should be fairly obvious. As I currently only have nouveau here, I'd
>>> be happy to get some more testers with other drivers.
>>>
>>> Patch #1 adds an internal private mount point to DRM core.
>>> Patch #2 replaces ->dev_mapping with a private anonymous inode for each device.
>>> Patch #3 removes the delayed dev_mapping initialization in TTM.
>>>
>>> The internal mnt-point is based on fs/aio.c and fs/anon_inode.c which do the
>>> same. It's not clear to me why we cannot share the mnt-point between all these,
>>> but Al Viro made clear that he will reject any patches on anon_inode.c which do
>>> that. So lets follow his recommendation and use our own internal mnt-point.
>> Also tested on i915 ivb now (before: nouveau+TTM). I think this is
>> ready for 3.14 if nobody finds any issues.
>
I talked to Al,
7:13 < viro> umm...
17:14 < viro> you do realize that your module will be impossible to unload?
17:14 < viro> kern_mount will pin that fs down
17:14 < viro> bumping module refcount
17:15 < viro> so kern_unmount() in module_exit is not going to be called at all
17:15 -!- rafael__ [^rafael@aerd124.neoplus.adsl.tpnet.pl] has quit
[Ping timeout: 608 seconds]
17:16 < viro> what you want is some variation on simple_pin_fs()
17:17 < viro> done from drm_dev_alloc()
17:18 < viro> with simple_release_fs() from drm_dev_free(), right after iput()
17:20 < viro> the export itself is OK (albeit we might be better off
exporting a variant of mount_pseudo() instead, so that aio and
this sucker would both just call mount_dname_pseudo())
17:21 < viro> the problem I see there is with kern_mount() use
17:47 -!- sameo [~samuel@192.55.55.41] has quit [Remote host closed
the connection]
So maybe we should think about it a bit more :-)
Dave.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC v2 0/3] DRM Anonymous Inodes
2014-01-20 2:00 ` Dave Airlie
@ 2014-01-20 13:55 ` David Herrmann
0 siblings, 0 replies; 8+ messages in thread
From: David Herrmann @ 2014-01-20 13:55 UTC (permalink / raw)
To: Dave Airlie
Cc: Daniel Vetter, Thomas Hellstrom, dri-devel@lists.freedesktop.org
Hi
On Mon, Jan 20, 2014 at 3:00 AM, Dave Airlie <airlied@gmail.com> wrote:
>>> Hi
>>>
>>> On Fri, Jan 3, 2014 at 3:41 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
>>>> Hi
>>>>
>>>> With 3.13-rc1 the required VFS core changes for anonymous backing inodes in DRM
>>>> got merged. This series reworks the previous patches (I think from early
>>>> August '13) and finally replaces the ugly drm_device->dev_mapping hack.
>>>>
>>>> The patches should be fairly obvious. As I currently only have nouveau here, I'd
>>>> be happy to get some more testers with other drivers.
>>>>
>>>> Patch #1 adds an internal private mount point to DRM core.
>>>> Patch #2 replaces ->dev_mapping with a private anonymous inode for each device.
>>>> Patch #3 removes the delayed dev_mapping initialization in TTM.
>>>>
>>>> The internal mnt-point is based on fs/aio.c and fs/anon_inode.c which do the
>>>> same. It's not clear to me why we cannot share the mnt-point between all these,
>>>> but Al Viro made clear that he will reject any patches on anon_inode.c which do
>>>> that. So lets follow his recommendation and use our own internal mnt-point.
>>> Also tested on i915 ivb now (before: nouveau+TTM). I think this is
>>> ready for 3.14 if nobody finds any issues.
>>
>
> I talked to Al,
>
> 7:13 < viro> umm...
> 17:14 < viro> you do realize that your module will be impossible to unload?
> 17:14 < viro> kern_mount will pin that fs down
> 17:14 < viro> bumping module refcount
> 17:15 < viro> so kern_unmount() in module_exit is not going to be called at all
> 17:15 -!- rafael__ [^rafael@aerd124.neoplus.adsl.tpnet.pl] has quit
> [Ping timeout: 608 seconds]
> 17:16 < viro> what you want is some variation on simple_pin_fs()
> 17:17 < viro> done from drm_dev_alloc()
> 17:18 < viro> with simple_release_fs() from drm_dev_free(), right after iput()
> 17:20 < viro> the export itself is OK (albeit we might be better off
> exporting a variant of mount_pseudo() instead, so that aio and
> this sucker would both just call mount_dname_pseudo())
> 17:21 < viro> the problem I see there is with kern_mount() use
> 17:47 -!- sameo [~samuel@192.55.55.41] has quit [Remote host closed
> the connection]
>
> So maybe we should think about it a bit more :-)
So we call simple_pin_fs() in drm_alloc_inode() and add a
drm_free_inode() which calls iput() followed by simple_release_fs()? I
will write up v3 and test with module re-loading this time.
Thanks
David
^ permalink raw reply [flat|nested] 8+ messages in thread