netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	Mark Bloch <markb@mellanox.com>,
	Yishai Hadas <yishaih@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>,
	linux-netdev <netdev@vger.kernel.org>
Subject: [PATCH mlx5-next 07/11] RDMA/mlx5: Use stages for callback to setup and release DEVX
Date: Wed, 28 Nov 2018 20:53:39 +0200	[thread overview]
Message-ID: <20181128185343.21669-8-leon@kernel.org> (raw)
In-Reply-To: <20181128185343.21669-1-leon@kernel.org>

From: Leon Romanovsky <leonro@mellanox.com>

Reuse existing infrastructure to initialize and release DEVX uid.
The DevX interface is intended for user space access, so it is supposed
to be initialized before ib_register_device(). Also it isn't supported
in switchdev mode and don't need to initialize it in that mode.

Fixes: 76dc5a8406bf ("IB/mlx5: Manage device uid for DEVX white list commands")
Reviewed-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx5/main.c    | 26 +++++++++++++++++++-------
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  1 +
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index b3d9af0cafc2..b15f1a70d33b 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -6218,6 +6218,22 @@ static void mlx5_ib_stage_dev_notifier_cleanup(struct mlx5_ib_dev *dev)
 	mlx5_notifier_unregister(dev->mdev, &dev->mdev_events);
 }

+static int mlx5_ib_stage_devx_init(struct mlx5_ib_dev *dev)
+{
+	int uid;
+
+	uid = mlx5_ib_devx_create(dev);
+	if (uid > 0)
+		dev->devx_whitelist_uid = uid;
+
+	return 0;
+}
+static void mlx5_ib_stage_devx_cleanup(struct mlx5_ib_dev *dev)
+{
+	if (dev->devx_whitelist_uid)
+		mlx5_ib_devx_destroy(dev, dev->devx_whitelist_uid);
+}
+
 void __mlx5_ib_remove(struct mlx5_ib_dev *dev,
 		      const struct mlx5_ib_profile *profile,
 		      int stage)
@@ -6229,8 +6245,6 @@ void __mlx5_ib_remove(struct mlx5_ib_dev *dev,
 			profile->stage[stage].cleanup(dev);
 	}

-	if (dev->devx_whitelist_uid)
-		mlx5_ib_devx_destroy(dev, dev->devx_whitelist_uid);
 	ib_dealloc_device((struct ib_device *)dev);
 }

@@ -6239,7 +6253,6 @@ void *__mlx5_ib_add(struct mlx5_ib_dev *dev,
 {
 	int err;
 	int i;
-	int uid;

 	for (i = 0; i < MLX5_IB_STAGE_MAX; i++) {
 		if (profile->stage[i].init) {
@@ -6249,10 +6262,6 @@ void *__mlx5_ib_add(struct mlx5_ib_dev *dev,
 		}
 	}

-	uid = mlx5_ib_devx_create(dev);
-	if (uid > 0)
-		dev->devx_whitelist_uid = uid;
-
 	dev->profile = profile;
 	dev->ib_active = true;

@@ -6304,6 +6313,9 @@ static const struct mlx5_ib_profile pf_profile = {
 	STAGE_CREATE(MLX5_IB_STAGE_PRE_IB_REG_UMR,
 		     NULL,
 		     mlx5_ib_stage_pre_ib_reg_umr_cleanup),
+	STAGE_CREATE(MLX5_IB_STAGE_WHITELIST_UID,
+		     mlx5_ib_stage_devx_init,
+		     mlx5_ib_stage_devx_cleanup),
 	STAGE_CREATE(MLX5_IB_STAGE_IB_REG,
 		     mlx5_ib_stage_ib_reg_init,
 		     mlx5_ib_stage_ib_reg_cleanup),
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 24af6fbb43e7..fe34129bb780 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -782,6 +782,7 @@ enum mlx5_ib_stages {
 	MLX5_IB_STAGE_UAR,
 	MLX5_IB_STAGE_BFREG,
 	MLX5_IB_STAGE_PRE_IB_REG_UMR,
+	MLX5_IB_STAGE_WHITELIST_UID,
 	MLX5_IB_STAGE_IB_REG,
 	MLX5_IB_STAGE_POST_IB_REG_UMR,
 	MLX5_IB_STAGE_DELAY_DROP,

  parent reply	other threads:[~2018-11-29  5:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28 18:53 [PATCH mlx5-next 00/11] Remove SRQ code from mlx5_core Leon Romanovsky
2018-11-28 18:53 ` [PATCH mlx5-next 01/11] net/mlx5: Align SRQ licenses and copyright information Leon Romanovsky
2018-11-28 18:53 ` [PATCH mlx5-next 02/11] net/mlx5: Remove dead transobj code Leon Romanovsky
2018-11-28 18:53 ` [PATCH mlx5-next 03/11] net/mlx5: Remove not-used lib/eq.h header file Leon Romanovsky
2018-11-28 18:53 ` [PATCH mlx5-next 04/11] net/mlx5: Remove references to local mlx5_core functions Leon Romanovsky
2018-11-28 18:53 ` [PATCH mlx5-next 05/11] net/mlx5: Move SRQ functions to RDMA part Leon Romanovsky
2018-11-28 18:53 ` [PATCH mlx5-next 06/11] RDMA/mlx5: Remove SRQ signature global flag Leon Romanovsky
2018-11-28 18:53 ` Leon Romanovsky [this message]
2018-11-28 18:53 ` [PATCH mlx5-next 08/11] RDMA/mlx5: Update SRQ functions signatures to mlx5_ib format Leon Romanovsky
2018-11-28 18:53 ` [PATCH mlx5-next 09/11] RDMA/mlx5: Initialize SRQ tables on mlx5_ib Leon Romanovsky
2018-11-28 18:53 ` [PATCH mlx5-next 10/11] RDMA/mlx5: Unfold create RMP function Leon Romanovsky
2018-11-28 18:53 ` [PATCH rdma-next 11/11] RDMA/mlx5: Unfold modify " Leon Romanovsky
2018-12-04  7:29 ` [PATCH mlx5-next 00/11] Remove SRQ code from mlx5_core Leon Romanovsky

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=20181128185343.21669-8-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=dledford@redhat.com \
    --cc=jgg@mellanox.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=markb@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    --cc=yishaih@mellanox.com \
    /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).