Quoting Abdiel Janulgue (2019-12-11 05:59:07) > Fault handler to handle missing pages for lmem objects. > > v2: Handle ENXIO in fault error, account for offset in region start > for fake lmem (Matt). > Add selftest (Chris). > > Signed-off-by: Abdiel Janulgue <abdiel.janulgue@xxxxxxxxxxxxxxx> > Signed-off-by: Matthew Auld <matthew.auld@xxxxxxxxx> > Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> > Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx> > --- > drivers/gpu/drm/i915/gem/i915_gem_lmem.c | 44 ++++++++ > drivers/gpu/drm/i915/gem/i915_gem_lmem.h | 6 + > drivers/gpu/drm/i915/gem/i915_gem_mman.c | 16 ++- > drivers/gpu/drm/i915/gem/i915_gem_mman.h | 1 + > .../drm/i915/gem/selftests/i915_gem_mman.c | 105 ++++++++++++++---- > 5 files changed, 147 insertions(+), 25 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_lmem.c b/drivers/gpu/drm/i915/gem/i915_gem_lmem.c > index 0e2bf6b7e143..7e6d8d1546e3 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_lmem.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_lmem.c > @@ -6,8 +6,40 @@ > #include "intel_memory_region.h" > #include "gem/i915_gem_region.h" > #include "gem/i915_gem_lmem.h" > +#include "gem/i915_gem_mman.h" > #include "i915_drv.h" > > +vm_fault_t vm_fault_lmem(struct vm_fault *vmf) > +{ > + struct vm_area_struct *area = vmf->vma; > + struct i915_mmap_offset *priv = area->vm_private_data; > + struct drm_i915_gem_object *obj = priv->obj; > + unsigned long size = area->vm_end - area->vm_start; > + bool write = area->vm_flags & VM_WRITE; > + vm_fault_t vmf_ret; > + int i, ret; > + > + /* Sanity check that we allow writing into this object */ > + if (i915_gem_object_is_readonly(obj) && write) > + return VM_FAULT_SIGBUS; > + > + ret = i915_gem_object_pin_pages(obj); > + if (ret) > + return i915_error_to_vmf_fault(ret); > + > + for (i = 0; i < size >> PAGE_SHIFT; i++) { > + vmf_ret = vmf_insert_pfn(area, > + (unsigned long)area->vm_start + i * PAGE_SIZE, > + i915_gem_object_lmem_io_pfn(obj, i)); > + if (vmf_ret != VM_FAULT_NOPAGE) > + break; > + } So why aren't we using remap_io_mapping() ? -Chris _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx