All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>,
	Matthew Auld <matthew.william.auld@gmail.com>
Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Matthew Auld <matthew.auld@intel.com>
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Add lmem fault handler
Date: Thu, 05 Dec 2019 10:31:47 +0000	[thread overview]
Message-ID: <157554190714.22727.11425566328816516124@skylake-alporthouse-com> (raw)
In-Reply-To: <CAM0jSHMgzJBsYfKvKSYrqnBqSUaFqG45eL83_kc8y_w3YdR8hg@mail.gmail.com>

Quoting Matthew Auld (2019-12-05 10:20:55)
> On Thu, 5 Dec 2019 at 10:14, Abdiel Janulgue
> <abdiel.janulgue@linux.intel.com> wrote:
> >
> > Fault handler to handle missing pages for lmem objects.
> >
> > Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
> > Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > ---
> >  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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-12-05 10:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-05 10:14 [Intel-gfx] [PATCH] drm/i915: Add lmem fault handler Abdiel Janulgue
2019-12-05 10:20 ` Matthew Auld
2019-12-05 10:31   ` Chris Wilson [this message]
2019-12-05 11:32 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2019-12-05 12:10 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2019-12-11  5:59 [Intel-gfx] [PATCH] " Abdiel Janulgue
2019-12-11  9:39 ` Chris Wilson
2019-12-11 15:29 ` Chris Wilson
2019-12-13  9:49 ` Dan Carpenter
2019-12-13  9:49   ` Dan Carpenter
2019-12-13  9:49   ` Dan Carpenter
2019-12-12 11:34 Abdiel Janulgue
2019-12-12 11:45 ` Chris Wilson
2019-12-12 14:19 ` Chris Wilson
2019-12-12 15:11   ` Matthew Auld
2019-12-12 15:19     ` Chris Wilson
2019-12-13  5:39       ` Abdiel Janulgue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=157554190714.22727.11425566328816516124@skylake-alporthouse-com \
    --to=chris@chris-wilson.co.uk \
    --cc=abdiel.janulgue@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=matthew.william.auld@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.