Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: vc04_services: Convert get_user_pages*() --> pin_user_pages*()

In 2019, we introduced pin_user_pages*() and now we are converting
get_user_pages*() to the new API as appropriate. [1] & [2] could
be referred for more information.

[1] Documentation/core-api/pin_user_pages.rst

[2] "Explicit pinning of user-space pages":
https://lwn.net/Articles/807108/

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Link: https://lore.kernel.org/r/1591124057-27696-1-git-send-email-jrdr.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Souptick Joarder and committed by
Greg Kroah-Hartman
aeb4ac79 c5a3b1db

+5 -11
+5 -11
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
··· 287 287 pagelistinfo->num_pages, pagelistinfo->dma_dir); 288 288 } 289 289 290 - if (pagelistinfo->pages_need_release) { 291 - unsigned int i; 292 - 293 - for (i = 0; i < pagelistinfo->num_pages; i++) 294 - put_page(pagelistinfo->pages[i]); 295 - } 290 + if (pagelistinfo->pages_need_release) 291 + unpin_user_pages(pagelistinfo->pages, pagelistinfo->num_pages); 296 292 297 293 dma_free_coherent(g_dev, pagelistinfo->pagelist_buffer_size, 298 294 pagelistinfo->pagelist, pagelistinfo->dma_addr); ··· 391 395 } 392 396 /* do not try and release vmalloc pages */ 393 397 } else { 394 - actual_pages = get_user_pages_fast( 398 + actual_pages = pin_user_pages_fast( 395 399 (unsigned long)buf & PAGE_MASK, 396 400 num_pages, 397 401 type == PAGELIST_READ, ··· 403 407 __func__, actual_pages, num_pages); 404 408 405 409 /* This is probably due to the process being killed */ 406 - while (actual_pages > 0) { 407 - actual_pages--; 408 - put_page(pages[actual_pages]); 409 - } 410 + if (actual_pages > 0) 411 + unpin_user_pages(pages, actual_pages); 410 412 cleanup_pagelistinfo(pagelistinfo); 411 413 return NULL; 412 414 }