From mboxrd@z Thu Jan 1 00:00:00 1970 From: Souptick Joarder Subject: Re: [PATCH] gpu: drm: i915: Change return type to vm_fault_t Date: Tue, 17 Apr 2018 21:57:50 +0530 Message-ID: References: <20180417151127.GA31655@jordon-HP-15-Notebook-PC> <87h8o9g8be.fsf@intel.com> <20180417161557.GA3603@bombadil.infradead.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1392648400==" Return-path: In-Reply-To: <20180417161557.GA3603@bombadil.infradead.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Matthew Wilcox Cc: airlied@linux.ie, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, rodrigo.vivi@intel.com List-Id: dri-devel@lists.freedesktop.org --===============1392648400== Content-Type: multipart/alternative; boundary="f4f5e80c392cdf848c056a0dd123" --f4f5e80c392cdf848c056a0dd123 Content-Type: text/plain; charset="UTF-8" On 17-Apr-2018 9:45 PM, "Matthew Wilcox" wrote: > > On Tue, Apr 17, 2018 at 09:14:32PM +0530, Souptick Joarder wrote: > > Not exactly. The plan for these patches is to introduce new vm_fault_t type > > in vm_operations_struct fault handlers. It's now available in 4.17-rc1. We will > > push all the required drivers/filesystem changes through different maintainers > > to linus tree. Once everything is converted into vm_fault_t type then Changing > > it from a signed to an unsigned int causes GCC to warn about an assignment > > from an incompatible type -- int foo(void) is incompatible with > > unsigned int foo(void). > > > > Please refer 1c8f422059ae ("mm: change return type to vm_fault_t") in 4.17-rc1. > > I think this patch would be clearer if you did > > - int ret; > + int err; > + vm_fault_t ret; > > Then it would be clearer to the maintainer that you're splitting apart the > VM_FAULT and errno codes. > > Sorry for not catching this during initial review. Ok, I will make required changes and send v2. Sorry, even I missed this :) > > > On Tue, Apr 17, 2018 at 8:59 PM, Jani Nikula > > wrote: > > > On Tue, 17 Apr 2018, Souptick Joarder 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. > > >> > > >> Reference id -> 1c8f422059ae ("mm: change return type to > > >> vm_fault_t") > > >> > > >> Signed-off-by: Souptick Joarder > > >> --- > > >> drivers/gpu/drm/i915/i915_drv.h | 3 ++- > > >> drivers/gpu/drm/i915/i915_gem.c | 15 ++++++++------- > > >> 2 files changed, 10 insertions(+), 8 deletions(-) > > >> > > >> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h > > >> index a42deeb..95b0d50 100644 > > >> --- a/drivers/gpu/drm/i915/i915_drv.h > > >> +++ b/drivers/gpu/drm/i915/i915_drv.h > > >> @@ -51,6 +51,7 @@ > > >> #include > > >> #include > > >> #include > > >> +#include > > >> > > >> #include "i915_params.h" > > >> #include "i915_reg.h" > > >> @@ -3363,7 +3364,7 @@ int i915_gem_wait_for_idle(struct drm_i915_private *dev_priv, > > >> unsigned int flags); > > >> int __must_check i915_gem_suspend(struct drm_i915_private *dev_priv); > > >> void i915_gem_resume(struct drm_i915_private *dev_priv); > > >> -int i915_gem_fault(struct vm_fault *vmf); > > >> +vm_fault_t i915_gem_fault(struct vm_fault *vmf); > > >> int i915_gem_object_wait(struct drm_i915_gem_object *obj, > > >> unsigned int flags, > > >> long timeout, > > >> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c > > >> index dd89abd..bdac690 100644 > > >> --- a/drivers/gpu/drm/i915/i915_gem.c > > >> +++ b/drivers/gpu/drm/i915/i915_gem.c > > >> @@ -1882,7 +1882,7 @@ int i915_gem_mmap_gtt_version(void) > > >> * The current feature set supported by i915_gem_fault() and thus GTT mmaps > > >> * is exposed via I915_PARAM_MMAP_GTT_VERSION (see i915_gem_mmap_gtt_version). > > >> */ > > >> -int i915_gem_fault(struct vm_fault *vmf) > > >> +vm_fault_t i915_gem_fault(struct vm_fault *vmf) > > >> { > > >> #define MIN_CHUNK_PAGES ((1 << 20) >> PAGE_SHIFT) /* 1 MiB */ > > >> struct vm_area_struct *area = vmf->vma; > > >> @@ -1895,6 +1895,7 @@ int i915_gem_fault(struct vm_fault *vmf) > > >> pgoff_t page_offset; > > >> unsigned int flags; > > >> int ret; > > >> + vm_fault_t retval; > > > > > > What's the point of changing the name? An unnecessary change. > > > > > > BR, > > > Jani. > > > > > >> > > >> /* We don't use vmf->pgoff since that has the fake offset */ > > >> page_offset = (vmf->address - area->vm_start) >> PAGE_SHIFT; > > >> @@ -2000,7 +2001,7 @@ int i915_gem_fault(struct vm_fault *vmf) > > >> * and so needs to be reported. > > >> */ > > >> if (!i915_terminally_wedged(&dev_priv->gpu_error)) { > > >> - ret = VM_FAULT_SIGBUS; > > >> + retval = VM_FAULT_SIGBUS; > > >> break; > > >> } > > >> case -EAGAIN: > > >> @@ -2017,21 +2018,21 @@ int i915_gem_fault(struct vm_fault *vmf) > > >> * EBUSY is ok: this just means that another thread > > >> * already did the job. > > >> */ > > >> - ret = VM_FAULT_NOPAGE; > > >> + retval = VM_FAULT_NOPAGE; > > >> break; > > >> case -ENOMEM: > > >> - ret = VM_FAULT_OOM; > > >> + retval = VM_FAULT_OOM; > > >> break; > > >> case -ENOSPC: > > >> case -EFAULT: > > >> - ret = VM_FAULT_SIGBUS; > > >> + retval = VM_FAULT_SIGBUS; > > >> break; > > >> default: > > >> WARN_ONCE(ret, "unhandled error in i915_gem_fault: %i\n", ret); > > >> - ret = VM_FAULT_SIGBUS; > > >> + retval = VM_FAULT_SIGBUS; > > >> break; > > >> } > > >> - return ret; > > >> + return retval; > > >> } > > >> > > >> static void __i915_gem_object_release_mmap(struct drm_i915_gem_object *obj) > > >> -- > > >> 1.9.1 > > >> > > > > > > -- > > > Jani Nikula, Intel Open Source Technology Center --f4f5e80c392cdf848c056a0dd123 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On 17-Apr-2018 9:45 PM, "Matthew Wilcox" <willy@infradead.org> wrote:
>
> On Tue, Apr 17, 2018 at 09:14:32PM +0530, Souptick Joarder wrote:
> > Not exactly. The plan for these patches is to introduce new vm_fa= ult_t type
> > in vm_operations_struct fault handlers. It's now available in= 4.17-rc1. We will
> > push all the required drivers/filesystem changes through differen= t maintainers
> > to linus tree. Once everything is converted into vm_fault_t type = then Changing
> > it from a signed to an unsigned int causes GCC to warn about an a= ssignment
> > from an incompatible type -- int foo(void) is incompatible with > > unsigned int foo(void).
> >
> > Please refer 1c8f422059ae ("mm: change return type to vm_fau= lt_t") in 4.17-rc1.
>
> I think this patch would be clearer if you did
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0int ret;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0int err;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0vm_fault_t ret;
>
> Then it would be clearer to the maintainer that you're splitting a= part the
> VM_FAULT and errno codes.
>
> Sorry for not catching this during initial review.

