mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roland Dreier <rolandd@cisco.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, openib-general@openib.org
Subject: [PATCH 12/16] IB uverbs: add mthca user PD support
Date: Tue, 28 Jun 2005 16:03:43 -0700	[thread overview]
Message-ID: <2005628163.px5sYyzsYWf21dJY@cisco.com> (raw)
In-Reply-To: <2005628163.gtJFW6uLUrGQteys@cisco.com>

Add support for userspace protection domains (PDs) to mthca.

Signed-off-by: Roland Dreier <rolandd@cisco.com>

---

 drivers/infiniband/hw/mthca/mthca_dev.h      |    3 ++-
 drivers/infiniband/hw/mthca/mthca_main.c     |    2 +-
 drivers/infiniband/hw/mthca/mthca_pd.c       |   24 +++++++++++++++---------
 drivers/infiniband/hw/mthca/mthca_provider.c |   10 +++++++++-
 drivers/infiniband/hw/mthca/mthca_provider.h |    1 +
 5 files changed, 28 insertions(+), 12 deletions(-)



--- linux.orig/drivers/infiniband/hw/mthca/mthca_dev.h	2005-06-28 15:19:20.685397179 -0700
+++ linux/drivers/infiniband/hw/mthca/mthca_dev.h	2005-06-28 15:20:20.514467380 -0700
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2005 Cisco Systems.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -378,7 +379,7 @@ void mthca_unregister_device(struct mthc
 int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar);
 void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar);
 
-int mthca_pd_alloc(struct mthca_dev *dev, struct mthca_pd *pd);
+int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd);
 void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd);
 
 struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size);
--- linux.orig/drivers/infiniband/hw/mthca/mthca_main.c	2005-06-28 15:19:20.685397179 -0700
+++ linux/drivers/infiniband/hw/mthca/mthca_main.c	2005-06-28 15:20:20.515467163 -0700
@@ -665,7 +665,7 @@ static int __devinit mthca_setup_hca(str
 		goto err_pd_table_free;
 	}
 
-	err = mthca_pd_alloc(dev, &dev->driver_pd);
+	err = mthca_pd_alloc(dev, 1, &dev->driver_pd);
 	if (err) {
 		mthca_err(dev, "Failed to create driver PD, "
 			  "aborting.\n");
--- linux.orig/drivers/infiniband/hw/mthca/mthca_pd.c	2005-06-28 15:19:20.684397395 -0700
+++ linux/drivers/infiniband/hw/mthca/mthca_pd.c	2005-06-28 15:20:20.513467597 -0700
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
+ * Copyright (c) 2005 Cisco Systems.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -37,23 +38,27 @@
 
 #include "mthca_dev.h"
 
-int mthca_pd_alloc(struct mthca_dev *dev, struct mthca_pd *pd)
+int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd)
 {
-	int err;
+	int err = 0;
 
 	might_sleep();
 
+	pd->privileged = privileged;
+
 	atomic_set(&pd->sqp_count, 0);
 	pd->pd_num = mthca_alloc(&dev->pd_table.alloc);
 	if (pd->pd_num == -1)
 		return -ENOMEM;
 
-	err = mthca_mr_alloc_notrans(dev, pd->pd_num,
-				     MTHCA_MPT_FLAG_LOCAL_READ |
-				     MTHCA_MPT_FLAG_LOCAL_WRITE,
-				     &pd->ntmr);
-	if (err)
-		mthca_free(&dev->pd_table.alloc, pd->pd_num);
+	if (privileged) {
+		err = mthca_mr_alloc_notrans(dev, pd->pd_num,
+					     MTHCA_MPT_FLAG_LOCAL_READ |
+					     MTHCA_MPT_FLAG_LOCAL_WRITE,
+					     &pd->ntmr);
+		if (err)
+			mthca_free(&dev->pd_table.alloc, pd->pd_num);
+	}
 
 	return err;
 }
@@ -61,7 +66,8 @@ int mthca_pd_alloc(struct mthca_dev *dev
 void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd)
 {
 	might_sleep();
-	mthca_free_mr(dev, &pd->ntmr);
+	if (pd->privileged)
+		mthca_free_mr(dev, &pd->ntmr);
 	mthca_free(&dev->pd_table.alloc, pd->pd_num);
 }
 
