IB: remove the write-only usecnt field from struct ib_mr
authorChristoph Hellwig <hch@lst.de>
Wed, 23 Dec 2015 18:12:54 +0000 (19:12 +0100)
committerDoug Ledford <dledford@redhat.com>
Wed, 23 Dec 2015 19:29:06 +0000 (14:29 -0500)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@sandisk.com>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/verbs.c
drivers/infiniband/hw/cxgb3/iwch_provider.c
drivers/infiniband/hw/cxgb4/mem.c
drivers/staging/rdma/ehca/ehca_mrmw.c
include/rdma/ib_verbs.h

index 5428ebee096f04347b5b13b18c19f17d372f509c..0a84182d277fb856f83de6cbd0c0543b6297e248 100644 (file)
@@ -993,7 +993,6 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
        mr->pd      = pd;
        mr->uobject = uobj;
        atomic_inc(&pd->usecnt);
-       atomic_set(&mr->usecnt, 0);
 
        uobj->object = mr;
        ret = idr_add_uobj(&ib_uverbs_mr_idr, uobj);
@@ -1091,11 +1090,6 @@ ssize_t ib_uverbs_rereg_mr(struct ib_uverbs_file *file,
                }
        }
 
-       if (atomic_read(&mr->usecnt)) {
-               ret = -EBUSY;
-               goto put_uobj_pd;
-       }
-
        old_pd = mr->pd;
        ret = mr->device->rereg_user_mr(mr, cmd.flags, cmd.start,
                                        cmd.length, cmd.hca_va,
index c5e0f07a7f829e5443b1fc1d24f694d72d012e23..072b94df870a6b2de69987e9d5154a428834c8a6 100644 (file)
@@ -1345,7 +1345,6 @@ struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags)
                mr->pd      = pd;
                mr->uobject = NULL;
                atomic_inc(&pd->usecnt);
-               atomic_set(&mr->usecnt, 0);
        }
 
        return mr;
@@ -1354,13 +1353,9 @@ EXPORT_SYMBOL(ib_get_dma_mr);
 
 int ib_dereg_mr(struct ib_mr *mr)
 {
-       struct ib_pd *pd;
+       struct ib_pd *pd = mr->pd;
        int ret;
 
-       if (atomic_read(&mr->usecnt))
-               return -EBUSY;
-
-       pd = mr->pd;
        ret = mr->device->dereg_mr(mr);
        if (!ret)
                atomic_dec(&pd->usecnt);
@@ -1396,7 +1391,6 @@ struct ib_mr *ib_alloc_mr(struct ib_pd *pd,
                mr->pd      = pd;
                mr->uobject = NULL;
                atomic_inc(&pd->usecnt);
-               atomic_set(&mr->usecnt, 0);
        }
 
        return mr;
index 6743e9ddb088a1b03810ca1ecfbdcc4426759e53..2734820d291b02387b8e925bb5f09ab6e23418dd 100644 (file)
@@ -458,9 +458,6 @@ static int iwch_dereg_mr(struct ib_mr *ib_mr)
        u32 mmid;
 
        PDBG("%s ib_mr %p\n", __func__, ib_mr);
-       /* There can be no memory windows */
-       if (atomic_read(&ib_mr->usecnt))
-               return -EINVAL;
 
        mhp = to_iwch_mr(ib_mr);
        kfree(mhp->pages);
index 1eb833aa0eb117b61044e06ee681be64f76ac925..7849890c478141e57136127c84f4cad9fd46227d 100644 (file)
@@ -704,9 +704,6 @@ int c4iw_dereg_mr(struct ib_mr *ib_mr)
        u32 mmid;
 
        PDBG("%s ib_mr %p\n", __func__, ib_mr);
-       /* There can be no memory windows */
-       if (atomic_read(&ib_mr->usecnt))
-               return -EINVAL;
 
        mhp = to_c4iw_mr(ib_mr);
        rhp = mhp->rhp;
index 1814af72cf2afd5334a562f44f6f09c5da91a505..06b832be9dfb3524b9ef466616c1ffacbb29efe8 100644 (file)
@@ -1339,7 +1339,6 @@ int ehca_reg_internal_maxmr(
        e_mr->ib.ib_mr.pd = &e_pd->ib_pd;
        e_mr->ib.ib_mr.uobject = NULL;
        atomic_inc(&(e_pd->ib_pd.usecnt));
-       atomic_set(&(e_mr->ib.ib_mr.usecnt), 0);
        *e_maxmr = e_mr;
        return 0;
 
index 197b620eec9f771c4fcda53820baa42de94fb463..36acb30eac85deb0de110db20c3594b80513e381 100644 (file)
@@ -1414,7 +1414,6 @@ struct ib_mr {
        u64                iova;
        u32                length;
        unsigned int       page_size;
-       atomic_t           usecnt; /* count number of MWs */
 };
 
 struct ib_mw {