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 04011A0524 for ; Fri, 5 Feb 2021 12:32:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EAA381889A0; Fri, 5 Feb 2021 12:32:25 +0100 (CET) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mails.dpdk.org (Postfix) with ESMTP id 0BB6A1889FA for ; Fri, 5 Feb 2021 12:32:25 +0100 (CET) Received: by mail-wr1-f49.google.com with SMTP id p15so7268973wrq.8 for ; Fri, 05 Feb 2021 03:32:25 -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=2kQLs0x+Rtt/lE77eykIsUzTD99j6BgSm2xaJN9JmZ4=; b=JZtW1v/0KaJADupp6FHXPIgLeTGmbKy82IoUsrvJvGZAe9Ep3nzwilfMoByg9pDOa1 HauEenTlzlYijGYAQif2f4tsoH8WV76lO14AOy6qpYGb8Z+xgb89ACNDodRU2FO/E0lo ooZWI3oWUnebnuRipe/XlzDLEQsJ56hkBbrzEV5Gz3ASVrhbiVxsT4D3Jr0ti7YKHDKO 3YQZjTWdRf8nzIuew/BViAx/NTjxYEq5wBpWQDEMnJs6U+fS/LkEWZOuR7fOkCRa+STe vQ+nhCUieDQjVslEzAeevgkibynpzOAFF3VyXE2t8lkBD+byXLV67rRwqDXXZw99rfGB jjQw== 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=2kQLs0x+Rtt/lE77eykIsUzTD99j6BgSm2xaJN9JmZ4=; b=bYZy4JwURuJjoQikMbDReRo0Y0LHZRJoVjnHxpXrp+h/GkwFFc5Mpqy3g/FWmJIKoN 5aVyXA6KS5szJt6VhpZYW4ONr8b3QrbuTMJKyocaOA2mY5dc5Ap1tITx9oCE/CVS0phX yOXTLqtWeQdIwBWbUZUvNtzfdHsZSbNQ+9cOdc47NCcmEJoIkXwCd1dHGI8kJHMKbCuW ATQmDaZ13FPAZI9BTgQSm/7OujtC+1CwQ8AprBIerB8jU1blHs1uKHicyUH4DQxj0iy+ HTIVP/J2hRSu7lhNrOTw5HzCaDvpTKK1RHNxzDj0IQte2NHSfU1UCw6AXz3RGOLaluns iheQ== X-Gm-Message-State: AOAM531ZTq8huLxdZ3taFRJFR87/7HGv+BMzuvTIZQ6uyFyZYx1OjBo1 MlRmHg3uuFm2sdb8KEW6ue96kgTSyr7fxXJh X-Google-Smtp-Source: ABdhPJwZNK0gdZv4TbMAJrwOoCUrGHEHaWlwuVPN06rpxaMKxTb+524R0XNFj9rF0iQSgX565Vjk9Q== X-Received: by 2002:adf:e80f:: with SMTP id o15mr4517409wrm.366.1612524744807; Fri, 05 Feb 2021 03:32:24 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id v1sm8679735wmj.31.2021.02.05.03.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 03:32:24 -0800 (PST) From: luca.boccassi@gmail.com To: "Min Hu (Connor)" Cc: Lijun Ou , dpdk stable Date: Fri, 5 Feb 2021 11:17:02 +0000 Message-Id: <20210205111920.1272063-136-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/hns3: fix crash with multi-process' 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/708ae015b3797504a78cdd69d80d4ecb0e7e7a50 Thanks. Luca Boccassi --- >From 708ae015b3797504a78cdd69d80d4ecb0e7e7a50 Mon Sep 17 00:00:00 2001 From: "Min Hu (Connor)" Date: Wed, 6 Jan 2021 11:46:31 +0800 Subject: [PATCH] net/hns3: fix crash with multi-process [ upstream commit 6b978ead2bbef03f77dca495034fc6ba7eee347f ] In current version, procedure of saving eth_dev in hns3 PMD init will be called more than twice, one for primary, the other for secondary. That will cause segmentation fault in Multi-process as eth_dev will be changed in secondary process, which is different from one in primary process. The initial problem was access to 'rte_eth_devices' global variable, which is wrong. But current approach can cause problem for the secondaries, moving 'eth_dev' to process private can work but before making things more complex. This patch deserted the procedure of saving eth_dev in hns3 PMD init. Instead, it creates an internal function that gets "struct hns3_hw" as parameter and it can be called internally without knowing 'eth_dev'and the .dev_ops can be wrapper to this. Fixes: 2390bf217f4d ("net/hns3: fix FEC state query") Signed-off-by: Min Hu (Connor) Signed-off-by: Lijun Ou --- drivers/net/hns3/hns3_ethdev.c | 16 ++++++++++------ drivers/net/hns3/hns3_ethdev.h | 2 -- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index c94a325d25..3f6ba61a37 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -5812,10 +5812,9 @@ get_current_fec_auto_state(struct hns3_hw *hw, uint8_t *state) } static int -hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa) +hns3_fec_get_internal(struct hns3_hw *hw, uint32_t *fec_capa) { #define QUERY_ACTIVE_SPEED 1 - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct hns3_sfp_speed_cmd *resp; uint32_t tmp_fec_capa; uint8_t auto_state; @@ -5875,6 +5874,14 @@ hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa) return 0; } +static int +hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa) +{ + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + return hns3_fec_get_internal(hw, fec_capa); +} + static int hns3_set_fec_hw(struct hns3_hw *hw, uint32_t mode) { @@ -6008,10 +6015,9 @@ hns3_query_dev_fec_info(struct hns3_hw *hw) { struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(hns); - struct rte_eth_dev *eth_dev = hns->eth_dev; int ret; - ret = hns3_fec_get(eth_dev, &pf->fec_mode); + ret = hns3_fec_get_internal(hw, &pf->fec_mode); if (ret) hns3_err(hw, "query device FEC info failed, ret = %d", ret); @@ -6097,8 +6103,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) PMD_INIT_FUNC_TRACE(); - hns->eth_dev = eth_dev; - eth_dev->process_private = (struct hns3_process_private *) rte_zmalloc_socket("hns3_filter_list", sizeof(struct hns3_process_private), diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index d59418b8c8..4c40df1cbb 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -743,8 +743,6 @@ struct hns3_adapter { struct hns3_vf vf; }; - struct rte_eth_dev *eth_dev; - bool rx_simple_allowed; bool rx_vec_allowed; bool tx_simple_allowed; -- 2.29.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-05 11:18:35.252172744 +0000 +++ 0136-net-hns3-fix-crash-with-multi-process.patch 2021-02-05 11:18:29.018695148 +0000 @@ -1 +1 @@ -From 6b978ead2bbef03f77dca495034fc6ba7eee347f Mon Sep 17 00:00:00 2001 +From 708ae015b3797504a78cdd69d80d4ecb0e7e7a50 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 6b978ead2bbef03f77dca495034fc6ba7eee347f ] + @@ -26 +27,0 @@ -Cc: stable@dpdk.org @@ -36 +37 @@ -index 7c34e382fb..90544fe328 100644 +index c94a325d25..3f6ba61a37 100644 @@ -39 +40 @@ -@@ -5821,10 +5821,9 @@ get_current_fec_auto_state(struct hns3_hw *hw, uint8_t *state) +@@ -5812,10 +5812,9 @@ get_current_fec_auto_state(struct hns3_hw *hw, uint8_t *state) @@ -51 +52 @@ -@@ -5884,6 +5883,14 @@ hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa) +@@ -5875,6 +5874,14 @@ hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa) @@ -66 +67 @@ -@@ -6017,10 +6024,9 @@ hns3_query_dev_fec_info(struct hns3_hw *hw) +@@ -6008,10 +6015,9 @@ hns3_query_dev_fec_info(struct hns3_hw *hw) @@ -78 +79 @@ -@@ -6106,8 +6112,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) +@@ -6097,8 +6103,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) @@ -88 +89 @@ -index 8d6b8cdbbc..31f78a175d 100644 +index d59418b8c8..4c40df1cbb 100644