From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 26625A0518 for ; Fri, 24 Jul 2020 14:08:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 17B801C039; Fri, 24 Jul 2020 14:08:51 +0200 (CEST) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id EB8071C1BD for ; Fri, 24 Jul 2020 14:08:49 +0200 (CEST) Received: by mail-wr1-f67.google.com with SMTP id z18so4527894wrm.12 for ; Fri, 24 Jul 2020 05:08:49 -0700 (PDT) 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=nvtZbDAV+aCestKjBh0mP+z07SQPfrlRO75fvfSHwA8=; b=RV72Vsgs/9N1toRvse7r8LPbPHMRqPI1FjiJOk85KjLpRe63rxkAw3Nqebqv4LEoXw bvBYG/dlHpqpsxcCtKYd9hvYb1iWQdnhTj1xbXJrwJX615/ddGCZZC3FqKHB9PXOceQh jzBcOlzAdO58xsR4z5gqIi4Pr+G3WB83uso4qApprGTaRGHGyM/QiC2TdVg7ovnsNBw9 LbOTVrYGzR4lvyQCvBTiQUX2PhdCmoXku/2GeCS8vGfLvNsEzMyoblXq+9JjEtxlk2hZ yBCYkLYeNxqoReVhfHOsABl4u7vHOt7yQXSyB0ktbRH9VA/4Yfn7IlTFeBgt8g+VkZ2Q 4vUg== 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=nvtZbDAV+aCestKjBh0mP+z07SQPfrlRO75fvfSHwA8=; b=pzWhrvCuWETd6BGqzAJe7fyVt7bJ03Xc4j/Jm/sAAmKfVRR6tqfSKExxhI5xUG90x+ PzOmwnUSlPpan5MJSM00IBLG6WFprJUf7eRpGJpOIOZiMbcjyed+EnUQ8QXvwXqW6Sou +1FNnepOD8UJptWR2c042ugqRfVYqg8Bp55MQiSRtvrRY3/mskNgJhHJ1C22H76yxoPp VWNObR/XMXTxS9U6oWECt1QZX3JHAzjoc6oTJ1kOPPGQwzlAbjovSdEJJbr5mbhBU8uB l+M5qJ3lMuXnFw1MsyAEbv9VwDsowjiZvTrFQXBN2Rx8bVthC61jwJzTQjNBbXnYk/Sb uQPg== X-Gm-Message-State: AOAM5339OsdU5xZvyI95BMIX76S+nBOK1IzpmCUhF3SQitgqeErXVr6g yrAzttZYl/WEq7Yf/uUU6Oc= X-Google-Smtp-Source: ABdhPJxKxvVs0o8dkue8PSSVysSuPnMZd0iH5rh0nicz/UJbvCVM7Y8muvw2P8edLoM6ZfyGuGr4gg== X-Received: by 2002:a5d:5589:: with SMTP id i9mr959943wrv.91.1595592529614; Fri, 24 Jul 2020 05:08:49 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id a10sm1146719wrx.15.2020.07.24.05.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 05:08:48 -0700 (PDT) From: luca.boccassi@gmail.com To: "Wei Hu (Xavier)" Cc: Lijun Ou , dpdk stable Date: Fri, 24 Jul 2020 12:59:20 +0100 Message-Id: <20200724120030.1863487-122-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200724120030.1863487-1-luca.boccassi@gmail.com> References: <20200724120030.1863487-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/hns3: check multi-process action register result' has been queued to stable release 19.11.4 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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 19.11.4 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/26/20. 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. Thanks. Luca Boccassi --- >From 25e48df34bb106cfb94936ad145e4627dbc8c776 Mon Sep 17 00:00:00 2001 From: "Wei Hu (Xavier)" Date: Sat, 4 Jul 2020 18:09:48 +0800 Subject: [PATCH] net/hns3: check multi-process action register result [ upstream commit 9570b1fdbdad47cab28dff58a017b0447bf32ed1 ] Currently, there is a coverity defect warning about hns3 PMD driver, the detail information as blow: CID 289969 (#1 of 1): Unchecked return value (CHECKED_RETURN) 1. check_return: Calling rte_mp_action_register without checking return value (as is done elsewhere 11 out of 13 times). The problem is that missing checking the return value of calling the API rte_mp_action_register during initialization. If registering an action function for primary and secondary communication failed, the secondary process can't work properly. This patch fixes it by adding check return value of the API function named rte_mp_action_register in the '.dev_init' implementation function of hns3 PMD driver. Coverity issue: 289969 Fixes: 23d4b61fee5d ("net/hns3: support multiple process") Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 22 ++++++++++++++++++-- drivers/net/hns3/hns3_ethdev_vf.c | 20 ++++++++++++++++-- drivers/net/hns3/hns3_mp.c | 34 ++++++++++++++++++++++++++----- drivers/net/hns3/hns3_mp.h | 4 ++-- 4 files changed, 69 insertions(+), 11 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 4922e1bde..971f2f900 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -5306,12 +5306,25 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) hns3_set_rxtx_function(eth_dev); eth_dev->dev_ops = &hns3_eth_dev_ops; if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - hns3_mp_init_secondary(); + ret = hns3_mp_init_secondary(); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to init for secondary " + "process, ret = %d", ret); + goto err_mp_init_secondary; + } + hw->secondary_cnt++; return 0; } - hns3_mp_init_primary(); + ret = hns3_mp_init_primary(); + if (ret) { + PMD_INIT_LOG(ERR, + "Failed to init for primary process, ret = %d", + ret); + goto err_mp_init_primary; + } + hw->adapter_state = HNS3_NIC_UNINITIALIZED; if (device_id == HNS3_DEV_ID_25GE_RDMA || @@ -5378,7 +5391,12 @@ err_rte_zmalloc: err_init_pf: rte_free(hw->reset.wait_data); + err_init_reset: + hns3_mp_uninit_primary(); + +err_mp_init_primary: +err_mp_init_secondary: eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index a2867f8ec..5e5da8685 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -2069,12 +2069,24 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) hns3_set_rxtx_function(eth_dev); eth_dev->dev_ops = &hns3vf_eth_dev_ops; if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - hns3_mp_init_secondary(); + ret = hns3_mp_init_secondary(); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to init for secondary " + "process, ret = %d", ret); + goto err_mp_init_secondary; + } + hw->secondary_cnt++; return 0; } - hns3_mp_init_primary(); + ret = hns3_mp_init_primary(); + if (ret) { + PMD_INIT_LOG(ERR, + "Failed to init for primary process, ret = %d", + ret); + goto err_mp_init_primary; + } hw->adapter_state = HNS3_NIC_UNINITIALIZED; hns->is_vf = true; @@ -2131,6 +2143,10 @@ err_init_vf: rte_free(hw->reset.wait_data); err_init_reset: + hns3_mp_uninit_primary(); + +err_mp_init_primary: +err_mp_init_secondary: eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c index 596c31064..639f46ced 100644 --- a/drivers/net/hns3/hns3_mp.c +++ b/drivers/net/hns3/hns3_mp.c @@ -14,6 +14,8 @@ #include "hns3_rxtx.h" #include "hns3_mp.h" +static bool hns3_inited; + /* * Initialize IPC message. * @@ -192,9 +194,20 @@ void hns3_mp_req_stop_rxtx(struct rte_eth_dev *dev) /* * Initialize by primary process. */ -void hns3_mp_init_primary(void) +int hns3_mp_init_primary(void) { - rte_mp_action_register(HNS3_MP_NAME, mp_primary_handle); + int ret; + + if (!hns3_inited) { + /* primary is allowed to not support IPC */ + ret = rte_mp_action_register(HNS3_MP_NAME, mp_primary_handle); + if (ret && rte_errno != ENOTSUP) + return ret; + + hns3_inited = true; + } + + return 0; } /* @@ -202,13 +215,24 @@ void hns3_mp_init_primary(void) */ void hns3_mp_uninit_primary(void) { - rte_mp_action_unregister(HNS3_MP_NAME); + if (hns3_inited) + rte_mp_action_unregister(HNS3_MP_NAME); } /* * Initialize by secondary process. */ -void hns3_mp_init_secondary(void) +int hns3_mp_init_secondary(void) { - rte_mp_action_register(HNS3_MP_NAME, mp_secondary_handle); + int ret; + + if (!hns3_inited) { + ret = rte_mp_action_register(HNS3_MP_NAME, mp_secondary_handle); + if (ret) + return ret; + + hns3_inited = true; + } + + return 0; } diff --git a/drivers/net/hns3/hns3_mp.h b/drivers/net/hns3/hns3_mp.h index aefbeb140..036546ae1 100644 --- a/drivers/net/hns3/hns3_mp.h +++ b/drivers/net/hns3/hns3_mp.h @@ -7,8 +7,8 @@ void hns3_mp_req_start_rxtx(struct rte_eth_dev *dev); void hns3_mp_req_stop_rxtx(struct rte_eth_dev *dev); -void hns3_mp_init_primary(void); +int hns3_mp_init_primary(void); void hns3_mp_uninit_primary(void); -void hns3_mp_init_secondary(void); +int hns3_mp_init_secondary(void); #endif /* _HNS3_MP_H_ */ -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-07-24 12:53:53.240087251 +0100 +++ 0122-net-hns3-check-multi-process-action-register-result.patch 2020-07-24 12:53:48.415008844 +0100 @@ -1,8 +1,10 @@ -From 9570b1fdbdad47cab28dff58a017b0447bf32ed1 Mon Sep 17 00:00:00 2001 +From 25e48df34bb106cfb94936ad145e4627dbc8c776 Mon Sep 17 00:00:00 2001 From: "Wei Hu (Xavier)" Date: Sat, 4 Jul 2020 18:09:48 +0800 Subject: [PATCH] net/hns3: check multi-process action register result +[ upstream commit 9570b1fdbdad47cab28dff58a017b0447bf32ed1 ] + Currently, there is a coverity defect warning about hns3 PMD driver, the detail information as blow: CID 289969 (#1 of 1): Unchecked return value (CHECKED_RETURN) @@ -20,7 +22,6 @@ Coverity issue: 289969 Fixes: 23d4b61fee5d ("net/hns3: support multiple process") -Cc: stable@dpdk.org Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) @@ -32,10 +33,10 @@ 4 files changed, 69 insertions(+), 11 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 13ce32432..9575a05ae 100644 +index 4922e1bde..971f2f900 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5448,12 +5448,25 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) +@@ -5306,12 +5306,25 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) hns3_set_rxtx_function(eth_dev); eth_dev->dev_ops = &hns3_eth_dev_ops; if (rte_eal_process_type() != RTE_PROC_PRIMARY) { @@ -61,9 +62,9 @@ + } + hw->adapter_state = HNS3_NIC_UNINITIALIZED; - hns->is_vf = false; - hw->data = eth_dev->data; -@@ -5514,7 +5527,12 @@ err_rte_zmalloc: + + if (device_id == HNS3_DEV_ID_25GE_RDMA || +@@ -5378,7 +5391,12 @@ err_rte_zmalloc: err_init_pf: rte_free(hw->reset.wait_data); @@ -77,10 +78,10 @@ eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 3c5998abe..54e5dac52 100644 +index a2867f8ec..5e5da8685 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2524,12 +2524,24 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) +@@ -2069,12 +2069,24 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) hns3_set_rxtx_function(eth_dev); eth_dev->dev_ops = &hns3vf_eth_dev_ops; if (rte_eal_process_type() != RTE_PROC_PRIMARY) { @@ -107,7 +108,7 @@ hw->adapter_state = HNS3_NIC_UNINITIALIZED; hns->is_vf = true; -@@ -2586,6 +2598,10 @@ err_init_vf: +@@ -2131,6 +2143,10 @@ err_init_vf: rte_free(hw->reset.wait_data); err_init_reset: