mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Souptick Joarder <jrdr.linux@gmail.com>
Cc: eric@anholt.net, airlied@linux.ie,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	svptas.linux@gmail.com, ajitn.linux@gmail.com,
	brajeswar.linux@gmail.com, sabyasachi.linux@gmail.com
Subject: Re: [PATCH] gpu: drm: v3d: use new return type vm_fault_t
Date: Tue, 3 Jul 2018 10:42:00 -0700	[thread overview]
Message-ID: <20180703174200.GA4834@bombadil.infradead.org> (raw)
In-Reply-To: <20180703161043.GA26927@jordon-HP-15-Notebook-PC>

On Tue, Jul 03, 2018 at 09:40:43PM +0530, 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.
> 
> see commit 1c8f422059ae ("mm: change return type to vm_fault_t")
> for reference.
> 
> 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.

I really think this changelog could do with more work.  Specifically for
this patch, I'd just say:

Convert v3d_gem_fault to return vm_fault_t

Instead of converting an errno into a vm_fault_t ourselves, use
vmf_insert_mixed() which returns a vm_fault_t directly.

>  	unsigned long pfn;
>  	pgoff_t pgoff;
> -	int ret;
>  
>  	/* We don't use vmf->pgoff since that has the fake offset: */
>  	pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
>  	pfn = page_to_pfn(bo->pages[pgoff]);
>  
> -	ret = vm_insert_mixed(vma, vmf->address, __pfn_to_pfn_t(pfn, PFN_DEV));
> -
> -	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 vmf_insert_mixed(vma, vmf->address,
> +		__pfn_to_pfn_t(pfn, PFN_DEV));
>  }

The line-split here is kind of ugly.  I'd do a little more extensive surgery:

-	unsigned long pfn;
+	pfn_t pfn;

- 	pfn = page_to_pfn(bo->pages[pgoff]);
+	pfn = __pfn_to_pfn_t(page_to_pfn(bo->pages[pgoff]), PFN_DEV);

+	return vmf_insert_mixed(vma, vmf->address, pfn);

      reply	other threads:[~2018-07-03 17:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-03 16:10 Souptick Joarder
2018-07-03 17:42 ` Matthew Wilcox [this message]

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=20180703174200.GA4834@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=airlied@linux.ie \
    --cc=ajitn.linux@gmail.com \
    --cc=brajeswar.linux@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eric@anholt.net \
    --cc=jrdr.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sabyasachi.linux@gmail.com \
    --cc=svptas.linux@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 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®