linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mike Marciniszyn
	<mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 04/31] staging/rdma/hfi1: Use rdmavt protection domain
Date: Tue, 19 Jan 2016 14:41:50 -0800	[thread overview]
Message-ID: <20160119224149.32765.48985.stgit@scvm10.sc.intel.com> (raw)
In-Reply-To: <20160119223610.32765.10571.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>

Remove protection domain from hfi1 and use rdmavt's version.

Reviewed-by: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/staging/rdma/hfi1/keys.c  |    4 +-
 drivers/staging/rdma/hfi1/mr.c    |    2 +
 drivers/staging/rdma/hfi1/ruc.c   |    4 +-
 drivers/staging/rdma/hfi1/verbs.c |   67 +++----------------------------------
 drivers/staging/rdma/hfi1/verbs.h |   15 +-------
 5 files changed, 12 insertions(+), 80 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/keys.c b/drivers/staging/rdma/hfi1/keys.c
index cb4e608..57a266f 100644
--- a/drivers/staging/rdma/hfi1/keys.c
+++ b/drivers/staging/rdma/hfi1/keys.c
@@ -176,7 +176,7 @@ out:
  * Check the IB SGE for validity and initialize our internal version
  * of it.
  */
-int hfi1_lkey_ok(struct hfi1_lkey_table *rkt, struct hfi1_pd *pd,
+int hfi1_lkey_ok(struct hfi1_lkey_table *rkt, struct rvt_pd *pd,
 		 struct hfi1_sge *isge, struct ib_sge *sge, int acc)
 {
 	struct hfi1_mregion *mr;
@@ -285,7 +285,7 @@ int hfi1_rkey_ok(struct hfi1_qp *qp, struct hfi1_sge *sge,
 	 */
 	rcu_read_lock();
 	if (rkey == 0) {
-		struct hfi1_pd *pd = to_ipd(qp->ibqp.pd);
+		struct rvt_pd *pd = ibpd_to_rvtpd(qp->ibqp.pd);
 		struct hfi1_ibdev *dev = to_idev(pd->ibpd.device);
 
 		if (pd->user)
diff --git a/drivers/staging/rdma/hfi1/mr.c b/drivers/staging/rdma/hfi1/mr.c
index a3f8b88..3f1ef58 100644
--- a/drivers/staging/rdma/hfi1/mr.c
+++ b/drivers/staging/rdma/hfi1/mr.c
@@ -116,7 +116,7 @@ struct ib_mr *hfi1_get_dma_mr(struct ib_pd *pd, int acc)
 	struct ib_mr *ret;
 	int rval;
 
-	if (to_ipd(pd)->user) {
+	if (ibpd_to_rvtpd(pd)->user) {
 		ret = ERR_PTR(-EPERM);
 		goto bail;
 	}
diff --git a/drivers/staging/rdma/hfi1/ruc.c b/drivers/staging/rdma/hfi1/ruc.c
index 4a91975..d255f31 100644
--- a/drivers/staging/rdma/hfi1/ruc.c
+++ b/drivers/staging/rdma/hfi1/ruc.c
@@ -102,11 +102,11 @@ static int init_sge(struct hfi1_qp *qp, struct hfi1_rwqe *wqe)
 	int i, j, ret;
 	struct ib_wc wc;
 	struct hfi1_lkey_table *rkt;
-	struct hfi1_pd *pd;
+	struct rvt_pd *pd;
 	struct hfi1_sge_state *ss;
 
 	rkt = &to_idev(qp->ibqp.device)->lk_table;
-	pd = to_ipd(qp->ibqp.srq ? qp->ibqp.srq->pd : qp->ibqp.pd);
+	pd = ibpd_to_rvtpd(qp->ibqp.srq ? qp->ibqp.srq->pd : qp->ibqp.pd);
 	ss = &qp->r_sge;
 	ss->sg_list = qp->r_sg_list;
 	qp->r_len = 0;
diff --git a/drivers/staging/rdma/hfi1/verbs.c b/drivers/staging/rdma/hfi1/verbs.c
index 347409e..ddfcfaf 100644
--- a/drivers/staging/rdma/hfi1/verbs.c
+++ b/drivers/staging/rdma/hfi1/verbs.c
@@ -368,7 +368,7 @@ static int post_one_send(struct hfi1_qp *qp, struct ib_send_wr *wr)
 	int j;
 	int acc;
 	struct hfi1_lkey_table *rkt;
-	struct hfi1_pd *pd;
+	struct rvt_pd *pd;
 	struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
 	struct hfi1_pportdata *ppd;
 	struct hfi1_ibport *ibp;
@@ -413,7 +413,7 @@ static int post_one_send(struct hfi1_qp *qp, struct ib_send_wr *wr)
 		return -ENOMEM;
 
 	rkt = &to_idev(qp->ibqp.device)->lk_table;
-	pd = to_ipd(qp->ibqp.pd);
+	pd = ibpd_to_rvtpd(qp->ibqp.pd);
 	wqe = get_swqe_ptr(qp, qp->s_head);
 
 
@@ -1394,7 +1394,7 @@ static int query_device(struct ib_device *ibdev,
 	props->max_mr = dev->lk_table.max;
 	props->max_fmr = dev->lk_table.max;
 	props->max_map_per_fmr = 32767;
-	props->max_pd = hfi1_max_pds;
+	props->max_pd = dev->rdi.dparms.props.max_pd;
 	props->max_qp_rd_atom = HFI1_MAX_RDMA_ATOMIC;
 	props->max_qp_init_rd_atom = 255;
 	/* props->max_res_rd_atom */
@@ -1592,61 +1592,6 @@ static int query_gid(struct ib_device *ibdev, u8 port,
 	return ret;
 }
 
-static struct ib_pd *alloc_pd(struct ib_device *ibdev,
-			      struct ib_ucontext *context,
-			      struct ib_udata *udata)
-{
-	struct hfi1_ibdev *dev = to_idev(ibdev);
-	struct hfi1_pd *pd;
-	struct ib_pd *ret;
-
-	/*
-	 * This is actually totally arbitrary.  Some correctness tests
-	 * assume there's a maximum number of PDs that can be allocated.
-	 * We don't actually have this limit, but we fail the test if
-	 * we allow allocations of more than we report for this value.
-	 */
-
-	pd = kmalloc(sizeof(*pd), GFP_KERNEL);
-	if (!pd) {
-		ret = ERR_PTR(-ENOMEM);
-		goto bail;
-	}
-
-	spin_lock(&dev->n_pds_lock);
-	if (dev->n_pds_allocated == hfi1_max_pds) {
-		spin_unlock(&dev->n_pds_lock);
-		kfree(pd);
-		ret = ERR_PTR(-ENOMEM);
-		goto bail;
-	}
-
-	dev->n_pds_allocated++;
-	spin_unlock(&dev->n_pds_lock);
-
-	/* ib_alloc_pd() will initialize pd->ibpd. */
-	pd->user = udata != NULL;
-
-	ret = &pd->ibpd;
-
-bail:
-	return ret;
-}
-
-static int dealloc_pd(struct ib_pd *ibpd)
-{
-	struct hfi1_pd *pd = to_ipd(ibpd);
-	struct hfi1_ibdev *dev = to_idev(ibpd->device);
-
-	spin_lock(&dev->n_pds_lock);
-	dev->n_pds_allocated--;
-	spin_unlock(&dev->n_pds_lock);
-
-	kfree(pd);
-
-	return 0;
-}
-
 /*
  * convert ah port,sl to sc
  */
@@ -1920,7 +1865,7 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
 		init_ibport(ppd + i);
 
 	/* Only need to initialize non-zero fields. */
-	spin_lock_init(&dev->n_pds_lock);
+
 	spin_lock_init(&dev->n_ahs_lock);
 	spin_lock_init(&dev->n_cqs_lock);
 	spin_lock_init(&dev->n_qps_lock);
@@ -2029,8 +1974,8 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
 	ibdev->query_gid = query_gid;
 	ibdev->alloc_ucontext = alloc_ucontext;
 	ibdev->dealloc_ucontext = dealloc_ucontext;
-	ibdev->alloc_pd = alloc_pd;
-	ibdev->dealloc_pd = dealloc_pd;
+	ibdev->alloc_pd = NULL;
+	ibdev->dealloc_pd = NULL;
 	ibdev->create_ah = create_ah;
 	ibdev->destroy_ah = destroy_ah;
 	ibdev->modify_ah = modify_ah;
diff --git a/drivers/staging/rdma/hfi1/verbs.h b/drivers/staging/rdma/hfi1/verbs.h
index a505545..3079149 100644
--- a/drivers/staging/rdma/hfi1/verbs.h
+++ b/drivers/staging/rdma/hfi1/verbs.h
@@ -234,12 +234,6 @@ struct hfi1_mcast {
 	int n_attached;
 };
 
-/* Protection domain */
-struct hfi1_pd {
-	struct ib_pd ibpd;
-	int user;               /* non-zero if created from user space */
-};
-
 /* Address Handle */
 struct hfi1_ah {
 	struct ib_ah ibah;
@@ -776,8 +770,6 @@ struct hfi1_ibdev {
 	u64 n_kmem_wait;
 	u64 n_send_schedule;
 
-	u32 n_pds_allocated;    /* number of PDs allocated for device */
-	spinlock_t n_pds_lock;
 	u32 n_ahs_allocated;    /* number of AHs allocated for device */
 	spinlock_t n_ahs_lock;
 	u32 n_cqs_allocated;    /* number of CQs allocated for device */
@@ -817,11 +809,6 @@ static inline struct hfi1_mr *to_imr(struct ib_mr *ibmr)
 	return container_of(ibmr, struct hfi1_mr, ibmr);
 }
 
-static inline struct hfi1_pd *to_ipd(struct ib_pd *ibpd)
-{
-	return container_of(ibpd, struct hfi1_pd, ibpd);
-}
-
 static inline struct hfi1_ah *to_iah(struct ib_ah *ibah)
 {
 	return container_of(ibah, struct hfi1_ah, ibah);
@@ -983,7 +970,7 @@ int hfi1_alloc_lkey(struct hfi1_mregion *mr, int dma_region);
 
 void hfi1_free_lkey(struct hfi1_mregion *mr);
 
-int hfi1_lkey_ok(struct hfi1_lkey_table *rkt, struct hfi1_pd *pd,
+int hfi1_lkey_ok(struct hfi1_lkey_table *rkt, struct rvt_pd *pd,
 		 struct hfi1_sge *isge, struct ib_sge *sge, int acc);
 
 int hfi1_rkey_ok(struct hfi1_qp *qp, struct hfi1_sge *sge,

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-01-19 22:41 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19 22:41 [PATCH 00/31] staging/rdma/hfi1: Add rdmavt support to hfi1 Dennis Dalessandro
     [not found] ` <20160119223610.32765.10571.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2016-01-19 22:41   ` [PATCH 01/31] staging/rdma/hfi1: Begin to use rdmavt for verbs Dennis Dalessandro
2016-01-19 22:41   ` [PATCH 02/31] staging/rdma/hfi1: Add basic rdmavt capability flags for hfi1 Dennis Dalessandro
2016-01-19 22:41   ` [PATCH 03/31] staging/rdma/hfi1: Consolidate dma ops " Dennis Dalessandro
2016-01-19 22:41   ` Dennis Dalessandro [this message]
2016-01-19 22:41   ` [PATCH 05/31] staging/rdma/hfi1: Remove MR data structures from hfi1 Dennis Dalessandro
2016-01-19 22:42   ` [PATCH 06/31] staging/rdma/hfi1: Remove driver specific members from hfi1 qp type Dennis Dalessandro
2016-01-19 22:42   ` [PATCH 07/31] staging/rdma/hfi1: Add device specific info prints Dennis Dalessandro
2016-01-19 22:42   ` [PATCH 08/31] staging/rdma/hfi1: Use correct rdmavt header files after move Dennis Dalessandro
2016-01-19 22:42   ` [PATCH 09/31] staging/rdma/hfi1: Use address handle in rdmavt and remove from hfi1 Dennis Dalessandro
2016-01-19 22:42   ` [PATCH 10/31] staging/rdma/hfi1: Implement hfi1 support for AH notification Dennis Dalessandro
2016-01-19 22:42   ` [PATCH 11/31] staging/rdma/hfi1: Remove hfi1 MR and hfi1 specific qp type Dennis Dalessandro
2016-01-19 22:42   ` [PATCH 12/31] staging/rdma/hfi1: Remove srq from hfi1 Dennis Dalessandro
2016-01-19 22:42   ` [PATCH 13/31] staging/rdma/hfi1: Remove ibport and use rdmavt version Dennis Dalessandro
2016-01-19 22:42   ` [PATCH 14/31] staging/rdma/hfi1: Remove mmap from hfi1 Dennis Dalessandro
2016-01-19 22:42   ` [PATCH 15/31] staging/rdma/hfi1: Use rdmavt pkey verbs function Dennis Dalessandro
2016-01-19 22:42   ` [PATCH 16/31] staging/rdma/hfi1: Remove user context allocation and de-alloction functions Dennis Dalessandro
2016-01-19 22:43   ` [PATCH 17/31] staging/rdma/hfi1: Use rdmavt send flags and recv flags Dennis Dalessandro
2016-01-19 22:43   ` [PATCH 18/31] staging/rdma/hfi1: Remove qpdev and qpn table from hfi1 Dennis Dalessandro
2016-01-19 22:43   ` [PATCH 19/31] staging/rdma/hfi1: Remove create_qp functionality Dennis Dalessandro
2016-01-19 22:43   ` [PATCH 20/31] staging/rdma/hfi1: Remove query_device function Dennis Dalessandro
2016-01-19 22:43   ` [PATCH 21/31] staging/rdma/hfi1: Remove CQ data structures and functions from hfi1 Dennis Dalessandro
2016-01-19 22:43   ` [PATCH 22/31] staging/rdma/hfi1: Clean up return handling Dennis Dalessandro
2016-01-19 22:43   ` [PATCH 23/31] staging/rdma/hfi1: Use rdmavt version of post_send Dennis Dalessandro
2016-01-19 22:43   ` [PATCH 24/31] staging/rdma/hfi1: Remove multicast verbs functions Dennis Dalessandro
2016-01-19 22:43   ` [PATCH 25/31] staging/rdma/hfi1: Remove modify queue pair from hfi1 Dennis Dalessandro
2016-01-19 22:43   ` [PATCH 26/31] staging/rdma/hfi1: Remove destroy qp verb Dennis Dalessandro
2016-01-19 22:43   ` [PATCH 27/31] staging/rdma/hfi1: Remove post_recv and use rdmavt version Dennis Dalessandro
2016-01-19 22:44   ` [PATCH 28/31] staging/rdma/hfi1: Clean up register device Dennis Dalessandro
2016-01-19 22:44   ` [PATCH 29/31] staging/rdma/hfi1: Use rdmavt device allocation function Dennis Dalessandro
2016-01-19 22:44   ` [PATCH 30/31] staging/rdma/hfi1: Remove create and free mad agents Dennis Dalessandro
2016-01-19 22:44   ` [PATCH 31/31] staging/rdma/hfi1: Remove hfi1_query_qp function Dennis Dalessandro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160119224149.32765.48985.stgit@scvm10.sc.intel.com \
    --to=dennis.dalessandro-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).