2019-08-04 22:54:32

by John Hubbard

[permalink] [raw]
Subject: [PATCH v2 13/34] rapidio: convert put_page() to put_user_page*()

From: John Hubbard <[email protected]>

For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().

This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").

Cc: Matt Porter <[email protected]>
Cc: Alexandre Bounine <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Logan Gunthorpe <[email protected]>
Cc: Christophe JAILLET <[email protected]>
Cc: Ioan Nicu <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Tvrtko Ursulin <[email protected]>
Signed-off-by: John Hubbard <[email protected]>
---
drivers/rapidio/devices/rio_mport_cdev.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 8155f59ece38..0e8ea0e5a89e 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -572,14 +572,12 @@ static void dma_req_free(struct kref *ref)
struct mport_dma_req *req = container_of(ref, struct mport_dma_req,
refcount);
struct mport_cdev_priv *priv = req->priv;
- unsigned int i;

dma_unmap_sg(req->dmach->device->dev,
req->sgt.sgl, req->sgt.nents, req->dir);
sg_free_table(&req->sgt);
if (req->page_list) {
- for (i = 0; i < req->nr_pages; i++)
- put_page(req->page_list[i]);
+ put_user_pages(req->page_list, req->nr_pages);
kfree(req->page_list);
}

@@ -815,7 +813,7 @@ rio_dma_transfer(struct file *filp, u32 transfer_mode,
struct mport_dma_req *req;
struct mport_dev *md = priv->md;
struct dma_chan *chan;
- int i, ret;
+ int ret;
int nents;

if (xfer->length == 0)
@@ -946,8 +944,7 @@ rio_dma_transfer(struct file *filp, u32 transfer_mode,

err_pg:
if (!req->page_list) {
- for (i = 0; i < nr_pages; i++)
- put_page(page_list[i]);
+ put_user_pages(page_list, nr_pages);
kfree(page_list);
}
err_req:
--
2.22.0