IB/core: Get rid of redundant verb ib_destroy_mr
authorSagi Grimberg <sagig@mellanox.com>
Thu, 30 Jul 2015 07:32:34 +0000 (10:32 +0300)
committerDoug Ledford <dledford@redhat.com>
Sun, 30 Aug 2015 22:08:44 +0000 (18:08 -0400)
This was added in a thought of uniting all mr allocation
and deallocation routines but the fact is we have a single
deallocation routine already, ib_dereg_mr.

And, move mlx5_ib_destroy_mr specific logic into mlx5_ib_dereg_mr
(includes only signature stuff for now).

And, fixup the only callers (iser/isert) accordingly.

Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/verbs.c
drivers/infiniband/hw/mlx5/main.c
drivers/infiniband/hw/mlx5/mlx5_ib.h
drivers/infiniband/hw/mlx5/mr.c
drivers/infiniband/ulp/iser/iser_verbs.c
drivers/infiniband/ulp/isert/ib_isert.c
include/rdma/ib_verbs.h

index bac3fb406a7470edb0deb1d66d6559118fe8ac53..8197ce7a64e5558a280e05cfe9273f039f049ba1 100644 (file)
@@ -1257,23 +1257,6 @@ struct ib_mr *ib_create_mr(struct ib_pd *pd,
 }
 EXPORT_SYMBOL(ib_create_mr);
 
