@@ -213,7 +213,6 @@ int drm_lastclose(struct drm_device * dev)
!drm_core_check_feature(dev, DRIVER_MODESET))
drm_dma_takedown(dev);
- dev->dev_mapping = NULL;
mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("lastclose completed\n");
@@ -112,8 +112,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)
@@ -127,16 +125,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);
+
+ /* set address_space for shared mappings */
+ filp->f_mapping = dev->anon_inode->i_mapping;
retcode = drm_open_helper(inode, filp, dev);
if (retcode)
@@ -150,12 +141,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;
}
@@ -533,9 +518,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 */
drm_master_put(&file_priv->master);
file_priv->is_master = 0;
@@ -31,6 +31,7 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <linux/anon_inodes.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
@@ -267,8 +268,14 @@ int drm_fill_in_dev(struct drm_device *dev,
mutex_init(&dev->struct_mutex);
mutex_init(&dev->ctxlist_mutex);
+ /* create private address_space on anon inode */
+ dev->anon_inode = anon_inode_new();
+ if (IS_ERR(dev->anon_inode))
+ return PTR_ERR(dev->anon_inode);
+
if (drm_ht_create(&dev->map_hash, 12)) {
- return -ENOMEM;
+ retcode = -ENOMEM;
+ goto err_inode;
}
/* the DRM has 6 basic counters */
@@ -309,6 +316,8 @@ int drm_fill_in_dev(struct drm_device *dev,
error_out_unreg:
drm_lastclose(dev);
+err_inode:
+ iput(dev->anon_inode);
return retcode;
}
EXPORT_SYMBOL(drm_fill_in_dev);
@@ -473,6 +482,7 @@ void drm_put_dev(struct drm_device *dev)
drm_put_minor(&dev->primary);
+ iput(dev->anon_inode);
list_del(&dev->driver_item);
kfree(dev->devname);
kfree(dev);
@@ -1420,7 +1420,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;
}
@@ -237,7 +237,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);
@@ -153,7 +153,7 @@ static struct {
static void evict_entry(struct drm_gem_object *obj,
enum tiler_fmt fmt, struct usergart_entry *entry)
{
- if (obj->dev->dev_mapping) {
+ if (obj->dev->anon_inode->i_mapping) {
struct omap_gem_object *omap_obj = to_omap_bo(obj);
int n = usergart[fmt].height;
size_t size = PAGE_SIZE * n;
@@ -164,12 +164,13 @@ static void evict_entry(struct drm_gem_object *obj,
int i;
/* if stride > than PAGE_SIZE then sparse mapping: */
for (i = n; i > 0; i--) {
- unmap_mapping_range(obj->dev->dev_mapping,
+ unmap_mapping_range(obj->dev->anon_inode->i_mapping,
off, PAGE_SIZE, 1);
off += PAGE_SIZE * m;
}
} else {
- unmap_mapping_range(obj->dev->dev_mapping, off, size, 1);
+ unmap_mapping_range(obj->dev->anon_inode->i_mapping,
+ off, size, 1);
}
}
@@ -82,7 +82,7 @@ int qxl_bo_create(struct qxl_device *qdev,
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
@@ -515,7 +515,7 @@ int qxl_ttm_init(struct qxl_device *qdev)
DRM_INFO("qxl: %luM of IO pages memory ready (VRAM domain)\n",
((unsigned)num_io_pages * PAGE_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");
@@ -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) {
@@ -735,7 +735,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) {
@@ -760,7 +760,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;
@@ -1187,7 +1187,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;