From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2E60C41621 for ; Tue, 24 Mar 2020 14:24:49 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 840C12078A for ; Tue, 24 Mar 2020 14:24:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 840C12078A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E9F824C8E; Tue, 24 Mar 2020 15:24:47 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 2E2E42BAE for ; Tue, 24 Mar 2020 15:24:46 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from asafp@mellanox.com) with ESMTPS (AES256-SHA encrypted); 24 Mar 2020 16:24:42 +0200 Received: from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 02OEOgQc022008; Tue, 24 Mar 2020 16:24:42 +0200 From: Asaf Penso To: dev@dpdk.org Cc: Viacheslav Ovsiienko , Shahaf Shuler , Maxime Coquelin , Matan Azrad Date: Tue, 24 Mar 2020 14:24:34 +0000 Message-Id: <1585059877-2369-2-git-send-email-asafp@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1585059877-2369-1-git-send-email-asafp@mellanox.com> References: <1585059877-2369-1-git-send-email-asafp@mellanox.com> Subject: [dpdk-dev] [PATCH 1/4] vdpa/mlx5: move virtual doorbell alloc to probe X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Matan Azrad 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 Acked-by: Viacheslav Ovsiienko --- 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