-int ib_destroy_mr(struct ib_mr *mr)
-{
-       struct ib_pd *pd;
-       int ret;
-
-       if (atomic_read(&mr->usecnt))
-               return -EBUSY;
-
-       pd = mr->pd;
-       ret = mr->device->destroy_mr(mr);
-       if (!ret)
-               atomic_dec(&pd->usecnt);
-
-       return ret;
-}
-EXPORT_SYMBOL(ib_destroy_mr);
-
 struct ib_mr *ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len)
 {
        struct ib_mr *mr;
index bac5f98965d0acdfcfdc81479f646a141d0b0bbb..48f02da87edc7aa955169cf92c17975e6b087af4 100644 (file)
@@ -1499,7 +1499,6 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
        dev->ib_dev.get_dma_mr          = mlx5_ib_get_dma_mr;
        dev->ib_dev.reg_user_mr         = mlx5_ib_reg_user_mr;
        dev->ib_dev.dereg_mr            = mlx5_ib_dereg_mr;
-       dev->ib_dev.destroy_mr          = mlx5_ib_destroy_mr;
        dev->ib_dev.attach_mcast        = mlx5_ib_mcg_attach;
        dev->ib_dev.detach_mcast        = mlx5_ib_mcg_detach;
        dev->ib_dev.process_mad         = mlx5_ib_process_mad;
index 7cae098364812242d549fc62d5585432051c3328..29c74e9ffc00b588e1726fb6f15789b732ba1a35 100644 (file)
@@ -573,7 +573,6 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 int mlx5_ib_update_mtt(struct mlx5_ib_mr *mr, u64 start_page_index,
                       int npages, int zap);
 int mlx5_ib_dereg_mr(struct ib_mr *ibmr);
-int mlx5_ib_destroy_mr(struct ib_mr *ibmr);
 struct ib_mr *mlx5_ib_create_mr(struct ib_pd *pd,
                                struct ib_mr_init_attr *mr_init_attr);
 struct ib_mr *mlx5_ib_alloc_fast_reg_mr(struct ib_pd *pd,
index 10d2b213a4d8599f60c3347136c18e17c0a05224..9559ee805696ddba63083e55ac40e620d5627907 100644 (file)
@@ -1170,6 +1170,19 @@ static int clean_mr(struct mlx5_ib_mr *mr)
        int umred = mr->umred;
        int err;
 
+       if (mr->sig) {
+               if (mlx5_core_destroy_psv(dev->mdev,
+                                         mr->sig->psv_memory.psv_idx))
+                       mlx5_ib_warn(dev, "failed to destroy mem psv %d\n",
+                                    mr->sig->psv_memory.psv_idx);
+               if (mlx5_core_destroy_psv(dev->mdev,
+                                         mr->sig->psv_wire.psv_idx))
+                       mlx5_ib_warn(dev, "failed to destroy wire psv %d\n",
+                                    mr->sig->psv_wire.psv_idx);
+               kfree(mr->sig);
+               mr->sig = NULL;
+       }
+
        if (!umred) {
                err = destroy_mkey(dev, mr);
                if (err) {
@@ -1317,36 +1330,6 @@ err_free:
        return ERR_PTR(err);
 }
 
-int mlx5_ib_destroy_mr(struct ib_mr *ibmr)
-{
-       struct mlx5_ib_dev *dev = to_mdev(ibmr->device);
-       struct mlx5_ib_mr *mr = to_mmr(ibmr);
-       int err;
-
-       if (mr->sig) {
-               if (mlx5_core_destroy_psv(dev->mdev,
-                                         mr->sig->psv_memory.psv_idx))
-                       mlx5_ib_warn(dev, "failed to destroy mem psv %d\n",
-                                    mr->sig->psv_memory.psv_idx);
-               if (mlx5_core_destroy_psv(dev->mdev,
-                                         mr->sig->psv_wire.psv_idx))
-                       mlx5_ib_warn(dev, "failed to destroy wire psv %d\n",
-                                    mr->sig->psv_wire.psv_idx);
-               kfree(mr->sig);
-       }
-
-       err = destroy_mkey(dev, mr);
-       if (err) {
-               mlx5_ib_warn(dev, "failed to destroy mkey 0x%x (%d)\n",
-                            mr->mmr.key, err);
-               return err;
-       }
-
-       kfree(mr);
-
-       return err;
-}
-
 struct ib_mr *mlx5_ib_alloc_fast_reg_mr(struct ib_pd *pd,
                                        int max_page_list_len)
 {
index 5c9f565ea0e88840c3c3c7a031e20180c3c8025d..712218675cf1c561fafd6c1468f65d03531b5830 100644 (file)
@@ -334,7 +334,7 @@ iser_free_pi_ctx(struct iser_pi_context *pi_ctx)
 {
        ib_free_fast_reg_page_list(pi_ctx->prot_frpl);
        ib_dereg_mr(pi_ctx->prot_mr);
-       ib_destroy_mr(pi_ctx->sig_mr);
+       ib_dereg_mr(pi_ctx->sig_mr);
        kfree(pi_ctx);
 }
 
index d851e1828d6f5152e9c8ca49de9b64a3b953f180..c054af17155371977a7ded4c6b22ba060ef26bdd 100644 (file)
@@ -491,7 +491,7 @@ isert_conn_free_fastreg_pool(struct isert_conn *isert_conn)
                if (fr_desc->pi_ctx) {
                        ib_free_fast_reg_page_list(fr_desc->pi_ctx->prot_frpl);
                        ib_dereg_mr(fr_desc->pi_ctx->prot_mr);
-                       ib_destroy_mr(fr_desc->pi_ctx->sig_mr);
+                       ib_dereg_mr(fr_desc->pi_ctx->sig_mr);
                        kfree(fr_desc->pi_ctx);
                }
                kfree(fr_desc);
index fd7a6950df75ea9bb4c0b1c222bd7ecedc6e615c..521c2059ede5afe415d592b76b84b50ebbfa7dae 100644 (file)
@@ -1671,7 +1671,6 @@ struct ib_device {
        int                        (*query_mr)(struct ib_mr *mr,
                                               struct ib_mr_attr *mr_attr);
        int                        (*dereg_mr)(struct ib_mr *mr);
-       int                        (*destroy_mr)(struct ib_mr *mr);
        struct ib_mr *             (*create_mr)(struct ib_pd *pd,
                                                struct ib_mr_init_attr *mr_init_attr);
        struct ib_mr *             (*alloc_fast_reg_mr)(struct ib_pd *pd,
@@ -2828,15 +2827,6 @@ int ib_dereg_mr(struct ib_mr *mr);
 struct ib_mr *ib_create_mr(struct ib_pd *pd,
                           struct ib_mr_init_attr *mr_init_attr);
 
-/**
- * ib_destroy_mr - Destroys a memory region that was created using
- *     ib_create_mr and removes it from HW translation tables.
- * @mr: The memory region to destroy.
- *
- * This function can fail, if the memory region has memory windows bound to it.
- */
-int ib_destroy_mr(struct ib_mr *mr);
-
 /**
  * ib_alloc_fast_reg_mr - Allocates memory region usable with the
  *   IB_WR_FAST_REG_MR send work request.