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 2E905A034F for ; Tue, 9 Nov 2021 13:36:45 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7ECC41139; Tue, 9 Nov 2021 13:36:43 +0100 (CET) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2059.outbound.protection.outlook.com [40.107.102.59]) by mails.dpdk.org (Postfix) with ESMTP id 82DE041123; Tue, 9 Nov 2021 13:36:39 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IjRaQv18xLFlLWUayZ8/jc7wDnk6q8HvUWabfBx4ADAkCFUuCwWPesGVliF42/kxqiRfORnK5RNpfADwY0nTN2np50y/lSYspYqX9qeKEelIspDjKXjAto0U/rNs6FpDZEyma7a7ZX9Htf2uQeDNAWpwnRaeusa5gktqH0FnkeJOIKuyWYivg829CmGY5Eh9tzh1kD9kzBdxQPe5UWraV8k4GLgH+/HYcMU8P++IJoUPZV4wwyiTXnH/pXGU1iV6uHClmKq932lOBUsiYeXQay97+wIprJ/rW14SMwU6YBepSExKM9i5ehmbaGkA/8XLqbR5wyzJFDfRX/Q6JSpZ8Q== 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=wfK6A01iNSJERHxRrWyhZn3+tj3xR88tVf2/uQ+hbME=; b=bXPy5EF2Q7rHoJlBL3aMs6sN1OG8RQcwxX+m8FflutrMJOBWWt8iAqzFr/UFUcKxk5DvfXOPQwzXMsAJDWJNbRk34BQ6t51mLuQmYB6YgPQSTmWPqYqD8XrEBqkWm8y0SuLq1Xy588rQA22R+739Dl2hBMLAHOtvJ4WJ1zfSwZiKF8hBW9+Rc9DhMlLuYcifSy7F4l7HIyIB4jLo7e0NroalxFQVoyb0I4AveN+jMt07a8iy4EluBA4iva9ebYcusvoFq+ZQjIJ85x8qPQv35mgTCB5oaZ8Iurpfa/zX8BfiDbXOK/V51hYGPkEa5sQg+o1eNpF7IebIxf+7WceZ3w== 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=wfK6A01iNSJERHxRrWyhZn3+tj3xR88tVf2/uQ+hbME=; b=F9Tn1RMQ9x88k4iBLjdp9k8wnw8bqy7pfxiPS7wuKarrjAXXcGN/2ld8bhJ6sDul1x4+9t0J/tuimVCtfduPqA8Kx0ofsSjXAW4JKRvrYZBwOuPXfDS+Xby00hkbbdsuoW+rVG2SZofNilIa/iIbNeQouKOnhoxjif6XY5pO44dKMJy/elhZWMfKRkS1sopiS0MXf7xLt5e2HLev77hHt4k8/R3jbw4yrpA1S/DzCSJoNh/lz3vMQj4SALanZ0gAiI5G1yxDk362zyKtSFj9bNOi5llG73JPpCdzXEn6b28KVRW0/H8JWMAGd47YbOl5A580k/2h1qFN9j79dGpZ/w== Received: from MWHPR15CA0060.namprd15.prod.outlook.com (2603:10b6:301:4c::22) by MWHPR12MB1423.namprd12.prod.outlook.com (2603:10b6:300:14::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Tue, 9 Nov 2021 12:36:37 +0000 Received: from CO1NAM11FT065.eop-nam11.prod.protection.outlook.com (2603:10b6:301:4c:cafe::ac) by MWHPR15CA0060.outlook.office365.com (2603:10b6:301:4c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Tue, 9 Nov 2021 12:36:37 +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 CO1NAM11FT065.mail.protection.outlook.com (10.13.174.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 12:36:37 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 9 Nov 2021 12:36:34 +0000 From: Matan Azrad To: Viacheslav Ovsiienko CC: , Thomas Monjalon , Michael Baum , , Michael Baum Date: Tue, 9 Nov 2021 14:36:11 +0200 Message-ID: <20211109123612.2301442-5-matan@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211109123612.2301442-1-matan@nvidia.com> References: <20211108172113.2241853-1-matan@nvidia.com> <20211109123612.2301442-1-matan@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b7b754c3-002a-4253-4b55-08d9a37d928f X-MS-TrafficTypeDiagnostic: MWHPR12MB1423: 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: yN4L8gu2K2RV+B8fqCS/UgIfAxhPFvkuNUgzLe/KtyeIbQLWhfyfu8M9Trpnc9d2pglKKmtL3cTgs9efshvIG/NB7mpA6LdAG6w/xVa7x0LQSaV9+Ydki75636m2vrXsTzUvG+cMIbTVlbSH67XHqb5kfzSI7An8qKBY4vcpKNxAMRTOPVuF8hfYH6Cf5zHiTceVzyZrCSh9nt4UyHHQiiIvOkpKv70EIK2l/KxZ7ckCQOX8sl0E66jWBdKJuaFjd9rewHY2IQbmSdiXZIGKRe/sym4EvrwE2y3gRN8X6Wb4tf1ew9hKzitGKZGUmWMGoWdQYuKHprWuDLEQBy83MOS9gx4NZjbw41ApVS+iccQSG+NsBMOKNbk8xtw6/tiSJ3YuJt2F+Ch8LUJ+7Vc6kZQyoK8Cw70A3ou4Rrs7uaAlEkr4J7m8f19hEaet6ItSJJgQEk7N3wzgrlxyaWQSoPlINGMRReO3lMR52gHiEEMfdTFpL+woWcUgbTiXLjqyViyQ1OnBVwG7u4/UsFSukr55KrMD4gDwzNngbmgaZFf9tiBJU4UGvZU11mfUAEOhGPz9CGrSNzrpyf5fbaILdQxbx3YbL7YKlNeGnlLl8Qfhmpkdxv3h7T+fAkl8ObK10u2KPNOKFanxXi+pDf0vrNRermYwwA/tqKr/kJBHWfF+KkgRnsXNaS1ybNvFsk6n6MPYK8FCsxQSUmfFdLcDJQ== 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)(36840700001)(46966006)(336012)(2906002)(36756003)(6286002)(83380400001)(4326008)(86362001)(2616005)(54906003)(37006003)(16526019)(26005)(6862004)(5660300002)(186003)(107886003)(426003)(6666004)(7696005)(7636003)(55016002)(316002)(82310400003)(36906005)(1076003)(8936002)(508600001)(8676002)(70586007)(36860700001)(70206006)(6636002)(47076005)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 12:36:37.3690 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7b754c3-002a-4253-4b55-08d9a37d928f 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: CO1NAM11FT065.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1423 Subject: [dpdk-stable] [PATCH v3 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 15212a2b30..22617924ea 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