diff options
author | Mika Kuoppala <mika.kuoppala@intel.com> | 2015-03-13 17:59:28 +0200 |
---|---|---|
committer | Mika Kuoppala <mika.kuoppala@intel.com> | 2015-03-13 18:49:26 +0200 |
commit | 30d316ab5de5d8eae275e3cb7c3a53ec60783348 (patch) | |
tree | 51b03b5b0aa5db8c89ae0942aa87dd271dbb9f7e /drivers/gpu/drm/i915/i915_gem.c | |
parent | ee5cd6dbe829dacc0e3e5e8b5a14854023b6dedf (diff) |
drm/i915: Make macro for gem object scatterlist traversalparser_test
Simplify usage to prevent mistakes in scatter list
traversal, due to mixing scatter list entity and page
counts.
Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 0fe313d0f609..3136e8ac02e8 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -632,6 +632,8 @@ i915_gem_shmem_pread(struct drm_device *dev, int prefaulted = 0; int needs_clflush = 0; struct sg_page_iter sg_iter; + struct page *page; + int i; user_data = to_user_ptr(args->data_ptr); remain = args->size; @@ -644,10 +646,8 @@ i915_gem_shmem_pread(struct drm_device *dev, offset = args->offset; - for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, - offset >> PAGE_SHIFT) { - struct page *page = sg_page_iter_page(&sg_iter); - + i = offset >> PAGE_SHIFT; + for_each_obj_page(obj, page, sg_iter, i) { if (remain <= 0) break; @@ -934,6 +934,8 @@ i915_gem_shmem_pwrite(struct drm_device *dev, int needs_clflush_after = 0; int needs_clflush_before = 0; struct sg_page_iter sg_iter; + struct page *page; + int i; user_data = to_user_ptr(args->data_ptr); remain = args->size; @@ -969,9 +971,8 @@ i915_gem_shmem_pwrite(struct drm_device *dev, offset = args->offset; obj->dirty = 1; - for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, - offset >> PAGE_SHIFT) { - struct page *page = sg_page_iter_page(&sg_iter); + i = offset >> PAGE_SHIFT; + for_each_obj_page(obj, page, sg_iter, i) { int partial_cacheline_write; if (remain <= 0) @@ -1984,7 +1985,8 @@ static void i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj) { struct sg_page_iter sg_iter; - int ret; + struct page *page; + int ret, i; BUG_ON(obj->madv == __I915_MADV_PURGED); @@ -2004,9 +2006,8 @@ i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj) if (obj->madv == I915_MADV_DONTNEED) obj->dirty = 0; - for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, 0) { - struct page *page = sg_page_iter_page(&sg_iter); - + i = 0; + for_each_obj_page(obj, page, sg_iter, i) { if (obj->dirty) set_page_dirty(page); |