Loading drivers/gpu/drm/ast/ast_ttm.c +3 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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->dev_mapping; ast_ttm_placement(astbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); Loading drivers/gpu/drm/bochs/bochs_mm.c +4 −2 Original line number Diff line number Diff line Loading @@ -225,7 +225,9 @@ int bochs_mm_init(struct bochs_device *bochs) ret = ttm_bo_device_init(&bochs->ttm.bdev, bochs->ttm.bo_global_ref.ref.object, &bochs_bo_driver, DRM_FILE_PAGE_OFFSET, &bochs_bo_driver, bochs->dev->anon_inode->i_mapping, DRM_FILE_PAGE_OFFSET, true); if (ret) { DRM_ERROR("Error initialising bo driver; %d\n", ret); Loading Loading @@ -359,7 +361,7 @@ static int bochs_bo_create(struct drm_device *dev, int size, int align, } bochsbo->bo.bdev = &bochs->ttm.bdev; bochsbo->bo.bdev->dev_mapping = dev->dev_mapping; bochsbo->bo.bdev->dev_mapping = dev->anon_inode->i_mapping; bochs_ttm_placement(bochsbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); Loading drivers/gpu/drm/cirrus/cirrus_ttm.c +3 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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->dev_mapping; cirrus_ttm_placement(cirrusbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); Loading drivers/gpu/drm/drm_fops.c +3 −22 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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) Loading @@ -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; } Loading Loading @@ -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); Loading Loading @@ -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); Loading drivers/gpu/drm/drm_stub.c +85 −1 Original line number Diff line number Diff line Loading @@ -31,8 +31,10 @@ * DEALINGS IN THE SOFTWARE. */ #include <linux/fs.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/mount.h> #include <linux/slab.h> #include <drm/drmP.h> #include <drm/drm_core.h> Loading Loading @@ -416,6 +418,78 @@ void drm_unplug_dev(struct drm_device *dev) } EXPORT_SYMBOL(drm_unplug_dev); /* * DRM internal mount * We want to be able to allocate our own "struct address_space" to control * memory-mappings in VRAM (or stolen RAM, ...). However, core MM does not allow * stand-alone address_space objects, so we need an underlying inode. As there * is no way to allocate an independent inode easily, we need a fake internal * VFS mount-point. * * The drm_fs_inode_new() function allocates a new inode, drm_fs_inode_free() * frees it again. You are allowed to use iget() and iput() to get references to * the inode. But each drm_fs_inode_new() call must be paired with exactly one * drm_fs_inode_free() call (which does not have to be the last iput()). * We use drm_fs_inode_*() to manage our internal VFS mount-point and share it * between multiple inode-users. You could, technically, call * iget() + drm_fs_inode_free() directly after alloc and sometime later do an * iput(), but this way you'd end up with a new vfsmount for each inode. */ static int drm_fs_cnt; static struct vfsmount *drm_fs_mnt; static const struct dentry_operations drm_fs_dops = { .d_dname = simple_dname, }; static const struct super_operations drm_fs_sops = { .statfs = simple_statfs, }; static struct dentry *drm_fs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { return mount_pseudo(fs_type, "drm:", &drm_fs_sops, &drm_fs_dops, 0x010203ff); } static struct file_system_type drm_fs_type = { .name = "drm", .owner = THIS_MODULE, .mount = drm_fs_mount, .kill_sb = kill_anon_super, }; static struct inode *drm_fs_inode_new(void) { struct inode *inode; int r; r = simple_pin_fs(&drm_fs_type, &drm_fs_mnt, &drm_fs_cnt); if (r < 0) { DRM_ERROR("Cannot mount pseudo fs: %d\n", r); return ERR_PTR(r); } inode = alloc_anon_inode(drm_fs_mnt->mnt_sb); if (IS_ERR(inode)) simple_release_fs(&drm_fs_mnt, &drm_fs_cnt); return inode; } static void drm_fs_inode_free(struct inode *inode) { if (inode) { iput(inode); simple_release_fs(&drm_fs_mnt, &drm_fs_cnt); } } /** * drm_dev_alloc - Allocate new drm device * @driver: DRM driver to allocate device for Loading Loading @@ -452,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) { Loading @@ -475,6 +556,8 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, 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; Loading Loading @@ -502,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); Loading Loading
drivers/gpu/drm/ast/ast_ttm.c +3 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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->dev_mapping; ast_ttm_placement(astbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); Loading
drivers/gpu/drm/bochs/bochs_mm.c +4 −2 Original line number Diff line number Diff line Loading @@ -225,7 +225,9 @@ int bochs_mm_init(struct bochs_device *bochs) ret = ttm_bo_device_init(&bochs->ttm.bdev, bochs->ttm.bo_global_ref.ref.object, &bochs_bo_driver, DRM_FILE_PAGE_OFFSET, &bochs_bo_driver, bochs->dev->anon_inode->i_mapping, DRM_FILE_PAGE_OFFSET, true); if (ret) { DRM_ERROR("Error initialising bo driver; %d\n", ret); Loading Loading @@ -359,7 +361,7 @@ static int bochs_bo_create(struct drm_device *dev, int size, int align, } bochsbo->bo.bdev = &bochs->ttm.bdev; bochsbo->bo.bdev->dev_mapping = dev->dev_mapping; bochsbo->bo.bdev->dev_mapping = dev->anon_inode->i_mapping; bochs_ttm_placement(bochsbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); Loading
drivers/gpu/drm/cirrus/cirrus_ttm.c +3 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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->dev_mapping; cirrus_ttm_placement(cirrusbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); Loading
drivers/gpu/drm/drm_fops.c +3 −22 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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) Loading @@ -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; } Loading Loading @@ -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); Loading Loading @@ -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); Loading
drivers/gpu/drm/drm_stub.c +85 −1 Original line number Diff line number Diff line Loading @@ -31,8 +31,10 @@ * DEALINGS IN THE SOFTWARE. */ #include <linux/fs.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/mount.h> #include <linux/slab.h> #include <drm/drmP.h> #include <drm/drm_core.h> Loading Loading @@ -416,6 +418,78 @@ void drm_unplug_dev(struct drm_device *dev) } EXPORT_SYMBOL(drm_unplug_dev); /* * DRM internal mount * We want to be able to allocate our own "struct address_space" to control * memory-mappings in VRAM (or stolen RAM, ...). However, core MM does not allow * stand-alone address_space objects, so we need an underlying inode. As there * is no way to allocate an independent inode easily, we need a fake internal * VFS mount-point. * * The drm_fs_inode_new() function allocates a new inode, drm_fs_inode_free() * frees it again. You are allowed to use iget() and iput() to get references to * the inode. But each drm_fs_inode_new() call must be paired with exactly one * drm_fs_inode_free() call (which does not have to be the last iput()). * We use drm_fs_inode_*() to manage our internal VFS mount-point and share it * between multiple inode-users. You could, technically, call * iget() + drm_fs_inode_free() directly after alloc and sometime later do an * iput(), but this way you'd end up with a new vfsmount for each inode. */ static int drm_fs_cnt; static struct vfsmount *drm_fs_mnt; static const struct dentry_operations drm_fs_dops = { .d_dname = simple_dname, }; static const struct super_operations drm_fs_sops = { .statfs = simple_statfs, }; static struct dentry *drm_fs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { return mount_pseudo(fs_type, "drm:", &drm_fs_sops, &drm_fs_dops, 0x010203ff); } static struct file_system_type drm_fs_type = { .name = "drm", .owner = THIS_MODULE, .mount = drm_fs_mount, .kill_sb = kill_anon_super, }; static struct inode *drm_fs_inode_new(void) { struct inode *inode; int r; r = simple_pin_fs(&drm_fs_type, &drm_fs_mnt, &drm_fs_cnt); if (r < 0) { DRM_ERROR("Cannot mount pseudo fs: %d\n", r); return ERR_PTR(r); } inode = alloc_anon_inode(drm_fs_mnt->mnt_sb); if (IS_ERR(inode)) simple_release_fs(&drm_fs_mnt, &drm_fs_cnt); return inode; } static void drm_fs_inode_free(struct inode *inode) { if (inode) { iput(inode); simple_release_fs(&drm_fs_mnt, &drm_fs_cnt); } } /** * drm_dev_alloc - Allocate new drm device * @driver: DRM driver to allocate device for Loading Loading @@ -452,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) { Loading @@ -475,6 +556,8 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, 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; Loading Loading @@ -502,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); Loading