From patchwork Mon Jun 17 15:07:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dragos Tatulea X-Patchwork-Id: 13700919 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2050.outbound.protection.outlook.com [40.107.237.50]) (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 B9F8116CD32; Mon, 17 Jun 2024 15:09:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718636961; cv=fail; b=fLWFhoj4NOTL96nbb/INcIt9og0ZYy6MQYZrYENm5w9Bu3tdwt72xtmmFnSba0jDlxy5/9b8B8XpPpAdOYY1s0VfQ9QQ+iVyEo2Xgk8SFhhddhJF442iK/DQTG2t3loZSquKWQXLPYogbg0mk4CYVeZxIEoSpIe+fc/kG6m0dbg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718636961; c=relaxed/simple; bh=cO9B2CFnexmejsPEZHTRU8ShI2mV3nLiEICpLKNndk8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=JTn6CZwkVq/S1u2ZN/4rIs7s1tGuezKLYTXFgItbWOu7zTJi0nulQyS+DYdjs+Dnt5LV9A05A9Yhs01UE4U4wW7Dsr0AmYngokv6sxguk15cNsW4u7WH/rVgtaTBJMjV3xVUObD6Iql8dA4Ewwx8FcWNw1l+VSQUBXegmLeSExc= 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=F1x9Wobo; arc=fail smtp.client-ip=40.107.237.50 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="F1x9Wobo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JG9E3xkX1aF6g3oYzkh7L6BZeElT/6GEDMAWK8pMuXpwcFkznS0M7KKOgYv/jaGo37kbOWnico9VDZf1c/57try0LlxILSKkRQgl6JQJBC/OwShvjwLsKRyBR0XoQxZ0LyuqYo3e7a0CKb5VTXzYDyb0gmdEdUNQXO0AR2BTs5TL9BSm25M69z29NckizvdwJTMttTtceMqX36tx4pZia4iaigktgWaYd2zC8HABkXiS0P/VUOBGpPiHt6o3Zgaavy3WdL6vAPa9FGBNTE3l81au+Xqif5njU7vI3i/QDrXlxXFINjxtTGZm0LjZiO1GP4/Yp2xbOAAzaObXqzNRYg== 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=MNyGSAOjuLKEuGmFqtGAZKOWKdkcBTc2njKCUShGqjc=; b=Ef3tLxLZVqzRHY7UZOx5d4pRubxtXjzspTUnTY6pQ02e8uZWHi1okDpDx6UH2EB14N7m+SG3tcl3EyIxC44h/YClXqt6x1zN+EQsg2egEx8g3NohquYp3cs7+dPap5MrG/+49b+l+ueSgzJG/i/hoAUgofR8VZH9g/Tw43cakpyLKS1QZHES0Chi+Y7mDVTIsGSd0b5WVw3pABqwTODHWlrgGGCdw6CiDBoJCaMe8OGsJdDnWHZ+N6SGup4Z1fwzcXshEXkhLvqg6/UyuqeU/C9xHmkvMRDCw3ca1AqO/Dd+chHB2UTrz9qkNI7DOi+MESg1AdX5YNJsoXQSWy9aiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=MNyGSAOjuLKEuGmFqtGAZKOWKdkcBTc2njKCUShGqjc=; b=F1x9WoboTXNCIJ1epBzrXAzt4WInRZU15+6BgqYpoJvZZQqxaZq0nLpaL79XBr4AWzivHyjbt/yxh6qTYfpHBqlKabUM3nalVsAYqQZOieoKNTKnIq5kobckPGTHbHpNEfTcFfcvlA/sF6fKBE7gVCM6nUOC7NIwFdzOFXc0mcvGJDnn9E/k5YOOPwQspunhw3f6PzKWRr+hlMAj6/PNJJeV99pzmoOKmGihDfRalhQqYMmKuCmYF1faUCGFE/MH7GOgt8TJB5K1m9EU9hmopzcEFMCJtbsw1Y/ZIkMK/HNgkJiFXYuMINohZu3DwX254IDFr4X3uBpQAdzOwtSe3Q== Received: from SA9PR10CA0015.namprd10.prod.outlook.com (2603:10b6:806:a7::20) by DS0PR12MB7771.namprd12.prod.outlook.com (2603:10b6:8:138::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 15:09:15 +0000 Received: from SA2PEPF00003AE7.namprd02.prod.outlook.com (2603:10b6:806:a7:cafe::57) by SA9PR10CA0015.outlook.office365.com (2603:10b6:806:a7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.31 via Frontend Transport; Mon, 17 Jun 2024 15:09:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SA2PEPF00003AE7.mail.protection.outlook.com (10.167.248.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Mon, 17 Jun 2024 15:09:14 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 17 Jun 2024 08:09:03 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 17 Jun 2024 08:09:02 -0700 Received: from dev-l-177.mtl.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 17 Jun 2024 08:08:59 -0700 From: Dragos Tatulea Date: Mon, 17 Jun 2024 18:07:53 +0300 Subject: [PATCH vhost 19/23] vdpa/mlx5: Use suspend/resume during VQP change Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240617-stage-vdpa-vq-precreate-v1-19-8c0483f0ca2a@nvidia.com> References: <20240617-stage-vdpa-vq-precreate-v1-0-8c0483f0ca2a@nvidia.com> In-Reply-To: <20240617-stage-vdpa-vq-precreate-v1-0-8c0483f0ca2a@nvidia.com> To: "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Saeed Mahameed , Leon Romanovsky , Tariq Toukan , Si-Wei Liu CC: , , , , Dragos Tatulea , Cosmin Ratiu X-Mailer: b4 0.13.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003AE7:EE_|DS0PR12MB7771:EE_ X-MS-Office365-Filtering-Correlation-Id: ff145d02-25c3-4663-b00b-08dc8edf73bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|7416011|36860700010|376011|1800799021|82310400023; X-Microsoft-Antispam-Message-Info: =?utf-8?q?8mvyK2T0Abe7AbkmFdZ4rbv2k0mT5Yx?= =?utf-8?q?Pu4PaADUbQt7KBACel6U9iTmWgIA9uONzC0itT34/Oe8+0DHnH0xW/OOYRjmwWJSR?= =?utf-8?q?EgmZLsT7zT0wywct9je6ht1t0yJffK8dU1Fhaie3S/oE72C7vOAIQzQ6/zQTrDmu6?= =?utf-8?q?LyXcFwp2bcZb2KiDWEhnZH3S6GoVoD+KaN9KMy2M174OZYbFQShRdvAdPrH5QZf5K?= =?utf-8?q?f7uH5nn4tCeaAxhfxhh3VZp9d62jYCV5NmKb0O2DeQKbAU8xdTIoQoqlNEKagNz1v?= =?utf-8?q?Q5bhsjv57PVP9mg7+HxO7nkIxYirFCUnuTTuXAxdAiqYqp5uHxA1GhhpwlZZaARlV?= =?utf-8?q?MM3cCwlv409jO8OflRhYv+csQxJA6VtAA6VbUQcsCQjnjXNO2x/Qi3rENJWFwJGFL?= =?utf-8?q?AJVcHL6SaVKbv2dW6mS7KClWmni95aIBmfApOBJ2StSVnmI4a/x5Luasj4Go1hEj5?= =?utf-8?q?HXJGlCKRgYbPfB/CO1ZagH8RpQW3ccErdT50KxNdZp+79+S9DdfOQi+GB++Y0mlh8?= =?utf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G:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230037)(7416011)(36860700010)(376011)(1800799021)(82310400023);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 15:09:14.8958 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff145d02-25c3-4663-b00b-08dc8edf73bc X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AE7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7771 Resume a VQ if it is already created when the number of VQ pairs increases. This is done in preparation for VQ pre-creation which is coming in a later patch. It is necessary because calling setup_vq() on an already created VQ will return early and will not enable the queue. For symmetry, suspend a VQ instead of tearing it down when the number of VQ pairs decreases. But only if the resume operation is supported. Signed-off-by: Dragos Tatulea Reviewed-by: Cosmin Ratiu Acked-by: Eugenio PĂ©rez --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 0e1c1b7ff297..249b5afbe34a 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -2130,14 +2130,22 @@ static int change_num_qps(struct mlx5_vdpa_dev *mvdev, int newqps) if (err) return err; - for (i = ndev->cur_num_vqs - 1; i >= 2 * newqps; i--) - teardown_vq(ndev, &ndev->vqs[i]); + for (i = ndev->cur_num_vqs - 1; i >= 2 * newqps; i--) { + struct mlx5_vdpa_virtqueue *mvq = &ndev->vqs[i]; + + if (is_resumable(ndev)) + suspend_vq(ndev, mvq); + else + teardown_vq(ndev, mvq); + } ndev->cur_num_vqs = 2 * newqps; } else { ndev->cur_num_vqs = 2 * newqps; for (i = cur_qps * 2; i < 2 * newqps; i++) { - err = setup_vq(ndev, &ndev->vqs[i], true); + struct mlx5_vdpa_virtqueue *mvq = &ndev->vqs[i]; + + err = mvq->initialized ? resume_vq(ndev, mvq) : setup_vq(ndev, mvq, true); if (err) goto clean_added; }