DPDK patches and discussions
 help / color / mirror / Atom feed
From: Asaf Penso <asafp@mellanox.com>
To: dev@dpdk.org
Cc: Viacheslav Ovsiienko <viacheslavo@mellanox.com>,
	Shahaf Shuler <shahafs@mellanox.com>,
	Maxime Coquelin <maxime.coquelin@redhat.com>,
	Matan Azrad <matan@mellanox.com>
Subject: [dpdk-dev] [PATCH 1/4] vdpa/mlx5: move virtual doorbell alloc to probe
Date: Tue, 24 Mar 2020 14:24:34 +0000	[thread overview]
Message-ID: <1585059877-2369-2-git-send-email-asafp@mellanox.com> (raw)
In-Reply-To: <1585059877-2369-1-git-send-email-asafp@mellanox.com>

From: Matan Azrad <matan@mellanox.com>

The configure and close operations may be called a lot of time by vhost
library according to the virtio connections in the guest.

VAR is the device memory space for the virtio queues doorbells.
Each VAR page can be shared for more than one queue while its owner must
synchronize the writes to it.

The mlx5 driver allocates single VAR page for all its queues.

Therefore, it is better to allocate it in probe device level instead of
creating and destroying it per new connection.

Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 drivers/vdpa/mlx5/mlx5_vdpa.c       | 14 +++++++++++++-
 drivers/vdpa/mlx5/mlx5_vdpa_virtq.c |  9 ---------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 97d914a..5542c29 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -447,6 +447,11 @@
 	priv->ctx = ctx;
 	priv->dev_addr.pci_addr = pci_dev->addr;
 	priv->dev_addr.type = PCI_ADDR;
+	priv->var = mlx5_glue->dv_alloc_var(ctx, 0);
+	if (!priv->var) {
+		DRV_LOG(ERR, "Failed to allocate VAR %u.\n", errno);
+		goto error;
+	}
 	priv->id = rte_vdpa_register_device(&priv->dev_addr, &mlx5_vdpa_ops);
 	if (priv->id < 0) {
 		DRV_LOG(ERR, "Failed to register vDPA device.");
@@ -461,8 +466,11 @@
 	return 0;
 
 error:
-	if (priv)
+	if (priv) {
+		if (priv->var)
+			mlx5_glue->dv_free_var(priv->var);
 		rte_free(priv);
+	}
 	if (ctx)
 		mlx5_glue->close_device(ctx);
 	return -rte_errno;
@@ -499,6 +507,10 @@
 	if (found) {
 		if (priv->configured)
 			mlx5_vdpa_dev_close(priv->vid);
+		if (priv->var) {
+			mlx5_glue->dv_free_var(priv->var);
+			priv->var = NULL;
+		}
 		mlx5_glue->close_device(priv->ctx);
 		rte_free(priv);
 	}
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
index 2312331..6390385 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
@@ -105,10 +105,6 @@
 		claim_zero(munmap(priv->virtq_db_addr, priv->var->length));
 		priv->virtq_db_addr = NULL;
 	}
-	if (priv->var) {
-		mlx5_glue->dv_free_var(priv->var);
-		priv->var = NULL;
-	}
 	priv->features = 0;
 }
 
@@ -343,11 +339,6 @@
 		DRV_LOG(ERR, "Failed to configure negotiated features.");
 		return -1;
 	}
-	priv->var = mlx5_glue->dv_alloc_var(priv->ctx, 0);
-	if (!priv->var) {
-		DRV_LOG(ERR, "Failed to allocate VAR %u.\n", errno);
-		return -1;
-	}
 	/* Always map the entire page. */
 	priv->virtq_db_addr = mmap(NULL, priv->var->length, PROT_READ |
 				   PROT_WRITE, MAP_SHARED, priv->ctx->cmd_fd,
-- 
1.8.3.1


  reply	other threads:[~2020-03-24 14:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 14:24 [dpdk-dev] [PATCH 0/4] vdpa/mlx5: support direct notification Asaf Penso
2020-03-24 14:24 ` Asaf Penso [this message]
2020-04-15  9:44   ` [dpdk-dev] [PATCH 1/4] vdpa/mlx5: move virtual doorbell alloc to probe Maxime Coquelin
2020-03-24 14:24 ` [dpdk-dev] [PATCH 2/4] vdpa/mlx5: support direct HW notifications Asaf Penso
2020-04-15  9:47   ` Maxime Coquelin
2020-04-17 11:54     ` Maxime Coquelin
2020-04-26  7:06       ` Matan Azrad
2020-04-27  7:45         ` Maxime Coquelin
2020-03-24 14:24 ` [dpdk-dev] [PATCH 3/4] vdpa/mlx5: validate notifier configuration Asaf Penso
2020-04-15  9:54   ` Maxime Coquelin
2020-03-24 14:24 ` [dpdk-dev] [PATCH 4/4] vdpa/mlx5: add log prints Asaf Penso
2020-04-17 11:54   ` Maxime Coquelin
2020-04-17 17:14 ` [dpdk-dev] [PATCH 0/4] vdpa/mlx5: support direct notification Maxime Coquelin

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=1585059877-2369-2-git-send-email-asafp@mellanox.com \
    --to=asafp@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=shahafs@mellanox.com \
    --cc=viacheslavo@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).