Ok, I will make required changes and send v2. Sorry, even I = missed this :)
>
> > On Tue, Apr 17, 2018 at 8:59 PM, Jani Nikula
> > <jani.nikula@li= nux.intel.com> wrote:
> > > On Tue, 17 Apr 2018, 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<= br> > > >> a VM_FAULT value rather than an errno. Once all instance= s
> > >> are converted, vm_fault_t will become a distinct type. > > >>
> > >> Reference id -> 1c8f422059ae ("mm: change return= type to
> > >> vm_fault_t")
> > >>
> > >> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> > >> ---
> > >>=C2=A0 drivers/gpu/drm/i915/i915_drv.h |=C2=A0 3 ++-
> > >>=C2=A0 drivers/gpu/drm/i915/i915_gem.c | 15 ++++++++-----= --
> > >>=C2=A0 2 files changed, 10 insertions(+), 8 deletions(-)<= br> > > >>
> > >> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/g= pu/drm/i915/i915_drv.h
> > >> index a42deeb..95b0d50 100644
> > >> --- a/drivers/gpu/drm/i915/i915_drv.h
> > >> +++ b/drivers/gpu/drm/i915/i915_drv.h
> > >> @@ -51,6 +51,7 @@
> > >>=C2=A0 #include <drm/drm_gem.h>
> > >>=C2=A0 #include <drm/drm_auth.h>
> > >>=C2=A0 #include <drm/drm_cache.h>
> > >> +#include <linux/mm_types.h>
> > >>
> > >>=C2=A0 #include "i915_params.h"
> > >>=C2=A0 #include "i915_reg.h"
> > >> @@ -3363,7 +3364,7 @@ int i915_gem_wait_for_idle(struct = drm_i915_private *dev_priv,
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned int flags);
> > >>=C2=A0 int __must_check i915_gem_suspend(struct drm_i915_= private *dev_priv);
> > >>=C2=A0 void i915_gem_resume(struct drm_i915_private *dev_= priv);
> > >> -int i915_gem_fault(struct vm_fault *vmf);
> > >> +vm_fault_t i915_gem_fault(struct vm_fault *vmf);
> > >>=C2=A0 int i915_gem_object_wait(struct drm_i915_gem_objec= t *obj,
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned int flags,
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 long timeout,
> > >> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/g= pu/drm/i915/i915_gem.c
> > >> index dd89abd..bdac690 100644
> > >> --- a/drivers/gpu/drm/i915/i915_gem.c
> > >> +++ b/drivers/gpu/drm/i915/i915_gem.c
> > >> @@ -1882,7 +1882,7 @@ int i915_gem_mmap_gtt_version(void= )
> > >>=C2=A0 =C2=A0* The current feature set supported by i915_= gem_fault() and thus GTT mmaps
> > >>=C2=A0 =C2=A0* is exposed via I915_PARAM_MMAP_GTT_VERSION= (see i915_gem_mmap_gtt_version).
> > >>=C2=A0 =C2=A0*/
> > >> -int i915_gem_fault(struct vm_fault *vmf)
> > >> +vm_fault_t i915_gem_fault(struct vm_fault *vmf)
> > >>=C2=A0 {
> > >>=C2=A0 #define MIN_CHUNK_PAGES ((1 << 20) >> = PAGE_SHIFT) /* 1 MiB */
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0struct vm_area_struct *area = =3D vmf->vma;
> > >> @@ -1895,6 +1895,7 @@ int i915_gem_fault(struct vm_fault= *vmf)
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0pgoff_t page_offset;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int flags;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0int ret;
> > >> +=C2=A0 =C2=A0 =C2=A0vm_fault_t retval;
> > >
> > > What's the point of changing the name? An unnecessary ch= ange.
> > >
> > > BR,
> > > Jani.
> > >
> > >>
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0/* We don't use vmf->pg= off since that has the fake offset */
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0page_offset =3D (vmf->addre= ss - area->vm_start) >> PAGE_SHIFT;
> > >> @@ -2000,7 +2001,7 @@ int i915_gem_fault(struct vm_fault= *vmf)
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *= and so needs to be reported.
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *= /
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if= (!i915_terminally_wedged(&dev_priv->gpu_error)) {
> > >> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0ret =3D VM_FAULT_SIGBUS;
> > >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0retval =3D VM_FAULT_SIGBUS;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0break;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<= br> > > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0case -EAGAIN:
> > >> @@ -2017,21 +2018,21 @@ int i915_gem_fault(struct vm_fau= lt *vmf)
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *= EBUSY is ok: this just means that another thread
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *= already did the job.
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *= /
> > >> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D= VM_FAULT_NOPAGE;
> > >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0retval = =3D VM_FAULT_NOPAGE;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0br= eak;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0case -ENOMEM:
> > >> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D= VM_FAULT_OOM;
> > >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0retval = =3D VM_FAULT_OOM;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0br= eak;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0case -ENOSPC:
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0case -EFAULT:
> > >> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D= VM_FAULT_SIGBUS;
> > >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0retval = =3D VM_FAULT_SIGBUS;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0br= eak;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0default:
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0WA= RN_ONCE(ret, "unhandled error in i915_gem_fault: %i\n", ret);
> > >> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D= VM_FAULT_SIGBUS;
> > >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0retval = =3D VM_FAULT_SIGBUS;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0br= eak;
> > >>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
> > >> -=C2=A0 =C2=A0 =C2=A0return ret;
> > >> +=C2=A0 =C2=A0 =C2=A0return retval;
> > >>=C2=A0 }
> > >>
> > >>=C2=A0 static void __i915_gem_object_release_mmap(struct = drm_i915_gem_object *obj)
> > >> --
> > >> 1.9.1
> > >>
> > >
> > > --
> > > Jani Nikula, Intel Open Source Technology Center

--f4f5e80c392cdf848c056a0dd123-- --===============1392648400== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1392648400==--