lkml.org 
[lkml]   [2022]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 1/7] IB/mlx5: Change ib_umem_odp_map_dma_single_page() to retain umem_mutex
Date
ib_umem_odp_map_dma_single_page(), which has been used only by the mlx5
driver, holds umem_mutex on success and releases on failure. This
behavior is not convenient for other drivers to use it, so change it to
always retain mutex on return.

Signed-off-by: Daisuke Matsuda <matsuda-daisuke@fujitsu.com>
---
drivers/infiniband/core/umem_odp.c | 6 ++----
drivers/infiniband/hw/mlx5/odp.c | 4 +++-
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c
index c459c4d011cf..92617a021439 100644
--- a/drivers/infiniband/core/umem_odp.c
+++ b/drivers/infiniband/core/umem_odp.c
@@ -328,8 +328,8 @@ static int ib_umem_odp_map_dma_single_page(
*
* Maps the range passed in the argument to DMA addresses.
* The DMA addresses of the mapped pages is updated in umem_odp->dma_list.
- * Upon success the ODP MR will be locked to let caller complete its device
- * page table update.
+ * The umem mutex is locked and not released in this function. The caller should
+ * complete its device page table update before releasing the lock.
*
* Returns the number of pages mapped in success, negative error code
* for failure.
@@ -456,8 +456,6 @@ int ib_umem_odp_map_dma_and_lock(struct ib_umem_odp *umem_odp, u64 user_virt,
/* upon success lock should stay on hold for the callee */
if (!ret)
ret = dma_index - start_idx;
- else
- mutex_unlock(&umem_odp->umem_mutex);

out_put_mm:
mmput(owning_mm);
diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c
index bc97958818bb..a0de27651586 100644
--- a/drivers/infiniband/hw/mlx5/odp.c
+++ b/drivers/infiniband/hw/mlx5/odp.c
@@ -572,8 +572,10 @@ static int pagefault_real_mr(struct mlx5_ib_mr *mr, struct ib_umem_odp *odp,
access_mask |= ODP_WRITE_ALLOWED_BIT;

np = ib_umem_odp_map_dma_and_lock(odp, user_va, bcnt, access_mask, fault);
- if (np < 0)
+ if (np < 0) {
+ mutex_unlock(&odp->umem_mutex);
return np;
+ }

/*
* No need to check whether the MTTs really belong to this MR, since
--
2.31.1
\
 
 \ /
  Last update: 2022-09-07 04:46    [W:2.643 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site