@@ -57,32 +57,15 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
void *shmem_pin_map(struct file *file)
{
- struct page **pages;
- size_t n_pages, i;
void *vaddr;
- n_pages = file->f_mapping->host->i_size >> PAGE_SHIFT;
- pages = kvmalloc_array(n_pages, sizeof(*pages), GFP_KERNEL);
- if (!pages)
- return NULL;
-
- for (i = 0; i < n_pages; i++) {
- pages[i] = shmem_read_mapping_page_gfp(file->f_mapping, i,
- GFP_KERNEL);
- if (IS_ERR(pages[i]))
- goto err_page;
- }
+ vaddr = vmap_file(file->f_mapping, 0, file->f_mapping->host->i_size,
+ VM_MAP, PAGE_KERNEL);
- vaddr = vmap(pages, n_pages, VM_MAP_PUT_PAGES, PAGE_KERNEL);
if (!vaddr)
- goto err_page;
+ return NULL;
mapping_set_unevictable(file->f_mapping);
return vaddr;
-err_page:
- while (i--)
- put_page(pages[i]);
- kvfree(pages);
- return NULL;
}
void shmem_unpin_map(struct file *file, void *ptr)
We no longer need to allocate a new array of pages to map this file to kernel virtual space. This simplifies shmem_pin_map(), and gets rid of a user of VM_MAP_PUT_PAGES. Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com> --- drivers/gpu/drm/i915/gt/shmem_utils.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-)