Quoting Matthew Auld (2019-12-05 10:20:55) > On Thu, 5 Dec 2019 at 10:14, Abdiel Janulgue > <abdiel.janulgue@xxxxxxxxxxxxxxx> wrote: > > > > Fault handler to handle missing pages for lmem objects. > > > > 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 | 43 ++++++++++++++++++++++++ > > drivers/gpu/drm/i915/gem/i915_gem_lmem.h | 6 ++++ > > drivers/gpu/drm/i915/gem/i915_gem_mman.c | 15 +++++++-- > > drivers/gpu/drm/i915/gem/i915_gem_mman.h | 1 + > > 4 files changed, 63 insertions(+), 2 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..78ac8d160cd7 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); > > Don't we need to handle -ENXIO in i915_error_to_vmf_fault? > > > + > > + 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; > > + } > > + > > + i915_gem_object_unpin_pages(obj); > > + > > + return vmf_ret; > > +} > > + > > const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops = { > > .flags = I915_GEM_OBJECT_HAS_IOMEM, > > > > @@ -56,6 +88,17 @@ i915_gem_object_lmem_io_map(struct drm_i915_gem_object *obj, > > return io_mapping_map_wc(&obj->mm.region->iomap, offset, size); > > } > > > > +unsigned long i915_gem_object_lmem_io_pfn(struct drm_i915_gem_object *obj, > > + unsigned long n) > > +{ > > + struct intel_memory_region *mem = obj->mm.region; > > + resource_size_t offset; > > + > > + offset = i915_gem_object_get_dma_address(obj, n); > > offset -= mem->region.start; for poor old fake local-memory. And so one asks for the selftests... -Chris _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx