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 2C1B242ECF for ; Thu, 20 Jul 2023 17:31:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 28968427EE; Thu, 20 Jul 2023 17:31:18 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 5BB2E400D6 for ; Thu, 20 Jul 2023 17:31:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689867075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r3xC32tbQ6daRQDWp5BiIWYncUlwg2jF41S6bLMhVWU=; b=gnRCPncvTa2bVuK/beEiQxeiRJFq3dM/eU7ehej6kMllZ7DowLnGMo9xo7Lxw/Xz/NdmWj 1gQRso5SW6Sibr46I9ij4yHnK03PqMuSevahqYmkyDUjXlB/PhHCbStvEeVYgW9cuThflk pv87brl+12CxJZc+4wsJ7DAt8xpQVYM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-135-34dT0PGYP_SLNuMWtCbZ4A-1; Thu, 20 Jul 2023 11:23:07 -0400 X-MC-Unique: 34dT0PGYP_SLNuMWtCbZ4A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 315368F1878; Thu, 20 Jul 2023 15:22:41 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59DA3492C13; Thu, 20 Jul 2023 15:22:40 +0000 (UTC) From: Kevin Traynor To: Viacheslav Ovsiienko Cc: dpdk stable Subject: patch 'net/mlx5: fix device removal event handling' has been queued to stable release 21.11.5 Date: Thu, 20 Jul 2023 16:18:57 +0100 Message-ID: <20230720151942.262154-106-ktraynor@redhat.com> In-Reply-To: <20230720151942.262154-1-ktraynor@redhat.com> References: <20230720151942.262154-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 21.11.5 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/25/23. 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://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/be94ef9a9b2f68d3d0f21ede73f4b2b57f1e2d5d Thanks. Kevin --- >From be94ef9a9b2f68d3d0f21ede73f4b2b57f1e2d5d Mon Sep 17 00:00:00 2001 From: Viacheslav Ovsiienko Date: Tue, 30 May 2023 18:13:28 +0300 Subject: [PATCH] net/mlx5: fix device removal event handling [ upstream commit 22dc56cfbd39692eb74fad93ff5ecc3df5fd0633 ] On the device removal kernel notifies user space application with queueing the IBV_DEVICE_FATAL_EVENT and triggering appropriate file descriptor. Mellanox kernel driver stack emits this event twice from different layers (mlx5 and uverbs). The IB port index is not applicable in the event structure and should be ignored for IBV_DEVICE_FATAL_EVENT events. Also, on the older kernels (at least from OFED 4.9) there might be race conditions causing the event queue close before application fetches the IBV_DEVICE_FATAL_EVENT message with ibv_get_async_event() API. To provide the reliable device removal event detection the patch: - ignores the IB port index for the IBV_DEVICE_FATAL_EVENT - introduces the flag to notify PMD about removal only once - acks event with ibv_ack_async_event after actual handling - checks for EIO error, making sure queue is not closed yet Fixes: 40d9f906f4e2 ("net/mlx5: fix device removal handler for multiport") Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/linux/mlx5_ethdev_os.c | 40 +++++++++++++++++-------- drivers/net/mlx5/mlx5.h | 1 + 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index 89095e856f..a22ffab3f7 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -746,4 +746,5 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh) for (i = 0; i < sh->max_port; ++i) { struct rte_eth_dev *dev; + struct mlx5_priv *priv; if (sh->port[i].ih_port_id >= RTE_MAX_ETHPORTS) { @@ -756,7 +757,12 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh) dev = &rte_eth_devices[sh->port[i].ih_port_id]; MLX5_ASSERT(dev); - if (dev->data->dev_conf.intr_conf.rmv) + priv = dev->data->dev_private; + MLX5_ASSERT(priv); + if (!priv->rmv_notified && dev->data->dev_conf.intr_conf.rmv) { + /* Notify driver about removal only once. */ + priv->rmv_notified = 1; rte_eth_dev_callback_process (dev, RTE_ETH_EVENT_INTR_RMV, NULL); + } } } @@ -830,19 +836,27 @@ mlx5_dev_interrupt_handler(void *cb_arg) uint32_t tmp; - if (mlx5_glue->get_async_event(sh->cdev->ctx, &event)) + if (mlx5_glue->get_async_event(sh->cdev->ctx, &event)) { + if (errno == EIO) { + DRV_LOG(DEBUG, + "IBV async event queue closed on: %s", + sh->ibdev_name); + mlx5_dev_interrupt_device_fatal(sh); + } break; + } + if (event.event_type == IBV_EVENT_DEVICE_FATAL) { + /* + * The DEVICE_FATAL event can be called by kernel + * twice - from mlx5 and uverbs layers, and port + * index is not applicable. We should notify all + * existing ports. + */ + mlx5_dev_interrupt_device_fatal(sh); + mlx5_glue->ack_async_event(&event); + continue; + } /* Retrieve and check IB port index. */ tmp = (uint32_t)event.element.port_num; - if (!tmp && event.event_type == IBV_EVENT_DEVICE_FATAL) { - /* - * The DEVICE_FATAL event is called once for - * entire device without port specifying. - * We should notify all existing ports. - */ - mlx5_glue->ack_async_event(&event); - mlx5_dev_interrupt_device_fatal(sh); - continue; - } - MLX5_ASSERT(tmp && (tmp <= sh->max_port)); + MLX5_ASSERT(tmp <= sh->max_port); if (!tmp) { /* Unsupported device level event. */ diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index f14a76f301..7caf27a7aa 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1418,4 +1418,5 @@ struct mlx5_priv { unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */ unsigned int lb_used:1; /* Loopback queue is referred to. */ + unsigned int rmv_notified:1; /* Notified about removal event */ uint32_t mark_enabled:1; /* If mark action is enabled on rxqs. */ uint16_t domain_id; /* Switch domain identifier. */ -- 2.41.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-07-20 16:18:07.967226434 +0100 +++ 0106-net-mlx5-fix-device-removal-event-handling.patch 2023-07-20 16:17:55.081752223 +0100 @@ -1 +1 @@ -From 22dc56cfbd39692eb74fad93ff5ecc3df5fd0633 Mon Sep 17 00:00:00 2001 +From be94ef9a9b2f68d3d0f21ede73f4b2b57f1e2d5d Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 22dc56cfbd39692eb74fad93ff5ecc3df5fd0633 ] + @@ -26 +27,0 @@ -Cc: stable@dpdk.org @@ -35 +36 @@ -index 55801534d1..639e629fe4 100644 +index 89095e856f..a22ffab3f7 100644 @@ -38 +39 @@ -@@ -747,4 +747,5 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh) +@@ -746,4 +746,5 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh) @@ -44 +45 @@ -@@ -757,7 +758,12 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh) +@@ -756,7 +757,12 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh) @@ -58 +59 @@ -@@ -831,19 +837,27 @@ mlx5_dev_interrupt_handler(void *cb_arg) +@@ -830,19 +836,27 @@ mlx5_dev_interrupt_handler(void *cb_arg) @@ -99 +100 @@ -index fffd3c79f1..10a2f33ea0 100644 +index f14a76f301..7caf27a7aa 100644 @@ -102 +103 @@ -@@ -1745,4 +1745,5 @@ struct mlx5_priv { +@@ -1418,4 +1418,5 @@ struct mlx5_priv { @@ -107 +108 @@ - uint32_t num_lag_ports:4; /* Number of ports can be bonded. */ + uint16_t domain_id; /* Switch domain identifier. */