From patchwork Fri Aug 30 10:58:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dragos Tatulea X-Patchwork-Id: 13784921 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2089.outbound.protection.outlook.com [40.107.100.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B26FF19007F; Fri, 30 Aug 2024 10:59:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725015579; cv=fail; b=SoZOcqZslLPZLb78c1MnAGFlzcrGZCuF57PYsPV1vDwqwDJnyOV+JSyN+Or/43/U1rsjiFef8L4jSy73u8aa2JRuDzTcbJ+QmwZ2Z/udlRyf/h6QsIF2zsd3a98cMxmwP6zZNWPIHBTq+L5WtBnyyVtK8xMmd4mFnTovCoe3ugA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725015579; c=relaxed/simple; bh=oUd524XZ03agGn80Re3RZoCUm1QgbxORyOfezmtmWes=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h0dY7Wkknj67MDsZjQlRaPyZjpIScKA8tP0cw6MhaWsPY/mSwP7YMlKAq/y1ZLhfX9E5bRo5k0umftwO2woM0MtoZus9YQG6voWI/wuZlGzk6hBKJN5DQ7DaVSmyacCUMx6XFnq3FYWTZAkIsbJ8HRMqcMEOHrpyQjC6YXaMsrE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=a4gil+eT; arc=fail smtp.client-ip=40.107.100.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="a4gil+eT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GNQw7nliBHKSpxs9MQ1iowM/SuNC1iQjV74cbuXTOqjY1l7gJTpUjQMKh1EGvV8H7XB6PlOTjV2Irwfb+2t2zttqJrb+L224qeJyL0cq4LPuJs/K+RKD133cRj2SuEu3hbb60OQeJXgMV1Nn6QbBIKWLeUluqda8vNn0Rjqe9JCkpV5/j0biGXA1uey8g2PSVldJn62U/hT2p4QVfDHI4uYdOZJ05hG8FPjCYFvGkaF2+HPfKE41GewglLKDOi47QEXyk23D3L8XCUgkjG7VsEnEZHV+0KiAJs3OlRDy1DEaeot38/MupYqS0wCAVYfSs7ANvPfELtgmU3ddN12aYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=kHe6hjjzB+AuYFTfA0Obn2d8V3Yt/lz1NalluwisKig=; b=XCoGisIyJ4uGbHt/sRd5gDJ/EKIkAmyynnxEx9OKMmaxnu3o87HFMKS/fk7OYIsGP97YhLi/hMwaao2kD3GSZbMb9grpr6/KoUPZNOCmJGvB1oLy8C3BCec/XLEts2rXqgnAWMmegbTho7Qbe8GS8anuhWfxYa/J5FR91be83lWJ+0WHkhHaL+WL+mRjgq6xGb1zWzKfoBrRV4gX1jcf1yHgZhBvUbwT7eAxcts6uCpOd1oLj1/VjmBT1eyDdLL5o2QMAHlaEMWZN5hx13HEecCqNG5LAX1iCocL4IszMldDyN/0gVEcetrW9Ri+o3ihEDS7WvgRtjAcas3TDE+DEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=kHe6hjjzB+AuYFTfA0Obn2d8V3Yt/lz1NalluwisKig=; b=a4gil+eTzAbIA7KKqA88w9V49nImnyEetbzzJ+1xYk9NNO60NS3pBkBOHA69+6aY1HKVxks/rT4V64lcjatVWCqwc0P0/5gtqwPrGw0trkFUUF+oHgRtyYwnD8jOYB3uSzLIaE3kifzqicrI1GMHoLtDOHc5rnNYBcDmL/cdSRhe9yWJN4W0aXbg4qU+7Pu1Ue29FlAEcTnRbzc+aano9kJeYu/9wb8TpB46iVwS5GBdc/Hv5AUOv1cnWlPNufR5qHtN1q4/3b1wVH9PiRtqRlJ72tcDH6M8lmSgTyAcK80vFHrD2hMxWH2LyerzwY1JLXFUMQILeKvnZqmDTpjKAA== Received: from CH0PR04CA0008.namprd04.prod.outlook.com (2603:10b6:610:76::13) by DS7PR12MB6312.namprd12.prod.outlook.com (2603:10b6:8:93::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 10:59:33 +0000 Received: from CH2PEPF0000009D.namprd02.prod.outlook.com (2603:10b6:610:76:cafe::1f) by CH0PR04CA0008.outlook.office365.com (2603:10b6:610:76::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20 via Frontend Transport; Fri, 30 Aug 2024 10:59:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CH2PEPF0000009D.mail.protection.outlook.com (10.167.244.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Fri, 30 Aug 2024 10:59:33 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 30 Aug 2024 03:59:17 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 30 Aug 2024 03:59:17 -0700 Received: from c-237-113-220-225.mtl.labs.mlnx (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 30 Aug 2024 03:59:14 -0700 From: Dragos Tatulea To: "Michael S . Tsirkin" , Jason Wang , Eugenio Perez Martin , Si-Wei Liu , , Gal Pressman CC: Dragos Tatulea , , , Parav Pandit , Xuan Zhuo , Cosmin Ratiu Subject: [PATCH vhost v2 5/7] vdpa/mlx5: Rename mr_mtx -> lock Date: Fri, 30 Aug 2024 13:58:36 +0300 Message-ID: <20240830105838.2666587-7-dtatulea@nvidia.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240830105838.2666587-2-dtatulea@nvidia.com> References: <20240830105838.2666587-2-dtatulea@nvidia.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000009D:EE_|DS7PR12MB6312:EE_ X-MS-Office365-Filtering-Correlation-Id: 01dc9583-d321-40d1-1580-08dcc8e2d46d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?iYVbb2gABAKwqRWh/Mk8xYA5Ex5wMW3?= =?utf-8?q?tvXgM2JiXYClfkeAnpGSlowjuIC/zIUcv5bXCg4kBct0tW/wubSY3+2kBxyQZvZRK?= =?utf-8?q?ejWDd0l8LzU3Pf/SlCgirYjBx4WnHq3zh77Pt5zoL9pAbr/Co4+tcbAJsA4SHJ19L?= =?utf-8?q?BHeWClmBebYE3VuG+1BaFbyDCFI4he6JAwKLLUofA9+NOTqJE2FgPKiKPB/5fQq1m?= =?utf-8?q?HBHdsxM5VoecvmDFRJSlplXgDCbvLNzxVvrftJmKw/Cdz0pWfoip2W4MGt/bBU89P?= =?utf-8?q?DMYOSg49Y4qW2O3dHOA4wblpM/VhC3q5qjtw9DfIgVbrBd0s5o3vNBBXtc/espI8A?= =?utf-8?q?LmFVQ7shXZXF0dhuKW65t2GY1qGoujkGr5iDK+ENKxxfGcsvABkqlOov8SBiaNG0e?= =?utf-8?q?ICie/907LW+hiK8Ec9O6vYtcTTxk4Prxj5WoWQiUQeW/J8bCs4kxhbSjqCMPLdwKs?= =?utf-8?q?5PZMOT79dOgsmsDeuThj3jfoDuWS33CQqxmRt6wVLlTNHYkyHc4il5VF3DGKmaKMv?= =?utf-8?q?lj+vRPu0V/JSoWrSTJLw8GqoJCUy4rb67vUDocCacz5eYAqc3xe3UaibWLZA/VYa0?= =?utf-8?q?URmgd2jh4y2T6+TEJFZQEJxX5x6UyaagVtk4/rASbr0VD0tfTINvRMyM/qW1sme+7?= =?utf-8?q?hqRpgynzT9xxEyFJLDbqkLQ8+idTEU7CEr/80B8k7S/5HuGGnWQfsSSWVy4ipYXBq?= =?utf-8?q?qVSEtrIiJrpdNS3rYNgEQ2Me9iBgbYswIyxQcp+mpbmJGubAoM5svq5eNUTE+tGeV?= =?utf-8?q?pY9qkEXubowvu6MpPzHfwDGqJl0c1Gh9QzUYgxedaz7wf4FlrNQpsFqUCTY71G/CL?= =?utf-8?q?M/DH1eGDgOIw9w+xmtwlGK1WtRcneTRXyJuXLYpffZcFqa07QNes0uREdYEgMaG/Y?= =?utf-8?q?G/F49F033kqfCUmEuYHzwXljsFkGfUfRpvJifNUAILartilPlGle9IOovRrv9gBKa?= =?utf-8?q?4G1grdLCNLp4u95HrDQNp3oK1nd+K+eioAkIRh/XziCIxq/NOMONkO8V/WGEsfmuO?= =?utf-8?q?InAQFaPsFiYORND8uxXUj8GnnUSro4+jcpNMApRpK45Fbzv2RtCFi8oeCWWbzIk0c?= =?utf-8?q?r+QTX+/Em8gKrvh1/TFTPSkgkxXfuu7QsdUVcGLxwsZU0HsViD3M22w0FoxcTF+3C?= =?utf-8?q?zLkMxqbeyRYHbdRoHOVY4Ea1/lmlPYkR1aG3JIFwi2AWrJV8cQXS9nYDYmKGARDS4?= =?utf-8?q?ogGwoWlhoe8cNRjM2L0uBDI9ksdlfpkicefHY4Zwht9HCszzBNKzSda/fuIJftcp+?= =?utf-8?q?lIh4f5AnFg2sro8NWyRH99U2k+2doShij4xqyCs5TQaBn10dq3Xvy9X6qUlHqfklA?= =?utf-8?q?J5YV/pWrvUDb2kcbIs/0XYO9uSYYF1UxzycYJKiVaGcOjCuRAbn+iBlA2Lz8qIJVe?= =?utf-8?q?fSxGC/9lFN5?= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 10:59:33.0288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01dc9583-d321-40d1-1580-08dcc8e2d46d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF0000009D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6312 Now that the mr resources have their own namespace in the struct, give the lock a clearer name. Signed-off-by: Dragos Tatulea Reviewed-by: Cosmin Ratiu Acked-by: Eugenio PĂ©rez --- drivers/vdpa/mlx5/core/mlx5_vdpa.h | 2 +- drivers/vdpa/mlx5/core/mr.c | 20 ++++++++++---------- drivers/vdpa/mlx5/core/resources.c | 6 +++--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/vdpa/mlx5/core/mlx5_vdpa.h b/drivers/vdpa/mlx5/core/mlx5_vdpa.h index 5ae6deea2a8a..89b564cecddf 100644 --- a/drivers/vdpa/mlx5/core/mlx5_vdpa.h +++ b/drivers/vdpa/mlx5/core/mlx5_vdpa.h @@ -87,7 +87,7 @@ struct mlx5_vdpa_mr_resources { struct mlx5_vdpa_mr *mr[MLX5_VDPA_NUM_AS]; unsigned int group2asid[MLX5_VDPA_NUMVQ_GROUPS]; struct list_head mr_list_head; - struct mutex mr_mtx; + struct mutex lock; }; struct mlx5_vdpa_dev { diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c index 95087d7ae78a..e0412297bae5 100644 --- a/drivers/vdpa/mlx5/core/mr.c +++ b/drivers/vdpa/mlx5/core/mr.c @@ -666,9 +666,9 @@ static void _mlx5_vdpa_put_mr(struct mlx5_vdpa_dev *mvdev, void mlx5_vdpa_put_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_mr *mr) { - mutex_lock(&mvdev->mres.mr_mtx); + mutex_lock(&mvdev->mres.lock); _mlx5_vdpa_put_mr(mvdev, mr); - mutex_unlock(&mvdev->mres.mr_mtx); + mutex_unlock(&mvdev->mres.lock); } static void _mlx5_vdpa_get_mr(struct mlx5_vdpa_dev *mvdev, @@ -683,9 +683,9 @@ static void _mlx5_vdpa_get_mr(struct mlx5_vdpa_dev *mvdev, void mlx5_vdpa_get_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_mr *mr) { - mutex_lock(&mvdev->mres.mr_mtx); + mutex_lock(&mvdev->mres.lock); _mlx5_vdpa_get_mr(mvdev, mr); - mutex_unlock(&mvdev->mres.mr_mtx); + mutex_unlock(&mvdev->mres.lock); } void mlx5_vdpa_update_mr(struct mlx5_vdpa_dev *mvdev, @@ -694,19 +694,19 @@ void mlx5_vdpa_update_mr(struct mlx5_vdpa_dev *mvdev, { struct mlx5_vdpa_mr *old_mr = mvdev->mres.mr[asid]; - mutex_lock(&mvdev->mres.mr_mtx); + mutex_lock(&mvdev->mres.lock); _mlx5_vdpa_put_mr(mvdev, old_mr); mvdev->mres.mr[asid] = new_mr; - mutex_unlock(&mvdev->mres.mr_mtx); + mutex_unlock(&mvdev->mres.lock); } static void mlx5_vdpa_show_mr_leaks(struct mlx5_vdpa_dev *mvdev) { struct mlx5_vdpa_mr *mr; - mutex_lock(&mvdev->mres.mr_mtx); + mutex_lock(&mvdev->mres.lock); list_for_each_entry(mr, &mvdev->mres.mr_list_head, mr_list) { @@ -715,7 +715,7 @@ static void mlx5_vdpa_show_mr_leaks(struct mlx5_vdpa_dev *mvdev) mr, mr->mkey, refcount_read(&mr->refcount)); } - mutex_unlock(&mvdev->mres.mr_mtx); + mutex_unlock(&mvdev->mres.lock); } @@ -779,9 +779,9 @@ struct mlx5_vdpa_mr *mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, if (!mr) return ERR_PTR(-ENOMEM); - mutex_lock(&mvdev->mres.mr_mtx); + mutex_lock(&mvdev->mres.lock); err = _mlx5_vdpa_create_mr(mvdev, mr, iotlb); - mutex_unlock(&mvdev->mres.mr_mtx); + mutex_unlock(&mvdev->mres.lock); if (err) goto out_err; diff --git a/drivers/vdpa/mlx5/core/resources.c b/drivers/vdpa/mlx5/core/resources.c index 3e3b3049cb08..fe2ca3458f6c 100644 --- a/drivers/vdpa/mlx5/core/resources.c +++ b/drivers/vdpa/mlx5/core/resources.c @@ -256,7 +256,7 @@ int mlx5_vdpa_alloc_resources(struct mlx5_vdpa_dev *mvdev) mlx5_vdpa_warn(mvdev, "resources already allocated\n"); return -EINVAL; } - mutex_init(&mvdev->mres.mr_mtx); + mutex_init(&mvdev->mres.lock); res->uar = mlx5_get_uars_page(mdev); if (IS_ERR(res->uar)) { err = PTR_ERR(res->uar); @@ -301,7 +301,7 @@ int mlx5_vdpa_alloc_resources(struct mlx5_vdpa_dev *mvdev) err_uctx: mlx5_put_uars_page(mdev, res->uar); err_uars: - mutex_destroy(&mvdev->mres.mr_mtx); + mutex_destroy(&mvdev->mres.lock); return err; } @@ -318,7 +318,7 @@ void mlx5_vdpa_free_resources(struct mlx5_vdpa_dev *mvdev) dealloc_pd(mvdev, res->pdn, res->uid); destroy_uctx(mvdev, res->uid); mlx5_put_uars_page(mvdev->mdev, res->uar); - mutex_destroy(&mvdev->mres.mr_mtx); + mutex_destroy(&mvdev->mres.lock); res->valid = false; } diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 3e55a7f1afcd..8a51c492a62a 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -3639,10 +3639,10 @@ static int mlx5_set_group_asid(struct vdpa_device *vdev, u32 group, mvdev->mres.group2asid[group] = asid; - mutex_lock(&mvdev->mres.mr_mtx); + mutex_lock(&mvdev->mres.lock); if (group == MLX5_VDPA_CVQ_GROUP && mvdev->mres.mr[asid]) err = mlx5_vdpa_update_cvq_iotlb(mvdev, mvdev->mres.mr[asid]->iotlb, asid); - mutex_unlock(&mvdev->mres.mr_mtx); + mutex_unlock(&mvdev->mres.lock); return err; }