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 BC5E8A0A02 for ; Mon, 17 May 2021 18:13:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7626041106; Mon, 17 May 2021 18:13:08 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id 1BE2F410EA for ; Mon, 17 May 2021 18:13:07 +0200 (CEST) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lifre-0007qc-Tl; Mon, 17 May 2021 16:13:07 +0000 From: Christian Ehrhardt To: Guoyang Zhou Cc: dpdk stable Date: Mon, 17 May 2021 18:08:14 +0200 Message-Id: <20210517161039.3132619-65-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> References: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/hinic: fix crash in secondary process' has been queued to stable release 19.11.9 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 19.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/19/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/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/be86991e714876ff68ec891378b75409c88197ba Thanks. Christian Ehrhardt --- >From be86991e714876ff68ec891378b75409c88197ba Mon Sep 17 00:00:00 2001 From: Guoyang Zhou Date: Tue, 23 Mar 2021 21:17:51 +0800 Subject: [PATCH] net/hinic: fix crash in secondary process [ upstream commit 4c670dfaa417bc5604c9c58b505a74e2725acdb2 ] Some apps, such as fstack, will use secondary process to access the memory of eth_dev_ops, and they want to get the info of dev, but hinic driver does not initialized it when in secondary process. Fixes: 66f64dd6dc86 ("net/hinic: fix secondary process") Signed-off-by: Guoyang Zhou --- drivers/net/hinic/base/hinic_compat.h | 25 ++++++++----------------- drivers/net/hinic/hinic_pmd_ethdev.c | 5 +++++ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/net/hinic/base/hinic_compat.h b/drivers/net/hinic/base/hinic_compat.h index 473a273b6b..ac42ca5f8e 100644 --- a/drivers/net/hinic/base/hinic_compat.h +++ b/drivers/net/hinic/base/hinic_compat.h @@ -203,6 +203,7 @@ static inline u32 readl(const volatile void *addr) #else #define CLOCK_TYPE CLOCK_MONOTONIC #endif +#define HINIC_MUTEX_TIMEOUT 10 static inline unsigned long clock_gettime_ms(void) { @@ -257,24 +258,14 @@ static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex) static inline int hinic_mutex_lock(pthread_mutex_t *pthreadmutex) { int err; + struct timespec tout; - err = pthread_mutex_lock(pthreadmutex); - if (!err) { - return err; - } else if (err == EOWNERDEAD) { - PMD_DRV_LOG(ERR, "Mutex lock failed. (ErrorNo=%d)", errno); -#if defined(__GLIBC__) -#if __GLIBC_PREREQ(2, 12) - (void)pthread_mutex_consistent(pthreadmutex); -#else - (void)pthread_mutex_consistent_np(pthreadmutex); -#endif -#else - (void)pthread_mutex_consistent(pthreadmutex); -#endif - } else { - PMD_DRV_LOG(ERR, "Mutex lock failed. (ErrorNo=%d)", errno); - } + (void)clock_gettime(CLOCK_TYPE, &tout); + + tout.tv_sec += HINIC_MUTEX_TIMEOUT; + err = pthread_mutex_timedlock(pthreadmutex, &tout); + if (err) + PMD_DRV_LOG(ERR, "Mutex lock failed. (ErrorNo=%d)", err); return err; } diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c index a0499da7d4..89ee5b7a78 100644 --- a/drivers/net/hinic/hinic_pmd_ethdev.c +++ b/drivers/net/hinic/hinic_pmd_ethdev.c @@ -2972,6 +2972,10 @@ static const struct eth_dev_ops hinic_pmd_vf_ops = { .filter_ctrl = hinic_dev_filter_ctrl, }; +static const struct eth_dev_ops hinic_dev_sec_ops = { + .dev_infos_get = hinic_dev_infos_get, +}; + static int hinic_func_init(struct rte_eth_dev *eth_dev) { struct rte_pci_device *pci_dev; @@ -2985,6 +2989,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev) /* EAL is SECONDARY and eth_dev is already created */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { + eth_dev->dev_ops = &hinic_dev_sec_ops; PMD_DRV_LOG(INFO, "Initialize %s in secondary process", eth_dev->data->name); -- 2.31.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-05-17 17:40:32.081105989 +0200 +++ 0065-net-hinic-fix-crash-in-secondary-process.patch 2021-05-17 17:40:29.219809853 +0200 @@ -1 +1 @@ -From 4c670dfaa417bc5604c9c58b505a74e2725acdb2 Mon Sep 17 00:00:00 2001 +From be86991e714876ff68ec891378b75409c88197ba Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 4c670dfaa417bc5604c9c58b505a74e2725acdb2 ] + @@ -11 +12,0 @@ -Cc: stable@dpdk.org @@ -20 +21 @@ -index 6dd210ec06..aea332046e 100644 +index 473a273b6b..ac42ca5f8e 100644 @@ -23 +24 @@ -@@ -171,6 +171,7 @@ static inline u32 readl(const volatile void *addr) +@@ -203,6 +203,7 @@ static inline u32 readl(const volatile void *addr) @@ -31 +32 @@ -@@ -225,24 +226,14 @@ static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex) +@@ -257,24 +258,14 @@ static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex) @@ -64 +65 @@ -index 2352dd1615..b5a36a863b 100644 +index a0499da7d4..89ee5b7a78 100644 @@ -67,2 +68,2 @@ -@@ -3063,6 +3063,10 @@ static const struct eth_dev_ops hinic_pmd_vf_ops = { - .flow_ops_get = hinic_dev_flow_ops_get, +@@ -2972,6 +2972,10 @@ static const struct eth_dev_ops hinic_pmd_vf_ops = { + .filter_ctrl = hinic_dev_filter_ctrl, @@ -78 +79 @@ -@@ -3077,6 +3081,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev) +@@ -2985,6 +2989,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)