--- linux.orig/drivers/infiniband/hw/mthca/mthca_provider.c	2005-06-28 15:20:18.380930082 -0700
+++ linux/drivers/infiniband/hw/mthca/mthca_provider.c	2005-06-28 15:20:20.513467597 -0700
@@ -368,12 +368,20 @@ static struct ib_pd *mthca_alloc_pd(stru
 	if (!pd)
 		return ERR_PTR(-ENOMEM);
 
-	err = mthca_pd_alloc(to_mdev(ibdev), pd);
+	err = mthca_pd_alloc(to_mdev(ibdev), !context, pd);
 	if (err) {
 		kfree(pd);
 		return ERR_PTR(err);
 	}
 
+	if (context) {
+		if (ib_copy_to_udata(udata, &pd->pd_num, sizeof (__u32))) {
+			mthca_pd_free(to_mdev(ibdev), pd);
+			kfree(pd);
+			return ERR_PTR(-EFAULT);
+		}
+	}
+
 	return &pd->ibpd;
 }
 
--- linux.orig/drivers/infiniband/hw/mthca/mthca_provider.h	2005-06-28 15:20:16.612313643 -0700
+++ linux/drivers/infiniband/hw/mthca/mthca_provider.h	2005-06-28 15:20:20.514467380 -0700
@@ -92,6 +92,7 @@ struct mthca_pd {
 	u32             pd_num;
 	atomic_t        sqp_count;
 	struct mthca_mr ntmr;
+	int             privileged;
 };
 
 struct mthca_eq {

  reply	other threads:[~2005-06-28 23:43 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-28 23:03 [PATCH 00/16] Add InfiniBand userspace verbs (direct userspace access) Roland Dreier
2005-06-28 23:03 ` [PATCH 01/16] IB uverbs: core API extensions Roland Dreier
2005-06-28 23:03   ` [PATCH 02/16] IB uverbs: update kernel midlayer for new API Roland Dreier
2005-06-28 23:03     ` [PATCH 03/16] IB uverbs: update mthca " Roland Dreier
2005-06-28 23:03       ` [PATCH 04/16] IB uverbs: add user verbs ABI header Roland Dreier
2005-06-28 23:03         ` [PATCH 05/16] IB uverbs: core implementation Roland Dreier
2005-06-28 23:03           ` [PATCH 06/16] IB uverbs: memory pinning implementation Roland Dreier
2005-06-28 23:03             ` [PATCH 07/16] IB uverbs: hook up Kconfig/Makefile Roland Dreier
2005-06-28 23:03               ` [PATCH 08/16] IB uverbs: add mthca ABI header Roland Dreier
2005-06-28 23:03                 ` [PATCH 09/16] IB uverbs: add mthca user doorbell record support Roland Dreier
2005-06-28 23:03                   ` [PATCH 10/16] IB uverbs: add mthca user context support Roland Dreier
2005-06-28 23:03                     ` [PATCH 11/16] IB uverbs: add mthca mmap support Roland Dreier
2005-06-28 23:03                       ` Roland Dreier [this message]
2005-06-28 23:03                         ` [PATCH 13/16] IB uverbs: add mthca user MR support Roland Dreier
2005-06-28 23:03                           ` [PATCH 14/16] IB uverbs: add mthca user CQ support Roland Dreier
2005-06-28 23:03                             ` [PATCH 15/16] IB uverbs: add mthca user QP support Roland Dreier
2005-06-28 23:03                               ` [PATCH 16/16] IB uverbs: add documentation file Roland Dreier
2005-06-29  0:10                             ` [PATCH 14/16] IB uverbs: add mthca user CQ support Andrew Morton
2005-06-29 16:06                               ` Roland Dreier
2005-06-29  0:07                         ` [PATCH 12/16] IB uverbs: add mthca user PD support Andrew Morton
2005-06-29 16:06                           ` Roland Dreier
2005-06-29  0:05                       ` [PATCH 11/16] IB uverbs: add mthca mmap support Andrew Morton
2005-06-29 16:06                         ` Roland Dreier
2005-07-05 19:20                         ` Roland Dreier
2005-07-05 20:53                           ` Michael S. Tsirkin
2005-07-05 22:07                             ` Roland Dreier
2005-06-29  0:02             ` [PATCH 06/16] IB uverbs: memory pinning implementation Andrew Morton
2005-06-29 16:06               ` Roland Dreier
2005-06-29  0:27           ` [PATCH 05/16] IB uverbs: core implementation Greg KH
2005-06-29  1:38             ` [openib-general] " Tom Duffy
2005-06-29  4:13             ` Troy Benjegerdes
2005-06-29 16:12               ` Greg KH
2005-06-29 16:32                 ` Troy Benjegerdes
2005-06-29 16:06             ` Roland Dreier
2005-06-29 17:01             ` Roland Dreier
2005-06-29 18:03               ` Greg KH
2005-06-30  3:13             ` [openib-general] " Ronald G. Minnich

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=2005628163.px5sYyzsYWf21dJY@cisco.com \
    --to=rolandd@cisco.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openib-general@openib.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

all inboxes | Powered by JetHome®