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 093D8A0524 for ; Fri, 5 Feb 2021 12:38:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0020A188A4B; Fri, 5 Feb 2021 12:38:12 +0100 (CET) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mails.dpdk.org (Postfix) with ESMTP id A71724067B for ; Fri, 5 Feb 2021 12:38:11 +0100 (CET) Received: by mail-wm1-f54.google.com with SMTP id l12so5769311wmq.2 for ; Fri, 05 Feb 2021 03:38:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qcdtSI2ZFJuQW0iyrG85SmQ/4K+rzlCRtbzYbJTM56A=; b=ZohpavWXWAAApQISjTWnOYtAZlzgwQ31wyEJNrS/nQa9SyuFVfoBE4c86shhyojmOC m4G+reYl+5XjIiUmWIT1gjryLQZHdJkrzpVlQipmRdqWpDAkO+42dPiRVG8AdblrQWt0 nGGEiapZlrc2lsdQO0rKPVN+JCXWedJAQ/JQ/rzZri0eK/O25E7nMiyyv6OR4W7ci4wG hONC1V3YlGcxKk7yXvnidMLFY+om6nLoMox/MxtPzPCASHRInwPth4QpXpkHnLUPEDLN fWHg+aFMMloOLBzBsskkRE4yYbIFHHdId1Rp/4dvgVXTjKIt6LNGvZGf4YNnbloF8tgj Qg8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qcdtSI2ZFJuQW0iyrG85SmQ/4K+rzlCRtbzYbJTM56A=; b=sXPNHuAeq0KYyrUJvgJQWZWVK5ZruDqGf+pbT9oZ4Yx5Q0etncSDVyw405Gb3ekjCg 0cJVzD5l6adgAIfIwLDn6re9LUCzhD1onTe2l3gRh+bEv17Kn/W2gZkXIVZvx7Qdpxvp o927YtFKKylVr+CgfQDC+wzkd17Egj7B4WRC5ftrz1Um75fI5fzIuUDQdPxB/v36LXGY cQvLLTOKTzUpCh9NM+PVRocOKQYnT9SUPaLxWfDrWN14ubKKZmDr5ycnW7n6nhnfts05 2vStH0ta03u7H4gQFNS/gqZm9zxooE5MCJGQ2k4u7l/KBxoyjicZUI5tNI3JZ5GVDbA5 mJtQ== X-Gm-Message-State: AOAM530oMKHeYIoebNPOLKRsFVAHKzxULWmnMf/nozKLiA5nCeut6zpe sSZQdxSRpRAjEEzuED05qms= X-Google-Smtp-Source: ABdhPJwULR+4ybPU5yD4V30qOFQj83e3q9SSDUCiNy5IDTEFoNGhWISJbxMeBRoN3eCDg/wrMv8rHg== X-Received: by 2002:a1c:25c2:: with SMTP id l185mr3228158wml.62.1612525091373; Fri, 05 Feb 2021 03:38:11 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id r1sm11432262wrl.95.2021.02.05.03.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 03:38:10 -0800 (PST) From: luca.boccassi@gmail.com To: Suanming Mou Cc: Viacheslav Ovsiienko , dpdk stable Date: Fri, 5 Feb 2021 11:18:48 +0000 Message-Id: <20210205111920.1272063-242-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205111920.1272063-1-luca.boccassi@gmail.com> References: <20210205111920.1272063-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/mlx5: fix crash on secondary process port close' has been queued to stable release 20.11.1 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/07/21. 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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/293737e4ec90c500576deb6abc807e353733d129 Thanks. Luca Boccassi --- >From 293737e4ec90c500576deb6abc807e353733d129 Mon Sep 17 00:00:00 2001 From: Suanming Mou Date: Sun, 24 Jan 2021 19:02:04 +0800 Subject: [PATCH] net/mlx5: fix crash on secondary process port close [ upstream commit 84a22cbcc467a02772dd24156773940331994c84 ] When secondary process starts, in rte_eth_dev_attach_secondary() function, the secondary process port device data in struct rte_eth_dev will be initialized to be shared with primary process port. When failsafe sub-port hot-plug happens, both primary and secondary process will release the sub-port, and primary process will clear the sub-port device data in fs_dev_remove() deactivate stage first before request secondary process to release the sub-port. In this case, the secondary process will not be able to get the priv memory pointer from the shared device data memory anymore, since the device data memory has been cleared. Since what secondary process needs in port detach is the UAR table size to unmap the UAR addresses. It used Tx queue number as size of UAR table in priv. In fact the uar_table_sz in struct mlx5_proc_priv means the size of UAR register table - the number of UAR records. However, the code set this field incorrectly to the size of mlx5_proc_priv structure. This commit fixes UAR table size to match with relevant Tx queue number, uses the UAR table size directly to avoid the secondary process to access the priv pointer in the shared device data memory when unmapping the UAR address. Fixes: 120dc4a7dcd3 ("net/mlx5: remove device register remap") Signed-off-by: Suanming Mou Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.c | 6 +++--- drivers/net/mlx5/mlx5_txq.c | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 53ccd1656d..a211fbc6b1 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1247,13 +1247,13 @@ mlx5_proc_priv_init(struct rte_eth_dev *dev) */ ppriv_size = sizeof(struct mlx5_proc_priv) + priv->txqs_n * sizeof(void *); - ppriv = mlx5_malloc(MLX5_MEM_RTE, ppriv_size, RTE_CACHE_LINE_SIZE, - dev->device->numa_node); + ppriv = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, ppriv_size, + RTE_CACHE_LINE_SIZE, dev->device->numa_node); if (!ppriv) { rte_errno = ENOMEM; return -rte_errno; } - ppriv->uar_table_sz = ppriv_size; + ppriv->uar_table_sz = priv->txqs_n; dev->process_private = ppriv; return 0; } diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index b81bb4a12d..c53af10d58 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -634,18 +634,23 @@ txq_uar_uninit_secondary(struct mlx5_txq_ctrl *txq_ctrl) void mlx5_tx_uar_uninit_secondary(struct rte_eth_dev *dev) { - struct mlx5_priv *priv = dev->data->dev_private; - struct mlx5_txq_data *txq; - struct mlx5_txq_ctrl *txq_ctrl; + struct mlx5_proc_priv *ppriv = (struct mlx5_proc_priv *) + dev->process_private; + const size_t page_size = rte_mem_page_size(); + void *addr; unsigned int i; + if (page_size == (size_t)-1) { + DRV_LOG(ERR, "Failed to get mem page size"); + return; + } MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY); - for (i = 0; i != priv->txqs_n; ++i) { - if (!(*priv->txqs)[i]) + for (i = 0; i != ppriv->uar_table_sz; ++i) { + if (!ppriv->uar_table[i]) continue; - txq = (*priv->txqs)[i]; - txq_ctrl = container_of(txq, struct mlx5_txq_ctrl, txq); - txq_uar_uninit_secondary(txq_ctrl); + addr = ppriv->uar_table[i]; + rte_mem_unmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size); + } } -- 2.29.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-05 11:18:39.841468115 +0000 +++ 0242-net-mlx5-fix-crash-on-secondary-process-port-close.patch 2021-02-05 11:18:29.246699489 +0000 @@ -1 +1 @@ -From 84a22cbcc467a02772dd24156773940331994c84 Mon Sep 17 00:00:00 2001 +From 293737e4ec90c500576deb6abc807e353733d129 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 84a22cbcc467a02772dd24156773940331994c84 ] + @@ -30 +31,0 @@ -Cc: stable@dpdk.org @@ -40 +41 @@ -index 50a6d2b19f..93629e5b05 100644 +index 53ccd1656d..a211fbc6b1 100644 @@ -43 +44 @@ -@@ -1251,13 +1251,13 @@ mlx5_proc_priv_init(struct rte_eth_dev *dev) +@@ -1247,13 +1247,13 @@ mlx5_proc_priv_init(struct rte_eth_dev *dev) @@ -61 +62 @@ -index 5142e50858..15624428aa 100644 +index b81bb4a12d..c53af10d58 100644