From patchwork Mon Jun 17 15:07:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragos Tatulea X-Patchwork-Id: 13700939 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2049.outbound.protection.outlook.com [40.107.237.49]) (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 BDB2014D2B4; Mon, 17 Jun 2024 15:09:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718636947; cv=fail; b=MGils4JwUiy7j+l7quUUJJqhqe9nZf9In3MYjGHSETh01b/bhnQp3s25ldTQq5eTXo/sbG4DKehGa/uwpLjG1rkpjEA84eic3zjMQL0sEbg4xatLdqzq1YfoPUiIbezKEuSFxA0C7LtT1XX3w07xnq9U8pNbjDmorK3L2HS/vJg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718636947; c=relaxed/simple; bh=FtsotHAA5lLceyZuQEQ3YvMUsF62ghgO/lGhjb+y9SY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=nCzq9EwBDpZLyBFOBiCGXyQC+4YO/ibsurP1MRZ38mP21GiBsAGTF6FJtHAUVYI9y8ArvF12m+RfA6Wc+ifAab/QFhvrUGiGeKr5kG68NPv2Bw19/czANt1tGYyQ9A7Qs8KXMrnFVQMynN0blX0uPH8/wj+XTd2V+Se3surd+Uw= 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=UGvoSd9A; arc=fail smtp.client-ip=40.107.237.49 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="UGvoSd9A" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fPEkiIsQhr7nEwX9aMvHSVOR5s6NWjnf7tCve+AKPKuIu1qP6M6qe2xqOCfqXlUZXPearTkPeXNVFAnWfOW7bDmK7ULrQbXKU6nxMhcYeURhEcvHaIlHdAaC7rJvG0wEHkK4r/iLwnVI9zZ56cY2ia4yoLZIaXuBGq+OuddtQUKqvlIOmBedPu5HtxARj2ipIw36x5qwxHT8YHdtkIBgfPEwZCBw40l8bEh6nSQFrF/n2x+a8rdPGx778/iGhsEsb7hTxgfi5EjCQksz6sw5H8n7q/K4atusUb1zrdxGENZKJylM8V93hhPqoCwUbBi+gQvztXldwa9+5ycezryOrA== 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=vMCMg/Kh9NkfVaGIWd1l1ejw1IymRROnaMM+828dieE=; b=bcMbY5MHsV1T+8mQms6urN99cGM/KfjEuwY5YmcoH3dO6Q6GOfqR1bcJvjnQAB5yl+SrOaT8QF+aN1wYEUQfSg1W7x2PB1AC5P1HJDyS2qn8+uThzSfmasLusq6wmfR0XjKkd0AmDTJ5/nNqLtY4UsXmrmSnzYL+54qcZYVHVGG1HPfSHBFBKSU+i2ca264WE7CFm9015KscbaVKUYkUipnpe71I5zl1haUPLMFmMjns3Y+lyArQxg/DrFZYI736s/eT+A8VF2pGZxnLGZZytMtLuGN7WaUeZTms/MuPF5BaN7PPbET2b4Ttq06T3CK2LZZStvVxaBJ5nzZ1+XXy8g== 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=vMCMg/Kh9NkfVaGIWd1l1ejw1IymRROnaMM+828dieE=; b=UGvoSd9AtfAQ8zM2b1CcrAYKkb8rVmfhwTZQOUIZulL0ARQ9AL4XjNirpk2MKpWnYUIg5qcAsTJbDNbvvmN5w3xxkVyMfBPjti9WSZLo/RGUqqyumYWEl6gM4X1QA/xjKuF+FmI9cKZHGQ9qt2GQhVmwP41VGxTr5OxN9pnYnCqChlxEPZWG/3FH0mgtg9RfE8nQT1SelKCy5dtmrfzNuT+W3cYmieCYA1gPRmtB/ZRwxC7AmWutBl1CwsHgtn5Whnl/PdFbBmHcUKbx37F+fUDEUrxAWU3bEh5i27VzNBbwB2N8vfrLf21bP22FWSWzbPyL7GsdQrYWdmtJEXAYPA== Received: from SN7PR04CA0089.namprd04.prod.outlook.com (2603:10b6:806:121::34) by PH7PR12MB8016.namprd12.prod.outlook.com (2603:10b6:510:26b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.28; Mon, 17 Jun 2024 15:09:01 +0000 Received: from SA2PEPF00003AE9.namprd02.prod.outlook.com (2603:10b6:806:121:cafe::62) by SN7PR04CA0089.outlook.office365.com (2603:10b6:806:121::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30 via Frontend Transport; Mon, 17 Jun 2024 15:09:01 +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 SA2PEPF00003AE9.mail.protection.outlook.com (10.167.248.9) 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:00 +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:08:47 -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:08:46 -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:43 -0700 From: Dragos Tatulea Date: Mon, 17 Jun 2024 18:07:49 +0300 Subject: [PATCH vhost 15/23] vdpa/mlx5: Accept Init -> Ready VQ transition in resume_vq() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240617-stage-vdpa-vq-precreate-v1-15-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: SA2PEPF00003AE9:EE_|PH7PR12MB8016:EE_ X-MS-Office365-Filtering-Correlation-Id: 0de57bcc-8219-4fd4-7fac-08dc8edf6b70 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|7416011|376011|36860700010|82310400023; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Iq0a39TmB+7anuNNFJKyefTWc+efeCo?= =?utf-8?q?3YS1vGA7mcwr0GlsY2jBq5aDkq7ZDzKm1zxlzk3f1lUIMVX2aO4mAoZ818kNBOGkW?= =?utf-8?q?4uYul1tAX71xhn+Dkon5kIyd1Xqv2DYpDSVykR9x3OwvqncBawVP1T0317qGmO1Vm?= =?utf-8?q?sdur/FFRhxPUBr0eqdP/4kE4X4dQ2bKeXlo5lIGHUwjS8rF+I3tj2MeGi93OgLwT6?= =?utf-8?q?Uh6ROH/4lIzlkM8at1+L837wq/Ta4Gc4lYo1585xRWSv4OwPoAIPBVeFlsPzMKFJg?= =?utf-8?q?WDK9JYLoO+F1DheSL4Wj2nAOMP0epaRzA36ksMoem0U/J4qsXlD1Y1CUSIgXWPe20?= =?utf-8?q?WeN2IkW6DOVrKmtUhpSdtycLhoK9HeIHAkxhytHG8nuza9O8oX+rRAm/kZ09oQ9YZ?= =?utf-8?q?yo71nNAE1JTO94NJsqKgrJM3kLhomZJptE6aYravOn+yP6dKp5/vBjiMXQQD3Ze9q?= =?utf-8?q?WCGnJ8iHImDYYgAlkSlW3trV3+HfuBrmBTD4JVRx9lYPrT/khoLY4jmAbacFqo68x?= =?utf-8?q?cHnKs3/hHfR3pS2ilR6arPtL5E9VUD4LIGHV3jPiFhrmbkJpL9jD8SwruGHDJfoH2?= =?utf-8?q?UkBWDR+OP+dw4t9kg7UAmtX4baI47GPYS34gQHmu0y9exCVTuGLPC2y4jLuTEXrkl?= =?utf-8?q?LqjK0dHcChjAumrpY76Ku2NiTNBLFv4yg9v3uVAllHsE/iPOqqL/nhIWkeUEvSHGj?= =?utf-8?q?/DDLF2f2UDtDCgodE+xYNdyKaFVCDVeC9nu6WH39Pk7so//zOBeEWydnE2JDLN+wP?= =?utf-8?q?zSLlWftcr9NHTXyUmxMThE/RyUdxa7diRXHm4CdyBu/sdTZeZJeOmLGA+BYvddaoE?= =?utf-8?q?xGM7V4tomAQK9UCtdfxEBCkxcWTy6v5SYv5U6Np6tq7+7/SMZSkP8hyJijzWptv0R?= =?utf-8?q?eafftHk1TANHsG8rtteUUeUfdxfE9FXk8BSwfKDjkioXzyRTWj8foXDt546dgM2fy?= =?utf-8?q?z02KlSvzBoWvCbEGTcVXqCyld+JT3ZOajea2TB3wWHNEQD+b6tair3F9EKIeRJKdG?= =?utf-8?q?UPaYMkbLW5RsPFuD5UXvwSALiTFG4N5dmlLDXLOzaTV6QtfSVroxZ1EPzwb+auZY5?= =?utf-8?q?9hNXf72kl6ugb7cn8WyuauuXcTzgI8I1RQIgccspHIiCk4nSxCDyLg4HYbAitXMSn?= =?utf-8?q?qAKoBtrclrven84lgbmIIVYMe7JS+pBLFkGrQamTaH2qLRR4mVG07A27q925RNLBi?= =?utf-8?q?nmd82yAbn5pTofyMxDhz1LdCuRBEevYkuWgKGkNEXFNMDhKrs3IUK8aK6+EbHIjw+?= =?utf-8?q?4s8QVVy/CDD0rgUDS7IpDlFQ9rl+puNSfU6p4ovDpUq5anq0w+ct9jVU6s/PEhdp2?= =?utf-8?q?Yd0sHgHmBIZmQaP8ZvWBs05Z52tt0hPRCg=3D=3D?= X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230037)(1800799021)(7416011)(376011)(36860700010)(82310400023);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 15:09:00.9747 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0de57bcc-8219-4fd4-7fac-08dc8edf6b70 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: SA2PEPF00003AE9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8016 Until now resume_vq() was used only for the suspend/resume scenario. This change also allows calling resume_vq() to bring it from Init to Ready state (VQ initialization). Signed-off-by: Dragos Tatulea Reviewed-by: Cosmin Ratiu --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index a2dd8fd58afa..e4d68d2d0bb4 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1557,11 +1557,31 @@ static void suspend_vqs(struct mlx5_vdpa_net *ndev) static void resume_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq) { - if (!mvq->initialized || !is_resumable(ndev)) + if (!mvq->initialized) return; - if (mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND) + switch (mvq->fw_state) { + case MLX5_VIRTIO_NET_Q_OBJECT_STATE_INIT: + /* Due to a FW quirk we need to modify the VQ fields first then change state. + * This should be fixed soon. After that, a single command can be used. + */ + if (modify_virtqueue(ndev, mvq, 0)) + mlx5_vdpa_warn(&ndev->mvdev, + "modify vq properties failed for vq %u\n", mvq->index); + break; + case MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND: + if (!is_resumable(ndev)) { + mlx5_vdpa_warn(&ndev->mvdev, "vq %d is not resumable\n", mvq->index); + return; + } + break; + case MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY: return; + default: + mlx5_vdpa_warn(&ndev->mvdev, "resume vq %u called from bad state %d\n", + mvq->index, mvq->fw_state); + return; + } if (modify_virtqueue_state(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY)) mlx5_vdpa_warn(&ndev->mvdev, "modify to resume failed for vq %u\n", mvq->index);