return -EINVAL;
/* readjust the vma */
- vma_set_file(vma, dmabuf->file);
+ fput(vma->vm_file);
+ vma->vm_file = get_file(dmabuf->file);
vma->vm_pgoff = pgoff;
return dmabuf->ops->mmap(dmabuf, vma);
* address_space (so unmap_mapping_range does what we want,
* in particular in the case of mmap'd dmabufs)
*/
+ fput(vma->vm_file);
+ get_file(etnaviv_obj->base.filp);
vma->vm_pgoff = 0;
- vma_set_file(vma, etnaviv_obj->base.filp);
+ vma->vm_file = etnaviv_obj->base.filp;
vma->vm_page_prot = vm_page_prot;
}
if (ret)
return ret;
- vma_set_file(vma, obj->base.filp);
+ fput(vma->vm_file);
+ vma->vm_file = get_file(obj->base.filp);
return 0;
}
* requires avoiding extraneous references to their filp, hence why
* we prefer to use an anonymous file for their mmaps.
*/
- vma_set_file(vma, anon);
- /* Drop the initial creation reference, the vma is now holding one. */
- fput(anon);
+ fput(vma->vm_file);
+ vma->vm_file = anon;
switch (mmo->mmap_type) {
case I915_MMAP_TYPE_WC:
* address_space (so unmap_mapping_range does what we want,
* in particular in the case of mmap'd dmabufs)
*/
+ fput(vma->vm_file);
+ get_file(obj->filp);
vma->vm_pgoff = 0;
- vma_set_file(vma, obj->filp);
+ vma->vm_file = obj->filp;
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
}
* address_space (so unmap_mapping_range does what we want,
* in particular in the case of mmap'd dmabufs)
*/
+ fput(vma->vm_file);
vma->vm_pgoff = 0;
- vma_set_file(vma, obj->filp);
+ vma->vm_file = get_file(obj->filp);
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
}
if (ret)
return ret;
- vma_set_file(vma, obj->filp);
+ fput(vma->vm_file);
+ vma->vm_file = get_file(obj->filp);
vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
vma_set_anonymous(vma);
}
- vma_set_file(vma, asma->file);
- /* XXX: merge this with the get_file() above if possible */
- fput(asma->file);
+ if (vma->vm_file)
+ fput(vma->vm_file);
+ vma->vm_file = asma->file;
out:
mutex_unlock(&ashmem_mutex);
}
#endif
-void vma_set_file(struct vm_area_struct *vma, struct file *file);
-
#ifdef CONFIG_NUMA_BALANCING
unsigned long change_prot_numa(struct vm_area_struct *vma,
unsigned long start, unsigned long end);
WRITE_ONCE(vma->vm_page_prot, vm_page_prot);
}
-/*
- * Change backing file, only valid to use during initial VMA setup.
- */
-void vma_set_file(struct vm_area_struct *vma, struct file *file)
-{
- /* Changing an anonymous vma with this is illegal */
- get_file(file);
- swap(vma->vm_file, file);
- fput(file);
-}
-EXPORT_SYMBOL(vma_set_file);
-
/*
* Requires inode->i_mapping->i_mmap_rwsem
*/