[PATCH 3/4] drm/i915/gem: Use set_pte_at() for assigning the vmapped PTE
From: Chris Wilson
Date: Fri Aug 21 2020 - 04:50:31 EST
Use set_pte_at() to assign the PTE pointer returned by alloc_vm_area(),
rather than a direct assignment.
Fixes: 6056e50033d9 ("drm/i915/gem: Support discontiguous lmem object maps")
Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Cc: Matthew Auld <matthew.auld@xxxxxxxxx>
---
drivers/gpu/drm/i915/gem/i915_gem_pages.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
index 0fee67f34d74..6838cf9bdae6 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
@@ -286,23 +286,34 @@ static void *i915_gem_object_map(struct drm_i915_gem_object *obj,
}
if (i915_gem_object_has_struct_page(obj)) {
+ unsigned long addr = (unsigned long)area->addr;
struct sgt_iter iter;
struct page *page;
pte_t **ptes = mem;
- for_each_sgt_page(page, iter, sgt)
- **ptes++ = mk_pte(page, pgprot);
+ for_each_sgt_page(page, iter, sgt) {
+ set_pte_at(&init_mm, addr, *ptes, mk_pte(page, pgprot));
+ addr += PAGE_SIZE;
+ ptes++;
+ }
+ GEM_BUG_ON(addr != (unsigned long)area->addr + obj->base.size);
} else {
+ unsigned long addr = (unsigned long)area->addr;
resource_size_t iomap;
struct sgt_iter iter;
pte_t **ptes = mem;
- dma_addr_t addr;
+ dma_addr_t offset;
iomap = obj->mm.region->iomap.base;
iomap -= obj->mm.region->region.start;
- for_each_sgt_daddr(addr, iter, sgt)
- **ptes++ = iomap_pte(iomap, addr, pgprot);
+ for_each_sgt_daddr(offset, iter, sgt) {
+ set_pte_at(&init_mm, addr, *ptes,
+ iomap_pte(iomap, offset, pgprot));
+ addr += PAGE_SIZE;
+ ptes++;
+ }
+ GEM_BUG_ON(addr != (unsigned long)area->addr + obj->base.size);
}
flush_vm_area(area);
--
2.20.1