Browse Source

drm/i915: don't assume struct page in i915_sg_trim

If we copy all the contents of the sg across and not just the page link,
we can then also put it to work in fake_get_huge_pages and beyond.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20180920142707.19659-1-matthew.auld@intel.com
Matthew Auld 7 years ago
parent
commit
c6d22ab61b
2 changed files with 5 additions and 1 deletions
  1. 3 1
      drivers/gpu/drm/i915/i915_gem.c
  2. 2 0
      drivers/gpu/drm/i915/selftests/huge_pages.c

+ 3 - 1
drivers/gpu/drm/i915/i915_gem.c

@@ -2506,7 +2506,9 @@ static bool i915_sg_trim(struct sg_table *orig_st)
 	new_sg = new_st.sgl;
 	new_sg = new_st.sgl;
 	for_each_sg(orig_st->sgl, sg, orig_st->nents, i) {
 	for_each_sg(orig_st->sgl, sg, orig_st->nents, i) {
 		sg_set_page(new_sg, sg_page(sg), sg->length, 0);
 		sg_set_page(new_sg, sg_page(sg), sg->length, 0);
-		/* called before being DMA mapped, no need to copy sg->dma_* */
+		sg_dma_address(new_sg) = sg_dma_address(sg);
+		sg_dma_len(new_sg) = sg_dma_len(sg);
+
 		new_sg = sg_next(new_sg);
 		new_sg = sg_next(new_sg);
 	}
 	}
 	GEM_BUG_ON(new_sg); /* Should walk exactly nents and hit the end */
 	GEM_BUG_ON(new_sg); /* Should walk exactly nents and hit the end */

+ 2 - 0
drivers/gpu/drm/i915/selftests/huge_pages.c

@@ -235,6 +235,8 @@ static int fake_get_huge_pages(struct drm_i915_gem_object *obj)
 		sg = sg_next(sg);
 		sg = sg_next(sg);
 	} while (1);
 	} while (1);
 
 
+	i915_sg_trim(st);
+
 	obj->mm.madv = I915_MADV_DONTNEED;
 	obj->mm.madv = I915_MADV_DONTNEED;
 
 
 	__i915_gem_object_set_pages(obj, st, sg_page_sizes);
 	__i915_gem_object_set_pages(obj, st, sg_page_sizes);