mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jordan Crouse <jcrouse@codeaurora.org>
To: Souptick Joarder <jrdr.linux@gmail.com>
Cc: Rob Clark <robdclark@gmail.com>,
	airlied@linux.ie, Matthew Wilcox <willy@infradead.org>,
	linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [Freedreno] [PATCH] gpu: drm: msm: Change return type to vm_fault_t
Date: Thu, 31 May 2018 11:59:02 -0600	[thread overview]
Message-ID: <20180531175902.GC11565@jcrouse-lnx.qualcomm.com> (raw)
In-Reply-To: <CAFqt6zY8VJ791_6C_pqrGgjG91T1kirEmUyA3JC+3JsN8QjFAw@mail.gmail.com>

On Mon, May 28, 2018 at 12:38:41PM +0530, Souptick Joarder wrote:
> On Mon, May 21, 2018 at 10:59 PM, Souptick Joarder <jrdr.linux@gmail.com> wrote:
> > Use new return type vm_fault_t for fault handler. For
> > now, this is just documenting that the function returns
> > a VM_FAULT value rather than an errno. Once all instances
> > are converted, vm_fault_t will become a distinct type.
> >
> > Ref- commit 1c8f422059ae ("mm: change return type to vm_fault_t")
> >
> > Previously vm_insert_mixed() returns err which driver
> > mapped into VM_FAULT_* type. The new function
> > vmf_insert_mixed() will replace this inefficiency by
> > returning VM_FAULT_* type.
> >
> > vmf_error() is the newly introduce inline function
> > in 4.17-rc6.
> >
> > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> > Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
> > ---
> >  drivers/gpu/drm/msm/msm_drv.h |  3 ++-
> >  drivers/gpu/drm/msm/msm_gem.c | 33 ++++++++++-----------------------
> >  2 files changed, 12 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
> > index 0a653dd..44b4ca7 100644
> > --- a/drivers/gpu/drm/msm/msm_drv.h
> > +++ b/drivers/gpu/drm/msm/msm_drv.h
> > @@ -33,6 +33,7 @@
> >  #include <linux/of_graph.h>
> >  #include <linux/of_device.h>
> >  #include <asm/sizes.h>
> > +#include <linux/mm_types.h>
> >
> >  #include <drm/drmP.h>
> >  #include <drm/drm_atomic.h>
> > @@ -188,7 +189,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
> >  int msm_gem_mmap_obj(struct drm_gem_object *obj,
> >                         struct vm_area_struct *vma);
> >  int msm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
> > -int msm_gem_fault(struct vm_fault *vmf);
> > +vm_fault_t msm_gem_fault(struct vm_fault *vmf);
> >  uint64_t msm_gem_mmap_offset(struct drm_gem_object *obj);
> >  int msm_gem_get_iova(struct drm_gem_object *obj,
> >                 struct msm_gem_address_space *aspace, uint64_t *iova);
> > diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
> > index 07376de..27a5ab5 100644
> > --- a/drivers/gpu/drm/msm/msm_gem.c
> > +++ b/drivers/gpu/drm/msm/msm_gem.c
> > @@ -217,7 +217,7 @@ int msm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
> >         return msm_gem_mmap_obj(vma->vm_private_data, vma);
> >  }
> >
> > -int msm_gem_fault(struct vm_fault *vmf)
> > +vm_fault_t msm_gem_fault(struct vm_fault *vmf)
> >  {
> >         struct vm_area_struct *vma = vmf->vma;
> >         struct drm_gem_object *obj = vma->vm_private_data;
> > @@ -225,15 +225,18 @@ int msm_gem_fault(struct vm_fault *vmf)
> >         struct page **pages;
> >         unsigned long pfn;
> >         pgoff_t pgoff;
> > -       int ret;
> > +       int err;
> > +       vm_fault_t ret;
> >
> >         /*
> >          * vm_ops.open/drm_gem_mmap_obj and close get and put
> >          * a reference on obj. So, we dont need to hold one here.
> >          */
> > -       ret = mutex_lock_interruptible(&msm_obj->lock);
> > -       if (ret)
> > +       err = mutex_lock_interruptible(&msm_obj->lock);
> > +       if (err) {
> > +               ret = VM_FAULT_NOPAGE;
> >                 goto out;
> > +       }
> >
> >         if (WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED)) {
> >                 mutex_unlock(&msm_obj->lock);
> > @@ -243,7 +246,7 @@ int msm_gem_fault(struct vm_fault *vmf)
> >         /* make sure we have pages attached now */
> >         pages = get_pages(obj);
> >         if (IS_ERR(pages)) {
> > -               ret = PTR_ERR(pages);
> > +               ret = vmf_error(PTR_ERR(pages));
> >                 goto out_unlock;
> >         }
> >
> > @@ -255,27 +258,11 @@ int msm_gem_fault(struct vm_fault *vmf)
> >         VERB("Inserting %p pfn %lx, pa %lx", (void *)vmf->address,
> >                         pfn, pfn << PAGE_SHIFT);
> >
> > -       ret = vm_insert_mixed(vma, vmf->address, __pfn_to_pfn_t(pfn, PFN_DEV));
> > -
> > +       ret = vmf_insert_mixed(vma, vmf->address, __pfn_to_pfn_t(pfn, PFN_DEV));
> >  out_unlock:
> >         mutex_unlock(&msm_obj->lock);
> >  out:
> > -       switch (ret) {
> > -       case -EAGAIN:
> > -       case 0:
> > -       case -ERESTARTSYS:
> > -       case -EINTR:
> > -       case -EBUSY:
> > -               /*
> > -                * EBUSY is ok: this just means that another thread
> > -                * already did the job.
> > -                */
> > -               return VM_FAULT_NOPAGE;
> > -       case -ENOMEM:
> > -               return VM_FAULT_OOM;
> > -       default:
> > -               return VM_FAULT_SIGBUS;
> > -       }
> > +       return ret;
> >  }
> >
> >  /** get mmap offset */
> > --
> > 1.9.1
> >
> 
> Any comment for this patch ?

Sorry for the delay, I wanted to get a chance to test it. It seems to pass the
usual regression tests. LGTM.

Jordan

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2018-05-31 18:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-21 17:29 Souptick Joarder
2018-05-28  7:08 ` Souptick Joarder
2018-05-31 17:59   ` Jordan Crouse [this message]
2018-05-31 18:53     ` [Freedreno] " Souptick Joarder
2018-06-18  3:40     ` Souptick Joarder
2018-06-18 21:43       ` Rob Clark

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=20180531175902.GC11565@jcrouse-lnx.qualcomm.com \
    --to=jcrouse@codeaurora.org \
    --cc=airlied@linux.ie \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jrdr.linux@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robdclark@gmail.com \
    --cc=willy@infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®