From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CC63CA0C41 for ; Sun, 7 Nov 2021 16:30:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8737D41140; Sun, 7 Nov 2021 16:30:31 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2055.outbound.protection.outlook.com [40.107.92.55]) by mails.dpdk.org (Postfix) with ESMTP id 07B6C4111A; Sun, 7 Nov 2021 16:30:30 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VLNsY32UJRPwHbogKwoD/JX9AqbOVyF/WWPFQOAYOQuv83h4TtwpKzaYSkgSatXwQ4x3ATlIx5X+JOg2bygo+m9nTFkDDGF78WZzcT5nApRFYKi4CyuSsGFN136+8KRV/C5FvSvTA+MzVb4wukHRXb8GG4mX8sr6NKKISrLlDoqJBx/2ho4BFLgwAm4X7MRYsN39QWcs70kf9LC8X44/H5YcfYHK9tfiRFbmN/5GSu/RtGfJCE6r//lAhspdlGe+ENMSc/TNwBWHXkC/kj/zLmtbJjondH18x5UUw13JFK9xaiNo47i2bVhdz5TXazY0oXrZtPJ5PXT5jVXMdNdOgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DO/rcYttn5sV90gE4sGEueJVlZf6dKUCl+RAfD2Ounw=; b=P0eo2p/5N7tC5WW4K2Jdtxz5bzxtOgQvd9ekDoVqVtSnKjNgxSSSlPPQAoLqj56BT38avK5ClEmpxbGD3WQkiG4qdZjRFvfXEwnQUEqOiRrXKFfiOj1080QcZS0MoSQL7iFh6JFL++BVbK9lDOiZQnNNVWb4pBgid5AyVA82buTgb9A8ep2/zrO555PT+VXPRSQ7Kam6vEoDzXC/29WhVDd5LdZp5QOgsOJK6q3pZh4aFHweBbAELr0r+Nkl+LdID3EagFCV6jLQA7POZsOdSx227b6eoPN/PlHWbKk53GiyFhUWmLDXuWAxspIaCRRLr1pFMPfjUxcGiD2rssubcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DO/rcYttn5sV90gE4sGEueJVlZf6dKUCl+RAfD2Ounw=; b=NvzLVifTJKfRd9XCq7amdMlv7yxo5fN1du5N1FNzHSowl58PqXO4+NzsyXBcYW5ch/RkEkiWRhKudqtHguwaglU3aGX7FmJMcu9SYN16Af0jPk6IDP/CqOiQXxJ/GA0NQAM25CJ1DciyXmCMbSLeKTcq3q0ddZnZ4ta/E9QqQBdSv5YONy6w8yqwnnWDP5UArk5NKAhCxwFH7V24w1ExI2WYFa+6KphkmIh7Z8N4rsINurSxL2BLJ2la0DogGMnPPvucO3zykf+YN6T2KlsHcr/G2EgLSBbE8WihFeKJvJl78N0fYFzoFE0EQDSFpo/t73d3SA65JY2srBmEp+luCw== Received: from MWHPR18CA0043.namprd18.prod.outlook.com (2603:10b6:320:31::29) by DM6PR12MB4355.namprd12.prod.outlook.com (2603:10b6:5:2a3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Sun, 7 Nov 2021 15:30:28 +0000 Received: from CO1NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:320:31:cafe::41) by MWHPR18CA0043.outlook.office365.com (2603:10b6:320:31::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Sun, 7 Nov 2021 15:30:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT010.mail.protection.outlook.com (10.13.175.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Sun, 7 Nov 2021 15:30:27 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 7 Nov 2021 15:30:25 +0000 From: Matan Azrad To: Viacheslav Ovsiienko CC: , Thomas Monjalon , Michael Baum , Date: Sun, 7 Nov 2021 17:29:18 +0200 Message-ID: <20211107152919.2158802-5-matan@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211107152919.2158802-1-matan@nvidia.com> References: <20211107152919.2158802-1-matan@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc36677d-fc24-4908-1112-08d9a20386b8 X-MS-TrafficTypeDiagnostic: DM6PR12MB4355: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:130; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p/c9N77CYhfa0x+ik3UCdC0hGQlK7YVgW6YZIIYfvzRP/UTObPOHBJz440KkErCFz9P4bFGVKPPlsFcVW1lfqUqIcB4b68uBiCOW3N7KHXyFXzUrJ7u/BKKjWyYXndFFms9WekrGH0AAVB7EAvi9AKraJkYral+EDKYET1smNSt1Nimp2jhJXMsgV3oJ9lzyUwKvc/gNj03gvhNf4dsOAOA696cwQLm0xuswJUIrIu9z0hSMVpDcenr3Pm7SOfjf6sv8mu5iMswyYaLS1YnPWEZ8iHPhW4ZDue1WsqyIr8ctmf93q4sJVORdcbnlvy/UtOvSqLRpUgVV/pxBCH8M7yMLtuX+tW4e6nwb+Sz/nqR+qFETCHWghXn0QsZqire85fWBczkLquZ8GjitPqdmXSxMD8PfLnu9Tmt1Jeh3113RCgCMjaN6UfeWJz6VWPUeC6eJdumhySXk8sZjOPMvJ699h0zYFZHFmGFHVJvLNZMqSx0TKdUZ5srf/42/wA6Igx+NoauPfLSXyzraTVQrdFRdKO/skTQBp4orh7neqROHXaDyvCxBj3AisCxBq94bOhmh3ynZDMTCMxGYDD4ArDtBgOn1KmNak0u4p0dWlG69hywtWeciJvNH07i9FUaQfvF71IpY0PDa4J3ZfEzeDwWt26PG8bPtOSZvhGnMnpU2n+2KpIxdx+la30MA+/cxDMzXsdeBsHvHdBPDG/deEw== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(37006003)(6636002)(26005)(8936002)(55016002)(356005)(186003)(7636003)(316002)(54906003)(82310400003)(4326008)(2906002)(508600001)(70586007)(70206006)(47076005)(1076003)(7696005)(5660300002)(6666004)(426003)(86362001)(6286002)(6862004)(16526019)(83380400001)(8676002)(2616005)(36756003)(36860700001)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2021 15:30:27.7397 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc36677d-fc24-4908-1112-08d9a20386b8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4355 Subject: [dpdk-stable] [PATCH 4/5] vdpa/mlx5: workaround guest MR registrations X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Michael Baum Due to kernel issue in direct MKEY creation using the DevX API, this patch replaces the virtio MR creation to use Verbs API. Fixes: cc07a42da250 ("vdpa/mlx5: prepare memory regions") Cc: stable@dpdk.org Signed-off-by: Michael Baum Signed-off-by: Matan Azrad --- drivers/vdpa/mlx5/mlx5_vdpa.h | 8 +++--- drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 41 +++++++++---------------------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h index 3a7cf088b8..f290fb4895 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.h +++ b/drivers/vdpa/mlx5/mlx5_vdpa.h @@ -59,10 +59,10 @@ struct mlx5_vdpa_event_qp { struct mlx5_vdpa_query_mr { SLIST_ENTRY(mlx5_vdpa_query_mr) next; - void *addr; - uint64_t length; - struct mlx5dv_devx_umem *umem; - struct mlx5_devx_obj *mkey; + union { + struct ibv_mr *mr; + struct mlx5_devx_obj *mkey; + }; int is_indirect; }; diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c index d7707bbd91..b1b9053bff 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c @@ -23,9 +23,10 @@ mlx5_vdpa_mem_dereg(struct mlx5_vdpa_priv *priv) entry = SLIST_FIRST(&priv->mr_list); while (entry) { next = SLIST_NEXT(entry, next); - claim_zero(mlx5_devx_cmd_destroy(entry->mkey)); - if (!entry->is_indirect) - claim_zero(mlx5_glue->devx_umem_dereg(entry->umem)); + if (entry->is_indirect) + claim_zero(mlx5_devx_cmd_destroy(entry->mkey)); + else + claim_zero(mlx5_glue->dereg_mr(entry->mr)); SLIST_REMOVE(&priv->mr_list, entry, mlx5_vdpa_query_mr, next); rte_free(entry); entry = next; @@ -202,7 +203,6 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) goto error; } DRV_LOG(DEBUG, "Dump fill Mkey = %u.", priv->null_mr->lkey); - memset(&mkey_attr, 0, sizeof(mkey_attr)); for (i = 0; i < mem->nregions; i++) { reg = &mem->regions[i]; entry = rte_zmalloc(__func__, sizeof(*entry), 0); @@ -211,28 +211,15 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) DRV_LOG(ERR, "Failed to allocate mem entry memory."); goto error; } - entry->umem = mlx5_glue->devx_umem_reg(priv->cdev->ctx, - (void *)(uintptr_t)reg->host_user_addr, - reg->size, IBV_ACCESS_LOCAL_WRITE); - if (!entry->umem) { - DRV_LOG(ERR, "Failed to register Umem by Devx."); - ret = -errno; - goto error; - } - mkey_attr.addr = (uintptr_t)(reg->guest_phys_addr); - mkey_attr.size = reg->size; - mkey_attr.umem_id = entry->umem->umem_id; - mkey_attr.pd = priv->cdev->pdn; - mkey_attr.pg_access = 1; - entry->mkey = mlx5_devx_cmd_mkey_create(priv->cdev->ctx, - &mkey_attr); - if (!entry->mkey) { + entry->mr = mlx5_glue->reg_mr_iova(priv->cdev->pd, + (void *)(uintptr_t)(reg->host_user_addr), + reg->size, reg->guest_phys_addr, + IBV_ACCESS_LOCAL_WRITE); + if (!entry->mr) { DRV_LOG(ERR, "Failed to create direct Mkey."); ret = -rte_errno; goto error; } - entry->addr = (void *)(uintptr_t)(reg->host_user_addr); - entry->length = reg->size; entry->is_indirect = 0; if (i > 0) { uint64_t sadd; @@ -262,12 +249,13 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) for (k = 0; k < reg->size; k += klm_size) { klm_array[klm_index].byte_count = k + klm_size > reg->size ? reg->size - k : klm_size; - klm_array[klm_index].mkey = entry->mkey->id; + klm_array[klm_index].mkey = entry->mr->lkey; klm_array[klm_index].address = reg->guest_phys_addr + k; klm_index++; } SLIST_INSERT_HEAD(&priv->mr_list, entry, next); } + memset(&mkey_attr, 0, sizeof(mkey_attr)); mkey_attr.addr = (uintptr_t)(mem->regions[0].guest_phys_addr); mkey_attr.size = mem_size; mkey_attr.pd = priv->cdev->pdn; @@ -295,13 +283,8 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) priv->gpa_mkey_index = entry->mkey->id; return 0; error: - if (entry) { - if (entry->mkey) - mlx5_devx_cmd_destroy(entry->mkey); - if (entry->umem) - mlx5_glue->devx_umem_dereg(entry->umem); + if (entry) rte_free(entry); - } mlx5_vdpa_mem_dereg(priv); rte_errno = -ret; return ret; -- 2.25.1