linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] rapidio: use get_user_pages_unlocked()
@ 2017-01-03 20:50 Lorenzo Stoakes
  2017-01-25 14:35 ` Bounine, Alexandre
  0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Stoakes @ 2017-01-03 20:50 UTC (permalink / raw)
  To: Matt Porter, Alexandre Bounine
  Cc: linux-mm, linux-kernel, Andrew Morton, Lorenzo Stoakes

Moving from get_user_pages() to get_user_pages_unlocked() simplifies the code
and takes advantage of VM_FAULT_RETRY functionality when faulting in pages.

Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
---
 drivers/rapidio/devices/rio_mport_cdev.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 9013a585507e..50b617af81bd 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -889,17 +889,16 @@ rio_dma_transfer(struct file *filp, u32 transfer_mode,
 			goto err_req;
 		}

-		down_read(&current->mm->mmap_sem);
-		pinned = get_user_pages(
+		pinned = get_user_pages_unlocked(
 				(unsigned long)xfer->loc_addr & PAGE_MASK,
 				nr_pages,
-				dir == DMA_FROM_DEVICE ? FOLL_WRITE : 0,
-				page_list, NULL);
-		up_read(&current->mm->mmap_sem);
+				page_list,
+				dir == DMA_FROM_DEVICE ? FOLL_WRITE : 0);

 		if (pinned != nr_pages) {
 			if (pinned < 0) {
-				rmcd_error("get_user_pages err=%ld", pinned);
+				rmcd_error("get_user_pages_unlocked err=%ld",
+					   pinned);
 				nr_pages = 0;
 			} else
 				rmcd_error("pinned %ld out of %ld pages",
--
2.11.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH RESEND] rapidio: use get_user_pages_unlocked()
  2017-01-03 20:50 [PATCH RESEND] rapidio: use get_user_pages_unlocked() Lorenzo Stoakes
@ 2017-01-25 14:35 ` Bounine, Alexandre
  0 siblings, 0 replies; 2+ messages in thread
From: Bounine, Alexandre @ 2017-01-25 14:35 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton,
	Matt Porter

Acked-by: Alexandre Bounine <alexandre.bounine@idt.com>

> -----Original Message-----
> From: Lorenzo Stoakes [mailto:lstoakes@gmail.com]
> Sent: Tuesday, January 03, 2017 3:50 PM
> To: Matt Porter; Bounine, Alexandre
> Cc: linux-mm@kvack.org; linux-kernel@vger.kernel.org; Andrew Morton;
> Lorenzo Stoakes
> Subject: [PATCH RESEND] rapidio: use get_user_pages_unlocked()
> 
> Moving from get_user_pages() to get_user_pages_unlocked() simplifies
> the code
> and takes advantage of VM_FAULT_RETRY functionality when faulting in
> pages.
> 
> Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
> ---
>  drivers/rapidio/devices/rio_mport_cdev.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/rapidio/devices/rio_mport_cdev.c
> b/drivers/rapidio/devices/rio_mport_cdev.c
> index 9013a585507e..50b617af81bd 100644
> --- a/drivers/rapidio/devices/rio_mport_cdev.c
> +++ b/drivers/rapidio/devices/rio_mport_cdev.c
> @@ -889,17 +889,16 @@ rio_dma_transfer(struct file *filp, u32
> transfer_mode,
>  			goto err_req;
>  		}
> 
> -		down_read(&current->mm->mmap_sem);
> -		pinned = get_user_pages(
> +		pinned = get_user_pages_unlocked(
>  				(unsigned long)xfer->loc_addr & PAGE_MASK,
>  				nr_pages,
> -				dir == DMA_FROM_DEVICE ? FOLL_WRITE : 0,
> -				page_list, NULL);
> -		up_read(&current->mm->mmap_sem);
> +				page_list,
> +				dir == DMA_FROM_DEVICE ? FOLL_WRITE : 0);
> 
>  		if (pinned != nr_pages) {
>  			if (pinned < 0) {
> -				rmcd_error("get_user_pages err=%ld", pinned);
> +				rmcd_error("get_user_pages_unlocked err=%ld",
> +					   pinned);
>  				nr_pages = 0;
>  			} else
>  				rmcd_error("pinned %ld out of %ld pages",
> --
> 2.11.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-25 14:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-03 20:50 [PATCH RESEND] rapidio: use get_user_pages_unlocked() Lorenzo Stoakes
2017-01-25 14:35 ` Bounine, Alexandre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).