linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rdma/qib: Remove deprecated kmap() call
@ 2023-03-07 17:15 Ira Weiny
  2023-03-08 20:24 ` Dennis Dalessandro
  2023-03-14 11:51 ` Leon Romanovsky
  0 siblings, 2 replies; 3+ messages in thread
From: Ira Weiny @ 2023-03-07 17:15 UTC (permalink / raw)
  To: Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky
  Cc: linux-rdma, linux-kernel, Ira Weiny

kmap() has been deprecated in favor of the kmap_local_page() call.
kmap_local_page() is thread local.

In the sdma coalesce case the page allocated is potentially free'ed in a
different context through qib_sdma_get_complete() ->
qib_user_sdma_make_progress().  The use of kmap_local_page() is
inappropriate in this call path.  However, the page is allocated using
GFP_KERNEL and will never be from highmem.

Remove the use of kmap calls and use page_address() in this case.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 drivers/infiniband/hw/qib/qib_user_sdma.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_user_sdma.c b/drivers/infiniband/hw/qib/qib_user_sdma.c
index 9fe03d6ffac1..336eb15a721f 100644
--- a/drivers/infiniband/hw/qib/qib_user_sdma.c
+++ b/drivers/infiniband/hw/qib/qib_user_sdma.c
@@ -320,7 +320,6 @@ static int qib_user_sdma_page_to_frags(const struct qib_devdata *dd,
 			unpin_user_page(page);
 		} else {
 			/* coalesce case */
-			kunmap(page);
 			__free_page(page);
 		}
 		ret = -ENOMEM;
@@ -572,7 +571,7 @@ static int qib_user_sdma_coalesce(const struct qib_devdata *dd,
 		goto done;
 	}
 
-	mpage = kmap(page);
+	mpage = page_address(page);
 	mpage_save = mpage;
 	for (i = 0; i < niov; i++) {
 		int cfur;
@@ -581,7 +580,7 @@ static int qib_user_sdma_coalesce(const struct qib_devdata *dd,
 				      iov[i].iov_base, iov[i].iov_len);
 		if (cfur) {
 			ret = -EFAULT;
-			goto free_unmap;
+			goto page_free;
 		}
 
 		mpage += iov[i].iov_len;
@@ -592,8 +591,7 @@ static int qib_user_sdma_coalesce(const struct qib_devdata *dd,
 			page, 0, 0, len, mpage_save);
 	goto done;
 
-free_unmap:
-	kunmap(page);
+page_free:
 	__free_page(page);
 done:
 	return ret;
@@ -627,9 +625,6 @@ static void qib_user_sdma_free_pkt_frag(struct device *dev,
 				       pkt->addr[i].dma_length,
 				       DMA_TO_DEVICE);
 
-		if (pkt->addr[i].kvaddr)
-			kunmap(pkt->addr[i].page);
-
 		if (pkt->addr[i].put_page)
 			unpin_user_page(pkt->addr[i].page);
 		else

---
base-commit: 8ca09d5fa3549d142c2080a72a4c70ce389163cd
change-id: 20230217-kmap-qib-27a563231f85

Best regards,
-- 
Ira Weiny <ira.weiny@intel.com>


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

* Re: [PATCH] rdma/qib: Remove deprecated kmap() call
  2023-03-07 17:15 [PATCH] rdma/qib: Remove deprecated kmap() call Ira Weiny
@ 2023-03-08 20:24 ` Dennis Dalessandro
  2023-03-14 11:51 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Dennis Dalessandro @ 2023-03-08 20:24 UTC (permalink / raw)
  To: Ira Weiny, Jason Gunthorpe, Leon Romanovsky; +Cc: linux-rdma, linux-kernel

On 3/7/23 12:15 PM, Ira Weiny wrote:
> kmap() has been deprecated in favor of the kmap_local_page() call.
> kmap_local_page() is thread local.
> 
> In the sdma coalesce case the page allocated is potentially free'ed in a
> different context through qib_sdma_get_complete() ->
> qib_user_sdma_make_progress().  The use of kmap_local_page() is
> inappropriate in this call path.  However, the page is allocated using
> GFP_KERNEL and will never be from highmem.
> 
> Remove the use of kmap calls and use page_address() in this case.
> 
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>

Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>

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

* Re: [PATCH] rdma/qib: Remove deprecated kmap() call
  2023-03-07 17:15 [PATCH] rdma/qib: Remove deprecated kmap() call Ira Weiny
  2023-03-08 20:24 ` Dennis Dalessandro
@ 2023-03-14 11:51 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2023-03-14 11:51 UTC (permalink / raw)
  To: Dennis Dalessandro, Jason Gunthorpe, Ira Weiny; +Cc: linux-rdma, linux-kernel


On Tue, 07 Mar 2023 09:15:31 -0800, Ira Weiny wrote:
> kmap() has been deprecated in favor of the kmap_local_page() call.
> kmap_local_page() is thread local.
> 
> In the sdma coalesce case the page allocated is potentially free'ed in a
> different context through qib_sdma_get_complete() ->
> qib_user_sdma_make_progress().  The use of kmap_local_page() is
> inappropriate in this call path.  However, the page is allocated using
> GFP_KERNEL and will never be from highmem.
> 
> [...]

Applied, thanks!

[1/1] rdma/qib: Remove deprecated kmap() call
      https://git.kernel.org/rdma/rdma/c/4f00848e490c59

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>

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

end of thread, other threads:[~2023-03-14 11:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07 17:15 [PATCH] rdma/qib: Remove deprecated kmap() call Ira Weiny
2023-03-08 20:24 ` Dennis Dalessandro
2023-03-14 11:51 ` Leon Romanovsky

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).