Commit 5949eac4 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

drm/i915: use shmem_read_mapping_page

Soon tmpfs will stop supporting ->readpage and read_cache_page_gfp(): once
"tmpfs: add shmem_read_mapping_page_gfp" has been applied, this patch can
be applied to ease the transition.

Make i915_gem_object_get_pages_gtt() use shmem_read_mapping_page_gfp() in
the one place it's needed; elsewhere use shmem_read_mapping_page(), with
the mapping's gfp_mask properly initialized.

Forget about __GFP_COLD: since tmpfs initializes its pages with memset,
asking for a cold page is counter-productive.

Include linux/shmem_fs.h also in drm_gem.c: with shmem_file_setup() now
declared there too, we shall remove the prototype from linux/mm.h later.
Signed-off-by: default avatarHugh Dickins <hughd@google.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Keith Packard <keithp@keithp.com>
Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3142b651
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/mman.h> #include <linux/mman.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/shmem_fs.h>
#include "drmP.h" #include "drmP.h"
/** @file drm_gem.c /** @file drm_gem.c
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "i915_drv.h" #include "i915_drv.h"
#include "i915_trace.h" #include "i915_trace.h"
#include "intel_drv.h" #include "intel_drv.h"
#include <linux/shmem_fs.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/swap.h> #include <linux/swap.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -359,8 +360,7 @@ i915_gem_shmem_pread_fast(struct drm_device *dev, ...@@ -359,8 +360,7 @@ i915_gem_shmem_pread_fast(struct drm_device *dev,
if ((page_offset + remain) > PAGE_SIZE) if ((page_offset + remain) > PAGE_SIZE)
page_length = PAGE_SIZE - page_offset; page_length = PAGE_SIZE - page_offset;
page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
GFP_HIGHUSER | __GFP_RECLAIMABLE);
if (IS_ERR(page)) if (IS_ERR(page))
return PTR_ERR(page); return PTR_ERR(page);
...@@ -463,8 +463,7 @@ i915_gem_shmem_pread_slow(struct drm_device *dev, ...@@ -463,8 +463,7 @@ i915_gem_shmem_pread_slow(struct drm_device *dev,
if ((data_page_offset + page_length) > PAGE_SIZE) if ((data_page_offset + page_length) > PAGE_SIZE)
page_length = PAGE_SIZE - data_page_offset; page_length = PAGE_SIZE - data_page_offset;
page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
GFP_HIGHUSER | __GFP_RECLAIMABLE);
if (IS_ERR(page)) { if (IS_ERR(page)) {
ret = PTR_ERR(page); ret = PTR_ERR(page);
goto out; goto out;
...@@ -797,8 +796,7 @@ i915_gem_shmem_pwrite_fast(struct drm_device *dev, ...@@ -797,8 +796,7 @@ i915_gem_shmem_pwrite_fast(struct drm_device *dev,
if ((page_offset + remain) > PAGE_SIZE) if ((page_offset + remain) > PAGE_SIZE)
page_length = PAGE_SIZE - page_offset; page_length = PAGE_SIZE - page_offset;
page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
GFP_HIGHUSER | __GFP_RECLAIMABLE);
if (IS_ERR(page)) if (IS_ERR(page))
return PTR_ERR(page); return PTR_ERR(page);
...@@ -907,8 +905,7 @@ i915_gem_shmem_pwrite_slow(struct drm_device *dev, ...@@ -907,8 +905,7 @@ i915_gem_shmem_pwrite_slow(struct drm_device *dev,
if ((data_page_offset + page_length) > PAGE_SIZE) if ((data_page_offset + page_length) > PAGE_SIZE)
page_length = PAGE_SIZE - data_page_offset; page_length = PAGE_SIZE - data_page_offset;
page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
GFP_HIGHUSER | __GFP_RECLAIMABLE);
if (IS_ERR(page)) { if (IS_ERR(page)) {
ret = PTR_ERR(page); ret = PTR_ERR(page);
goto out; goto out;
...@@ -1558,12 +1555,10 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj, ...@@ -1558,12 +1555,10 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj,
inode = obj->base.filp->f_path.dentry->d_inode; inode = obj->base.filp->f_path.dentry->d_inode;
mapping = inode->i_mapping; mapping = inode->i_mapping;
gfpmask |= mapping_gfp_mask(mapping);
for (i = 0; i < page_count; i++) { for (i = 0; i < page_count; i++) {
page = read_cache_page_gfp(mapping, i, page = shmem_read_mapping_page_gfp(mapping, i, gfpmask);
GFP_HIGHUSER |
__GFP_COLD |
__GFP_RECLAIMABLE |
gfpmask);
if (IS_ERR(page)) if (IS_ERR(page))
goto err_pages; goto err_pages;
...@@ -3565,6 +3560,7 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, ...@@ -3565,6 +3560,7 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_i915_gem_object *obj; struct drm_i915_gem_object *obj;
struct address_space *mapping;
obj = kzalloc(sizeof(*obj), GFP_KERNEL); obj = kzalloc(sizeof(*obj), GFP_KERNEL);
if (obj == NULL) if (obj == NULL)
...@@ -3575,6 +3571,9 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, ...@@ -3575,6 +3571,9 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
return NULL; return NULL;
} }
mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping;
mapping_set_gfp_mask(mapping, GFP_HIGHUSER | __GFP_RECLAIMABLE);
i915_gem_info_add_obj(dev_priv, size); i915_gem_info_add_obj(dev_priv, size);
obj->base.write_domain = I915_GEM_DOMAIN_CPU; obj->base.write_domain = I915_GEM_DOMAIN_CPU;
...@@ -3950,8 +3949,7 @@ void i915_gem_detach_phys_object(struct drm_device *dev, ...@@ -3950,8 +3949,7 @@ void i915_gem_detach_phys_object(struct drm_device *dev,
page_count = obj->base.size / PAGE_SIZE; page_count = obj->base.size / PAGE_SIZE;
for (i = 0; i < page_count; i++) { for (i = 0; i < page_count; i++) {
struct page *page = read_cache_page_gfp(mapping, i, struct page *page = shmem_read_mapping_page(mapping, i);
GFP_HIGHUSER | __GFP_RECLAIMABLE);
if (!IS_ERR(page)) { if (!IS_ERR(page)) {
char *dst = kmap_atomic(page); char *dst = kmap_atomic(page);
memcpy(dst, vaddr + i*PAGE_SIZE, PAGE_SIZE); memcpy(dst, vaddr + i*PAGE_SIZE, PAGE_SIZE);
...@@ -4012,8 +4010,7 @@ i915_gem_attach_phys_object(struct drm_device *dev, ...@@ -4012,8 +4010,7 @@ i915_gem_attach_phys_object(struct drm_device *dev,
struct page *page; struct page *page;
char *dst, *src; char *dst, *src;
page = read_cache_page_gfp(mapping, i, page = shmem_read_mapping_page(mapping, i);
GFP_HIGHUSER | __GFP_RECLAIMABLE);
if (IS_ERR(page)) if (IS_ERR(page))
return PTR_ERR(page); return PTR_ERR(page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment