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 75AF245610 for ; Fri, 12 Jul 2024 12:51:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F526402E5; Fri, 12 Jul 2024 12:51:22 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 993BE40261 for ; Fri, 12 Jul 2024 12:51:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DMXSOktKQLWcMqigCC4+0r8JGjrmB1jprY3L96StXTCHnY1jGGJmceB4uF0IGS+2I7lKSiz2AYaeflUb/NkDE9loRp+N2BNLyK6uOnway/NF1VrsMAQ8efj1XkhvVA9MMX603pzU9NTP+UJ4l54ZflGmxmqs2FFXVSdg+pTO3CscgNhvosO2j18w+Fvl3Q6iNnWz577RrH+ba3nDS42lJx0Qjx402WtZX0Xrc75HWLiHmvlECdA74oOpRjGRxNEPvNBbjdnrvP0mqY6OJxTczEPmXfHuTf1WN29Eb/Z5gBQPTjXMr6FGMrecVKJ/lJLreaNbGSwa7NEh/Ve4c3Pp9w== 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=ftyRaERMTmwaj8xuD8Em5cC/4tUFFHUFjWcoTNCWCpY=; b=LzPJ3zDWcP2rBP6aRPzIYR4tbxMJnugEfpG+HpqZLXhLF3A1qvfKxS6V+boUSaaBEC2WBU9WIo39PC3T5Fkzvov0W+Of99r4zZv5zDSo8rUDsWWoC5wbWrZDsFi6DfPkWGSBId0BtIcnR768v4y6/7SM2OUvT/VV3oFJ+du83+6PAxFU7urh2JfBFZfPjtcbg47X6L7NrgBtfNITIav99m94CFvQ4aaUIoYZ2icOvIrVyeeJKnJLMOqhUwgrJM2MrZk+I62idQXeXqxX1DDNUytkxprqZoLQQOtrh7spbkQJCsuwxBBWxBkDtMPFXOkPiaqS+xGj7EC1SgdzjEVE4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=ftyRaERMTmwaj8xuD8Em5cC/4tUFFHUFjWcoTNCWCpY=; b=iTnICkDr2pK6j+K8b4YBOPcaFkXJnMsB1Q/056BubkH0s3PXZRbT8Nur1hNwzCZcJv9Q9slog+neUnd63hB0LrxfEVVYPYKsdURucwMxb+FPtDAtkfKEmJj6r+AsnKVknro06vUOfyyT1DC7gBZE+sZdOe6lbu6qECvSM/RBNqU6YbM7WiQ5/pn5Bk+5uHu9HZB81zhRsiPuQb6GsW936XakbQIm+jXmyZ96Lq4dJqWDXCk0V/hQKQ6djHnGC7P7pnbKxer41Q9WWJljq8bR4O7NLH9KDKMfM7hn/S+OHRUk3U/S/Z/gbqHoZXsOBehit1mlyT5paRUYSafZaFMy0Q== Received: from DM6PR02CA0150.namprd02.prod.outlook.com (2603:10b6:5:332::17) by SA1PR12MB5616.namprd12.prod.outlook.com (2603:10b6:806:22a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23; Fri, 12 Jul 2024 10:51:17 +0000 Received: from DS1PEPF00017098.namprd05.prod.outlook.com (2603:10b6:5:332:cafe::5d) by DM6PR02CA0150.outlook.office365.com (2603:10b6:5:332::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23 via Frontend Transport; Fri, 12 Jul 2024 10:51:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS1PEPF00017098.mail.protection.outlook.com (10.167.18.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.17 via Frontend Transport; Fri, 12 Jul 2024 10:51:17 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 12 Jul 2024 03:51:03 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 12 Jul 2024 03:51:01 -0700 From: Xueming Li To: Maxime Coquelin CC: David Marchand , dpdk stable Subject: patch 'net/virtio-user: fix shadow control queue notification init' has been queued to stable release 23.11.2 Date: Fri, 12 Jul 2024 18:44:40 +0800 Message-ID: <20240712104528.308638-55-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240712104528.308638-1-xuemingl@nvidia.com> References: <20240712104528.308638-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017098:EE_|SA1PR12MB5616:EE_ X-MS-Office365-Filtering-Correlation-Id: 427410cc-6214-4396-eaa4-08dca2608e90 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?jMcENY++khyJR0haqsGqdwMjmTaYfAz12nul1tC040yxYcCEiTGoxWNENnVW?= =?us-ascii?Q?//bYKQZ48hRW9LEEEtxL56qv41Go7uioZx3k7J1RyhIV+0jD7xdBFL990fm6?= =?us-ascii?Q?XUlsurDje5rcf6KUGk5hEtr3VmbFuXfmPDVBXZAe3ZzwuleHRMMXExHaBktE?= =?us-ascii?Q?sU/OPvEVe1LyTyuAVHFv6+xpWQrlxjyHD4+L+2ZNNZOqMh4UcnwqtIcVFqVC?= =?us-ascii?Q?yTYp+Q1f9GO4586NtW40CEU/m8yyzo70Z4UuZ6rqbiVFx7g1gySpOdaz3XB2?= =?us-ascii?Q?vKdMwEPKddocTh0GhdUx0wWWcguV7Y1kgU97B5j9h6F4LYBJ1ql0VeKxJB4r?= =?us-ascii?Q?hk08PEehjG0xaE+oycecS+RKfpfSESyNqAtgFKNNA0TMANwoleukcrZzNCL2?= =?us-ascii?Q?n5MqrDOHjgnqNQSHD7TRXDQ3lHVdK0+WiJkRV6WjHjE0nLa5/8wF7BNNogNc?= =?us-ascii?Q?CLMv4TKNNiHj1WRXRvXM4jDIN7rKUujZYNGqMZ0YMVdct5qBDBA06pz8W3Bk?= =?us-ascii?Q?pS25ufho/7OZwo3f7TAaX9YVx9dskCYdEJ/PNHHImusy2c2wbJ/lmy7HoSLJ?=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Uz?= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 10:51:17.0627 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 427410cc-6214-4396-eaa4-08dca2608e90 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017098.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5616 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 Hi, FYI, your patch has been queued to stable release 23.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/14/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://git.dpdk.org/dpdk-stable/log/?h=23.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=f745eb9e509c326cce0f240319b374d3de9a4a62 Thanks. Xueming Li --- >From f745eb9e509c326cce0f240319b374d3de9a4a62 Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Thu, 28 Mar 2024 14:08:12 +0100 Subject: [PATCH] net/virtio-user: fix shadow control queue notification init Cc: Xueming Li [ upstream commit 4de6c17a449ef0fafecae637bd73cd4d03c36d92 ] The Virtio-user control queue kick and call FDs were not uninitialized at device stop time. This patch fixes this using the queues iterator helper for both initialization and uninitialization. Fixes: 90966e8e5b67 ("net/virtio-user: send shadow virtqueue info to the backend") Signed-off-by: Maxime Coquelin Acked-by: David Marchand --- .../net/virtio/virtio_user/virtio_user_dev.c | 90 +++++++++---------- 1 file changed, 43 insertions(+), 47 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index ce9e73493d..ef320d3395 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -32,6 +32,45 @@ const char * const virtio_user_backend_strings[] = { [VIRTIO_USER_BACKEND_VHOST_VDPA] = "VHOST_VDPA", }; +static int +virtio_user_uninit_notify_queue(struct virtio_user_dev *dev, uint32_t queue_sel) +{ + if (dev->kickfds[queue_sel] >= 0) { + close(dev->kickfds[queue_sel]); + dev->kickfds[queue_sel] = -1; + } + + if (dev->callfds[queue_sel] >= 0) { + close(dev->callfds[queue_sel]); + dev->callfds[queue_sel] = -1; + } + + return 0; +} + +static int +virtio_user_init_notify_queue(struct virtio_user_dev *dev, uint32_t queue_sel) +{ + /* May use invalid flag, but some backend uses kickfd and + * callfd as criteria to judge if dev is alive. so finally we + * use real event_fd. + */ + dev->callfds[queue_sel] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); + if (dev->callfds[queue_sel] < 0) { + PMD_DRV_LOG(ERR, "(%s) Failed to setup callfd for queue %u: %s", + dev->path, queue_sel, strerror(errno)); + return -1; + } + dev->kickfds[queue_sel] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); + if (dev->kickfds[queue_sel] < 0) { + PMD_DRV_LOG(ERR, "(%s) Failed to setup kickfd for queue %u: %s", + dev->path, queue_sel, strerror(errno)); + return -1; + } + + return 0; +} + static int virtio_user_destroy_queue(struct virtio_user_dev *dev, uint32_t queue_sel) { @@ -423,46 +462,13 @@ out: static int virtio_user_dev_init_notify(struct virtio_user_dev *dev) { - uint32_t i, j, nr_vq; - int callfd; - int kickfd; - nr_vq = dev->max_queue_pairs * 2; - if (dev->hw_cvq) - nr_vq++; - - for (i = 0; i < nr_vq; i++) { - /* May use invalid flag, but some backend uses kickfd and - * callfd as criteria to judge if dev is alive. so finally we - * use real event_fd. - */ - callfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); - if (callfd < 0) { - PMD_DRV_LOG(ERR, "(%s) callfd error, %s", dev->path, strerror(errno)); - goto err; - } - kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); - if (kickfd < 0) { - close(callfd); - PMD_DRV_LOG(ERR, "(%s) kickfd error, %s", dev->path, strerror(errno)); - goto err; - } - dev->callfds[i] = callfd; - dev->kickfds[i] = kickfd; - } + if (virtio_user_foreach_queue(dev, virtio_user_init_notify_queue) < 0) + goto err; return 0; err: - for (j = 0; j < i; j++) { - if (dev->kickfds[j] >= 0) { - close(dev->kickfds[j]); - dev->kickfds[j] = -1; - } - if (dev->callfds[j] >= 0) { - close(dev->callfds[j]); - dev->callfds[j] = -1; - } - } + virtio_user_foreach_queue(dev, virtio_user_uninit_notify_queue); return -1; } @@ -470,18 +476,8 @@ err: static void virtio_user_dev_uninit_notify(struct virtio_user_dev *dev) { - uint32_t i; + virtio_user_foreach_queue(dev, virtio_user_uninit_notify_queue); - for (i = 0; i < dev->max_queue_pairs * 2; ++i) { - if (dev->kickfds[i] >= 0) { - close(dev->kickfds[i]); - dev->kickfds[i] = -1; - } - if (dev->callfds[i] >= 0) { - close(dev->callfds[i]); - dev->callfds[i] = -1; - } - } } static int -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-07-12 18:40:16.684180917 +0800 +++ 0054-net-virtio-user-fix-shadow-control-queue-notificatio.patch 2024-07-12 18:40:14.106594227 +0800 @@ -1 +1 @@ -From 4de6c17a449ef0fafecae637bd73cd4d03c36d92 Mon Sep 17 00:00:00 2001 +From f745eb9e509c326cce0f240319b374d3de9a4a62 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 4de6c17a449ef0fafecae637bd73cd4d03c36d92 ] @@ -13 +15,0 @@ -Cc: stable@dpdk.org @@ -22 +24 @@ -index 07f45984fe..ba067d6d9c 100644 +index ce9e73493d..ef320d3395 100644 @@ -25 +27 @@ -@@ -33,6 +33,45 @@ const char * const virtio_user_backend_strings[] = { +@@ -32,6 +32,45 @@ const char * const virtio_user_backend_strings[] = { @@ -71 +73 @@ -@@ -423,33 +462,9 @@ out: +@@ -423,46 +462,13 @@ out: @@ -78 +80 @@ -- + @@ -82 +84 @@ - +- @@ -105,4 +106,0 @@ - if (dev->device_features & (1ULL << VIRTIO_F_NOTIFICATION_DATA)) - if (dev->ops->map_notification_area && -@@ -458,16 +473,7 @@ virtio_user_dev_init_notify(struct virtio_user_dev *dev) - @@ -125 +123 @@ -@@ -475,18 +481,8 @@ err: +@@ -470,18 +476,8 @@ err: @@ -142,2 +139,0 @@ - if (dev->ops->unmap_notification_area && dev->notify_area) - dev->ops->unmap_notification_area(dev); @@ -144,0 +141,2 @@ + + static int